torres.electronico
Well-known-Alfil
Bueno, acá esta todo lo que prometi
Ver el archivo adjunto 111257
Saludos
Ver el archivo adjunto 111257
Código:
;********************************************************
;www.facebook.com/eductecinformal
;sites.google.com/a/educ.ar/eti/
;www.forosdeelectronica.com
;prof.martintorres@educ.ar
;********************************************************
DEFINE OSC 20 ;defíne oscilador externo de 20 MHZ.
TRISA=255
TRISB = %00000011 ; Configuro B.0 y1 como entradas y B.3-4-5-6-7 como salidas
TRISC = %00000000 ; configuro todo el puerto C como salida
ADCON1=%10000010
DEFINE LCD_DREG PORTC ;bit de datos del LCD empezando
DEFINE LCD_DBIT 4 ;por portC.2, portC.3, portC.4 y portC.5
DEFINE LCD_RSREG PORTC ;bit de registro del LCD conectar
DEFINE LCD_RSBIT 2 ;en el puerto portC.0
DEFINE LCD_EREG PORTC ;bit de Enable conectar en el
DEFINE LCD_EBIT 3 ;puerto portD.1
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
led_BajaFREC var PORTB.7
led_AltaFREC VAR PORTB.6
led_BajaTENS VAR PORTB.5
ContactorRED VAR PORTB.4
ContactorGEN VAR PORTB.3
relayMOTOR var PORTB.2
TENSION VAR WORD
TENSION2 VAR WORD
BAJA VAR WORD
ALTA VAR WORD
ACUMULA VAR WORD
MEDIR VAR BYTE
FREC var word
FREC2 VAR WORD
aux var byte
bandera var byte
;********************************************************
;*********************** inicio *************************
;********************************************************
arranque:
LOW PORTB.7 : LOW PORTB.6 : LOW PORTB.5 : LOW PORTB.4 : LOW PORTB.3 : LOW PORTB.2
lcdout $FE, 1
LCDOut " Ctrl Gen Elect "
LCDOut $fe,$C0,"beta1.0"
pause 500
goto inicioSLEEP
;********************************************************
;******************* Modo APAGADO ***********************
;********************************************************
InicioSLEEP:
ContactorRED = 1
gosub tensionred
gosub frecuenciared
acumula = acumula/10
lcdout $FE, 1
LCDOut "VAC:",dec tension," Frec",dec FREC
LCDOut $fe,$C0,"Min:",dec baja," /Max:",dec alta
pause 100
if tension < 180 then
led_BajaTENS = 1
goto InicioGEN
endif
goto inicioSLEEP
;********************************************************
;**************** Modo VERIFICACION *********************
;********************************************************
InicioGEN:
for aux = 1 to 3
gosub tensionred
gosub frecuenciared
lcdout $FE, 1
LCDOut "VAC:",dec tension," Frec",dec FREC
LCDOut $fe,$C0,"Problema en RED"
pause 100
next
bandera = bandera + 1
if bandera = 3 then arranqueMOTOR
if tension > 180 then
led_BajaTENS = 0
goto InicioSLEEP
endif
goto inicioGEN
arranqueMOTOR:
lcdout $FE, 1
LCDOut "Atencion"
LCDOut $fe,$C0,"ArranqueGENERADOR"
pause 100
relaymotor = 1
pause 1000
relaymotor = 0
; FALTA SENSAR LA TENSION DEL GENERADOR PARA CONMUTAR
;********************************************************
;****************** Modo ENCENDIDO **********************
;********************************************************
lcdout $FE, 1
LCDOut "GENERADOR on"
LCDOut $fe,$C0,"VAC:",dec tension2," Frec",dec FREC2
ContactorRED = 0
PAUSE 800
ContactorGEN = 1
pause 1000
GOTO HASTAACA
;********************************************************
;******************* Sub PROGRAMAS **********************
;********************************************************
tensionRED:
ADCIN 0,TENSION
if tension > alta then alta = tension
if tension < baja then baja = tension
acumula = acumula + tension
medir = medir + 1
if medir = 10 then return
goto tensionRED
frecuenciaRED:
count portb.0,1000,frec
if FREC > 52 then led_AltaFREC = 1
if FREC < 48 then led_BajaFREC = 1
return
tensionGEN:
ADCIN 0,TENSION2
if tension > alta then alta = tension
if tension < baja then baja = tension
acumula = acumula + tension
medir = medir + 1
if medir = 10 then return
goto tensionRED
frecuenciaGEN:
count portb.1,1000,frec2
if FREC > 52 then led_AltaFREC = 1
if FREC < 48 then led_BajaFREC = 1
return
HASTAACA:
lcdout $FE, 1
LCDOut "HASTA ACA POR HOY"
LCDOut $fe,$C0,"DESPUES SIGO..."
end
;if FREC > 52 then EMER1 ;SI PULSOS EXCEDE 750 IR A EMER1
;if pFREC < 48 then EMER2 ; SI PULSOS DECIENDE 320 IR A EMER2
;LOW ALARMA0:LOW ALARMA1
;GOTO LOOP
;EMER1: ; RUTINA EMER1
;HIGH ALARMA0
;LOW ALARMA1
;GOTO LOOP
;EMER2:
;RUNITA EMER2
;LOW ALARMA0
;HIGH ALARMA1
;GOTO LOOP
Saludos