me siento luchando contra molinos de viento
aca los nuevos codigos
Define CONF_WORD = 0x3f72
Define CLOCK_FREQUENCY = 20
AllDigital
TRISA = %000001
TRISB = 0
TRISE.0 = 0
TRISE.1 = 0
TRISE.2 = 0
TRISC = %00000011
TRISD = 0
'OPTION_REG.7 = 0
TRISD = 0
ADCON1 = 0x0e
Dim posicion As Byte
posicion = 0
'Define SIMULATION_WAITMS_VALUE = 1
TRISC.7 = 1
TRISC.6 = 0
INTCON.7 = 1
INTCON.6 = 1
PIE1.5 = 1 'hab interrupcion x Rx
PIR1.5 = 0 'limpio la interrupcion
RCSTA.7 = 1 'configuro rx ytx
Dim papelera As Byte
Hseropen 9600 'Velocidad del puerto serie, configura Usart
RCSTA.CREN = 0 'Disable
Hserget papelera 'Limpia bufer Uart
Hserget papelera
Hserget papelera
RCSTA.CREN = 1 'Enable, Continuous Receive Enable bit*/
Hserout CrLf 'limpia el buffer
Dim tempp(

As Byte 'temperatura programada , la que manda el display
Dim templ(

As Byte 'temperatura leida,la que transmito al micro del display
'''''''''''''''''''''''''''''''VARIABLES DE TX Y RX'''''''''''''''''''''''''''''''
Dim indice As Byte
Dim array As Byte
Dim paso As Byte
Dim contar As Byte
''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''
Define ADC_CLOCK = 2
Define ADC_SAMPLEUS = 5
'Symbol buzer = RC3
'WaitMs 1000 ''''''''''''''''''''''''''''''''''''''''
't1 a 50ms
''''''''''''''''''''''''''''''''''''''''''''''
Dim seguir As Byte 'este cada x cantidad va a adquirir los datos de lectura de adc
Dim toglear As Byte 'este cada 2 seg cambia para cuando se aproxima a la lectura
Dim pulsos As Bit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Dim temp(10) As Byte 'temp byte de temp leidas
'''''''''''''''''''''''''''
Dim warning As Byte
warning = 0
Dim aviso As Bit
aviso = 0
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim espera As Word
espera = 40
'''''''''''''''''''''''''''''''''''''
'valores de alarma x sobretemp
Dim offset As Byte
offset = 5
Dim falta As Byte
falta = 5 'cuando falta este empieza a toglear
Dim casi As Byte 'aca guardo la diferencia para generar los pulsos
Dim dif As Byte
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ascii As Byte
ascii = 223
inicio:
'INTCON.4 = 1 'externa x flanco de subida
'INTCON.1 = 0 'limpio el flag de int externa
'WaitMs 1000
'Low buzer
mostrar:
'''''''''''''''''''''''''''''''''''''''''''
Low RB6
ciclo:
seguir = 0 'lo reseteo y adquiero datos
PORTD = 0
WaitUs espera 'a que se estabilice
Adcin 0, templ(0)
If tempp(0) = 0 Then
RA1 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadodos
Endif
If templ(0) >= tempp(0) Then
RA1 = 0 'si es >tambien lo apago
Goto salto1
'''''''''''''''''''''''''''''''''''''''
Endif
If templ(0) < tempp(0) Then casi = tempp(0) - falta
If templ(0) >= casi Then
RA1 = pulsos
Else
High RA1
Endif
estadodos:
offset = 5 'recupero datos
casi = 0
dif = 0
'falta = 10
salto1:
'salto1:
''''''''''''''''''''''''''''''''''''''''''
PORTD = 1
WaitUs espera 'a que se estabilice
Adcin 0, templ(1)
If tempp(1) = 0 Then
RA2 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadotres
Endif
If templ(1) >= tempp(1) Then
RA2 = 0 'si es >tambien lo apago
Goto salto2
''''''''''''''''''''''''''''''''''''''''''''''''
Endif
If templ(1) < tempp(1) Then casi = tempp(1) - falta
If templ(1) >= casi Then
RA2 = pulsos
Else
High RA2
Endif
estadotres:
offset = 5 'recupero datos
casi = 0
dif = 0
salto2:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PORTD = 2
WaitUs espera 'a que se estabilice
Adcin 0, templ(2)
If tempp(2) = 0 Then
RC4 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadocuatro 'salto al siguiente eswtado
Endif
If templ(2) >= tempp(2) Then
RA4 = 0 'si es >tambien lo apago
Goto salto3
Endif
If templ(2) < tempp(2) Then casi = tempp(2) - falta
If templ(2) >= casi Then
RC4 = pulsos
Else
High RC4
Endif
estadocuatro:
offset = 5 'recupero datos
casi = 0
dif = 0
salto3:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PORTD = 3
WaitUs espera 'a que se estabilice
Adcin 0, templ(3)
If tempp(3) = 0 Then
RA5 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadocinco 'salto al siguiente eswtado
Endif
If templ(3) >= tempp(3) Then
RA5 = 0 'si es >tambien lo apago
Goto salto4
Endif
If templ(3) < tempp(3) Then casi = tempp(3) - falta
If templ(3) >= casi Then
RA5 = pulsos
Else
High RA5
Endif
estadocinco:
offset = 5 'recupero datos
casi = 0
dif = 0
salto4:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PORTD = 4
WaitUs espera 'a que se estabilice
Adcin 0, templ(4)
If tempp(4) = 0 Then
RE0 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadoseis 'salto al siguiente eswtado
Endif
If templ(4) >= tempp(4) Then
RE0 = 0 'si es >tambien lo apago
Goto salto5
Endif
If templ(4) < tempp(4) Then casi = tempp(4) - falta
If templ(4) >= casi Then
RE0 = pulsos
Else
High RE0
Endif
estadoseis:
offset = 5 'recupero datos
casi = 0
dif = 0
salto5:
''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PORTD = 5
WaitUs espera 'a que se estabilice
Adcin 0, templ(5)
If tempp(5) = 0 Then
RE1 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadosiete 'salto al siguiente eswtado
Endif
If templ(5) >= tempp(5) Then
RE1 = 0 'si es >tambien lo apago
Goto salto6
Endif
If templ(5) < tempp(5) Then casi = tempp(5) - falta
If templ(5) >= casi Then
RE1 = pulsos
Else
High RE1
Endif
estadosiete:
offset = 5 'recupero datos
casi = 0
dif = 0
salto6:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PORTD = 6
WaitUs espera 'a que se estabilice
Adcin 0, templ(6)
If tempp(6) = 0 Then
RE2 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadoocho 'salto al siguiente eswtado
Endif
If templ(6) >= tempp(6) Then
RE2 = 0 'si es >tambien lo apago
Goto salto7
Endif
If templ(6) < tempp(6) Then casi = tempp(6) - falta
If templ(6) >= casi Then
RE2 = pulsos
Else
High RE2
Endif
estadoocho:
offset = 5 'recupero datos
casi = 0
dif = 0
salto7:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PORTD = 7
WaitUs espera 'a que se estabilice
Adcin 0, templ(7)
If tempp(7) = 0 Then
RC3 = 0 'si programe cero grado de pedido entonces lo apago
Goto estadonueve 'salto al siguiente eswtado
Endif
If templ(7) >= tempp(7) Then
RC3 = 0 'si es >tambien lo apago
Goto salto8
Endif
If templ(7) < tempp(7) Then casi = tempp(7) - falta
If templ(7) >= casi Then
RC3 = pulsos
Else
High RC3
Endif
estadonueve:
offset = 5 'recupero datos
casi = 0
dif = 0
salto8:
High RB6
WaitMs 100
Toggle pulsos
Goto mostrar
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End
On Interrupt
Save System
'Toggle pulsos
If RCSTA.1 = 1 Then
RCSTA.CREN = 0 'Disable
Hserget papelera 'Limpia bufer Uart
Hserget papelera
Hserget papelera
RCSTA.CREN = 1
Endif
If PIR1.5 = 1 Then
Hserget tempp(indice)
indice = indice + 1
Endif
If indice < 7 Then 'indice = 0
Hserout #templ(indice), CrLf
Else
indice = 0
Endif
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Endif ''''''''''''''''''''''''''''''''''''''''''''''
Resume
End
y ahora el display con el teclado
Define CONF_WORD = 0x3f72
AllDigital
TRISA = 0x0f
TRISB = 0xff
TRISC = 0
TRISD = 0x00
TRISC.6 = 1
OPTION.7 = 0 'pullup
''''''''''''''''''''''''''''''''''''''''''''''''''
'Define SIMULATION_WAITMS_VALUE = 1
Define CLOCK_FREQUENCY = 20
TRISC.7 = 1
TRISC.6 = 0
INTCON.7 = 1
INTCON.6 = 1
PIE1.5 = 1 'hab interrupcion x Rx
PIR1.5 = 0 'limpio la interrupcion
RCSTA.7 = 1 'configuro rx ytx
Dim papelera As Byte
Hseropen 9600 'Velocidad del puerto serie, configura Usart
RCSTA.CREN = 0 'Disable
Hserget papelera 'Limpia bufer Uart
Hserget papelera
Hserget papelera
RCSTA.CREN = 1 'Enable, Continuous Receive Enable bit*/
Hserout CrLf 'limpia el buffer
'''''''
Dim indice As Byte
'+++++++++++++++++++++++?*************USART++++++++++++++++++++++++++++++++++++++
'+++++++++++++++++++++++++++++++++++++++++++++++++++
Dim templ(

As Byte 'igual que el otro temperatura leida
Dim tempp(

As Byte 'temperatura programada '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tempp(0) = 100
tempp(1) = 110
tempp(2) = 120
tempp(3) = 130
tempp(4) = 140
tempp(5) = 150
tempp(6) = 160
tempp(7) = 170
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
''+++++++++variables de manejo''''''''''''''''''''''''''''''
Symbol cambio = RB3 'cambia la pantalla
Dim ciclo As Byte
Dim i As Byte
Dim guardar As Byte
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dim offset As Byte
offset = 5
Dim alarma As Word
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
''+++++++++variables de manejo''''''''''''''''''''''''''''''
Dim posicion As Byte 'lo incremento para selecconar una pantalla
Symbol sube = RB1
Symbol baja = RB2
Symbol enter = RB4
Symbol volver = RB5
Symbol habtx = RA0
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTD
Define LCD_DBIT = 4
Define LCD_RSREG = PORTD
Define LCD_RSBIT = 2
Define LCD_EREG = PORTD
Define LCD_EBIT = 3
'Define LCD_RWREG = PORTD
'Define LCD_RWBIT = 1
Define LCD_COMMANDUS = 2000
Define LCD_INITMS = 50
'Gosub trans
Lcdinit 0
'T1CON.TMR1ON = 1 'lo prendo despues del display
Hserout #tempp(0), #tempp(1), #tempp(2), #tempp(3), #tempp(4), #tempp(5), #tempp(6), #tempp(7), Lf, CrLf
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inicio:
While cambio = 1
'Lcdcmdout LcdClear
WaitMs 100
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "MANGUERA 1)" #tempp(0), "---" #templ(0), " "
Lcdcmdout LcdLine2Home
Lcdout "PISTOLA 1)" #tempp(1), "---" #templ(1), " "
Lcdcmdout LcdLine3Home
Lcdout "MANGUERA 2)" #tempp(2), "---" #templ(2), " "
Lcdcmdout LcdLine4Home
Lcdout "PISTOLA 2)" #tempp(3), "---" #templ(3), " "
'Gosub control
WaitMs 100
If enter = 0 Then Gosub prog
'++++++++++++++++++++++++++++++++++++
Goto inicio
Wend
''''''''''''''''''''''''''''''''''''''''''''''''
Lcdcmdout LcdClear
WaitMs 200
While cambio = 1
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "MANGUERA 3)" #tempp(4), "---" #templ(4), " "
Lcdcmdout LcdLine2Home
Lcdout "PISTOLA 3)" #tempp(5), "---" #templ(5), " "
Lcdcmdout LcdLine3Home
Lcdout "MANGUERA 4)" #tempp(6), "---" #templ(6), " "
Lcdcmdout LcdLine4Home
Lcdout "PISTOLA 4)" #tempp(7), "---" #templ(

, " "
'Gosub control
WaitMs 100
If enter = 0 Then Gosub prog
Wend
'''''''''''''''''''''''''''''''''''''
'Lcdcmdout LcdClear
'WaitMs 200
'While cambio = 1
''Lcdcmdout LcdClear
'Lcdcmdout LcdLine1Home
'Lcdout "MANGUERA 5)" #nueve, "---" #tnueve, " "
'Lcdcmdout LcdLine2Home
'Lcdout "PISTOLA 5)" #diez, "---" #tdiez, " "
'Lcdcmdout LcdLine3Home
'Lcdout "MANGUERA 6)" #once, "---" #tonce, " "
'Lcdcmdout LcdLine4Home
'Lcdout "PISTOLA 6)" #doce, "---" #tdoce, " "
'Gosub control
'If enter = 0 Then Gosub prog
'Wend
'WaitMs 250
'+++++++++++++++++++++++++++++++++++++++++++++
'Lcdcmdout LcdClear
'WaitMs 200
'While cambio = 1
''Lcdcmdout LcdClear
'Lcdcmdout LcdLine1Home
'Lcdout "TANQUE " #trece, "---" #ttrece, " "
'Lcdcmdout LcdLine2Home
'Lcdout "++++++++++++"
'Lcdcmdout LcdLine3Home
'Lcdout "++++++++++++++"
'Lcdcmdout LcdLine4Home
'Lcdout "++++++++++++"
'Gosub controlIf enter = 0 Then Gosub prog
'Wend
'+++++++++++++++++++++++++++++++++++++++++++
'T1CON.TMR1ON = 1
Goto inicio
End
prog:
Lcdcmdout LcdClear
WaitMs 200
'T1CON.TMR1ON = 0 'lo apago para prgramar
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "MANGUERA 1 " #tempp(0), " "
If sube = 0 Then tempp(0) = tempp(0) + 1
If baja = 0 Then tempp(0) = tempp(0) - 1
WaitMs 100
Wend
'++++++++++++++++++++++++++++++++++++++++
WaitMs 200
Lcdcmdout LcdClear
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "PISTOLA 1 " #tempp(1), " "
If sube = 0 Then tempp(1) = tempp(1) + 1
If baja = 0 Then tempp(1) = tempp(1) - 1
WaitMs 100
Wend
'''+++++++++++++++++++++++++++++++++++++++
WaitMs 200
Lcdcmdout LcdClear
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "MANGUERA 2 " #tempp(2), " "
If sube = 0 Then tempp(2) = tempp(2) + 1
If baja = 0 Then tempp(2) = tempp(2) - 1
WaitMs 100
Wend
'+++++++++++++++++++++++++++++++++++++++++++++++++
WaitMs 200
Lcdcmdout LcdClear
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "PISTOLA 2 " #tempp(3), " "
If sube = 0 Then tempp(3) = tempp(3) + 1
If baja = 0 Then tempp(3) = tempp(3) - 1
WaitMs 100
Wend
'+++++++++++++++++++++++++++++++++++++++++++++++++++
WaitMs 200
Lcdcmdout LcdClear
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "MANGUERA 3 " #tempp(4), " "
If sube = 0 Then tempp(4) = tempp(4) + 1
If baja = 0 Then tempp(4) = tempp(4) - 1
WaitMs 100
Wend
'+++++++++++++++++++++++++++++++++++++++++++++++++++
WaitMs 200
Lcdcmdout LcdClear
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "PISTOLA 3 " #tempp(5), " "
If sube = 0 Then tempp(5) = tempp(5) + 1
If baja = 0 Then tempp(5) = tempp(5) - 1
WaitMs 100
Wend
'+++++++++++++++++++++++++++++++++++
WaitMs 200
Lcdcmdout LcdClear
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "MANGUERA 4 " #tempp(6), " "
If sube = 0 Then tempp(6) = tempp(6) + 1
If baja = 0 Then tempp(6) = tempp(6) - 1
WaitMs 100
Wend
'++++++++++++++++++++++++++++++++++++++++++++
WaitMs 200
Lcdcmdout LcdClear
While enter = 1
'Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "PISTOLA 4 " #tempp(7), " "
If sube = 0 Then tempp(7) = tempp(7) + 1
If baja = 0 Then tempp(7) = tempp(7) - 1
WaitMs 100
Wend
'+++++++++++++++++++++++++++++++++++++++++++
'++++++++++++++++++++++++++++++++++++++++++++++
Hserout #tempp(0), #tempp(1), #tempp(2), #tempp(3), #tempp(4), #tempp(5), #tempp(6), #tempp(7), Lf, CrLf
WaitMs 200
Goto inicio
Return
End
On Interrupt
Save System
If RCSTA.1 = 1 Then
RCSTA.CREN = 0 'Disable
Hserget papelera 'Limpia bufer Uart
Hserget papelera
Hserget papelera
RCSTA.CREN = 1
Endif
If PIR1.5 = 1 Then
Hserget templ(indice)
indice = indice + 1
Endif
If indice < 7 Then 'indice = 0
Hserout #tempp(indice), CrLf
Else
indice = 0
Endif
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Endif ''''''''''''''''''''''''''''''''''''''''''''''
Resume
'+++++++++++++++++++++++++++++++++
'''''''''''''''''''''''''''''''''''
End
no hay nada que hacer , el tipo sigue sin andar,puede ser mas ayuda?