Click to see the message board for discussions!

Wednesday, December 1, 2010

How to implement PID controller !

So here it is guys!

PID Controller Implementation.

Lets start with the implementation assuming that all of you have good knowledge of PID theory. If not, then there are lots of book and material available on the internet.

There are two ways to build a controller:

-Analog controller
-Digital Controller

Lets just stick to analog controllers at this moment.


Analog controllers

Analog controllers are usually build using traditional operational amplifiers

Design 1: Ideal PID algorithm

Below is a simple inverting amplifier.




The equation (transfer function) of this amplifier is

 V2 / V1 = – Z2 / Z1

Now replacing Z1 and Z2 with a resistor and capacitor, we have the following op amp below.


Using some ECA (Electrical Circuit Analysis) , we have

V2 / V1 = – {(Rf / Ri + Ci / Cf) + (1 / RiCfD) + (RfCi) * D} = – {Kp + Ki / D + Kd D}

Hence the PID controller is :

PROPORTIONAL GAIN is Kp = (Rf / Ri + Ci / Cf),
INTEGRAL GAIN is Ki = (1 / RiCf), and
DERIVATIVE GAIN is Kd = RfCi.
Choosing the right values of the resistors and capacitors will lead to a better controller.


Design 2: Parallel PID algorithm

This is the best method to implement the controller since it is very robust and easily tunable. Below image summarizes how it works.



This is how it is implemented,


PROPORTIONAL GAIN is KP = (R2p / R1p),
INTEGRAL GAIN is KI = 1 / (R1i C1i), and
DERIVATIVE GAIN is KD = (R1d C1d), and
CASCADED GAIN is KC = (R2C / R1C).

You can easily use variable resistors and capacitors to get a tuned response.

Design 2: Series PID algorithm

Here the controller is a product of PI controller and PD controller. Following is the diagram:


The PID controller:
PROPORTIONAL GAIN is KP = (R2i R2d / R1i R1d + R2d C1d / R1i C1i),
INTEGRAL GAIN is KI = R2d / (R1d R1i C1i), and
DERIVATIVE GAIN is KD = (R2i R2d C1d) / R1i.
---------------------------------------------------------------------------------------------------------------

So guys, this was short tutorial on how to implement a PID controller using an op amp.
For detailed information, derivation and an implemented example please see this.

Please let me know what you think about this post! Do comment.


Have fun.

Categories:

12 comments:

Really really useful!!! thanks so much for the diagrams!! this really works!!!!

Where is the digital controller?

This was useful! Actually the material is better than in our school..

Many Thanks, I am beginer with PID Controller System.

Hi, I am interested in how I can send my input for the analogy controller - input to the operational amplifier. Let's take an example, I am trying to control a DC to AC converter and my demand voltage is 240V how do I create this demand physically.

@Ikechukwu Okoro:

Use a subtracting circuit. On the positive, you put your demand, on the negative, you put the output of the system, and the output of the subtracter is the input to the PID:

Ref->(+)->| PID |->| System |------>Out
^ |
|_(-) _________________|

I notice that you invert the output of the Parallel but not the output of the Ideal. Why?

This is good for matlab.
But this is not good if you are solving things on paper.
Sometimes, Kp, Ki and Kd values are given in percentage.
In such cases, the gains have to be calculated differently.
They are not simply Kp, Ki and Kd.
The following link explains how to do it.
http://elearning.vtu.ac.in/P8/e-notes/06IT64/Unit2-MS.pdf

@israel how do you selected the value of resistances and capacitance?

Thanks in advance. I'm gonna try design #1. Hope that will work well!

Thank You and I have a neat proposal: How Many Home Renovation Shows Are There house hunters renovation

Post a Comment

 
  • About the author

    Hi , thank you very much for visiting my blog. I'm Qaiser, creator of Mechatronics Heaven. This blog is meant to help mechatronics engineers and provides a free knowledge sharing portal. Contact me if you have any questions or suggestions.
  • Consectetuer

    Hello
  • Popular

  • Comments