hello there,
i am newbie in the forum and i have register because i have a strange problem with my programm......
i have 3 ds18B20 & and a 18f4550 and when i read tempurature from the ds's i get the same tempurature and for the 3's... the tempurature i effective from the last ds18B20...the third....
here is my code....
please help....
i am newbie in the forum and i have register because i have a strange problem with my programm......
i have 3 ds18B20 & and a 18f4550 and when i read tempurature from the ds's i get the same tempurature and for the 3's... the tempurature i effective from the last ds18B20...the third....
here is my code....
please help....
Code:
'------------------------------------------------------------------------------------------
Define CLOCK_FREQUENCY = 20
AllDigital
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 = 0
Define LCD_RWBIT = 0
'Lcdcmdout LcdClear
'Lcdcmdout LcdLine1Home
Dim temp1 As Word
Dim temp11 As Byte
Dim temp2 As Word
Dim temp21 As Byte
Dim temp3 As Word
Dim temp31 As Byte
Lcdinit
start:
s1:
temp1 = 0
temp11 = 0
Define 1WIRE_REG = PORTB
Define 1WIRE_BIT = 0
1wireInit
1wireSendByte 0xcc, 0x44
WaitMs 1
1wireInit
1wireSendByte 0xcc, 0xbe
1wireGetByte temp1.LB, temp1.HB
'---resolution 12bit => 0.0625 *C 1*C/0.0625=16
If temp1 < 2000 Then '2000*0.0625=125*C
temp11 = temp1 / 16
temp1 = (temp1 - ((temp1 / 16) * 16)) / 10
PORTB.3 = 0
Else
temp1 = 65535 - temp1
temp11 = temp1 / 16
temp1 = temp1 - ((temp1 / 16) * 16)
PORTB.3 = 1
Endif
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "test ds1820"
Lcdcmdout LcdLine2Home
Lcdout "t1: ", #temp11, ".", #temp1
WaitMs 2000
s2:
temp2 = 0
temp21 = 0
Define 1WIRE_REG = PORTB
Define 1WIRE_BIT = 1
1wireInit
1wireSendByte 0xcc, 0x44
WaitMs 1
1wireInit
1wireSendByte 0xcc, 0xbe
1wireGetByte temp2.LB, temp2.HB
'---resolution 12bit => 0.0625 *C 1*C/0.0625=16
If temp2 < 2000 Then '2000*0.0625=125*C
temp21 = temp2 / 16
temp2 = (temp2 - ((temp2 / 16) * 16)) / 10
PORTB.3 = 0
Else
temp2 = 65535 - temp2
temp21 = temp2 / 16
temp2 = temp2 - ((temp2 / 16) * 16)
PORTB.3 = 1
Endif
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "test ds1820"
Lcdcmdout LcdLine2Home
Lcdout "t2: ", #temp21, ".", #temp2
WaitMs 2000
s3:
temp3 = 0
temp31 = 0
Define 1WIRE_REG = PORTB
Define 1WIRE_BIT = 2
1wireInit
1wireSendByte 0xcc, 0x44
WaitMs 1
1wireInit
1wireSendByte 0xcc, 0xbe
1wireGetByte temp3.LB, temp3.HB
'---resolution 12bit => 0.0625 *C 1*C/0.0625=16
If temp3 < 2000 Then '2000*0.0625=125*C
temp31 = temp3 / 16
temp3 = (temp3 - ((temp3 / 16) * 16)) / 10
PORTB.3 = 0
Else
temp3 = 65535 - temp3
temp31 = temp3 / 16
temp3 = temp3 - ((temp3 / 16) * 16)
PORTB.3 = 1
Endif
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "test ds1820"
Lcdcmdout LcdLine2Home
Lcdout "t3: ", #temp31, ".", #temp3
WaitMs 2000
Goto start
'---------------------------------------------------------------------------------------------------
Last edited by a moderator: