5
\$\begingroup\$

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

  1. reading 2 ADC channels every second

  2. 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

  1. Should I increase the period of PID execution time or
  2. 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.

\$\endgroup\$
1
\$\begingroup\$
  1. Should I increase the period of PID execution time or

Something meaningful should be able happen between each sample. I think one second much too close. I would suggest starting with 10 seconds or more between samples.

2.0 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).

P,I, and D should be calculated together in my understanding. Using previous values will skew the process, it seems to me. Previous values are already handled in I and D.

But the problem is I cannot figure out how each terms are converted to the real output

Its not rocket science. Its really up to your system and how you decide to plug in numbers for P I & D. For example, If you decide that an output value of >= 100 is off, and < 100 on, P is adjusted until in the ballpark, and I and D to finish it up.

Find a copy of PID without a phd and study it well, if you haven't.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.