I am trying to think of a way to stop the change in readings of a temperature probe.
If the temperature changes from 20 F to 21 F and then back to 20 F quickly enough I will drive a relay crazy with the off on off of the quick temperature changes.
I could put a delay in there so it would have time to stabilize, or only poll the temp sensor every 5 minutes. Both would work. Anyone have a more eloquent idea?
Bob
Temperature ambiguity
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Temperature ambiguity
Hello Bob,
I think the normal way to overcome this type of problem is with the use of hysteresis.
I'm guessing at the moment you are doing something like this.
if sensor < 21 then switch on
else switch off
Whereas you probably need to instead do something like this.
if sensor < 21 then switch on
else if sensor > 23 switch off
This way the sensor will only be switch on if the reading is less then 21 but only switched off when the sensor is greater then 23 giving you a hysteresis of 4. If there is substantial noise coming from the temp problem then you might have to increase the hysteresis to overcome the noise and avoid oscillation.
A choke or ferrite ring could potentially be placed on the wire to the temp sensor to get rid of some induced noise.
http://en.wikipedia.org/wiki/Ferrite_bead
Averaging a set of ADC readings should also help.
I think the normal way to overcome this type of problem is with the use of hysteresis.
I'm guessing at the moment you are doing something like this.
if sensor < 21 then switch on
else switch off
Whereas you probably need to instead do something like this.
if sensor < 21 then switch on
else if sensor > 23 switch off
This way the sensor will only be switch on if the reading is less then 21 but only switched off when the sensor is greater then 23 giving you a hysteresis of 4. If there is substantial noise coming from the temp problem then you might have to increase the hysteresis to overcome the noise and avoid oscillation.
A choke or ferrite ring could potentially be placed on the wire to the temp sensor to get rid of some induced noise.
http://en.wikipedia.org/wiki/Ferrite_bead
Averaging a set of ADC readings should also help.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: Temperature ambiguity
Hi Bob,
You could build in some hysteresis, so that you change the threshold point depending upon whether your relay is switched on or switched off. For example:
if (off and temperature < 20) Switch on; // only switches on when temp is 19 or less
if (on and temperature > 20) Switch off; // only switches off when temp is 21 or more
Leigh
You could build in some hysteresis, so that you change the threshold point depending upon whether your relay is switched on or switched off. For example:
if (off and temperature < 20) Switch on; // only switches on when temp is 19 or less
if (on and temperature > 20) Switch off; // only switches off when temp is 21 or more
Leigh
-
- Posts: 157
- Joined: Sat Jan 22, 2011 10:39 pm
- Location: Michigan
- Has thanked: 6 times
- Been thanked: 27 times
- Contact:
Re: Temperature ambiguity
Hey thanks for the ideas.
Problem is not noise. Just simple dealing with the almost change in temperature.
Have it working to just read inside temperature for right now but was noticing a flip flop between 72 F and 73 F. This was happening over a period of about 5 seconds and lasted several minutes till if finally settled at 73 F.
Will be checking for 5 degree increments from 45 F down to -20 F. IE: if temp >35 then ON else OFF.
I probably will have the same issue with the Humidity sensor. Glad I am using an SSR and not a relay to control the motor.
A few degrees one way or another will not hurt things.
I am not measuring to a 1/10 degree, do not need that much accuracy.
Will try you ideas and see what happens.
Problem is not noise. Just simple dealing with the almost change in temperature.
Have it working to just read inside temperature for right now but was noticing a flip flop between 72 F and 73 F. This was happening over a period of about 5 seconds and lasted several minutes till if finally settled at 73 F.
Will be checking for 5 degree increments from 45 F down to -20 F. IE: if temp >35 then ON else OFF.
I probably will have the same issue with the Humidity sensor. Glad I am using an SSR and not a relay to control the motor.
A few degrees one way or another will not hurt things.
I am not measuring to a 1/10 degree, do not need that much accuracy.
Will try you ideas and see what happens.
-
- Posts: 528
- Joined: Sat Dec 01, 2012 1:23 pm
- Location: Sweden
- Has thanked: 49 times
- Been thanked: 101 times
Re: Temperature ambiguity
Hysteresis is the way to go Bob. It is a common oversight (at least I tend to forget about it from time to time
)
I think it's the way the mind works, either it is or isn't.
One could also implement a counter and use it as a timer. If you wanted to use the temperature data to keep the temperature as stable as possible using a fan or heater element for example. If you wanted the temperature to be very stable but don't want the relay/mosfet/etc to switch on/off all the time, then you could reset then start the counter every time the temperature changes and if the counter reaches a set number (trial and error to find a number that works for you) then enable/disable relay.
Just a thought

I think it's the way the mind works, either it is or isn't.
One could also implement a counter and use it as a timer. If you wanted to use the temperature data to keep the temperature as stable as possible using a fan or heater element for example. If you wanted the temperature to be very stable but don't want the relay/mosfet/etc to switch on/off all the time, then you could reset then start the counter every time the temperature changes and if the counter reaches a set number (trial and error to find a number that works for you) then enable/disable relay.
Just a thought

-
- Posts: 157
- Joined: Sat Jan 22, 2011 10:39 pm
- Location: Michigan
- Has thanked: 6 times
- Been thanked: 27 times
- Contact:
Re: Temperature ambiguity
Have built most of the live circuit, had to order new LCD display, the ones I had are bad.
I have been playing with it in the Simulator. I found about the best way to go it to have the program read and display the temperature and humidity all the time, and only have it run the decision trees every 3-5 minutes. I am lucky in the fact that accuracy is not mission critical here. Most home thermostats only read whole numbers, and I have never seen humidity expressed in anything but whole numbers.
Hardest part of all this is trying to find a small project box already cut out for a 4x20 lcd. I hate cutting rectangular holes.
did find a place for bezels though:
http://www.rmfproducts.com/bezel142.htm
I have been playing with it in the Simulator. I found about the best way to go it to have the program read and display the temperature and humidity all the time, and only have it run the decision trees every 3-5 minutes. I am lucky in the fact that accuracy is not mission critical here. Most home thermostats only read whole numbers, and I have never seen humidity expressed in anything but whole numbers.
Hardest part of all this is trying to find a small project box already cut out for a 4x20 lcd. I hate cutting rectangular holes.
did find a place for bezels though:
http://www.rmfproducts.com/bezel142.htm