1 / 20

Design Realization lecture 23

Design Realization lecture 23. John Canny 11/13/03. Last time. Circuit design critique Control principles Simulation – Matlab/Simulink. This time. Finish circuit design critique Graphical programming and real-time control (Simulink).

marycaro
Download Presentation

Design Realization lecture 23

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Design Realization lecture 23 John Canny 11/13/03

  2. Last time • Circuit design critique • Control principles • Simulation – Matlab/Simulink

  3. This time • Finish circuit design critique • Graphical programming and real-time control (Simulink). • Automatic real-time code generation (Real-Time Workshop).

  4. PD Control • In addition to position feedback, a multiple of the velocity (derivative) is fed back as well to stabilize the system:

  5. PD Stabilization • Why does derivative feedback stabilize the system? • Derivative feedback simulates a damper. • Motion in a fluid creates viscous drag (F  -v). • Viscous drag quickly robs the system of energy.

  6. PID Control • Sometimes there is a residual error between desired and actual output (not for DC motors). • Computing the integral of the difference signal will reduce it to zero in the steady state.

  7. PID Tracking Controller • All three terms P,I,D are computed on the difference signal: PID controller

  8. Example2: Pendubot • A two-axis robot. The first (blue) link is driven, the second (red) link is passive. • The model includesgravity, and is quitenon-linear.

  9. Example2: Pendubot • Use feedback and feedforward PID blocks to stabilize two oscillatory modes.

  10. Implementing PID Controllers • Normally, the controller CPU is running at fixed discrete time steps. • Derivatives can be computed by differencing consecutive samples, integrals by summing samples since time zero. • This approach introduces delays and can cause problems at high frequency. • Make sure that amplifiers “roll off” at high frequency – use a low-pass amplifier.

  11. Discrete lowpass amplifier • Input is (x1,…,xn), output is (y1,…,yn) yk = a yk-1 + (1-a)b xk a, b constants, a < 1. • If x = 0, y non-zero, then the amplifier outputs a decreasing geometric sequence, which is a discrete approximation to exponential decay. • It simulates a simple RC low-pass circuit.

  12. Discrete lowpass amplifier • The amplifier’s DC Gain is b • Corner frequency c = (- ln a)/t = 2fcwhere t is the discrete step time.

  13. Transfer functions • The variable s represents frequency: • T(s) = 1/s is an integrator • T(s) = s is a derivative operator • T(s) = 1/(a + bs) is a low-pass filter with corner frequency a/b • T(s) = (c + ds) is a high-pass filter with corner frequency c/d • T(s) = (a + bs)/(c + ds) is a general gain block, DC gain = a/c, high frequency gain = b/d.

  14. Real-time Simulink execution • Simulink does not have a real-time clock (at least under Windows), and runs in virtual time. • It can be driven in real-time if one of its blocks (especially input/output blocks) updates at regular real-time speed. • The remainder of the Simulink code must run fast enough to keep up.

  15. Example: Real-time Theremin Model • 1-wire sensors control pitch and volume. • Real-time sound output via sound card.

  16. Example: Real-time Simulink Model • The simsound block includes a separate thread which sends data to the sound card. • This thread signals the main program thread with a semaphore when it is ready to accept data, or when its buffer is full. • The buffer contains data with time stamps at the desired real-time update rate. • Simulink runs a little faster than the sound card update rate, and the sound thread interpolates from Simulink’s timestamps to real time.

  17. Example: Real-time Simulink Model • The AtoD block also includes a separate thread to acquire A-to-D input data. • This thread runs as fast as it can to provide the most up-to-date sensor data to the running simulation.

  18. Automatic code generation • There is a companion to Matlab/Simulink called “real-time workshop” (RTW). • RTW automatically generates C code to run a Simulink model. It can handle new user-defined blocks (e.g. for sensor input or motor output). • This code can be compiled and run on the control processor.

  19. Automatic code generation • RTW code generation includes scheduling and event-handling and allows blocks to run at different rates. • It also allows complicated models that may not run correctly with a simple discrete-step approximation.

  20. Summary • Feedback control methods: PD and PID. • Feedforward control. • Real-time use of Simulink. • Code generation with Real-Time Workshop.

More Related