'PIC18F2520
Define CLOCK_FREQUENCY = 12
AllDigital
'Define SIMULATION_WAITMS_VALUE = 1
Define LCD_LINES = 2
Define LCD_CHARS = 16
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 2
Define LCD_RWREG = 0
Define LCD_RWBIT = 0
Define LCD_EREG = PORTB
Define LCD_EBIT = 3
Define LCD_READ_BUSY_FLAG = 0
Lcdinit 0
Define 1WIRE_REG = PORTB
Define 1WIRE_BIT = 1
Dim finish As Bit
Dim sign As Bit
Dim temp As Word
Symbol led = PORTC.2
led = 1
WaitMs 1000
led = 0
loop:
1wireInit
1wireSendByte 0xcc, 0x44
WaitMs 1000
loop1:
1wireGetBit finish
If finish = 0 Then Goto loop1
1wireInit
1wireSendByte 0xcc, 0xbe
1wireGetByte temp.LB, temp.HB
Lcdcmdout LcdClear
Lcdout #temp 'raw data readout
WaitMs 2000
sign = temp.15
If sign = 1 Then
led = 1
Lcdout "-"
temp = 65535 - temp
temp = temp + 1
Endif
temp = temp / 16
Lcdout #temp
WaitMs 2000
Goto loop
****************************************************
above is the code i use for reading Ds18b20 it is give proper reading for positive temperature.
The negative temp is not shown i only get to 0 Deg C and raw data is showing 10 in ice cold water.
LED is not getting triggered, tried different DS18B20 from different suppliers.
any ideas ??
cheers
mastero
Define CLOCK_FREQUENCY = 12
AllDigital
'Define SIMULATION_WAITMS_VALUE = 1
Define LCD_LINES = 2
Define LCD_CHARS = 16
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 2
Define LCD_RWREG = 0
Define LCD_RWBIT = 0
Define LCD_EREG = PORTB
Define LCD_EBIT = 3
Define LCD_READ_BUSY_FLAG = 0
Lcdinit 0
Define 1WIRE_REG = PORTB
Define 1WIRE_BIT = 1
Dim finish As Bit
Dim sign As Bit
Dim temp As Word
Symbol led = PORTC.2
led = 1
WaitMs 1000
led = 0
loop:
1wireInit
1wireSendByte 0xcc, 0x44
WaitMs 1000
loop1:
1wireGetBit finish
If finish = 0 Then Goto loop1
1wireInit
1wireSendByte 0xcc, 0xbe
1wireGetByte temp.LB, temp.HB
Lcdcmdout LcdClear
Lcdout #temp 'raw data readout
WaitMs 2000
sign = temp.15
If sign = 1 Then
led = 1
Lcdout "-"
temp = 65535 - temp
temp = temp + 1
Endif
temp = temp / 16
Lcdout #temp
WaitMs 2000
Goto loop
****************************************************
above is the code i use for reading Ds18b20 it is give proper reading for positive temperature.
The negative temp is not shown i only get to 0 Deg C and raw data is showing 10 in ice cold water.
LED is not getting triggered, tried different DS18B20 from different suppliers.
any ideas ??
cheers
mastero