Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Understanding CRC in DS18B20

Status
Not open for further replies.

Gastonio

Newbie level 5
Joined
May 8, 2010
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,359
Hi, first of all Merry Christmas to you all. And I would like to ask about CRC in DS18B20. I made project with a 8051 and DS18B20, however I didn't use CRC because it was tricky to understand, how it works. I would like to implement this error correction in my final year project and I am asking for your help. Can you please explain, how it works and guide me to the right path. I read CRC datasheet, however I couldn't fully understand.
Besides, I've found topic about CRC here, however it didn't help.
 

The CRC value is in position 8 of the scratchpad memory. The DS18B20 calculates it by feeding each bit of the preceding 7 positions into the calculation as shown on the data sheet. To check you have read the device correctly, your host system has the option of doing the same calculation in software then comparing the result with the CRC generated by the 18B20. It is entirely optional, personally I have never seen a read error on one of these devices but perhaps if the cables were at critical length it would be advisable.

Brian.
 

Thank you for the answer. Well, I know it's optional and It works good without it, however want to build a radio thermometer and use CRC as additional thing in my final year project.
 

I haven't done it but it should be very easy. Remember you are reading the data from the DS18B20 one bit at a time so you need to set up a counter to count from zero when you start reading to 56 at the finish. The block diagram in the data sheet has square boxes which indicate a shift right function and circles where an exclusive OR (XOR) is needed. You need to set up a shift register in software into which you feed each bit as you read it and perform the XOR when necessary. You should get the same CRC as stored in the 18B20 after all 56 bits have been fed in. So it's like this:

1. reset device and local CRC count
2. read 56 bits in, saving as bytes 0 to 7 and also feeding the bits to the CRC equation.
3. read in a further 8 bits which are the CRC as calculated by the DS18B20. These are NOT fed into the CRC equation.
4. Compare the DS18B20 result with the local CRC.

If the values don't match there is nothing you can do except reset and start again.

Brian.
 
Thanks, Brian. I'll try to understand again.
 

Hi, first of all Merry Christmas to you all. And I would like to ask about CRC in DS18B20. I made project with a 8051 and DS18B20, however I didn't use CRC because it was tricky to understand, how it works. I would like to implement this error correction in my final year project and I am asking for your help. Can you please explain, how it works and guide me to the right path. I read CRC datasheet, however I couldn't fully understand.
Besides, I've found topic about CRC here, however it didn't help.

Hi,
Have you seen this app. note :

Understanding and Using Cyclic Redundancy Checks with Maxim iButton products
**broken link removed**
 

Hi, yeah, I read it. Still can't figure it out. Could someone please show an example of this with incoming temperature bits like that: 0000 0111 1101 0000 (+125 degrees). Polynomial is X^8+X^5+X^4+1. First LSB is checked and then MSB. Maybe an example will clear it up.
 

Well, I think I figured out the work of CRC error correction. So all in all I can use another polynomial in my project, not just that suggested by maxim. In transmitter part I send temperature code with additional digits (remainder) which came from dividing temperature code with generating polynomial. In receiver part I accept that temperature code with remainder and divide it with that generating polynomial and decide what to do with that received code. If received code has remainder after division I can just skip it and wait for another code and if there is no reminder (0) then I accept that code and show it on LCD.
I'll just need to think and write subroutine for that.
Am I correct?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top