PID Control Versus PLC

DjFab

Member
Join Date
May 2005
Posts
2
Hi, I know that most PLC nowadays contains function blocks of PID control variable. I would like to know to create and programme a PID function using the basic of a PLC programme, in ladder or FBD. Thanks.
 
If you want to "roll your own" PID you simply use the mathematical functions in the PLC to solve the PID equations. There are a number of variations on the equations, but you can find them in most PLC instruction manuals, or in any good text on control system.
 
here you go.
using the feedback concept the process variable (PV) is regulated according to the difference between its current value and the value
of the set point (SP) (i.e. what it should be). The output is the action required on the system
to keep the regulation.

The PID calculation is achieved by a method of sampling; Ts specifies the minimum sample period.
If Ts is less than the application scan time, the effective sample interval will be the application scan time.
The maximum effective sample period is Ts plus the application scan time. The outputs are recalculated
only if a new sample is made.

The input Auto determines whether the function block is to operate in AUTO or MANUAL mode:

AUTO Mode Operation
==================

If a new sample is made and Auto = TRUE, the output Xout is calculated as follows:

Xout = Kp * ( E[t] + I[t]/Ti + D[t] * Td)

where

E[t] = SP - PV (error)
I[t] = I[t-1] + ( E[t] * T ) (integral term)
D[t] = ( E[t] - E[t-1] ) / T (derivative term)

E[t-1] is the stored error value (i.e. value on last sample)
I[t-1] is the stored integral term (i.e. value on last sample)
T is the elapsed time in milliseconds since the last sample

On initialisation (i.e. first application program scan), the stored integral term is set to zero, and the
action is calculated using proportional action only (i.e. Xout = Kp * E[t]).

If Ti = 0, the stored integral term is set to zero and Xout is calculated using proportional and derivative
action only (i.e. Xout = Kp * (E[t] + D[t] * Td) ).

Once Xout has been calculated, the increment stop (INCstop), decrement stop (DECstop) and the clamp
(Xmax and Xmin) are applied. If INCstop = TRUE and Xout has increased since the last sample or if
DECstop = TRUE and Xout has decreased since the last sample, Xout is set to its previous value. If
Xout > Xmax or Xout < Xmin, Xout is clamped to the range Xmin to Xmax, LIMIThi is set to Xout > Xmax,
and LIMITlo to Xout < Xmin.

If INCstop, DECstop or the clamp are active, the previous integral term is retained (i.e. the stored
integral term is not set to the current integral term). On initialisation, INCstop and DECstop have no
effect.

MANUAL mode operation
====================

If a new sample is made and Auto = FALSE, the output Xout immediately follows the adjustment
value (XO) clamped to the range Xmin to Xmax. LIMIThi is set to XO > Xmax and LIMITlo to XO < Xmin.
The stored error term is set to (SP - PV) and the stored integral term is set to zero. The increment
and decrement stop (INCstop and DECstop) have no effect.

Parameter Summary
=================

Parameter Type Description
--- --- ---
Auto BOOLEAN TRUE for AUTO mode, FALSE for MANUAL mode
PV REAL Process variable
SP REAL Set point
XO REAL Adjustment value (in MANUAL mode, Xout = XO)
Kp REAL Proportionality constant
Ti TIMER Integral time constant
Td TIMER Derivative time constant
Ts TIMER Sampling period
Xmax REAL Maximum value of Xout
Xmin REAL Minimum value of Xout
INCstop REAL Increment stop
DECstop REAL Decrement stop
Xout REAL PID_II function output
LIMIThi REAL TRUE if Xout is clamped at its maximum value (Xmax)
LIMITlo REAL TRUE if Xout is clamped at its minimum value (Xmin)

N.B. Parameters PV, SP, XO, Kp, Xmax, and Xmin must be finite (i.e. not +/- infinities or NaNs).


call: PV, SP, XO, Kp, Xmax, Xmin (REAL); Auto, INCstop, DECstop (BOOLEAN); Ts, Ti, Td (TIMER)
return: Xout (REAL); LIMIThi, LIMITlo (BOOLEAN)

prototype: PID_II(PV, SP, Auto, XO, Kp, Ti, Td, Ts, Xmax, Xmin, INCstop, DECstop);
Xout := PID_II.Xout;
LIMIThi := PID_II.LIMIThi;
LIMITlo := PID_II.LIMITlo;

notes:

Loss of precision and underflow may occur.

Due to the limitations of ISaGRAF TIMER data type, Ti, Td and Ts cannot have a value of 24 hours or greater.

If Xmax < Xmin, the function assumes that the values have been reversed and 'swaps' the
values. The 'Reversed' error counter is incremented for every application program scan that the
values are reversed.

Either the following behaviour will occur *TBD*:

EITHER:

If overflow occurs during the execution of the function, the stored integral and error terms are set to
zero. In AUTO mode, if SP > PV, Xout is set to Xmax, LIMIThi to TRUE and LIMITlo to FALSE. If
SP < PV, Xout is set to Xmin, LIMIThi to FALSE and LIMITlo to TRUE. In MANUAL mode Xout is set
to XO clamped to the range Xmin to Xmax, LIMIThi is set to XO > Xmax and LIMITlo is set to XO < Xmin.

OR:

If overflow occurs during the execution of the function, the stored integral and error terms are set to
zero. In AUTO mode, Xout is set to zero, and LIMIThi and LIMITlo to FALSE. In MANUAL mode, Xout is
set to XO clamped to the range Xmin to Xmax, LIMIThi is set to XO > Xmax and LIMITlo is set to XO < Xmin.

example:
 
Make life easy for yourself. I hate having to muck about with maths and tune PID loops. I can make more money doing other things.

