Go Down

Topic: Dallas DS18S20 problems (Read 3795 times) previous topic - next topic

bovbjergdk

When using the following code, the temperature is ocassionally shown as 85, which I beleive is a fault code. The rest of the time the temperatures are OK. I am using parasitic mode with an 4.7 k pull up resistor. If I power the Vdd pin of the DS18S20, the readings are all ok.
I suspect it to be a timing problem, but where do I change the timing?
Somewhere in this forum, it has been mentioned, that an error exists with the "S" vesion of the DS18S20, but I have not been able to discover the nature of this error.

Any suggestions?

kind regards
Jens
Code: [Select]
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

void setup(void)
{
 // start serial port
 Serial.begin(9600);
 Serial.println("Dallas Temperature IC Control Library Demo");

 // Start up the library
 sensors.begin();
}

void loop(void)
{
 // call sensors.requestTemperatures() to issue a global temperature
 // request to all devices on the bus
 Serial.print("Requesting temperatures...");
 sensors.requestTemperatures(); // Send the command to get temperatures
 Serial.println("DONE");
 
 Serial.print("Temperature for the device 1 (index 0) is: ");
 Serial.println(sensors.getTempCByIndex(0));  
}

alm7100

Hi
On a S type i think you most have a least 750ms from the request to the read (see the datasheet)

bovbjergdk

Yes, I am aware of that, but where do I ad or change this delay.
I have tried to put in delays in the sketch without any luck.

Kind regards
Jens

Aleksi_M

#3
Jan 20, 2010, 01:14 pm Last Edit: Jan 20, 2010, 01:17 pm by Aleksi_M Reason: 1
If you get occasionally the value 85 (power-on value) right on the first time your code is running (eg. right after startup/powering), then you should be able to fix it simply by doing "dummy" temperature conversion request (for at least one of the sensors in the bus). The goal here is to give some power for the internal capacitors of the  sensors - after that they should be able to work as supposed.


The 750ms delay should be issued after you have issued the 44h (Convert T) command and pulled the OneWire bus high. Check the datasheet where you can find operation examples.

bovbjergdk

The 85 error does not only appear on reset or startup. It also occour in the middle of a series of correct measurements. Please notice, that I am using the DallasTemperature libary, so I do not issue a 44h command in my sketch.

alm7100

Hi

 // request to all devices on the bus
 Serial.print("Requesting temperatures...");
 sensors.requestTemperatures(); // Send the command to get temperatures
 delayms(750) <<<<<<-------------- this is not the command but you shut put i here
 Serial.println("DONE");
 
 Serial.print("Temperature for the device 1 (index 0) is: ");
 Serial.println(sensors.getTempCByIndex(0));

tkbyd

It may also be that you need to let the device "rest" between each read, as well as incorporating the delay already discussed, the one within the read-a-temperature routine.

But that "rest" does not need to be long. Two seconds should be more than enough, and you can probably "shave" that if your application requires it.

And/Or... and this is probably a good idea anyway... don't rely on what the Dallas datasheets call "parasitic power" to supply the DS18S20. Run three wires to it... the two you have already, plus one to supply Vcc continuously. With just two wires, the device is running itself off of the "on" moments of the data wire. It "works"... but the whole thing works more reliably the other way.

As for the faults in the DS1820, you may be picking up echos of the fact that there was a bad batch a long time ago. I think they were of a different variant of the 1820, and I think the fault only affected the calibration.

There's a useful thread discussing all sorts of 1820 issues at...

http://www.picaxeforum.co.uk/archive/index.php/t-7960.html

Go Up