68 views

Uploaded by lizhi0007

Control system Lab, advanced PID controller

- Z6 Pendulum Cart Position Control
- App Term Vari Freq Drive
- Iaetsd-modelling of One Link Flexible Arm Manipulator Using
- Fixing PID
- art%3A10.1007%2Fs12046-009-0049-2
- [PID] Optimal Tuning of PID controllers
- Control Systems - 2
- rstune
- Tutorial Sol Ch 8
- Process Control Lab
- A refinement procedure for PID controllers
- PID Tutorial -2
- Tuning Paper
- shams_I&ECR
- PID Introduction
- matlab cincai
- 9714-48581-1-PB PI conical
- Paper1_Speedcontrol
- Temperature Control Hatchery Incubator Using Microcontroller.pdf
- 05361327

You are on page 1of 13

In this digital era, PID controllers have evolved from basic textbook structure to more

sophisticated algorithms. Features such as setpoint/derivative weightings and anti-windup

scheme are often added to improve the closed-loop response. In our previous article A Decorated

PID Controller, we consider a PID structure with modification and additional functions as

follows

To lessen the effect of measurement noise, derivative part is implemented as a filter with

parameter

Setpoint weightings for proportional and derivative paths can be adjusted via

and

, respectively

A feedback diagram with this advanced PID controller is constructed using Xcos palettes as in

Figure 1.

In equation form, this controller can be described as

(1)

with

(2)

where

and

controller output, and saturated controller output, respectively. As described in our Discrete-time

PID Controller Implementation article, using backward difference relationship

(3)

(4)

(5)

To implement this PID scheme as a computer algorithm, we have to convert (5) to a difference

equation. It is straightforward to show that (5) can be rewritten as

(6)

with coefficients

(7)

(8)

Equation (8) is ready for implementation on a target processor. Before that phase, we want to

make sure that our equation and coefficients are without error. One easy way is to perform

simulation on Xcos and compare the response to the original continuous-time PID controller. For

this purpose, we construct a model advpid_imp.zcos as shown in Figure 2, consisting of 2

feedback loops. The upper loop is controlled by discrete-time PID in the form (6), and the lower

loop contains the continuous-time PID. The simulation results from the two closed-loop systems

are then compared to verify how well they match.

Note that the discrete-time PID in the upper loop is contained in a superblock. The internal

details are shown in Figure 3, which corresponds to the discrete-time controller (6).

Also, at the output of discrete-time PID controller, a LPF transfer function is inserted to prevent

an algebraic loop error, normally occurred with hybrid simulation. The LPF pole is chosen well

above the closed-loop bandwidth so the filter does not have noticeable effect on the responses.

For easy editing, all the parameters in advpid_imp.zcos are initialized using a script file

advpid_imp.sce. The plant is chosen as a third-order lag transfer function

(9)

s = poly(0,'s');

P = syslin('c',1/(s+1)^3);

Then, controller parameters are assigned values. These can be chosen as you like since the

purpose of this simulation is to compare the responses. Here the PID gains are obtained from

Zieglers Nichols frequency domain tuning method, and others are assigned some practical

values.

kp = 4.8;

// PID gains

ki = 2.7;

kd = 2.1;

N = 10;

// filter coefficient

kt = 1.2; // back calculation gain for anti-windup

wp = 0.7;

// setpoint weight for proportional term

wd = 0.1;

// setpoint weight for derivative term

Ts = 0.01;

// sampling peroid

For sampling period Ts, the value should match the simulation sampling period in the clock.

The parameters left to be assigned are the limits in saturation block. Put in some reasonable

values such that some saturation effect happens during transient, since we prefer response

comparison with the back calculation term activated. Too small the limit range would cause

severe performance degradation. By some trial and error, we are finally satisfied with these

values for saturation block

ulim = 2000;

llim = -2000;

Finally, the coefficients in (7) need to be computed. We introduce additional variables x1 and x2

for terms that appear in several places.

x1

x2

a1

a2

b1

b2

b3

c1

c2

c3

c4

d1

d2

d3

=

=

=

=

=

=

=

=

=

=

=

=

=

=

(1+N*Ts);

(2+N*Ts);

x2/x1;

-1/x1;

kp;

-kp*x2/x1;

kp/x1;

ki*Ts;

-ki*Ts/x1;

kt*Ts;

-kt*Ts/x1;

kd*N/x1;

-2*kd*N/x1;

kd*N/x1;

clicking on the simulation start button. The simulation results in Figure 4 show that the plant and

controller outputs from continuous and discrete PID are almost identical. This makes us

confident that the discrete-time PID and its coefficients are derived correctly.

After the verification process by Xcos simulation, we are now ready to implement our advanced

PID controller on a target processor, in this case a PIC24EP256MC202 by Microchip. The plant

is a DC motor with H-bridge drive, as described in the DC Motor Control Part I article. Figure 5

shows the experimental setup used. The rightmost board is our controller prototype, where the

PID algorithm will be downloaded and executed.

The source code is written entirely in C. The whole code, consisting of a couple of source files, is

rather long and messy due to supporting functions such as UART communication, command

handling, etc. Below we discuss only the parts related to our PID controller implementation.

The sampling period, controller parameters and resulting coefficients are defined as global

variables, with some initial values assigned

// sampling

double Ts =

// -- these

double Kp =

double Ki =

double Kd =

double Kt =

double Wp =

double Wd =

int N = 20;

period

0.01;

// sampling time

parameters are user-adjustable

1272; // proportional gain

8777; // integral gain

46; // derivative gain

10; // tracking gain

0.5; // proportional weight

0; // derivative weight

// filter coefficient

// ----- coefficients of PID algorithm -------------double a1, a2, b1, b2, b3, c1, c2, c3, c4;

double d1, d2, d3;

and also variables to keep previous values of controller inputs and outputs

double ep_2, ep_1, ep_0, e_1, e_0, eus_1, eus_0, ed_2, ed_1, ed_0 ;

double u_2, u_1, u_0, u_0n; // variables used in PID computation

Now, the coefficients have to be computed before the algorithm starts, and every time the user

changes any parameter involved. So it is convenient to put the computation in a function

void PIDSetup(void) // PID coefficient setup

// -- this function must be invoked anytime

// -- any parameter involved is changed by user

{

double x1, x2;

_T1IE = 0; // disable timer 1

x1

x2

a1

a2

b1

b2

b3

c1

c2

c3

c4

d1

d2

d3

=

=

=

=

=

=

=

=

=

=

=

=

=

=

1 + N*Ts;

2 + N*Ts;

x2/x1;

-1/x1;

Kp;

-Kp*x2/x1;

Kp/x1;

Ki*Ts;

-Ki*Ts/x1;

Kt*Ts;

-Kt*Ts/x1;

Kd*N/x1;

-2*Kd*N/x1;

Kd*N/x1;

_T1IE = 1;

_T1IF = 0;

// enable timer 1

// reset timer 1 interrupt flag

As usual, the actual PID algorithm is placed in a timer interrupt, in this case timer 1.

void __attribute__((interrupt, auto_psv)) _T1Interrupt(void)

// Timer 1 interrupt every Ts second

{

// perform position read from QEI module of PIC24EP256MC202

QEIpVal.half[0] = POS1CNTL; // read lsw

QEIpVal.half[1] = POS1HLD; // read msw from hold register

dcmpos = QEIpVal.full*360/ENCPPMx4;

// position in degree

if (SysFlag.PosLoop == CLOSED) // closed loop PID control

{

u_2 = u_1;

u_1 = u_0;

ep_2 = ep_1;

ep_1 = ep_0;

ep_0 = Wp*pcmd - dcmpos;

e_1 = e_0;

e_0 = pcmd - dcmpos;

// true error

eus_1 = eus_0;

// back calculation error

if (abs(u_0) <= PWMMAX) eus_0 = 0;

else if (u_0>PWMMAX) eus_0 = PWMMAX - u_0;

else eus_0 = -u_0 - PWMMAX;

ed_2 = ed_1;

ed_1 = ed_0;

ed_0 = Wd*pcmd - dcmpos;

u_0 =

a1*u_1+a2*u_2+b1*ep_0+b2*ep_1+b3*ep_2+c1*e_0+c2*e_1+c3*eus_0+c4*eus_1+d1*ed_0

+d2*ed_1+d3*ed_2;

if (u_0>=0) { // positive sense

if (u_0 < PWMMAX) PWMVal = (unsigned int)u_0; // limit to PWM

range

else PWMVal = PWMMAX;

DIR = 0;

}

else

range

{ // negative sense

u_0n = -u_0;

if (u_0n < PWMMAX) PWMVal = (unsigned int)u_0n;

// limit to PWM

DIR = 1;

}

OC1R = PWMVal;

} // if (SysFlag.PosLoop == CLOSED)

_T1IF = 0; // reset interrupt flag

}

Note that our H-brige driver is commanded by a pair of signals: PWM and DIR, as explained in

the DC Motor Control Part I article. The motor turns clockwise and counter-clockwise when DIR

= 0 and 1, respectively, and the motor speed corresponds to the duty cycle of PWM signal,

dictated by PWMVal variable.

Experimental Results

An initial set of PID gains is achieved by performing some naive automatic tuning based on the

Ziegler-Nichols frequency domain method. The C code is not shown in this article, though it is

quite similar to that given in our Digital PID Controllers document. The automatic tuning yields

. Other parameters are set to

. As shown in Figure 6, This set of PID gains with

rather high Ki value results in oscillary response (dashed red). So we begin fine tuning by

reducing

to

, and

, resulting in the dotted blue, and black, respectively.

The overshoot and oscillation lessen with decreasing

Next, we try incresing

from

, to

, and

.

Our last experiment for this article is varying the proportional setpoint weight

gains are fixed at

responses with

reduced by decreasing

,

, and

. The PID

. Interestingly, the overshoot can be

We leave it to anyone who implements this advanced PID controller on his/her system to

experiment with the anti-windup back calculation gain

and derivative setpoint weighting

. It is suggested in some literature that

command would not affect the derivative action of the controller. We set

and

- Z6 Pendulum Cart Position ControlUploaded byazlina suerman
- App Term Vari Freq DriveUploaded byrizaazari4530
- Iaetsd-modelling of One Link Flexible Arm Manipulator UsingUploaded byiaetsdiaetsd
- Fixing PIDUploaded byGeorge Markas
- art%3A10.1007%2Fs12046-009-0049-2Uploaded bydebasishmee5808
- [PID] Optimal Tuning of PID controllersUploaded byDiem Nguyen
- Control Systems - 2Uploaded by34plt34
- rstuneUploaded byaaguillont723
- Tutorial Sol Ch 8Uploaded byAudrey Patrick Kalla
- Process Control LabUploaded bymirdza94
- A refinement procedure for PID controllersUploaded byMahir Asif Shadman
- PID Tutorial -2Uploaded byAli Amir
- Tuning PaperUploaded byMohamed Rezk
- shams_I&ECRUploaded byShamsMohd
- PID IntroductionUploaded byprathamesh.gangal999
- matlab cincaiUploaded byabdul qahar
- 9714-48581-1-PB PI conicalUploaded byPandimadevi Ganesan
- Paper1_SpeedcontrolUploaded byDuvan Morales Guzman
- Temperature Control Hatchery Incubator Using Microcontroller.pdfUploaded byCuong Mai
- 05361327Uploaded byNaveen Kumar
- PID ScrollbarUploaded byElsayed Amer
- r05311003 Process Control InstrumentationUploaded bySrinivasa Rao G
- DYCOPS_2013Uploaded byShamsMohd
- Quanser Course Material Sample - Ball and Beam Rotary WorkstationUploaded byNabil Shaukat
- capitulo_14Uploaded byLeonardo Olan Valdivieso
- Tj Project Report-final 1 23Uploaded byTarush Jain
- Pid ControllersUploaded bySrinivas Acharya
- Genetic Algorithm Based PID Control Tuning for a Model BioreactorUploaded byertyucb
- NR-311004- Process Control InstrumentationUploaded bySrinivasa Rao G
- Temperature control TrainerUploaded byAjeet Kumar

- Control a DC Motor With an ArduinoUploaded bylizhi0007
- Do an Xu Ly Anh Nhan Dang Mat Nguoi Tren MatlabUploaded bylizhi0007
- Closed Loop Speed and Position Control of DC MotorsUploaded bylizhi0007
- Circle Hough TransformUploaded bylizhi0007
- SVM Tutorial Part1Uploaded bylizhi0007
- SVM Tutorial Part2Uploaded bylizhi0007
- SVM Tutorial Part3Uploaded bylizhi0007
- Convolutional Neural NetworksUploaded bylizhi0007
- A Quick Introduction to NeuralUploaded bylizhi0007
- NenanhMP4Uploaded bylizhi0007
- Ly Thu Yet CalibrationUploaded bylizhi0007
- Active Contour Without EdgesUploaded bylizhi0007
- The Hough TransformUploaded bylizhi0007
- PWM Driver VerilogUploaded bylizhi0007
- Svmtrain.mUploaded bylizhi0007
- Detecting Arrow KeysUploaded bylizhi0007
- Basic Structures OpenCVUploaded bylizhi0007
- How to Install the Latest Eclipse Release in Ubuntu 14Uploaded bylizhi0007
- HistogramUploaded bylizhi0007
- Simple DFT In OpencvUploaded bylizhi0007
- Read & Display ImageUploaded bylizhi0007
- Histogram Calculation — OpenCV 3.0Uploaded bylizhi0007
- Bc Tdg Truong Dhsp Gui Ttkd Final Dua Len WebUploaded bylizhi0007
- Christens en RptUploaded byPriya_Daarshin_3816
- Hướng dẫn khám bệnh tại bệnh viện Đại học Y dược TPHCM.docxUploaded bylizhi0007
- Opencv Tutorials 2.4.3Uploaded byNindo Harun Prabantara
- Histogram Equalization of Grayscale or Color ImageUploaded bylizhi0007
- BC Tudanhgia DHQNam 2013Uploaded bylizhi0007
- BCtudanhgiaLH_1vivrUploaded bylizhi0007

- Buffon s NeedleUploaded byPurbayan Chakraborty
- SD2155_2010_PMUploaded bymannefriman
- Coupled pendulumUploaded bySubhasis Panda
- Wilkerson Phd 2010Uploaded byPopescu
- Mi Sic IbilityUploaded byratchagaraja
- lecture 3Uploaded byGuilherme Henrique
- Excitation Systems of Synchronous MachinesUploaded byspark_star
- Loctite 3478 EnUploaded byMohsin Modi
- Needle Valve EngineeringUploaded bymartin rivero
- Marsh Funnel Testing for Rheology Analysis of Bentonite Slurries for Slurry ShieldsUploaded byTalyn Sanz
- Filter Elements for Liquid Filters EnUploaded byTony Tony Tony
- YEA-SIAZ-C844-0.2Uploaded byIvan Smolej
- Davis et al., 2005 (IMP)Uploaded byXenon Argon
- EE-260 Lecture 14 AutoTransformerUploaded byJeff Hardy
- 1-s2.0-S0735193312001145-mainUploaded byMostafa El-Balashony
- IEEE 1368-2006 Aeolian Vibration Field MeasurementsUploaded byjorge pla
- Application of InterpolationUploaded byMarkChristianFajardo
- Cryog Processing Tc113571Uploaded byFernando Carvalho
- Handbook of p IdsUploaded byatti174
- Stab le Fluids - Jos StamUploaded byrelel
- LpgUploaded bysanjeev
- Design and Development of Cascade Refrigeration SystemUploaded byIRJET Journal
- (8) Ore Processing (Beneficiation)Uploaded byCatherine Leneses
- Beams on Elastic FoundationUploaded byprabhu81
- Phamv NECC Fa12 GEO101Uploaded byvictoriapham
- John Searl Anti Gravity the Dream Made RealityUploaded byJason Verbelli
- IRJET-Slenderness Effect on Axially Loaded RC Columns Confined with FRP Sheets and FerrocementUploaded byIRJET Journal
- H Bridge.pdfUploaded byJeremy Miller
- DIN-1055-6-2005_Parte1Uploaded byAngel Alvarez
- Modification of Mononobe-Okabe TheoryUploaded bygilopez88