hola amigos les comento que cuando lo simulo en proteus me responde muy bien en el momento que esta en la placa solo visualizo el temporizador ( la placa con otro programa funciona bien).
aca les dejo el programa:
aca les dejo el programa:
Código:
DEVICE 16F876
INTCON = %10100000 'se habilita TOIE interr. de TMR0)
ON INTERRUPT GOTO contdor 'Enable software interrupts, and point to interrupt handler
'****************************************************************
' DEFINICION PARA EL LCD
'******************************************************
lCD_DTPIN = PORTC.4 'PARA 4 LINEAS DE DATOS EN EL LCD
LCD_RSPIN = PORTC.2 'asigna portd.2 a RS
LCD_ENPIN = PORTC.3 'Asigna portd.3 a E
LCD_LINES = 2 'LCD de dos filas
LCD_INTERFACE = 4 'un bus de 4 líneas
'******************************************************
' DEFINICIO PARA EL ADC
'******************************************************
ADIN_RES 10 'Set the resolution to 10
ADIN_TAD FRC 'Choose the RC osc for ADC samples
ADIN_STIME 100 'Allow 100us for charge time
'******************************************************
'VARIABLES
'******************************************************
DIM TEM0 as WORD 'temp del canal0 LECTURA DEL ADC (10 BITS)
DIM TEM1 AS FLOAT 'temp del canal1
DIM TEM2 AS WORD 'temp del canal2
DIM tempr AS WORD
DIM TEMP0 AS WORD ' temp programada del canal0
DIM TP[5] AS BYTE ' tiempo
dim TE0[11] AS BYTE ' temperatura
dim i as byte
dim j as byte
dim uni as byte
dim deci as byte
dim ovflow as byte
dim rseg as byte
dim rmin as byte
DIM u as bit 'inicio
'********************************************************
'condiciones iniciales
'********************************************************
ADCON1= $80 'CONFIGURO LOS 8 CANALES COMO ENTRADAS ANALOGICAS
TRISC=%00000000 'CONFIGURO AL PUERTO C
TRISB=%00000111
TE0[0]=20 'temperatura de 20ºC
TE0[1]=25 'temperatura de 25ºC
TE0[2]=30
TE0[3]=35
TE0[4]=40
TE0[5]=45
TE0[6]=50
TE0[7]=55
TE0[8]=60
TE0[9]=65
TE0[10]=70
TP[0]=1 'triempo de 20 MINUTOS
TP[1]=30 'triempo de 30 MINUTOS
TP[2]=40 ' 40
TP[3]=50 ' 50
TP[4]=60 ' 60
'********************************************************
'********************************************************
i=0
j=0
ovflow=0
portb.3=0
portB.5=0
portb.0=0
option_reg=$06
'********************************************************
inicio: u=0
print $fe,1
aa: print at 1,1, "A P A G A D O"
print at 2,1,"Pulse INI"
IF PORTB.0=0 THEN GOTO aa 'pregunta sise ha activado la carga
print $fe,1
rmin=0
rseg=0
u=1 'se activala carga
ini: GOSUB Lee_TP
gosub canal0
print at 1,1,"TP=",dec TP[J]," "
print at 2,1,"TE0_P=",DEC TE0[I]
print AT 2,9,"TE0_R=",DEC TEMPR
if rmin=TP[j] then
portB.5=0 'apagado carga 0
gosub alarma 'se activa la alarma
rmin=0 'se pasa a 0 rmin
rseg=0 'se pone a cero rseg
goto iniCIO
end if
goto ini
DISABLE
'********************************************************
contdor: intcon.2=0
print at 1,9,"M=",dec rmin," ","S",dec rseg," "
tmr0=240
if u=1 then tmr0=240
ovflow=ovflow+1
if ovflow=100 then goto uno
RESUME
ENABLE
return
uno: ovflow=0
rseg=rseg+1
if rseg=60 then goto dos
RESUME
ENABLE
return
dos: ovflow=0
rseg=0
rmin=rmin+1
if rmin=60 then rmin=0
paus: RESUME 'Return to main program
ENABLE
return
'********************************************************
canal0:
GOSUB lee_TE0
TEMP0 = ADIN 1 'LEE EL SENSOR DEL CSANAL 0
tempr=0.049*TEMP0+20 'ACONDICIONADO A TEMPERATURA
PRINT AT 1,6,"tempr= ",dec tempr," ",dec temp0
if rmin=tp[j] then
portB.5=0 'finaliza
goto fin
endif
IF tempr>TE0[i] THEN
PORTB.5 = 0 ' APAGA
ELSE
PORTB.5 = 1 ' PRENDE
ENDIF
fin: return
'********************************************************
'rutina que define la temperatura del canal 0
'********************************************************
lee_TE0:
if portb.1=1 then i=i+1 'se incrementa
m0: if portb.1=1 then goto m0
if i>10 then i=0
return
'********************************************************
'rutina que define la temperatura del canal 1
'********************************************************
'rutina que define el tiempo de activación
'********************************************************
lee_TP:
if portb.2=1 THEN J=j+1 'se incrementa
m1: if portb.2=1 then goto m1
if j>4 then j=0
return
'********************************************************
'rutina que acriva la alarma
'********************************************************
alarma:
portb.3=1 'alarma
delayms 500
portb.3=0
delayms 500
portb.3=1
delayms 500
portb.3=0
return
'********************************************************
END
Última edición por un moderador: