I'm trying to implement a PID controller in C for an embbeded system. This is the first time. I think I haven't fully understand the theory.
For the proportional term, we have an output from PID controller that is
P = Kp*err
Suppose I have a power supply with a variable output voltage. The power supply output is connected to a low-value resistor that dissipates power and transfer heat to some water. I need to reach and maintain a temperature of the water by increasing/decreasing voltage across the resistor (i.e., the dissipated power). The loop is closed by the temperature measurement.
Should I set the power supply output voltage to 6V? I think so.
Should I set Vout=5V or increase Vout by 5V so setting it to 11V?
The mathematics say the output of PID controller *is* Kp*err, but I'm not sure. With the increase of temperature, the errore decreases to a minimum, so the Vout. At the steady state the error should be zero, but the voltage from the power supply can't be zero.
So I'm thinking to implement the proportional term as:
Vout += kp*err (note +=)
but this isn't what I found in literature.