PID control equation

S

Thread Starter

Shelly Maharaj

Hi,
I am trying to control a motor using PID control using the Texas Instruments DSP board, tms320c31. I would just like someone to tell me if I used the right PID control equation. I used the bilinear transformation 2/T(z-1)/(z+1) to
transfer the time equation y(t) = kpe(t) + ki*(integral of e(t)) + kd de(t)/dt
and obtained the difference equation
y)n) = y(n-2) + k1e(n) + k2e(n-1) +k3e(n-2)where K1 = Kp + 2Kd/T + K1T/2
K2 = KiT - 4Kd/T
k3 = KiT/2 + 2Kd/T - Kp

but it is not working..instead of converging to the setpoint it is diverging. What I did was just use arbitrary values for the gains (i.e without modelling) so I don't kn ow if that is the problem. I know that varying the gains will
affect the system but I didn't think to such extent. Any advice?
Thanks,
Shelly
 
P

Peter Nachtwey

1. The equation looks good except for a type error K1 = K1 = Kp + 2Kd/T + KiT/2. Should be Ki instead of K1.

2. A common problem is overflow. Big positive numbers look like negative numbers. Check the K2 term since it will overflow if Kd is very big.
 
D
There are three types of PID control equations, see below:

Type A:

Type B:

Type C:

Of course you need to filter the process variable PV before using it, and CO must be in the admissible range [CO(min) CO(max)] in order to avoid the so called wind-up, i.e., after the calculation of CO using any one of the above PID equations, do this

CO = its upper limit CO(max) if CO > CO(max);
CO = its lower limit CO(min) if CO < CO(min);

CO(max) and CO(min) are such that if CO changes within the range [CO(min) CO(max)], PV will respond to this CO change; Changes of CO out side of [CO(min) CO(max)] will have no effect on PV.

Studies show that Type C is the best. For more details take a look at

"http://bestune.50megs.com/typeABC.htm":http://bestune.50megs.com/typeABC.htm

Dan
 
I
Shelly,
If you still have this problem try the following and I believe this would work.
Consider your control realization as a numeric integration and differentiation problem with time step T.
Also, separate components of your control for more convenient realization.
Let the overall PID control be:
y(n)=yp(n)+yi(n)+yd(n)
then control components are:
yp(n)=kp*e(n),
yi(n)=yi(n-1)+ki*e(n)*T,
yd(n)=kd*(e(n)-e(n-1))/T
Initial value for the integral component can be
yi(0)=0.
Igor Boiko
[email protected]
 
J

Jorge M. Tirabasso

Hello Shelly

My tried and working equation is as follows:

y(n) = y(n-1) + [ Kp + (Ki T / 2) + (Kd/T) ] e(n) + [ (Ki T / 2) - Kp - (2
Kd / T) ] e(n-1) + (Kd/T) e(n-2)

It was derived using trapezoidal integration.

Start testing using small values for proportional gain and set Ki and Kd to zero. If still diverges from the setpoint check feedback phase
and rounding errors

Hope this helps.
Regards.


Jorge M. Tirabasso
Sistemas DACS S.A.
J. A. Cabrera 4621
Buenos Aires C1414BGI
Argentina
54 11 4833-0020
[email protected]
[email protected]
http://www.icubo.org/dacs
 
Top