PDA

View Full Version : Dallas one-wire question



Travin77
- 6th May 2006, 16:06
Hello again. I am dealing with a dallas one-wire temp sensor. I have used rentron electronics pages as a reference. I know how to poll the temp sensor to get its address. In my app, I need the the pic (16f876a with 20mhz) to poll it automatically without have to be hardcoded into the program. Here is what I have done so far:

OWOUT DQ, 1, [$33]
OWIN DQ, 0, [STR ID\8] this should place the address in the array.

Then to use the temp sensor:

OWOUT D, 1, [$55,str ID\8,$44]
w1:
OWIN D, 4, [Stat]' Check for still busy converting
IF Stat = 0 THEN W1' Still busy?, then loop
OWOUT D, 1,[$55,str ID\8,$BE]
OWIN D, 2, [Temp.LOWBYTE,Temp.HIGHBYTE]' Read two bytes, then end communications
IF Temp.bit15 = 1 THEN Below_32 ' Check for temp below 0°C

this code is straight off of Bruce's website (great site by the way). When the pic is fired up, the lcd outputs a temp of 32.32F with obviously is not correct. Any ideas? Thanks.

jimbab
- 7th May 2006, 07:37
Hi there,

Which Dallas 1 wire sensor are you using ? The DS18x20 type or iButton types.
Also do you plan on having more than one on the 1 wire bus ?

If there is only one device on the bus you so not need the devices ROM code but can use the "Skip ROM"(CCh) command instead of "Match ROM"(55h). If there is more than one device on the bus you will have to do a full search ROM routine to get the ROM code of the device you want to use.

There is also the question of "strong pull-up" if the device is a DS18x20 type if in parasite power mode or a DS1920 iButton type which is always in parasite mode. In parasite mode you have to pull the bus up to 5 volts during the time the conversion takes place. I use a P-channel MOSFET controled by one of the PortB outputs to do the strong pull-up. The strong pull-up routine is time based since no information can be taken from the bus when it is turned on.

There is also a difference between the DS18B20 and DS18S20 as to the resolution. The DS18S20 is 9 bit resolution while the DS18B20 can be set from 9 to 12 bit resolution. The DS18B20 comes on with the default valuse set to 12 bit resolution.

From the value of "32.32F" it sounds like the device is not answering at all and the "Temp" is just returning all 0.

Let me know just what your configuration is.

Jim

Travin77
- 7th May 2006, 17:32
There will only be one sensor on the line. It is not set on parasitic power. The model is ds18b20. I noticed the skip rom command in your post but must have entirely missed it in the datasheet. I am going to play with that for a while. Thanks.