I'm working on a humidity controller which uses PID algorithm to control the process values. I have to implement 2 PID routines as there are 2 process values ( Humidity and Temperature) to be controlled. I read many articles on PID controllers and I believe I understand the significance of each terms.
But the problem is I cannot figure out how each terms are converted to the real output ( varying On/Off cycles of Air heater and a boiler). What I have done so far are
In main routine
reading 2 ADC channels every second
calculating the PID output (value from 0-100) every second
Integral and derivative terms are added to the power calculated every Ti & Td cycles (programmable in 0-240 seconds). Since my PID output calculation is executed every second ,the very next execution after adding an integral term ( Or derivative) will result in a less power than the previous value (ie when integral or derivative power are added).
In ISR (@ period 2ms) I use 2 values ( On time and off time which are calculated using the PID output and cylic time( also programmable in secs)desired for the output) to change the output.
As you can see the with these timings integral power and derivative power does not going to have any effect on the output duty cycle and My questions are
- Should I increase the period of PID execution time or
- Should I retain the value of last calculated integral term ( or derivative) with the proportional term till the next addition of the integral ( or derivative).
I know I will get an idea how to play around each terms when it is tested on the system and after analyzing the response of the system. But I just want to clear my all doubts and to finish maximum part of the code possible before I get a machine to test on.