Lecture Introduction to Control Systems - Chapter 7: Digital control systems (Dr. Huynh Thai Hoang). The main topics covered in this chapter include: introduction to digital control system; digital PID controller; examples of digital control system; convert continuous signals to digital signals;...
Lecture Notes Introduction to Control Systems Instructor: Dr Huynh Thai Hoang Department of Automatic Control Faculty of Electrical & Electronics Engineering Ho Chi Minh City University of Technology Email: hthoang@hcmut.edu.vn huynhthaihoang@yahoo.com Homepage: www4.hcmut.edu.vn/~hthoang/ www4 hcmut edu vn/ hthoang/ 16 November 2012 © H T Hoang - www4.hcmut.edu.vn/~hthoang/ Chapter Digital Control Systems 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ Content Introduction to digital control system Digital PID controller Examples of digital control system 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ Introduction to digital control systems 16 November 2012 © H T Hoàng - www4.hcmut.edu.vn/~hthoang/ Digital control systems r(kT) Computer u(kT) D/A uR(t) Plant y(t) yfb(kT) A/D Sensor “Computer” = computational equipments based on microprocessor technology (microprocessor (microprocessor, microcontroller, PC, DSP,…) Advantages d a tages of o digital d g ta co control t o syste system: Flexibility Easy to implement complex control algorithms Computer C t can control t l many plants l t att the th same time ti 16 November 2012 © H T Hoàng - www4.hcmut.edu.vn/~hthoang/ Digital controller r(kT) Computer u(kT) (kT) D/A uR(t) Plant y(t) yfb(kT) A/D 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 controller t ll Optimal controllers Adaptive controllers,… controllers 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ A/D conversion x(t) x(t) () x*(t) T A/D Sampling t x*(t) () [010 010] 010] t T 2T time (T): time interval between samples Resolution: indicates the number of digital values an A/D / can produce over the range g of analog g values kT A/D conversion = time discretization + level quantization 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ D/A conversion xR (t) x*(t) D/A x*(t) [010 010] t T 2T kT xR(t) t 16 November 2012 © H T Hoàng - www4.hcmut.edu.vn/~hthoang/ Digital PID controllers 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ Continuous PID controller r(t) + e(t) u(t) PID G(s) y(t) t de(t ) u(t ) K P e(t ) K I e( )d K D dt Discretize the continous PID control signal in order to implement the PID controller in microcontrollers or computers 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 10 Discrete integral factor e(t) u(t) e()d u(k) e(k) GI(z) t u(t ) e( )d Continuous integral: Discrete integral: kT ( k 1)T kT 0 ( k 1)T u( kT ) e( )d e( )d e( )d T u ( k ) u ( k 1) [e( k 1) e( k )] Transfer function of discrete integral factor: T z 1 GI ( z ) z 1 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 12 Transfer function of discrete PID controller C ti Continuous PID controller: t ll K GPID ( s ) K P K D s s Discrete PID controller: KIT z KD z GPID ( z ) K P z 1 T z P 16 November 2012 I D © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 13 Difference equation of discrete PID controller KIT z KD z GPID ( z ) K P z 1 T z U ( z) K I T z 1 K D 1 KP ( z ) 1 E ( z) T 1 z (1 z 1 )U ( z ) K P (1 z 1 ) K I T (1 z 1 ) K D (1 z 1 ) E ( z ) T u( k ) u( k 1) K P [e( k ) e( k 1)] KIT [e( k ) e( k 1)] KD [e( k ) 2e( k 1) e( k 2)] T 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 14 Digital PID control programming float PID_control(float PID control(float setpoint, setpoint float measure) { ek_2 = ek_1; ek_1 = ek; //update old error uk_1 = uk; //update old control signal ek = setpoint – measure; //calculate current error uk = uk_1 uk + Kp Kp*(ek-ek (ek ek_1) 1) + Ki Ki*T/2*(ek+ek T/2 (ek ek_1) 1) +… … Kd/T*(ek – 2*ek_1+ek_2); //calculate PID control signal If uk > Umax, uk = Umax; If uk < Umin, 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, uk ek_1 ek and ek_2 ek must be initialized to be zero Umax and Umin are constants 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 15 Approaches to design discrete controllers Indirect design: First design a continuous controller, controller then discretize the controller to have a discrete control system y The p performances of the obtained discrete control system are approximate those of the continuous control system provided that the sample time is small enough h Direct design: Directly design discrete controllers in Z domain Methods: root locus, pole placement, analytical method, … 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 16 Implementation of control systems 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 17 Knowlegde required C t l theory Control th Electronic circuits Sensors and measurement Power electronic Microcontroller Programming Knowledge relalated to the plant to be controlled 16 November 2012 © H T Hoàng - www4.hcmut.edu.vn/~hthoang/ 18 Basic conponents of microcontrollers A microcontroller i t ll basically b i ll contains t i one or more ffollowing ll i components: Central processing unit(CPU) Random Access Memory)(RAM) Read Only y Memory(ROM) y( ) Input/output ports Timers and Counters Interrupt Controls Analog to digital converters Digital Di it l analog l converters t Serial interfacing ports Oscillatory circuits 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 19 Microcontrollers 16 November 2012 © H T Hoàng - www4.hcmut.edu.vn/~hthoang/ 20 Digital control of DC motor User Interface MicroController Power amplifier Motor Measurement 16 November 2012 © H T Hoang - www4.hcmut.edu.vn/~hthoang/ 21 Example of microcontroller based motor control 16 November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ 22 Digital control of thermal process User Interface MicroController Power amplifier Heater Measurement 16 November 2012 © H T Hoang - www4.hcmut.edu.vn/~hthoang/ 23 Temperature controller and user interface VCC 4.7k 4.7k 4.7k Q1 VCC3 VCC2 VCC1 PORTD 1k A1015 D6 LED 7DOAN LED_7DOAN B A C D E 11 F G A B C D E F G DOT VCC SW5 A1015 PORTD Q4 DOT D 10 1k A1015 1k PORTD 4.7k Q3 VCC4 A1015 PORTD 12 1k Q2 VCC 10k 10k PIC16F877A V_sensor VREF+ PORTC 15 16 17 18 23 24 25 26 C16 13 33p C17 33p 16 November 2012 10MHz CRYSTAL 14 12 31 MCLR*/VPP RA0/AN0 RA1/AN1 RA2/AN2/VREF-/CVREF RA3/AN3/VREF+ RA4/T0CKI/C1OUT RA5/AN4/SS*/C2OUT RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL RC4/SDI/SDA RC5/SDO RC6/TX/CK RC7/RX/DT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 33 34 35 36 37 38 39 40 DOT A B C D E F G 19 20 21 22 27 28 29 30 SW4 SW3 SW2 SW1 SW4 SW4 SW3 SW3 PORTD PORTD PORTD PORTD SW2 SW2 OSC1/CLKIN RE0/RD*/AN5 RE1/WR*/AN6 RE2/CS*/AN7 10 SW1 OSC2/CLKOUT VSS VSS VDD VDD 11 32 VCC © H T Hồng - ÐHBK TPHCM SW1 24 Temperature measurement using thermocouple U1 LM35 35 + - 10uF V22 R1 25k OP07 5V -5V V3 + - Thermo couple J1 + C2 10uF 16 November 2012 - - OP07 100 V1 OP07 Vout PA0/ADC0 OP07 -5V U3 1.8k -5V R2 + U5 R4 R6 R3 100 3.9k 100 R5 5V 5V U4 GND C1 U2 VOUT 5V VC C 5V -5V © H T Hồng - ÐHBK TPHCM 25 Power circuit R3 FUSE Heater +12V 470 U15 MOC3020 PORTC R1 Q2 BTA16 220Vac 0Vdc Q1 Q2SC1815 47k R2 330 16 November 2012 © H T Hoàng - ÐHBK TPHCM 26 .. .Chapter Digital Control Systems 16 November 2012 © H T Hoàng - www4.hcmut.edu.vn/~hthoang/ Content Introduction to digital control system Digital PID controller Examples of digital control. .. November 2012 © H T Hồng - www4.hcmut.edu.vn/~hthoang/ Introduction to digital control systems 16 November 2012 © H T Hoàng - www4.hcmut.edu.vn/~hthoang/ Digital control systems r(kT) Computer... converter: to convert digital signals to continuous signals Computer: to execute pre-programmed control algorithms PID controller t ll Optimal controllers Adaptive controllers,… controllers