Professional Documents
Culture Documents
**** 28/octubre/2008
DISPLAY LCD HD 44480 RA0,RA1,RA2,RA3=DATOS(PINES 11-14) RB3=ENABLE RA4=RS vcc (pin 2) gnd (pin 1) vee(pin 3) SALIDAS alarma1 portb.0 salida salida a vcc (PIN 6) (PIN 4)
alarma_boton portb.2 solo_hora_boton portb.7 hora_boton portb.4 prog_boton portb.5 periodo_boton portb.6
symbol hora_boton=portb.4 symbol prog_boton=portb.5 symbol periodo_boton=portb.6 ticks var byte hora var byte horaal VAR BYTE minuto var byte minutoal VAR BYTE segundo var byte semana VAR BYTE delay var byte DESC VAR BYTE desc1 var byte lunes var bit martes var bit miercoles var bit jueves var bit viernes var bit sabado var bit domingo VAR Bit PATTERN VAR BYTE i var byte minutoluz var byte TRISA=0 TRISB= $f4
SEGUNDO=2 semana= 1 TICKS=0 DESC=0 DESC1=0 Lcdout $fe, 1 lcdout $FE,2 lcdout CRN mensaje de cortesia Clear LCD screen
pause 10 INICIALIZAR VECTOR INTERRUPCOPN OPTION_REG=$05 timer prescaler es cargado a 64 a traves de option_reg 00000101
ON INTERRUPT GOTO ISR INTCON=$A0 BORRAR DISPLAY LOOP: bucle principal de ejecucion habilita INTERRUPCIONES POR TMR0
bloque de ajuste minutos,hora, segundos y dia de la semana IF solo_hora_boton=0 THEN GOSUB RETARDO IF solo_hora_boton=0 THEN MINUTO=MINUTO+1 gosub minuto60 endif endif bloque de ajuste minutos,hora, segundos y dia de la semana IF HORA_boton=0 THEN GOSUB RETARDO IF HORA_boton=0 THEN minuto=60 hora=hora+1 GOSUB minuto60 HORA24 si se pulsa el boton de ajuste si se pulsa el boton de ajuste si se pulsa el boton de ajuste se incrementan minutos si se pulsa el boton de ajuste
endif endif bloque de ajuste hora de alarma IF PROG_boton=0 THEN GOSUB RETARDO IF PROG_boton=0 THEN MINUTOAL=MINUTOAL+1 IF MINUTOAL>59 THEN MINUTOAL=0 horaAL=horaAL+1 endif if horaal>23 then horaal=0 endif endif bloque ajuste periodicidad de alarma ( 6 modos) IF periodo_boton=0 THEN GOSUB RETARDO IF periodo_boton=0 THEN DESC=DESC +1 DESC1=DESC IF DESC=6 THEN desc=0 DESC1=0 ENDIF endif endif bloque apagado de alarma y de la luz IF alarma_boton=0 THEN pause 150 IF alarma_boton=0 THEN si se pulsa el boton de ajuste de semanas si se pulsa el boton de ajuste de semanas si se pulsa el boton de ajuste se incrementan minutos horas hora alarmas si se pulsa el boton de ajuste hora alarmas
condicion de alarma if hora=horaal and minuto=minutoal and segundo=1 and ( semana= lunes*1 or semana=martes*2 or semana=miercoles*3 or semana=jueves*4 or semana=vie rnes*5 or semana=sabado*6 or semana=domingo *7) then GOSUB LUZON HIGH ALARMA1 desc=5 ENDIF apaga la luz de fondo al minuto if minutoluz=minuto then gosub luz_fondo_off endif gosub display goto loop RUTINA DE SERVICIO DISABLE ISR: TICKS=TICKS +1 if ticks<61 THEN SINACTUALIZAR TICKS=0 SEGUNDO=SEGUNDO+1 IF SEGUNDO=60 THEN SEGUNDO=0 MINUTO=MINUTO+1 gosub minuto60 ENDIF bucle principal de ejecucion enciende luz de fondo activa alarma PINTA EN PANTALLA
SINACTUALIZAR: INTCON.2=0 RESUME ENABLE END display: lcdout $FE,2 lcdout dEC2 hora, : ,DEC2 minuto , : ,DEC2 SEGUNDO, LOOKUP semana,["0","L","M","M","J","V","S","D","M"] ,pattern LCDOUT PATTERN LOOKUP semana,["F","U","A","I","U","I","A","O","A"] ,pattern lcdout pattern lcdout $FE,2 LcdOut $FE, $C0 Principio segunda linea REACTIVA TMR0
lcdout dEC2 horaAL, : ,DEC2 minutoAL , select case desc case 0: gosub borra case 1: gosub llena LCDOUT Tod case 2: LMXJVSD todos los dias LCDOUT OFF
laborales
gosub llena sabado=0 domingo=0 LCDOUT Lab case 3 : gosub llena lunes=0 LCDOUT NoL LMXJV libra lunes
lcdout
Ma
IF SEMANA=1 then martes=1 if semana=2 then miercoles=1 if semana=3 then jueves=1 if semana=4 then viernes=1 if semana=5 then sabado=1 if semana=6 then domingo=1 if semana=7 then lunes=1 case 5: lcdout ON
end select return llena: lunes=1 martes=1 miercoles=1 jueves=1 viernes=1 sabado=1 domingo=1 return borra: lunes=0 martes=0 miercoles=0 jueves=0 viernes=0 sabado=0 domingo=0 inicializa a 0 los indicadores semanales inicializa a 1 los indicadores semanales
minutoluz = minuto+1 if minutoluz>60 then minutoluz=1 RETURN RETARDO: PAUSE 250 GOSUB LUZON RETURN HORA24: si se incrementan las horas mas de 24h enciende luz de fondo antirebotes de 150ms pulsadores activando tambien la luz de fondo
IF HORA=24 THEN HORA=0 semana=semana+1 if semana>7 then endif RETURN minuto60: si se incrementan los minutos mas de 60 semana=1
IF MINUTO=60 THEN MINUTO=0 HORA=HORA+1 GOSUB HORA24 ENDIF return luz_fondo_off: low luz minutoluz=61 return apaga luz de fondo