I have a thermistor hooked up to my #5 analog input and cannot get it to stop reading and bouncing around from 73.5°F to 74.92°F.
I am trying to use it as a thermostat and don't want the darn stat clicking on and off when it gets close to set point.
Any suggestions on leveling off or averaging this sensor?
Are the sensors always like this? (Bouncing like mad).
Actually that might be a normal reading for your setup. Not sure of how much of the total 0-5vdc range your sensor is using without knowing more about the sensor and how you have wired into your circuit. Also how you are scaling or mapping the value might give some light to the situation. Keep in mind that the 10 bit A/D conversions give around 5mv steps of resolution for each count. Figure out what a 5mv change represents for your scaling and see if you aren't just seeing the normal LSB switching on and off. Also the Atmel total accuracy spec is +/- 2 LSB, or +/- 20mv on a 0-5 volt scale.
All that aside it sound like what you have can be made to work. What most thermostats have mechanically built in, and what you need to add to you code, is called hysteresis so you don't 'chatter' on and off right at the setpoint value.
What you need is a moving band of temperature, say maybe 2 degrees wide. Say you have a target setpoint, of desired temp of 70 degrees. Your decision to turn on the heat should be at 69 and lower and turn off at 71 and higher. This gap has to be adjusted to change with the setpoint such that if you demanded 80 degrees the the on and off decision points would be 79 and 81.
You may have to increase that gap wider depending on the amount of noise or variation of your sensor readings, the total heat load of what you are heating up and the heat capacity of you heat source.
Tighter control then that would require more sophisticated control algorithms such as PID control and a variable output control, either analog or PWM to drive the heating element.
iRagDoll, I am going to stick with thermistors as they are the most commercially acceptable in the industry. Thank you for your input though.
Lefty, I am using a 10K thermistor from SparkFun (Datasheet: http://www.sparkfun.com/datasheets/Sensors/Thermistor23816403-1.pdf). I understand the logic that is supposed to happen with the thermostat as far as deadbands and what not. I am in the HVAC and control industry.
I do have a delay so it doesn't "chatter" on and off. I was looking more to average the thermistor reading so it doesn't keep swinging (even 1 degree is a big swing if done quick enough).
Any thoughts?
It also shows 73.5 in the room when the mercury bulb shows 68 degrees. I am using the program from the examples to read the thermistor. Any thoughts on that?
Thanks guys! I will be hooking up the stat to my furnace tonight! Test run :)... Brrrrr!!!!
I was looking more to average the thermistor reading so it doesn't keep swinging (even 1 degree is a big swing if done quick enough).
Any thoughts?
I would try software filtering before external electrical filtering, cause it's free.
Take four readings in a row just adding it to the same variable and then divide by four to get your 'filtered reading'. Then zero out the variable and take another four readings, divide, lather, rinse, repeat. Try eight readings and divide if needed. You are trading speed for stability, but most temp applications are not too demanding for Arduino speed.
It also shows 73.5 in the room when the mercury bulb shows 68 degrees. I am using the program from the examples to read the thermistor. Any thoughts on that?
4 1/2 degrees high? I would want to know if at say 90 degrees is it's still a 4 1/2 high error. Such linear 'offset' errors can easily adjusted out in either software (simple add the offset in software), or if your using a simple resistor/thermistor circuit reduce the resistor by say 1000 ohms and add a 10 turn 1K ohm trim pot and then adjust the pot so the reading equals your reference bulb. If it's not a linear error and unacceptable performance for your application then you have to blame it on either the sensor or your software scaling/mapping method.
PS: They say a man with one watch always knows the time, man with
two watches never quite sure.
What is the tolerance on the resistor used with the Thermistor?
Also, where did you get the data to convert from resistance to temperature? From Vishay's website they provide tables... meaning that a function might not be good enough to get a temperature X resistance plot.
Have you tried plotting the data and creating a regression on the curve?
4 fahrenheit is way too much error for this type of NTC. :\
As usual retrolefty has the best advice. Sorry, iRagDoll a better sensor wont fix short cycling or chattering.
I do have a delay so it doesn't "chatter" on and off. I was looking more to average the thermistor reading so it doesn't keep swinging (even 1 degree is a big swing if done quick enough).
Please note delay is NOT deadband. Delay is TIME and deadband is TEMPERATURE. Hysteresis - Wikipedia see In Engineering, Control Systems a little more than halfway down. There is some loose confusion among HVAC workers between "delay" and "hysteresis", the difference is subtle but vitally important.
I have this issue with my thermistor device as well.
I went in and in my programming have the sensor readings set up as if/then statements. This way I can setup "windows" of acceptable values...
For example...
If the temp you want the room to be is 74 degrees, then you set the acceptable window from 72-76 (sensor reading). This 4 degree swing is essentially debouncing the system. You also have to set the parameters so that the temp must remain outside the window for a given amount of time before the system attempts to correct it.
Desired temp: 74
Window: 72-76
Time to correction: 5 minutes
If/Then: If the temp falls out of the window for 5 minutes, take corrective action until the desired temp is reached
My application has a 15 second buffer between changes to the system and a window of 5 degrees C (but it requires exceptionally quick use of the temp data)