EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Dallas DS18B20 CRC

Started by suppamax July 10, 2008
Hi everybody.

I've got a problem using Dallas DS18s20 temperature sensor.
In particular, it seems to me it sends a wrong crc.

Here's how I use it.
Firstly, I perform a temperature conversion, and a second later I read
data stored in its scratchpad.
Data regarding temperature and fixed values seems correct (temperature
is correct, the other parameters are always the same), but the crc is
wrong.

What can I do to solve the problem?



Thanks,



Max
"suppamax" <max.giacometti@gmail.com> wrote in message 
news:32a4a836-80e0-4659-b512-396e1062c2df@r66g2000hsg.googlegroups.com...
> I've got a problem using Dallas DS18s20 temperature sensor. > In particular, it seems to me it sends a wrong crc. > > Here's how I use it. > Firstly, I perform a temperature conversion, and a second later I read > data stored in its scratchpad. > Data regarding temperature and fixed values seems correct (temperature > is correct, the other parameters are always the same), but the crc is > wrong. > > What can I do to solve the problem?
Max, How are you determining that the CRC is incorrect? Is it possible that the bus master is incorrectly calculating what the CRC should be? Hard to say much else without more information. What hardware are you using (microcontroller/microprocessor), how are you calculating CRC, etc? There is apretty good writeup in the datasheet and Dallas (now Maxim) application note AN27 covers CRC quite thoroughly. Good luck, Richard
I see, I didn't give you a lot of informations.

My micro reads correctly data from the bus, I've verified it using an
oscilloscope.

The micro also calculates the CRC correclty, I've verified it using an
online crc calculator.

Another trial for that is I always receive default data from DS18s20
correctly.


I have no idea about how to solve this bug...




Max
Another thing I noticed is this one.
For some couples (temperature, counts remaining) I always receive a
wrong CRC, while when "counts remaining" is one unit less, the crc is
correct. For example

Temperature - LSB = 0xA3
Temperature - MSB = 0x01
TH = 0x4B
TL = 0x46
configuration register = 0x7F
reserved = 0xFF
counts remaining = 0x0D  <===
reserved = 0x10
CRC = 0xCE [CORRECT]

but sometimes I receive

Temperature - LSB = 0xA3
Temperature - MSB = 0x01
TH = 0x4B
TL = 0x46
configuration register = 0x7F
reserved = 0xFF
counts remaining = 0x0E  <===
reserved = 0x10
CRC = 0xD8 [WRONG correct CRC is 0x9B]

Thermometer doesn't work in parasite power mode, and it has sufficient
time to perform temperature conversion (1 second).



Max
suppamax wrote:
> > I see, I didn't give you a lot of informations. > > My micro reads correctly data from the bus, I've verified it using > an oscilloscope. The micro also calculates the CRC correclty, I've > verified it using an online crc calculator. Another trial for that > is I always receive default data from DS18s20 correctly. > > I have no idea about how to solve this bug...
Well, you have certainly minimized your help by avoiding quoting any earlier correspondence. If you want to post a followup via groups.google.com, ensure you quote enough for the article to make sense. Google is only an interface to Usenet; it's not Usenet itself. Don't assume your readers can, or ever will, see any previous articles. More details at: <http://cfaj.freeshell.org/google/> -- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section.

The 2024 Embedded Online Conference