17
Design Realization lecture 22 John Canny 11/6/03

Design Realization lecture 22 John Canny 11/6/03

Embed Size (px)

Citation preview

Page 1: Design Realization lecture 22 John Canny 11/6/03

Design Realization lecture 22

John Canny

11/6/03

Page 2: Design Realization lecture 22 John Canny 11/6/03

Last time

Some physics: Bending and stretching

Construction methods: Molding Welding Structural components Modular systems

Page 3: Design Realization lecture 22 John Canny 11/6/03

This time

Circuit design critique

Control principles

Simulation – Matlab/Simulink

Page 4: Design Realization lecture 22 John Canny 11/6/03

Feedback Control

Often we want to move a system in a particular way, by controlling a parameter such as: Position control Speed control Force control

Feedback control uses sensor(s) to measure this parameter and make corrections.

Feedback must be applied with care to avoid ever-increasing corrections (instability).

Page 5: Design Realization lecture 22 John Canny 11/6/03

Feedback Control

Naively, we want to do something like this:

-

+

MotorPotentiometer on shaft

(angle sensor)

V+

Input(voltagerepresentingdesired angle)

Amplifier

Page 6: Design Realization lecture 22 John Canny 11/6/03

Feedback Control

Any difference between input and measured shaft angle will be amplified, moving the motor.

If the direction is correct, the motor will reduce the difference. With high gain, the error 0.

-

+

MotorPotentiometer on shaft

(angle sensor)

V+

Input

Amplifier

Page 7: Design Realization lecture 22 John Canny 11/6/03

Simulink Models

Tools like Matlab/Simulink allow us to design and test controllers before building them.

Here is the controller just shown in Simulink:

angleVoltage

Page 8: Design Realization lecture 22 John Canny 11/6/03

Feedback Instability

Problem: the amplifier has delay, the motor has inertia, keeps moving even after error 0.

If gain is too high, it will overshoot, “ring” or possibly oscillate.

Page 9: Design Realization lecture 22 John Canny 11/6/03

PD Stabilizing Controller

The simplest way to control feedback is with a “PD” (Proportional Derivative) controller.

A multiple of the derivative of the output is subtracted from the amplifier input.

Page 10: Design Realization lecture 22 John Canny 11/6/03

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.

Page 11: Design Realization lecture 22 John Canny 11/6/03

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.

Page 12: Design Realization lecture 22 John Canny 11/6/03

PID Tracking Controller

All three terms P,I,D are computed on the difference signal:

PID controller

Page 13: Design Realization lecture 22 John Canny 11/6/03

Implementing PID Controllers

Normally, the controller CPU is running at fixed discrete time steps.

Derivates can be computed by differencing consecutive samples, integrals by summing samples.

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.

Page 14: Design Realization lecture 22 John Canny 11/6/03

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.

Page 15: Design Realization lecture 22 John Canny 11/6/03

Discrete lowpass amplifier

The amplifier’s DC Gain is b Corner frequency c = (- ln a)/t = 2fc

where t is the discrete step time.

Page 16: Design Realization lecture 22 John Canny 11/6/03

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.

Page 17: Design Realization lecture 22 John Canny 11/6/03

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.