Hi
I'm trying to get the temperature values from a DS18B20 but it seems like I receive only the lower 6 bits. Right now I have 101110 wich is 2.8750.
When I touch the sensor it will increase the values, like 110011 wich is 3.1875. So I think the sensor is ok but for some reason it doesnt give me all bits. I use a 4.7k pull up.
My program looks like this:
And it gives me "High= 0 Low= 101110" on the LCD.Code:ADCON1 = %00001111 DEFINE OSC 48 DEFINE LOADER_USED 1 DEFINE RESET_ORG 800h ' For Microchip USB Bootloader DEFINE INTERRUPT_ORG 808h ' For Microchip USB Bootloader Define LCD_DREG PORTA Define LCD_DBIT 0 Define LCD_RSREG PORTA Define LCD_RSBIT 4 Define LCD_EREG PORTB Define LCD_EBIT 3 DEFINE LCD_BITS 4 DEFINE LCD_LINES 2 DEFINE LCD_RWREG PORTA DEFINE LCD_RWBIT 2 DQ VAR PortC.0 ' One-wire Data-Pin "DQ" on PortC.0 Busy VAR BIT ' Busy Status-Bit R_Temp VAR WORD ' RAW Temperature readings Low PORTA.5 ' LCD R/W line low (W) MainProgram: OWOUT DQ, 1, [$CC, $44] ' Skip ROM search & do temp conversion Wait_Up: OWIN DQ, 4, [Busy] ' Read busy-bit IF Busy = 0 THEN Wait_Up ' Still busy..?, Wait_Up..! OWOUT DQ, 1, [$CC, $BE] ' Skip ROM search & read scratchpad memory OWIN DQ, 2, [R_Temp.Lowbyte, R_Temp.Highbyte]' Read two bytes / end comms lcdout $fe,1,"High= ",bin R_Temp.Highbyte," Low= ",bin R_Temp.Lowbyte GOTO MainProgram END
I have two sensors to test with and they act the same way.
What can be wrong here? I tried to take the code direct from here: http://www.rentron.com/PicBasic/one-wire3.htm
But no success. It just print +2.8750 on LCD.
Thanks in advance.
Stefan.




Bookmarks