Introduction to Introduction to Control SystemsControl Systems

26
Lecture Notes Lecture Notes Introduction to Introduction to Control Systems Control Systems Instructor: Dr. Huynh Thai Hoang Department of Automatic Control Faculty of Electrical & Electronics Engineering Ho Chi Minh City University of Technology Ho Chi Minh City University of Technology Email: [email protected] [email protected] Homepage: www4 hcmut edu vn/ hthoang/ 16 November 2012 © H. T. Hoang - www4.hcmut.edu.vn/~hthoang/ 1 Homepage: www4.hcmut.edu.vn/~hthoang/

Transcript of Introduction to Introduction to Control SystemsControl Systems

Lecture NotesLecture Notes

Introduction to Introduction to Control SystemsControl Systems

Instructor: Dr. Huynh Thai HoangDepartment of Automatic Control

Faculty of Electrical & Electronics EngineeringHo Chi Minh City University of TechnologyHo Chi Minh City University of Technology

Email: [email protected]@yahoo.com

Homepage: www4 hcmut edu vn/ hthoang/

16 November 2012 © H. T. Hoang - www4.hcmut.edu.vn/~hthoang/ 1

Homepage: www4.hcmut.edu.vn/~hthoang/

Chapter 7Chapter 7

Digital Control SystemsDigital Control SystemsDigital Control SystemsDigital Control Systems

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 2

Introduction to digital control system

ContentContent

Introduction to digital control system Digital PID controller Examples of digital control system

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 3

Introduction Introduction to digital control systemsto digital control systems

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 4

Digital Digital control systemscontrol systems

Computer D/A Plantr(kT) y(t)u(kT) uR(t)

A/Dyfb(kT)

Sensor

“Computer” = computational equipments based on microprocessor technology (microprocessormicroprocessor technology (microprocessor, microcontroller, PC, DSP,…).

Advantages of digital control system:d a tages o d g ta co t o systeFlexibilityEasy to implement complex control algorithms

C t t l l t t th ti

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 5

Computer can control many plants at the same time.

Digital controllerDigital controller

(kT) (t)Computer D/A Plantr(kT) y(t)u(kT) uR(t)

A/Dyfb(kT)

Sensor

A/D converter: to convert continuous signals to digital signals D/A converter: to convert digital signals to continuous signals Computer: to execute pre-programmed control algorithms

PID t ll PID controllerOptimal controllers Adaptive controllers

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 6

Adaptive controllers,…

A/D conversionA/D conversion

x(t) x*(t)Tx(t) x (t)T

A/D( ) A/Dx(t) Sampling time (T): time interval between 2 samples.

[010 0 010]

t0

*( )

2 samples. Resolution: indicates

the number of digital /[010 0..010]x*(t) values an A/D can

produce over the range of analog

0t

T 2T kT

g gvalues.

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 7

A/D conversion = time discretization + level quantization

D/A conversionD/A conversion

(t)x*(t) xR (t)D/A

[010 0..010]x*(t)

0t

T 2T kT0xR(t)T 2T kT

t

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 8

0

Digital PID controllersDigital PID controllers

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 9

Continuous Continuous PID controllerPID controller

r(t)+

y(t)e(t) u(t)G(s)PID

dttdeKdeKteKtu

t

DIP)()()()(

0

dt0

Discretize the continous PID control signal in order to implement the PID controller in microcontrollers or computers

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 10

Discrete difference Discrete difference factorfactor

u(t)e(t) u(k)e(k)d/dt

u(t)e(t)

d )(

GD(z)u(k)e(k)

dttdetu )()( Continuous differential factor:

Discrete difference factor:T

kekeku )]1[()()(

Transfer function of discrete difference factor:

1)(U )1(1)()()( 1 z

TzEzUzGD

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 11

Discrete integral Discrete integral factorfactor

u(t)e(t) u(k)e(k)

t

e()du(t)e(t)

GI(z)u(k)e(k)

detu 0

)()( Continuous integral:

Discrete integral:

dekTukT

0

)()( dedekT

Tk

Tk

)1(

)1(

0

)()(0 Tk )1(0

)]()1([2

)1()( kekeTkuku 2

Transfer function of discrete integral factor:

1)( zTG

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 12

12)(

zzGI

Transfer function of discrete PID controllerTransfer function of discrete PID controller

C ti PID t ll Continuous PID controller:

sKKKsG DPPID )(

Discrete PID controller:

s DPPID )(

zKzTKKzG DIPPID

11)(

Discrete PID controller:

zTzKzG PPID 12

)(

P I DP I D

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 13

Difference equation of discrete Difference equation of discrete PID controllerPID controller

zKzTK 11z

zT

KzzTKKzG DI

PPID1

11

2)(

1)( 1 KTKU )1(11

2)()( 1

1

1

zT

KzzTKK

zEzU DI

P

)()1()1(2

)1()()1( 21111 zEzT

KzTKzKzUz DIP

)]1()([

...)]1()([)1()(

kkTKkekeKkuku

I

P

)]2()1(2)([

...)]1()([2

kkkK

keke

D

I

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 14

)]2()1(2)([ kekekeT

D

Digital PID control programming Digital PID control programming

float PID control(float setpoint float measure)float PID_control(float setpoint, float measure){

ek_2 = ek_1; ek_1 = ek; //update old erroruk_1 = uk; //update old control signalek = setpoint – measure; //calculate current erroruk = uk 1 + Kp*(ek-ek 1) + Ki*T/2*(ek+ek 1) +…uk uk_1 Kp (ek ek_1) Ki T/2 (ek ek_1) …

Kd/T*(ek – 2*ek_1+ek_2); //calculate PID control signalIf uk > Umax, uk = Umax;If uk < Umin uk = Umin;If uk < Umin, uk = Umin;return(uk)

}

Note: Kp, Ki, Kd, uk, uk_1, ek, ek_1, ek_2 must be declared as global variables; uk 1 ek 1 and ek 2 must be initialized to

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 15

global variables; uk_1, ek_1 and ek_2 must be initialized to be zero. Umax and Umin are constants.

Approaches to design discrete controllersApproaches to design discrete controllers

Indirect design: First design a continuous controller Indirect design: First design a continuous controller,then discretize the controller to have a discrete controlsystem. The performances of the obtained discretey pcontrol system are approximate those of the continuouscontrol system provided that the sample time is small

henough.

Direct design: Directly design discrete controllers in Zdomain.Methods: root locus, pole placement, analyticalmethod, …

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 16

Implementation of control systemsImplementation of control systems

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 17

Knowlegde requiredKnowlegde required

C t l th Control theory

Electronic circuits

Sensors and measurement

Power electronic Power electronic

Microcontroller

Programming

Knowledge relalated to the plant to be controlled Knowledge relalated to the plant to be controlled

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 18

Basic conponents of microcontrollersBasic conponents of microcontrollers

A i t ll b i ll t i f ll iA microcontroller basically contains one or more following components: Central processing unit(CPU) Central processing unit(CPU) Random Access Memory)(RAM) Read Only Memory(ROM)y y( ) Input/output ports Timers and Counters Interrupt Controls Analog to digital converters

Di it l l t Digital analog converters Serial interfacing ports Oscillatory circuits

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 19

Oscillatory circuits

MicrocontrollersMicrocontrollers

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 20

Digital control of DC motorDigital control of DC motor

UserMicro-

ControllerPower

amplifier MotorUser

Interface

MeasurementMeasurement

16 November 2012 21© H. T. Hoang - www4.hcmut.edu.vn/~hthoang/

Example of microcontroller based motor controlExample of microcontroller based motor control

16 November 2012 © H. T. Hoàng - www4.hcmut.edu.vn/~hthoang/ 22

Digital control of thermal processDigital control of thermal process

UserMicro-

ControllerPower

amplifierHeaterUser

Interface

MeasurementMeasurement

16 November 2012 23© H. T. Hoang - www4.hcmut.edu.vn/~hthoang/

4.7k 4.7kVCC

4.7k 4.7k

Temperature controller and user interfaceTemperature controller and user interface

1k

D6LED 7DOAN1 4 5 7

1kPORTD<6>

Q2

A1015

Q3

A1015PORTD<4> 1k 1k

Q1

A1015PORTD<5>

Q4

A1015PORTD<7>

. . . .

LED_7DOAN4 5 7

VC

C1

AF

VC

C2

VC

C3

VC

C4

G CDO

T

DE B

DOT

238 910 1112 6

AFG CD DE B

G

C

ED

VCCVCC F

AB

D

SW4A

V_sensor

GF

B

VREF+SW4

10k

E

PIC16F877A

234567

3334353637383940

1

RA0/AN0RA1/AN1RA2/AN2/VREF-/CVREFRA3/AN3/VREF+RA4/T0CKI/C1OUT

RB0/INTRB1RB2

RB3/PGMRB4RB5

RB6/PGC

MCLR*/VPPDOT

10k

C

SW5

SW2

SW3

PORTD<5>

10MHz

C16

33p

SW3

SW4

PORTD<6>

PORTD<4>

G

SW1

SW2

7 40

1516171823242526

1920212227282930

1389

RA5/AN4/SS*/C2OUT RB7/PGD

RC0/T1OSO/T1CKIRC1/T1OSI/CCP2RC2/CCP1RC3/SCK/SCLRC4/SDI/SDARC5/SDORC6/TX/CKRC7/RX/DT

RD0/PSP0RD1/PSP1RD2/PSP2RD3/PSP3RD4/PSP4RD5/PSP5RD6/PSP6RD7/PSP7

OSC1/CLKINRE0/RD*/AN5

SW2

SW3

PORTC<2>

PORTD<7>

16 November 2012 © H. T. Hoàng - ÐHBK TPHCM 24

10MHzCRYSTAL

VCC SW1

C17

33p

SW114

3211

3112

910

OSC2/CLKOUT

VDDVDD

VSSVSS

RE1/WR*/AN6RE2/CS*/AN7

Temperature measurement using thermocoupleTemperature measurement using thermocouple

5V

U27 1

5V

5VU1

LM35

1VC

C

2C1

10uF

-

+

OP07

3

26

4 8

5 5V 5

352

GN

D

VOUT

V V2 R1

25k

0

0

-5V

-

+

U4

OP07

3

26

7 1

5V 5V

-

+

U5

OP07

3

26

7 1

R5 PA0/ADC0

3G

V3 Vout

OP07

4 85V

R6R2J1Thermo couple

1 +

U3

36

7 1

OP07

4 8-5V -5VR41.8k

100

V1 R3

C210uF

3.9k1001

-5V

-OP07

26

4 8

V1 R3

100

0

16 November 2012 © H. T. Hoàng - ÐHBK TPHCM 25

0 00

Power circuitPower circuit

+12V

6

HeaterFUSER3

470

220Vac0Vdc

Q2BTA16

Q1R1

U15MOC3020

1

2

4PORTC<2>Q2SC1815

47k

R2330

16 November 2012 © H. T. Hoàng - ÐHBK TPHCM 26