DS18B20 v DS1820

stocky

Senior Member
I knwo there is a difference - ie programmable resolution vs non-programmable

I guess I cant use a DS1820 instead of a DS18B20 then :-(

Anyone say different?
 

eclectic

Moderator
Sorry Mate.

Man 2 page 128

"Note the readtemp command does not work with the older DS1820 or DS18S20
as they have a different internal resolution. This command cannot be used on
pin0 or pin3 of the PICAXE-08M/14M, or pin6 of the 20M."

e
 

pha555

Senior Member
The ReadTemp and ReadTemp12 commands were specifically developed for the DS18B20.

But, if you do have the older format (DS18S20 - marked as DS1820 on the device) all is not lost. You can get 0.5 degrees C resolution.

The following was posted on the Yahoo PICAXE groups as message #2441

**************************

' For DS18S20, P H Anderson, Dec 26, '05

Symbol TReading = W0
Symbol Whole = B2
Symbol Fract = B3
Symbol SignBit = B4
Symbol Dig = B5
Symbol TempC_10 = W4

Top:
ReadTemp12 6,TReading

SignBit = TReading / 256 / 128
If SignBit = 0 Then Positive
' its negative
TReading = TReading ^ $ffff + 1

Positive:

TempC_10 = TReading * 5 ' TC = value * 0.5

GoSub DisplayTemp

Wait 1
GoTo Top


DisplayTemp:

Whole = TempC_10 / 10
Fract = TempC_10 % 10
If SignBit = 0 Then DisplayTemp_1
SerTxD ("-")

DisplayTemp_1:

SerTxD (#Whole, ".")
' be sure the fractional is two digits
Dig = Fract / 10
SerTxD (#Dig)
Dig = Fract % 10
SerTxD (#Dig, 13, 10)

Return

***************

Peter Anderson, http://www.phanderson.com
 

manuka

Senior Member
Good find! Diverse approaches from others of course have arisen, with => www.rentron.com/PICX4.htm typical. I'd also been lumbered ~y2k with scores of the original DS1820 sensors, but must have binned them, as none handy to verify this workaround.

NB however: Although I'd not experienced this (using at that pre PICAXE era PC reading),the DS1820 (& variants such as DS1822) was known to be failure prone-a significant reason behind it's replacement.

FWIW cheap DMMs (selling at times here in NZ for ~US$5) can make handy instant digital thermometers when reading a LM35 (°C) or LM34 (°F), which deliver a linear 10mV per degree. Thus 20°C would show 20 x 0.01V= 0.20V. The LM35 is cheaper (~US$2-3) than a DS18B20, & is hence educationally quite appealing,especially since - gasp!- no micro is needed for simple work ...

See also the Prof. Mason 08M/LM35 data logger => http://profmason.com/?p=255
 

Attachments

Last edited:

stocky

Senior Member
BUGGA! _ Still stuffed!

Cant use Readtemp on Pin 3 of an 08M!

PIN 0 - output for a LED
Pin 1 - ADC Input
Pin 2 - Output for MOSFET
Pin 3 - *was* going to use for TEMP input
Pin 4 - Output for another MOSFET

What a pain! The only input I have spare CANT be used for Readtemp and cant be used for ADC to free up a pin that I can use for readtemp

Also means I cant use a LM Chip either! GRRRR

Might have to go to a 14M with all those unused I/O

:-(

Back to the drawing board!
 
Last edited:

stocky

Senior Member
Thanks PHA555

I tried that & changed the code a little as I need only 1 Deg increments

seems to work ok! :)

Now to order some 14M's..........

Stocky
 

burgo

New Member
What about owin/owout?

Not sure exactly what your constraints are, but are you able to use the one-wire in and out commands on Pin 3? If so you can use these to control the DS18S20 a little more manually. I have done this and can post the code if anyone is interested.

In addition, you can get the full 16th of a degree accuracy using this method. You need to read the entire scratchpad (8 bytes) and do a little maths, but again, I can post the code for this.

Cheers,
Burgo.
 

BeanieBots

Moderator
One wire commands are only supported on X1 variety of chips. Hence, not possible on 08M. Pin 3 on 08M is input ONLY. One wire commands require bi-directional pins.
 

tronixstuff

New Member
eBay DS1820...

Sorry Mate.

Man 2 page 128

"Note the readtemp command does not work with the older DS1820 or DS18S20
as they have a different internal resolution. This command cannot be used on
pin0 or pin3 of the PICAXE-08M/14M, or pin6 of the 20M."

e
I learned that lesson yesterday, ordering some DS1820s which the seller claimed to be DS18S20s, but labelled DS1820. Back to a regular supplier!
 

Dippy

Moderator
Are you going to send them back to the Vendor and inform them of the mistake in their advertisement/page ?
 

pha555

Senior Member
The original DS1820 was replaced by the DS18S20. Dallas changed the packaging from a PR-35 (elongated transistor) to a TO-92. But, they continued to identify the device as DS1820.

So, if you have parts marked DS1820, they are DS18S20.

The newer DS18B20 is marked DS18B20. The format is different and I think it was the intent that people would use the DS18B20 in favor of the DS18S20.

Peter Anderson, http://www.phanderson.com/picaxe/
 

westaust55

Moderator
From a perusal of the DS1822 datasheet, it is for all intents idential to the DS18B20 so yes the PICAXE READTEMP/READTEMP12 commands should work as will the more basic 1-Wire commands on X1 and X2 PICAXE parts.
 
Top