Sie sind auf Seite 1von 5

UNIVERSIDAD ESTATAL PENÍNSULA DE SANTA ELENA

FACULTAD DE SISTEMAS Y TELECOMUNICACIONES


ESCUELA DE ELECTRÓNICA Y TELECOMUNICACIONES

TALLER: LECCION:# OTROS :


TAREA: 2
MICROCONTROLADORES MICROCONTROLADORES ASIGNATURA ASIGNATURA
NOMBRE Y APELLIDO: NEREXI BACILIO FECHA 23-01-18
WELLINGTON BASILIO
CURSO: Electrónica y Telecomunicaciones 8/1

TAREA DE COMPARAR DATOS DE DOS SENSORES


OBJETIVO DE LA TAREA:

 CONFIGURAR LOS PUERTOS DE ENTRADA Y SALIDA DENTRO DEL


PROGRAMA MICROBASIC PRO FOR PIC, ADQUIRIR LOS DATOS DE DOS
SENSORES PARA LUEGO REALIZAR EL CODIGO QUE NOS PERMITA
COMPARAR DICHOS VALORES Y MOSTRAR COMO RESULTADO UNA
ALERTA CON DIODO LED, VERDE, AMARILLO Y ROJO, MAYOR, MENOR, E
IGUAL RESPECTIVAMENTE.
 ALMACENAR DENTRO DEL MICROCONTROLADOR, EN 20 LOCALIDADES
DIFERENTES LOS 10 ULTIMOS DATOS LEIDOS.

DESARROLLO:

CÓDIGO EN MIKROBASIC PRO FOR PIC:

program datos_sensores

dim adc_rd as word


dim adc_rd1 as word
dim S1 as word
dim S2 as word
dim counter as byte

' Lcd module connections


dim LCD_RS as sbit at RD4_bit
LCD_EN as sbit at RD5_bit
LCD_D4 as sbit at RD0_bit
LCD_D5 as sbit at RD1_bit
LCD_D6 as sbit at RD2_bit
LCD_D7 as sbit at RD3_bit

LCD_RS_Direction as sbit at TRISD4_bit


LCD_EN_Direction as sbit at TRISD5_bit
LCD_D4_Direction as sbit at TRISD0_bit
LCD_D5_Direction as sbit at TRISD1_bit
LCD_D6_Direction as sbit at TRISD2_bit
UNIVERSIDAD ESTATAL PENÍNSULA DE SANTA ELENA
FACULTAD DE SISTEMAS Y TELECOMUNICACIONES
ESCUELA DE ELECTRÓNICA Y TELECOMUNICACIONES

LCD_D7_Direction as sbit at TRISD3_bit


' End Lcd module connections

dim txt1 as char[16]


txt2 as char[9]
txt3 as char[16]
txt4 as char[9]

main:
ANSEL = 0x04 ' Configure AN2 pin as analog
TRISA = 0xFF ' PORTA is input
ANSELH = 0 ' Configure other AN pins as digital I/O
TRISB = 0
PORTB = 0
TRISD = 0
PORTD = 0xFF
TRISD = 0xFF

txt1 = "S1(LM35)="
txt2 = " "
txt3 = "S2(LDR)="
txt4 = " "

while TRUE ' Endless loop

while counter < 10 ' Fill data buffer

Lcd_Init() ' Initialize Lcd


Lcd_Cmd(_LCD_CLEAR) ' Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off

Lcd_Out(1,1,txt1) ' Write text in first row


Lcd_Out(2,1,txt3) ' Write text in first row

adc_rd = ADC_Read(0) ' get ADC value from 0nd channel


adc_rd1 = ADC_Read(1) ' get ADC value from 1nd channel

S1 = (adc_rd*0x1E8)/0x3E8
S2 = adc_rd1

EEPROM_Write(0x80,S1)
'PORTC = EEPROM_Read(0x80) ' and display data on PORTC
wordtostr(S1,txt2) 'Aqui tenemos la temperatura en milivoltios (5/1024=4.88 e-3) conversor de 10 bits
'PORTD = adc_rd ' display adc_rd[7..0]
Lcd_Out(1,10,txt2) ' Write text in second row

EEPROM_Write(0x81,S2)
'PORTC = EEPROM_Read(0x81) ' and display data on PORTC
wordtostr(S2,txt4)
'PORTD = adc_rd1 ' display adc_rd[7..0]
Lcd_Out(2,10,txt4) ' Write text in second row
UNIVERSIDAD ESTATAL PENÍNSULA DE SANTA ELENA
FACULTAD DE SISTEMAS Y TELECOMUNICACIONES
ESCUELA DE ELECTRÓNICA Y TELECOMUNICACIONES

if (S1 > S2) then


portb=%00000001
end if

if (S1 < S2) then


portb=%00000010
end if

if (S1 = S2) then


portb=%00000100
end if
counter = counter + 1
delay_ms(100)
Lcd_Cmd(_LCD_CLEAR) ' Clear display

wend
wend
end.

SIMULACIÓN EN PROTEUS:
UNIVERSIDAD ESTATAL PENÍNSULA DE SANTA ELENA
FACULTAD DE SISTEMAS Y TELECOMUNICACIONES
ESCUELA DE ELECTRÓNICA Y TELECOMUNICACIONES

CUANDO S1 ES MAYOR QUE S2

CUANDO S1 ES MENOR QUE S2


UNIVERSIDAD ESTATAL PENÍNSULA DE SANTA ELENA
FACULTAD DE SISTEMAS Y TELECOMUNICACIONES
ESCUELA DE ELECTRÓNICA Y TELECOMUNICACIONES

CUANDO S1 Y S2 SON IGUALES

Conclusión:

La practica dada se realizo el trabajo con el pic 16 f887 para facilitar sus entradas y
salidas al conectar con el lcd y los 3 led

se logró mostrar en una pantalla LCD(LM016L) los datos obtenidos de los 2 sensores
analógico conectados, en donde comparamos los datos del sensor 1 (sensor de
temperatura LM35) y el dato de la fotorresistencia como sensor 2.

Conectamos 3 diodos leds donde según sus datos de comparación mostrarán el valor
del sensor 1 es mayor, menor o igual al dato del sensor 2.

Una vez obtenidos los 10 últimos datos de información obtenidas por cada uno de los
sensores, son almacenados en diferentes localidades de la memoria eeprom del
microcontrolador.

Das könnte Ihnen auch gefallen