I'm currently building & programming a controller for an electrical central heating. The system has the following hardware components:
- heater
- pump
- temperature sensors
To control the temperature in the heating system, the heater and the pump have to be turned on. Both are controlled by PWM.
I decided to use a PID (Proportional Integral Derivative) controller because it's commonly used in many solutions.
The first test I did was already successful with the following settings:
The target temperature of 55°C is never reached, but I'm very happy with the stable heater results. The heater is using around 80% power which results in a stable temperature output.
I performed more tests to see if I can tune the settings to reach the SetPoint, but I discovered that the heater control becomes more unstable (fluctuates between 50% and 100%) with these settings:
This can be explained because I'm using the output of the PID to control the heater. So the closer it gets to the setpoint, the smaller the PID output. But to keep the temperature at 55°C, the heater probably needs to be at 90% power. So how do I finetune the system? I'm thinking about:
- put the SetPoint to 60°C and try if the PID stabilize around 55°C
- use a bias (for example heater = 50% + PID output)
My PID controller uses the following formula:
heater = kp_gain * pid_error + (kd_gain * (pid_error - pid_error_old) / 55) + (ki_gain * (pid_error + pid_error_old) / 55);
What I'm looking for is to reach the setpoint of 55°C with a stable heater output (my guess it would be around 90%). How can I achieve this?