TODOPIC
Microcontroladores PIC => Lenguaje Basic para microcontroladores PIC => Mensaje iniciado por: janiro74 en 15 de Abril de 2010, 18:07:28
-
No se que puedo hacer pero en el lcd solo se ve tla temperatura en la segunda linea y en la primera me sale
temp:-----------16
+22 ºc
no se como visualizarlo para con este circuito saber los codigos para luego poder dirigirme a ellos .
alguien sabe como hacerlo o la direccion de algun ejemplo para estudiarlo y modificarlo?
Este es parte del codigo en mikrobasic pro que es el compilador ke uso porque sé poco y solo de este.De antemano muchas GRACIAS
dim i,j1,j2 as byte
text as string[6]
tmp_sign as byte
DIM MAC AS longint
DIM MACLCD AS string[10]
main:
ANSEL=0
ANSELH=0
text="Temp:"
adcon1=255
PORTA=255
PORTB=0
PORTD=0
TRISA=255
TRISB=255
TRISD=0
Lcd_Init()
lcd_cmd(_Lcd_Cursor_OFF)
lcd_out(1,1,text)
lcd_chr(2,15,"º")
lcd_chr(2,16,"C")
ow_WRITE(PORTA,5,$33)
MAC=ow_read(PORTA,5)
LongintToStr (MAC,MACLCD)
LCD_OUT (1,6,MACLCD)
while TRUE
ow_reset(PORTA,5)
ow_write(PORTA,5,$CC)
ow_write(PORTA,5,$44)
delay_us(120)
i=ow_reset(PORTA,5)
ow_write(PORTA,5,$CC)
ow_write(PORTA,5,$BE)
j1=ow_read(PORTA,5)
j2=ow_read(PORTA,5)
if j2 = $FF then
tmp_sign = "-"
j1= j1 or $FF
j1= j1 + $01
else
tmp_sign="+"
end if
j2=(j1 and $01)*5
j1=j1>>1
if j1<=10 then
PORTA.0=1
end if
ByteToStr(j1,text)
lcd_chr(2,7,tmp_sign)
lcd_chr(2,8,text[1])
lcd_chr(2,9,text[2])
lcd_chr(2,10,46)
ByteToStr(j2,text)
lcd_chr(2,11,text[2])
Delay_Ms(500)
wend
end.
MI intencion es monitorizar las temperaturas de las habitaciones de una casa .Una vez sepa los codigos los meteré en variables para
convertirlos en nombres. cocina, salon, etc
-
pero habia que ver como ha configurados los pines del LCD , lo que no estoy seguro si tiene el LCD en 4 Bit modo o 8 Bit, si por casualidad lo tiene en 4 Bit modo te recomiendo que el resto de pine libre D0 hasta D3 los ponga a tierra, ojo ponerlo a tierra con una resistencia de 75 a 100 Ohmio, segun que tipo de LCD modelo no soportan esta opcion y deberia leerte el datasheet del LCD.
-
el lcd esta con 4 bit y bien configurado porque si no no se veria bien la temperatura. Donde creo que esta el fallo es en la llamada de esos 64 bits y en la conversion para la lcd pero no veo ningun ejemplo por ningun sitio y no se hacerlo
-
ha! porsi a alguen le interesa le he conectado un lcd de POWERTIP 2x16 ke me hallegado hoy el PC1602ARS-HSO-G y no se veia nada y lo he alimentado a 6v y va perfecto
pero lo de sacar la direccion fisica del ds18b20 todavia no lo he conseguido. ayuda porfa
-
Bueno compañeros pues aqui os dejo un cosigo que funciona para la lectura de la rom de ds1820
por supuesto no es mio , mi cabeza no da todavia pa tanto pero lo estoy estudiando pa entenderlo bien
program leer_rom_ds1820
dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
' "P16F690"
'Program for reading ROM code from One-Wire family,
'tested with DS1822 and DS18B20
'First 2 hex values is the family code, ex. 28 for DS18B20. Least significant byte
'Following 12 hex values is the serialnumber
'Last 2 hex values is the CRC code for the ROM code. Most significant byte
'Put these values in the multiple onewire program, can only read one at the time
' Lcd module connections
dim sensor as byte[8]
dim i, hexm, k, hextext as byte
dim hex1 as string[1]
sub procedure checkrom()
Ow_Reset(PORTa, 5)
Ow_Write(PORTa, 5, 0x33)
for i = 0 to 7
sensor = Ow_Read(PORTa, 5) 'Read and save ROM code
next i
end sub
Sub procedure valjfall(dim hexm as byte)
If hexm < 10 Then
hextext = hexm
Exit
End If
Select Case (hexm)
Case 10
hextext = "A"
Case 11
hextext = "B"
Case 12
hextext = "C"
Case 13
hextext = "D"
Case 14
hextext = "E"
Case 15
hextext = "F"
End Select
hextext = hextext - 48 'Trick for geting it right in the ASCII table
End Sub
Sub procedure dec2hex()
for k = 0 to 7
hexm = sensor[k] div 16
valjfall(hexm)
hex1[0] = byte(hextext + 48)
hexm = sensor[k] mod 16
valjfall(hexm)
hex1[1] = byte(hextext + 48)
select case k
case 0
Lcd_Out(2, 1, hex1)
case 1
Lcd_Out(2, 3, hex1)
case 2
Lcd_Out(2, 5, hex1)
case 3
Lcd_Out(2, 7, hex1)
case 4
Lcd_Out(2, 9, hex1)
case 5
Lcd_Out(2, 11, hex1)
case 6
Lcd_Out(2, 13, hex1)
case 7
Lcd_Out(2, 15, hex1)
end select
next k
End Sub
main:
ANSEL = 0 'Digital
ANSELH = 0
'C1ON_bit = 0 'Comparator 1 off
'C2ON_bit = 0 'Comparator 2 off
Lcd_Init() ' Initialize Lcd
Lcd_Cmd(_LCD_CLEAR) ' Clear Lcd
Lcd_Cmd(_LCD_CURSOR_OFF) ' Turn cursor off
Lcd_Out(1, 1, " | ROMCODE: |")
'Program start
checkrom()
dec2hex()
DELAY_MS(2000)
'GOTO MAIN
end.
está en mikrobasic pro for pic