After trying a few commercial thermostats for my central heating (hot water), i was not really satisfied. They don't provide a smooth regulation.
Then i decided to build my own one reusing my flash destroyer hardware board.
It has the following features :
- PID based regulation
- PWM with a 5mn period cycle to drive the on/off gas boiler
- Up to 8 temperature sensors (DS18B20 or DS18S20) on a 1wire bus
- Auto detection, at power up time, of all the sensors and sorting them according to their internal Id
- Per sensor, compute mean temp value on 8 successive samples (each is 10 bits) then providing an enhanced measurement
- Select the lowest temp among all sensors and use it as "measured temp" for the regulation
- Setup values are stored in the pic eeprom
- Displays temp of each sensor in °C (round robin)
- Displays the percentage of time the heater is on in a PWM cycle
- Displays via a blinking dot when heater is on ("on" period of the PWM cycle)
- Direct change of temp setting via 2 push buttons (- and +)
- Access to a simple menu to change some settings (P, I and D coeff, luminosity of the display) by pressing simultaneously both buttons
Some very limited modifications of the DP Flash Destroyer board are needed :
- Remove the eeprom
- Pin 6 of the eeprom support is used for the 1wire bus
- Pin 5 of the eeprom support is used for the + button (other side to ground)
- Existing button connection is used for - button. An external one can be put in parallel if you need to group + and - in a more convenient location
- Pin 17 of the PIC18f2550 is used to control the boiler (was not used on Flash Destroyer)
My boiler is controlled directly via the AC mains then i have used a solid state relay, driven via a simple npn transistor plus 2 resistors.
Other types of interface can easily be buit, for example with a mechanical relay or with a power mosfet depending of the load you want to drive.
Some pics of the thermostat :
The firmware, after the initializations, enters a main infinite loop in which all "tasks" are sequentially activated when needed. Most of them rely on their own timer, implemented as a counter, which is decremented via the timer interrupt until it reachs zero.
The display is driven directly from the timer interrupt which ensure the digits multiplexing. The on state duration of each digit is adjusted (a given number of timer interrupt ticks) to allow to drive the luminosity according to the value set by the user (or to the default one).
For the PID, the P_coeff and the D_coeff are used as a multiplier. The I_coeff is used as a divider as the integral is based on the sum of the previous samples.
Your Flash Destroyer was probably sleeping in your drawer since many months. You can give it a new long life :)