I've built a microcontroller based thermostat that I am using to control my home HVAC system. The actual programming and physical assembly has been straightforward. I'm using DS18B20 sensors, so I have far more precision available than I actually need. I take a sample once a second from the sensors.

What I'm trying to figure out is what the appropriate value for hysteresis and averaging period for temperature measurements are. Hysteresis is pretty easy to implement. I have a value of 1.33 F presently, meaning I turn off the AC when the temperature reaches 1.33 F below my set temperature. I'm using an exponential weighted moving average for the temperature value. This is because I don't have much RAM available. I used the typical alpha = 2/(N+1) with N=360 for an approximately six minute averaging period.

The combination of the above two values seems to have produced a system that behaves acceptably. Initial experiments with N=60 for the exponential weighted moving average resulted in a system that cycled on and off very fast.

Are there any industry standards for implementing things like this? My goal is to avoid short cycling the system. I live in a net cooling climate if that matters. Also my system isn't terribly oversized. In the peak heat of the summer the system needs to run greater than an 85% duty cycle to keep the house cool.

  • \$\begingroup\$ My thermostat cycles between +1 and -1 deg F. 1.33 deg F sounds reasonable. \$\endgroup\$ – Robert Endl Jun 10 at 7:19
  • \$\begingroup\$ For closed loop control, delays are death. And variable delays even a worse death. So I don't average stuff when operating closed loop controls -- as a rule. Just set hysteresis appropriately for the fastest readings you can get. \$\endgroup\$ – jonk Jun 10 at 8:45
  • \$\begingroup\$ I agree with jonk. I am surprised that you haven't created a long period oscillator. You might want to average for a few seconds to filter out any noise, but no longer. Two degrees of hysteresis is typical for all the thermostats that I have used. Also, note that some compressors have a minimum off time, is your controller expected to handle that, or is that built into the compressor circuitry? \$\endgroup\$ – Mattman944 Jun 10 at 10:30
  • \$\begingroup\$ @Mattman944 if I toggle the AC connection on the 4-wires quickly, it just runs the compressor for a while then turns off. So obviously there is some cycle time & duty cycle control somewhere in the HVAC system. There are a crazy number of safeguards in the actual code I wrote to avoid this "flapping" type behavior, including a minimum 2 minute cycle time. Does "long period oscillator" refer to some concept in closed loop control or is it exactly what it sounds like? \$\endgroup\$ – Eric Urban Jun 10 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.