DS1620.setTempHi()?
Jeff Dege
Posts: 85
Is there some reason why DS1620.setTempHi() and DS1620.setTempLo() do not set the temperature threshold values within the DS1620?
Comments
regards peter
I will, though it might take me a couple of days.
You claim those methods do not work, so show your code calling
those methods. There may be something wrong in your declarations
or the way you use the DS1620 class.
regards peter
And the DS1620 class does _not_ have setTempHi() or setTempLo() methods. They're non-virtual methods that it inherits from TempSensor.
In other words, setTempHi() and setTempLo() only set the threshold values within the TempSensor class. They do not create "WRITE TH" or "WRITE TL" commands and send them to the DS1620.
The two classes as they exist now work just fine for communicating the temperature to a Javelin program, and provide a Javelin program the information it needs to turn heaters/AC on or off. But they do not put the DS1620 into thermostat mode, and the three thermostat output pins on the DS1620 cannot be used for anything.
It should be simple enough to change the methods in class TempSensor to virtual, and then provide over-riding methods in class DS1620 that set the temperature thresholds within the chip.
becomes part of the DS1620 class.
Now you ask the question so I can undestand it (I don't use the DS1620 and had no
idea it has multiple modes).
If you want more functions, you can extend the DS1620 class or adapt the
DS1620 class. Note that TempSensor is an abstract class. Not all temperature sensors
have multiple modes. So it looks you must write code for the other mode yourself.
Perhaps someone else already has done this, but I don't remember any post about
the DS1620.
regards peter
·
It turns out that the DS1620 class is not written so as to enable those outputs. I will modify the classes in question so that these outputs are enabled, and post the code here. (I can't simply extend the class, because the methods in question were not declared virtual in the base class.)
You can override the setTempLo() and setTempHi() with code that
also call super.setTempLo()·etc. so the private treshold
parameters are set also.
You also need to write a method that instructs when which output
is switched (if that is not already dictated by the sensor itself)
and a method that returns the state of those switches.
regards peter
Exactly.
I could override getTempLo() and getTempHi() to return the values in the chip, but the tempLo() and tempHi() and tempOK() methods in TempSensor are written to access the member variables tLo and tHi directly, rather than through the access functions getTempLo() and getTempHi(). So I'd have to override tempLo() and tempHi(), as well, if I wanted to consistently use the settings in the chip to drive the behavior.
Of course, it might make most sense to have tempLo(), tempLo(), and tempOK() work from the corresponding in the chip's status register.
I did notice something, while we are at it.
The CPU flag on the DS1620 is stored in non-volatile RAM. The datasheet says it can be written at least 50,000 times.
But the constructor the DS1620 class writes it every time an object is constructed. It'd probably be better to read the flag first, and to set it only if it had been cleared, rather than writing it every time.
in eeprom. So you need to read those to check if a new value
is to be written.
You can make the private treshold settings in TempSensor protected,
then you can directly access them from DS1620.
The DS1620 as is, was written for the free-running mode of the DS1620.
You could write an entire new class DS1620th that supports the thermostat mode.
I don't think a given DS1620 will be used in both modes in the same application.
regards peter
·