Pages: [1]   Go Down
Author Topic: DS18B20 Copy to EEPROM  Command  (Read 1259 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

G'Day,
Have a few DS18B20 talking Ok to the Duemilanove, and displaying temp via a Max7219. The problem I have is retaining the setAlarm Temp after powering down the unit. I know I need the copyscratch [hex48] but unable to find it in the OneWire or DallasTemperature lib's. What are my options.
Tks
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm curious why you're worried about the internal flags when you're got them wired up to a fully fledged microcontroller ?. The library writers probably didn't bother implementing the function because they couldn't see a use for them when you've got a relatively powerful processor to do it.  You could store the values in the Arduino's eeprom and upload them to the one wire devices in the setup part of the sketch. Or you could have the arduino deciding if an alarm condition exists from what the thermometers are telling it.
Logged


0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not using the Hi Lo  registers for alarms but to store an identifier code. This allows me to change a faulty DS18B20  and initialize the new DS with the same identifier. This is how I've set up the PC application.
and Dallas units.
Also the DallasTemperature lib, does have setHighAlarmTemp and setLowAlarmTemp, but this would have to be sent each time the Arduino unit was powered up. This does not make sense to me.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
this would have to be sent each time the Arduino unit was powered up.
This makes sense from a defensive programming point-of-view.
Logged

Per Arduino ad Astra

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Grove,
That's true from a defensive programmer point of view, but equally if the set points were read first and compared with what they should be, and if different one could suspect that the DS hardware could be possibly faulty. What I'm attempting to do is check the hardware devices for possible flakeness. Also I will have over 30 temperature sensors and keeping track of what one is where is often a difficult task. By having the identifier in the Hi Lo registers simplifies this task, plus allows me to easily replace sensors with a simple look-up table in the PC application.
Logged

Van Alstyne, TX
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Haven't smoked an Arduino... yet.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oz,
    You can do something like this to make up for the lack of CopyScratchPad command:
Code:
OneWire ow(OWpin);
#define OW_CMD_COPY_SCRATCH  0x48

ow.write(OW_CMD_COPY_SCRATCH, 0);

Use 0 if providing separate power for the sensors.
Use 1 if the sensors are using parasitic power.

The Copy ScratchPad to EEPROM command is specific to the
temperature sensors so they wouldn't go in the OneWire class.

   -Rusty-
« Last Edit: April 26, 2010, 03:06:18 pm by Fe2o3Fish » Logged

Van Alstyne, TX
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Haven't smoked an Arduino... yet.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, the DallasTemperature library I have saves the scratchpad to EEPROM when a DallasTemperature::writeScratchPad() is called.
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Rusty,
Tks for the constructive reply, but (hum always a BUT somewhere) still lost the new alarm value after powering off.

OneWire oneWire(ONE_WIRE_BUS)
....
sensors.setLowAlarmTemp(DallasTemp,i);
oneWire.write(0x48, 0);

Also the DallasTemperature::writeScratchPad() looks like it only writes to the scratch pad and leaves the EEPROM as is.

There is a third option, and that is I'm doing something wrong, anyway will have another play with it tonight.
Grant
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Rusty,
Now fixed, and thanks for putting me on the correct track.
What was missing was a
   ow.select(DallasTemp);
before the    
   ow.write(OW_CMD_COPY_SCRATCH, 0);
Grant.
Logged

Van Alstyne, TX
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Haven't smoked an Arduino... yet.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, using the work-around I gave you.

Still, we may have different DallasTemperature libraries.
The README file in mine states:
Arduino Library for Dallas Temperature ICs, version 2.5.0
but I just got the 3.5.0 version.  Both versions copy the scratchpad into EEProm in the writeScratchPad().  Removing the _wire->reset()
call still applies.  :-)
« Last Edit: April 27, 2010, 09:16:41 pm by Fe2o3Fish » Logged

Pages: [1]   Go Up
Jump to: