onewire beta component

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time
Contact:

onewire beta component

Post by Eric »

I had quiet some difficulties to get the onewire betacomponent examples working:(http://www.matrixmultimedia.com/Flowcode_Components.php )
The initial results when I compiled the code gave erroneous results: 22 degrees room temperature resulted in a readout of 2.72 degrees on the lcd. See also my previous post on this: http://79.99.43.2/mmforums/viewtopic.php?f=5&t=4537

This is why:

There exist several versions of the Maxim DS1820: DS1820, DS18S20 and DS18B20.

Due to several problems with the original design, the DS1820 is now obsolete for some years.
Maxim redesigned the DS1820 and called it DS18S20, which is functionally fully compatible with the DS1820. They both have a resolution of 9 bits, meaning they can read temperatures up to 0.5 degrees ( higher resolutions are possible but not without extra manipulations ).
In fact, all DS1820 that are on the market now are in reality DS18S20. They are even labelled as DS1820.

DS18B20, on the other hand, has a resolution which is programmable from 9 to 12 bits and has an internal scratchpad structure which is not compatible with DS1820/DS18S20. Routines written for DS18B20 are NOT compatibel with DS1820/DS18S20.
I think that the examples that are provided on the beta components site are written for DS18B20 and not for DS1820 as indicated in the code.

Knowing the difference in resolution between these sensors, it can be explained why in my project 22 degrees room temperature resulted in 2,72 degrees on the lcd.
The trick is in the evaluation of byte 0 and 1 of the scratchpad in case you use a real DS1820/DS18S20.
The only thing that has to be done is a shift right 1 of byte 0, resulting in the "whole" part of the temperature, next a shift left 7 of the same byte 0, resulting in the "fraction" part of 0.0 or 0.5 degree.
if the result of this shift operation is 128, the fraction is ".5", if the result is zero the fraction is ".0"
Only these 2 fractions are possible due to the resolution of 9 bits.
If byte 1 of the scratchpad is zero, the sign is positive, if byte 1 is 1 or higher (mostly all bits are 1), the sign is negative. In that case the "whole" part of byte 0 should be read in 2-complement.

I hope this helps.

Post Reply