PDA

View Full Version : Reading 5 DS18B20 Problem



CocaColaKid
- 26th August 2005, 15:42
I'm running into some problems that aren't making much sense to me so I'm hoping someone here can point out why this is not working the way I think it should. For some reason the raw_temp variable is not loading properly into the array. I can read each sensor fine but when I go to store the value into the array it doesn't seem to store information in the right locations.





x var byte ' Loop counter
dq var byte[9] ' 9 Byte Arrray for DS18B20
raw_temp var word[5] ' Raw Temperature

read_temps:
for x = 0 to 4
owout x,1,[$CC,$44] ' Send start temperature conversion command
low portb.5 ' Turn on transistor between rail and data pin
pause 750 ' Allow enough time to process Tconv
high portb.5 ' Turn off transistor between rail and data pin
owout x,1,[$CC,$BE] ' Send read scratch pad command
owin x,0,[STR dq\9] ' Read all 9 bytes and store them in dq array
raw_temp.Byte0[x] = dq[0] ' Isolate raw temperature from the rest
raw_temp.Byte1[x] = dq[1]
next x
goto read_temps

Melanie
- 26th August 2005, 16:11
http://www.picbasic.co.uk/forum/showthread.php?t=544

Read section 5.

CocaColaKid
- 30th August 2005, 20:51
Is there a way that I could issue a Start Temperature Conversion to all 5 sensors at the same time? The datasheet says it can be done when running on a bus however all my sensors have its there own IO's. I did it this way for field servicing simplicity. Just replace the sensor and your done if one should happen to fail.