Almost, but there's not enough digits.
64-bits (8-bytes), will have 16 hex digits.
Try it this way ...
Code:LcdOut HEX2 ID[i]
Almost, but there's not enough digits.
64-bits (8-bytes), will have 16 hex digits.
Try it this way ...
Code:LcdOut HEX2 ID[i]
DT
Thank you all for reply !
In this book : "PIC Microcontrollers: Know It All" from Lucio Di Jasio, Tim Wilmshurst, Dogan Ibrahim, John Morton, Martin Bates, Jack Smith, D.W. Smith, and Chuck Hellebuyck - witch is my inspiration , I read this :
"Dallas Semiconductor’s 1-wire specifications define device serial numbers as 8 bytes (64 bits) long.The family code for 18B20 digital thermometer chips is $28. The CRC (cyclic redundancy code) is an error-checking feature, so that, should we desire, we may verify that the 56 bits of the family code and serial number have been correctly received and were not corrupted. We’ll not further consider how CRCs are calculated, as it’s a topic well beyond the level of this introductory book.
When we run the program, we see the following output:
28 4C D4 3E 0 0 0 D6
...
The digits 4C D4 3E 0 0 0 D6 are, of course, dependent upon the particular DS18B20 chip.
I plugged in a second DS18B20 chip and found its serial number:
28 FE DA 3E 0 0 0 C1
In the output, $28 is the family number and $D6 (or $C1 in the second example) is the CRC. The center six bytes represent the serial number of the chip. But, here’s a difference between the result and the serial number specification isn’t there? The definition has the CRC sent first and the family code sent last. Yet, Program 22.1 displays the family code first, and the CRC last.The explanation is that 1-wire devices store the least significant byte at the lower address and
the most significant byte at the higher address. Bytes are transmitted and received from lowest address to highest address. Hence, the net effect is the send/receive byte order is reversed from the data sheet description. This is more confusing to describe than to use; when we wish to address a particular device, we just repeat the byte order we read with Program 22.1"
So, I think it is enough for me these results.
Next step is : Reading multiple sensors on the same bus.
...Wish me luck !
I will keep you informed and - hope- I will receive yours advices again.
All the best !
Last edited by fratello; - 10th January 2009 at 11:26.
Hi, Fratello
From the Datasheet Organigrams ... you'll see the Bytes Order is inverted ...
as you worked Well ...
Here Data are shown with their signification ... Hope it will helpCode:'***************************************************************************** SensID:' Sensor Identification '***************************************************************************** OWOUT DQ, 1, [ $33 ] ' Read Chip code OWIN DQ, 2, [ FAM,ID[6],ID[5],ID[4],ID[3],ID[2],ID[1],CRC] IF FAM = $05 THEN LCDOUT $FE,$80, "DS 2405 " PAUSE 1000 LCDOUT $FE,$80, " CRC: ",HEX2 CRC," FAM: ", HEX2 FAM ENDIF IF FAM = $10 THEN LCDOUT $FE,$80, "DS 18S20/1820" PAUSE 1000 LCDOUT $FE,$80, " CRC: ",HEX2 CRC," FAM: ", HEX2 FAM ENDIF IF FAM = $28 THEN LCDOUT $FE,$80, "DS 18B20 " OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_11bit] 'Skip ROM search and write N_bits ' resolution to scratch pad PAUSE 1000 LCDOUT $FE,$80, " CRC: ",HEX2 CRC," FAM: ", HEX2 FAM ENDIF LCDOUT $FE,$C0," ID:",HEX2 ID[1],HEX2 ID[2],HEX2 ID[3],HEX2 ID[4],HEX2 ID[5],HEX2 ID[6]
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Thanks for support !!!!
First code (post #18) return this result : 28 CA C6 48 1 0 0 A7
Second code (post # 22) return : CA C6 48 01 00 00
In the code that I write now I use something like this :
"Init1
OWOut DQ, 1, [$55, $28, $FE, $DA, $3E, $0, $0, $C1, $4E, $FF, $FF, $7F]
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $48]
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $B8]
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $BE]
Pause 1000
OWOut DQ, 0, [Temperature.Byte0, Temperature.Byte1, 0, 0, DS18B20_12bit]
Init2
OWOut DQ, 1, [$55, $28, $FE, $DA, $3E, $0, $0, $C1, $4E, $FF, $FF, $7F] 'SENSOR 2 !!!!!!!!! not reading yet !!!!
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $48] 'SENSOR 2 !!!!!!!!! not reading yet !!!!
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $B8] 'SENSOR 2 !!!!!!!!!
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $BE] 'SENSOR 2 !!!!!!!!!
Pause 1000
OWOut DQ, 0, [Temperature.Byte0, Temperature.Byte1, 0, 0, DS18B20_12bit]
Main
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $44] ' Start temperature conversion Sensor 1
WaitLoop:
While not DQ
Wend
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $BE]
OWIn DQ, 0, [Temperature.Byte0, Temperature.Byte1]
GoSub Convert_Temp
GoSub DisplayTemp
Part2
OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $44] ' Start temperature conversion Sensor 2
WaitLoop2:
While not DQ
Wend"
I hope it's good...will see !
Last edited by fratello; - 10th January 2009 at 21:40.
Hello !
Me again ......I write the code attached, but the temperature on display don't modify (IN = 91.25 'C ; OUT = 25.18 'C)... Know somebody where is the mistake ? Thanks in advance...
Last edited by fratello; - 12th January 2009 at 11:23.
I found the mistakes ! I re-re-re...-write te code. Now works fine !
I did it !! I am verry happy ! I take a little pause -just a few hours- and I will try to adapt this code to the old code of thermostat, for having both function : dual termometre and thermostat. I will keep you informed ! All the best !
I know the accuracy is +/- 0.5 'C , but it is normal this ? One sensor show 25.21 'C and the other 26.18 'C... I put the sensors together, and I fix them with one earring, this is the temperatures after 15 min... Maybe i's something wrong in my code ?!
Last edited by fratello; - 12th January 2009 at 14:01. Reason: later edit :
Hope I am not boring with this subject !
1. I replace one sensor and now both temperatures are similar.
2.I write the code for dual thermometer and thermostat ; works verry good !
If somebody have idea to improve this code, please post here !
I wish you all the best !
Hi, Fratello
What about a nice Bargraph to show what's going on ... ???
like this one :
Better shown on attachmentCode:'***************************************************************************** '***************************************************************************** ' AFFICHAGE '***************************************************************************** '***************************************************************************** 'Motifs CGRAM LCDOUT $FE,$40,$00,$00,$00,$00,$00,$04,$04,$04 ' Cust Char $0 'Small bar LCDOUT $FE,$48,$00,$00,$00,$04,$04,$04,$04,$04 ' Cust Char $1 'Mid bar LCDOUT $FE,$50,$04,$04,$04,$04,$04,$04,$04,$04 ' Cust Char $2 'Big bar LCDOUT $FE,$58,$04,$04,$0E,$0E,$0E,$1F,$1B,$11 ' Cust Char $3 'Arrow LCDOUT $FE,$60,$11,$1B,$1F,$0E,$0E,$0E,$04,$04 ' Cust Char $4 'Inv Arrow LCDOUT $FE,$68,$04,$04,$0E,$1F,$1F,$0E,$04,$04 ' Cust Char $5 'Diamond '***************************************************************************** Aff:'Affichage temp '***************************************************************************** 'préparation chiffre : sign = 1 = valeur négative Decal = ( TempC // 5 ) << 1 IF NOT sign THEN Loscale = ( TempC /5 ) * 5 Hiscale = (( TempC /5 ) + 1) * 5 IF Float > 25 AND Float <= 75 then Decal = Decal + 1 IF Float > 75 Then Decal = Decal + 2 ELSE Loscale = (( TempC /5 + 1 ) * 5) * -1 Hiscale = ((TempC /5) * 5 )* -1 Decal = 10 - Decal IF Float > 25 AND Float <= 75 then Decal = Decal - 1 IF Float > 75 Then Decal = Decal - 2 TempC = TempC * -1 ENDIF 'Impression valeurs 1ère ligne IF Sign THEN LCDOUT $FE, $80 ,SDEC2 Loscale,178,Unit," " IF TempC = 0 THEN LCDOUT "-" LCDOUT SDEC TempC,".",dec2 Float IF ABS TempC < 10 then LCDOUT " " LCDOUT $FE,$80 + 11,SDEC2 Hiscale,178,Unit ELSE LCDOUT $FE, $81 ,SDEC2 Loscale,178,Unit," ",SDEC TempC,".",dec2 Float IF TempC < 10 then LCDOUT " " LCDOUT $FE,$80 + 12,SDEC2 Hiscale,178,Unit ENDIF 'Impression échelle 2ème ligne LCDOUT $FE,$C0,$01,$00,$02,$00,$01,$00,$01,$00,$01,$00,$01,$00,$02,$00,$01,$00 'Impression index IF Tempeff < ( Setpoint - 5 ) THEN LCDOUT $FE, $C2 + Decal,$03 'Index Chauffage ELSE IF Tempeff > ( Setpoint + 5 ) THEN LCDOUT $FE, $C2 + Decal,$04 ' Index Refroidissement ELSE LCDOUT $FE, $C2 + Decal,$05 ' Index Zone neutre ENDIF ENDIF
Last edited by Acetronics2; - 13th January 2009 at 12:38.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks