Discrete Controller Design Thanh Vo-Duy Department of Industrial Automation thanh.voduy@hust.edu.vn Content • Digital Controllers • Dead-Beat Controller • Dahlin Controller • Microcontroller Implementation • PID Controller • Exercises Prior to Lecture Discrete-time System with analog reference input Discrete-time System with digital reference input Digital Controllers • Consider the Discrete-time System as • - Reference Input • - Error signal • - Output of the Controller • - Output of the System • - Digitized plant with Zero-order hold Digital Controllers • The close-loop transfer function of the system • Desired transfer function • So, required controller Digital Controllers Dead-Beat Controller • Dead-Beat Controller: brings system to steady state in the smallest number of time steps where • Digital Controller transfer function Digital Controllers Dead-Beat Controller • Example: Design the Dead-Beat Controller for the system given by Assume that T = 1s Digital Controllers Dead-Beat Controller • Solution: The transfer function of the system with ZOH: since T = 1s From (1): Digital Controllers Dead-Beat Controller • Solution (cont.) It can be chosen that . So, choose The controller’s transfer function: Digital Controllers Dead-Beat Controller • Solution (cont.) Step response of the system Control signal [...]... Controllers PID Controller • PID Tuning – Ziegler-Nichols tuning algorithm A system can be approximated as: 𝐾𝑒 −𝑠𝑇 𝐷 𝐺 𝑠 = 1 + 𝑠𝑇1 where 𝑇 𝐷 : System time delay 𝑇1 : Time constant of system Digital Controllers PID Controller • Open-loop Tuning Controller Proportional PI PID 𝑲𝒑 𝑇1 𝐾𝑇 𝐷 0.9𝑇1 𝐾𝑇 𝐷 1.2𝑇1 𝐾𝑇 𝐷 𝑻𝒊 𝑻𝒅 3.3𝑇 𝐷 2𝑇 𝐷 0.5𝑇 𝐷 Digital Controllers PID Controller • Close-loop Tuning 1 Leave the controller. .. 𝑒 −0.1 𝑧 −1 − 1 − 𝑒 −0.1 𝑧 −𝑘−1 Digital Controllers Dahlin Controller • Solution (cont.) 1 − 0.904𝑧 −1 0.095𝑧 −𝑘−1 𝐷 𝑧 = −3 0.095𝑧 1 − 0.904𝑧 −1 − 0.095𝑧 −𝑘−1 Choose 𝑘 = 2, so 0.095𝑧 3 − 0.0858𝑧 2 𝐷 𝑧 = 0.095𝑧 3 − 0.0858𝑧 2 − 0.009 Digital Controllers Dahlin Controller • Solution (cont.) Digital Controllers Microcontroller Implementation • Implement Dead-Beat Controller in the Example 𝑧 3 − 0.904𝑧... sluggish response Digital Controllers PID Controller Digital Controllers PID Controller • Input – Output relationship of PID Controller 1 𝑢 𝑡 = 𝐾 𝑝 [𝑒 𝑡 + 𝑇𝑖 𝑡 0 𝑑𝑒 𝑡 𝑒 𝑡 𝑑𝑡 + 𝑇 𝑑 ] 𝑑𝑡 where 𝑒 𝑡 = 𝑟 𝑡 − 𝑦(𝑡) 𝑇𝑖 and 𝑇 𝑑 : Integral and derivative action time • Another form 𝑡 𝑢 𝑡 = 𝐾 𝑝 𝑒 𝑡 + 𝐾𝑖 where 𝐾 𝑖 = 𝐾𝑝 𝑇𝑖 0 𝑑𝑒 𝑡 𝑒 𝑡 𝑑𝑡 + 𝐾 𝑑 + 𝑢0 𝑑𝑡 and 𝐾 𝑑 = 𝐾 𝑝 𝑇 𝑑 (2) Digital Controllers PID Controller • Build computer... 𝑒 𝑧 • Transfer function of required controller 1 𝐷 𝑧 = 𝐻𝐺 𝑧 𝑧 −𝑘−1 1− 𝑒 − 𝑇 𝑞 𝑧 −1 1− 𝑇 −𝑞 𝑒 − 1− 𝑒 − 𝑇 𝑞 𝑧 −𝑘−1 Digital Controllers Dahlin Controller • Example: The open-loop transfer function of a plant: 𝑒 −2𝑠 𝐺 𝑠 = 1 + 10𝑠 assume that T = 1s Design a Dahlin digital controller for the system (let’s choose 𝑞 = 10 note: 𝑒 −0.1 = 0.904) Digital Controllers Dahlin Controller • Solution 0.095𝑧 −3 𝐻𝐺 𝑧... uk_3=uk_2;uk_2=uk_1;uk_1=uk; ek_1=ek; Calculate error ek = rk – yk; Stop? Yes 1 2 End No Digital Controllers Microcontroller Implementation • Do the same work with Dahlin Controller 0.095𝑧 3 − 0.0858𝑧 2 𝐷 𝑧 = 0.095𝑧 3 − 0.0858𝑧 2 − 0.009 Digital Controllers PID Controller • PID – Proportional – Integral – Derivative controller • Proportional - 𝐾 𝑝 (or 𝑃): error is multiplied by 𝐾 𝑝 • High 𝐾 𝑝 causes instability,... Increase/decrease controller gain until stable oscillation This gain is called 𝐾 𝑢 (ultimate gain) 4 Read the period 𝑃 𝑢 5 Calculate controller parameters: PI: 𝐾 𝑝 = 0.45𝐾 𝑢 and 𝑇𝑖 = 𝑃 𝑢 /1.2 PID: 𝐾 𝑝 = 0.6𝐾 𝑢 , 𝑇𝑖 = 𝑃 𝑢 /2, 𝑇 𝑑 = 𝑃 𝑢 /8 Exercises 1 Open-loop transfer function of a plant: 𝑒 −4𝑠 𝐺 𝑠 = 1 + 2𝑠 a Design a dead-beat controller Assume T=1s Plot the system response in Matlab-Simulink b Design a Dahlin controller. .. PID Controller Use approximation in (2) 𝑑𝑒 𝑡 𝑒[𝑘] − 𝑒[𝑘 − 1] ≈ 𝑑𝑡 𝑇 𝑛 𝑡 𝑒 𝑡 𝑑𝑡 ≈ 0 → 𝑢[𝑘] = 𝐾 𝑝 𝑇𝑒[𝑘] 𝑘=1 𝑒 𝑘 − 𝑒 𝑘−1 𝑇 𝑒 𝑘 + 𝑇𝑑 + 𝑇 𝑇𝑖 𝑛 𝑒 𝑘 𝑘=1 + 𝑢0 Digital Controllers PID Controller • Build computer equation – Velocity PID Controller Use z-Transform of (2) 𝑈 𝑧 𝑇 1 − 𝑧 −1 = 𝐾𝑝 1 + + 𝑇𝑑 −1 𝐸 𝑧 𝑇𝑖 1 − 𝑧 𝑇 𝐾𝑝 𝑇 𝑒 𝑘 − 𝑒 𝑘−1 + 𝑒 𝑘 𝑇𝑖 → 𝑢 𝑘 = 𝑢 𝑘 − 1 + 𝐾𝑝 𝐾𝑝 𝑇𝑑 + 𝑒 𝑘 − 2𝑒 𝑘 − 1 − 𝑒 𝑘 − 2 𝑇 Digital Controllers...Digital Controllers Dahlin Controller • Dahlin Controller: produces an exponential response → smoother than Dead-Beat • Response of the system: 1 𝑒 −𝑎𝑠 𝑌 𝑠 = 𝑠 1 + 𝑠𝑞 If 𝑎 = 𝑘𝑇 → 𝑌 𝑧 = 𝑧 −𝑘−1 1 − 1 − 𝑧 −1 1− 𝑇 −𝑞 𝑒 𝑇 − 𝑞 −1 𝑒 𝑧 Digital Controllers Dahlin Controller • Closed-loop transfer function (unit step input): 𝑌 𝑧 𝑇 𝑧 = = 𝑅 𝑧... z-Transform 𝑍 𝑓 𝑛𝑇 + 𝑚𝑇 = 𝑧 𝑚 𝐹 𝑧 𝑍 𝑓 𝑛𝑇 − 𝑚𝑇 = 𝑧 −𝑚 𝐹(𝑧) • Build computer equation for Controller s transfer function • Implement the equation on specified MCU Digital Controllers Microcontroller Implementation 1 Build computer equation: 𝑈 𝑧 𝐷 𝑧 = 𝐸 𝑧 𝑒 𝑘 − 0.904𝑒 𝑘 − 1 + 0.095𝑢 𝑘 − 3 → 𝑢 𝑘 = 0.095 Digital Controllers Microcontroller Implementation 2 Implement on MCU Start 1 Initialization uk=uk_1=uk_2=uk_3=0;... results Exercises 2 Explain the difference between Positional and Velocity form of PID controller 3 The open-loop unit step response of a system is shown as figure below Obtain the transfer function of the system and use Ziegler-Nicholes algorithm to design: - A Proportional Controller - A PI Controller - A PID Controller Exercises 4 A mechanical process has the transfer function: 𝐾𝑒 −𝑠𝑇 𝐷 𝐺 𝑠 = 𝑠 . Discrete Controller Design Thanh Vo-Duy Department of Industrial Automation thanh.voduy@hust.edu.vn Content • Digital Controllers • Dead-Beat Controller • Dahlin Controller • Microcontroller. Implementation • PID Controller • Exercises Prior to Lecture Discrete- time System with analog reference input Discrete- time System with digital reference input Digital Controllers • Consider the Discrete- time. where • Digital Controller transfer function Digital Controllers Dead-Beat Controller • Example: Design the Dead-Beat Controller for the system