Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling...
-
Upload
irma-white -
Category
Documents
-
view
224 -
download
0
Transcript of Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling...
![Page 1: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/1.jpg)
Computer Control: An Overview Wittenmark, Åström, Årzén
• Computer controlled Systems
• The sampling process
• Approximation of continuous time controllers
• Aliasing and new Frequencies: Anti-aliasing filters
• PID Control: Discretization, integrator windup
• Real time implementation
![Page 2: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/2.jpg)
Computer controlled systems
Quantization in timeand magnitude
![Page 3: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/3.jpg)
The sampling process
Periodic sampling
Sampling instants: times when the measured physical variables are converted into digital form
Sampling period: time between two sampling instants (denoted by h or T)
![Page 4: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/4.jpg)
Sampling and Reconstruction
Sampler: A device that converts a continuous time signal into a sequence of numbers, e.g., A/D converter
A/D: 8-16 bits 2^8 to 2^16 levels of quantization, normally higher than the precision of physical sensor
Reconstructor: Converts numbers from the computer to analog signals
D/A converter combined with a hold circuit (Zero Order Hold)
![Page 5: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/5.jpg)
Discretization of continuous controllers
k J
Disk drive system controller design:
Analysis done on board
![Page 6: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/6.jpg)
Sampling continuous signals
![Page 7: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/7.jpg)
Aliasing and new frequencies
Can information be lost by sampling a continuous time signal? sin(2 0.9t) & sin(2 0.1t)
Are sampled values obtained from a low frequency signal or a high frequency signal? It may be possible that some continuous signal CANNOT be recovered from the sampled signal
May have loss of information
![Page 8: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/8.jpg)
If a signal contains no frequencies above 0, then the continuous time signal can be uniquely reconstructed from a periodically sampled sequence provided the sampling frequency is higher than 20 (Nyquist rate)
Shannon’s Sampling Theorem (1949)
Can recover 0.1 Hz but not 0.9 Hz
![Page 9: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/9.jpg)
Can recover 0.1 Hz but not 0.9 Hz
What should be the sampling frequency for recovering the 0.9 Hz sinusoidal?
Sampling Theory- Example
![Page 10: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/10.jpg)
Aliasing & Anti-aliasing Filters
Aliasing (or frequency folding): High frequency signal interpreted as a low frequency signal when sampled at lower than the Nyquist rate (the 0.9=1-0.1 Hz signal)
w1-w1 wsws-w1 ws+w1
……
![Page 11: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/11.jpg)
… anti-aliasing filters
To prevent aliasing:
Remove all frequencies above the Nyquist frequency before sampling the signal.
Antialiasing filter (low pass analog filter)
High attenuation at and above Nyquist frequency
Bessel/Butterworth filters (order 2-6):
![Page 12: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/12.jpg)
Example: Pre-filtering
Square wave + 0.9 Hz sine disturbance
Sampled at 1 Hz (alias freq 0.1 Hz)
Filtered bya 0.25HzLPF.
Sampledvalues
![Page 13: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/13.jpg)
Summary
Information can be lost through sampling if the signal contains frequencies higher than the Nyquist frequency.
Sampling creates new frequencies (aliases).
![Page 14: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/14.jpg)
… summary
Aliasing makes it necessary to filter the signals before they are sampled.
Effect of the anti-aliasing filters must be considered when designing controllers. The dynamics can be neglected if the samplingperiod is sufficiently short.
![Page 15: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/15.jpg)
Computer control (Wittenmark, Astrom, Arzen)
PID Control: Discretization, saturation and windup
Other practical issues
![Page 16: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/16.jpg)
PID Control
Most common controller:
e: error, K: gain, Ti: integration time, Td: derivative time
System error as K & 1/Ti , stability improves as Td , increasing 1/Ti reduces stability
Originally implemented using analog technology
![Page 17: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/17.jpg)
PID Control & DiscretizationModifications to PID:
Derivative term:
Derivative not acting on the command signal
N: gain athigh freq:3-20
![Page 18: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/18.jpg)
Discretization of PID Controller
Proportional part needs no approximation:
Integral part: can be approximated as
![Page 19: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/19.jpg)
.. Discretization of PID: P+I+D
Derivative part: D(t)
use backward differences for approximation:
![Page 20: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/20.jpg)
Integrator windupActuators can become saturated due
to large inputs Examples of saturated actuators: - throttle position in an automobile - amplifier output voltage - aircraft control surfaces
![Page 21: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/21.jpg)
A taste of the practical worldIf error is large, Integral Control can
saturate the actuator.
PID
error
Integrator output can become large (windup) with no effect on the output (due to saturation).
System y reference
+
-
u uc
![Page 22: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/22.jpg)
… integrator windupIntegrator output winds up until the sign of
e(t) changes and the integration turns the other way around Solution: Reset integrator when actuator is saturated
Using anti-windup
Without anti windup
y
uc
Desired output
![Page 23: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/23.jpg)
PID implementation
Signalsdouble uc; // set point
double y; // measured variable
double v; // control output
double u; //limited control output
Statesdouble I = 0; //Integral part
double D = 0; //Derivative part
double yold=0; //delayed measured variable
Parameters
double Kp, Ki, Kd;
double Ts; //Sampling time
double ul, uh; //output limits
![Page 24: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/24.jpg)
PID class
oo
PID
Signals signals;
States states;
Parameters par;
double calculateOutput(uc, y);
void updateState(double u);
Calculate, Perform integratoranti-windup
![Page 25: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/25.jpg)
Main programmain( ) {double uc, y, u;PID pid = new PID( ); // Can pass parameters herelong time = getCurrentTimeMillis( ); // Get current
timewhile (true) {
y = readY( ); uc = readUc( );u = pid.calculateOutput(uc,y);writeU(u);pid.updateState(u);time = time + pid.par.Ts*1000; // Increment timewaitUntil(time); // Wait until "time“- RTOS call
}
![Page 26: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/26.jpg)
void updateState(double u)
void updateState(double u) {states.I = states.I + par.bi*(signals.uc
- signals.y) +par.ar*(u - signals.v);states.yold = signals.y;}
![Page 27: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/27.jpg)
calculateOutput( )double calculateOutput(double uc, double y) {….double P = par.K*(par.b*uc - y);states.D = par.ad*states.D - par.bd*(y - states.yold);signals.v = P + states.I + states.D;if (signals.v < par.ulow) {signals.u = par.ulow;} else {if (signals.v > par.uhigh) {signals.u = par.uhigh;} else {signals.u = signals.v;}}return signals.u;}
![Page 28: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/28.jpg)
Summary of PID
PID is a useful controller.Things to consider:
Filtering of the derivative term Updating the integrator Anti windup compensation
![Page 29: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/29.jpg)
Some practical issues
Numerical accuracy is improved if more bits are used: float coeff; vs double coeff; (64 bits)
A/D and D/A Much less accuracy Typical resolutions: 8, 12, 16 bits Better to have a good resolution at the
A/D converter than D/AA control system is less crucial for a quantized
signal applied to the input of the plant.
![Page 30: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/30.jpg)
… practical issues
Nonlinearities such as quantization by A/D can result in oscillations Do simulations to find out if A/D, D/A resolutions can
improve performance
Selection of the sampling period A common rule: = 0.1 to 0.6, : desired BW of the closed-loop
system
![Page 31: Computer Control: An Overview Wittenmark, Åström, Årzén Computer controlled Systems The sampling process Approximation of continuous time controllers Aliasing.](https://reader034.fdocuments.net/reader034/viewer/2022051315/56649de55503460f94add9f1/html5/thumbnails/31.jpg)
… practical issues
Anti-aliasing filters Must provide attenuation at Nyquist
frequencyAnti-reset windup is important to
include in the controller.