Omron CJ1 and CS1 have an autotune PID function. It is also 2 degree of freedom (advanced PID). You just turn on a bit and when the function has completed autotuning, the bit turns off and the PID is fully operational. Same algorithm as they use in their advanced autotune temperature controllers.
 
Hi thanks for your reply..
I would like to know if you know a PLC porgram that i could use at home for simulation and programming of process and process variable.
 
Omron CX-One has a full simulator, as do many other PLC packages these days.
 
Hi every body,

Does anyone know who to implement a PID control by ISAGRAFT? I could not find the PID function block in ISAGRAFT?

And after I write and simulate aapplication in ISAGRAFT by ST language, can I download it to a "real PCL", such as Simatic S7-300?

Thanks very much!!

I'm newbie:)
 
DjFab said:
Hi, I know that most PLC nowadays contains function blocks of PID control variable. I would like to know to create and programme a PID function using the basic of a PLC programme, in ladder or FBD. Thanks.

(sounds like a new homework problem, guys....)

Let me get this straight... you have a PLC that has FBD programming, and no PID instruction? 20 years ago I needed PID in a PLC-2, and ended up writing one in a BASIC module and tying it to the PLC2. It was W-O-R-K , and, even at the end, wasn't really the best way to go....but, in those dayz, we had to do stuff like this. That was then.

So, sure, as the previous posters have said, you could do it, but, just because you can do a thing does not mean you should do a thing. This is a textbook example of this rule.

Frankly, since the old dayz, any time I've been tempted to do PID in a PLC, I shell out the 200 bucks for a panel mounted controller with all the bells and whistles, (autotune, signal conditioning, etc.) and move on with life. There's just too much overhead to 'doing it' in a PLC, especially with only a few loops involved. Add up the cost of the analog I/O, signal conditioning, digital I/O, OPERATOR INTERFACE, tuning costs, commissioning costs, and you'll come up with the same conculsion.
 
Tom Jenkins said:
If you want to "roll your own" PID you simply use the mathematical functions in the PLC to solve the PID equations. There are a number of variations on the equations,
This is key. There are many forms of PID and some are better than others for different applications. One should find out what the application is before suggesting the best form of PID.

but you can find them in most PLC instruction manuals, or in any good text on control system.
Actaully, I have not seen how one implements a PID in the control books. That is a topic that doesn't get covered well.

I agree with jdbrandt. Buy a dedicate PID controller that is optimised for your application.

BLK, Isagraf is not the right programming language for implementing a PID. Isagraf is best for state machines, not continous process like a PID. If I were to implement a PID in Isagraf it would look like one state where the PID action is executed once on entry and then it would wait for the time period to expire and then repeat the step.

BobB, have you figured out what the degrees of freedom are for yet? We just bought a Omron PLC on ebay. I should lookup that PID.
 
Some years back good PID control with PLC's was almost impossible, well not many worked that well, but now most PLC's seem to have some good PID blocks.

But then again people like Eurotherm spend a lot of money developing controllers to perfection.
To be quite honest to put one of these Eurotherms in auto tune & let it run is nice & easy, but there is a thrill in having to do it manually.
 
thanks Peter Nachtwey.
I'm using the embedded PLC BL2500 from OEM technology, and I have only ISAGRAF to work with it.
could you please tell me another sofware to program this PLC?
 
There are many forms of PID. Which is in you PLC?

PIDs come in many forms. Some of the terms may only use the PV or change in PV. This means the gain is in the feedback path only. Those PIDs that have all the gains mulitplied by error I call PIDs. A PID with the derivative gain mulitplied by the rate of the PV I call a PI-D because the derivative gain is in the negative feedback path only. Many PLC PIDs are PI-D. Some take this a step further and put the proportional gain all in the feedback path. In this case it is an I-PD. There is a reason why some one made these PIDs. Some of the more advanced PIDs are called two degrees of freedom PIDs which one to ratio the feedback from the forward path and the feedback path for each gain. I am still waiting for BobB to say why this is important. It is important, but most wouldn't know what to do with the flexibilty.

There is also the velocity form and the position form. I hate those terms because they have nothing to do with position and velocity. I prefer do call them the incremental and full value or absolute form. The incremental form is more resistant to integrator windup. It also is better if you are changing gains on the fly. However, the incremental form requires that there is an integrator and that is it properly tuned.

Finally there is my favorite state space versus discrete form of PID. Both have all the variations listed above.

So which one should one implement? None are that difficult if you now what the application is and how to implement PIDs. However, if you are doing temperature control I think it makes sense to buy a temperature controller because you can bet the manufacturer has picked the right form of PID for that application. The same goes for motion control.

blk said:
thanks Peter Nachtwey.
I'm using the embedded PLC BL2500 from OEM technology, and I have only ISAGRAF to work with it.
could you please tell me another sofware to program this PLC?
Use structured text in a action or step and have the graph loop to that step every second or two depending on the required update rate. A PID should require only one step that loops to itself over and over again. One could use another step for initialization and yet another for manual mode but the basic operation should require just one step with a few lines of structured text in it.
 

Similar Topics

I have S7 1512C controler for controlling 48 PID temperature loop, the output is PWM. Please I need the best, most efficient way to write the...
Replies
13
Views
587
Hi all, I'm having trouble solving a problem I've been working on for several months, and thought you might like a stab at it. The machine runs...
Replies
22
Views
920
How can I connect PID Output to a valve. In ladder logic program is there any logic do I want to add between valve and PID? PV=SP What will be the...
Replies
7
Views
406
I am setting up control for Hypochlorite dosing. The easy part is the dosing calculation for flow pacing but I would also like to setup trimming...
Replies
8
Views
942
Hey guys! I'm a newbie in the control area, so I'm gonna drop some thoughts here... We want to control the opening of big silos (about 1900...
Replies
6
Views
1,484
Back
Top Bottom