me 534 - 01 introduction (rev. 2.1)courses.me.metu.edu.tr/courses/me534/protected/me... · –...
TRANSCRIPT
Outline – Introduction• Classification of Control SystemsClassification of Control Systems• Analog Controllers
– Op-amp circuits– PID ImplementationPID Implementation– Comparison
• Signals in Control Engineering• Elements of Control Computer• Elements of Control Computer
– I/O interfaces – Control computer
C t l l ith– Control algorithm• Example: Water Level Control
– P control law– Hysteresis control
Chapter 1 ME 534 2
Classification of Control Systemsy
Continuous time Control• Continuous-time Control– Mostly referred to as “Analog Control”– Controller takes corrective action continuously in time.y– Analog circuit elements are used to implement such controllers.
• Discrete-time Control– Also known as “Digital- or Numerical Control”– Corrections take place at particular instances in time.
• Controller’s output stays constant between these instances.– Microprocessors are generally employed to realize these
controllers. • Hybrid Control• Hybrid Control
– A blend of both control systems (and strategies).
Chapter 1 ME 534 3
Discrete-time Control Applicationspp
• Home appliances • Millitary applicationspp– Dishwasher– Washing machine– Fridge
y pp– Advanced weapons systems– Radar systems
• CNC Machine ToolsFridge• Robotics
– Mobile robotsI d t i l b t
• CNC Machine Tools• Electric Motor Drivers• Consumer goods
– Industrial robots • Automations systems
– Factory automation
g– TV sets– CD / DVD players / recorders– Camcordersy
• Aerospace applications– Aircraft control / guidance
Satellites
Camcorders– Mobile phones
• Personal ComputingH d di k d i– Satellites
– Rocket / missile guidance– Hard disk drives– CD-RW drives
Chapter 1 ME 534 4
Digital Applications (Cont’d)g pp ( )
• Automobiles• Automobiles– Several computers are on
board.Some functions performed– Some functions performed by these computers (called electronic control units or ECUs))
• Fuel injection / Ignition control
• Anti-lock Break Systems (ABS)(ABS)
• Stability and traction control (anti-skid)
• Active suspensionActive suspension• Climate control• Automatic transmission
system
Chapter 1 ME 534 5
y
Typical Digital Control Systemyp g yPower Disturbance
Control
ControlElement
m(t) u(t) y(t)
ControlComputer
Sensorb(t)
• Function of control computer:• Function of control computer:– Computation of correction signal
Generating command / reference– Generating command / reference– Decision making– Implementation of complex logical operations
Chapter 1 ME 534 6
Implementation of complex logical operations.
Typical Analog Control Systemyp g y
• Function of analog computer:– Analog filtering of the measurement noise in the input signals– Comparison of the measurement (b) and the command (r)– Generation of correction signal (m) on a continuous basis.
Chapter 1 ME 534 7
Analog Control using Op-ampsg g p p• Analog controllers are frequently
implemented via operational amplifiers(or simply op-amps).
– One can implement almost any desired function.
+
_2
1
3 6
7
8
Output
+V
Offset null No connection
Inverting input
Non-inverting input
• Op-amps are very versatile amplifiers:– Precise– Error tolerant / Robust
+3
4 5
6 Output
-V Offset null
Non-inverting input
– Low-cost
• There exists a wide variety of specialized op-amps for differentspecialized op-amps for different applications:
– Radio/video S / d– Sonar/radar
– Automation– Automotive
I t t ti tChapter 1 ME 534 8
– Instrumentation, etc.
Inverting Amplifierg pA number of different functions can be implemented by employing op-amps with various passive circuit elements.
Integrator:
ZA = RZB = 1/(Cs)
11)(E ⎤⎡
Transfer function of this circuit is
( ) ( )E s Z s
s1
RC1
)s(E)s(E
i
o⎥⎦⎤
⎢⎣⎡−=
Differentiator:( ) ( )( )( ) ( )
o Bi
i A
E s Z sG sE s Z s
= = −
ZA = 1/(Cs)ZB = Rwhere ZA, ZB refer to the generalized
s)RC()s(E)s(E
i
o −=
impedances [Ω] of the components.Note that the bipolar voltage supply(+V, -V) of the circuit is customarilyNOT shown for the sake of simplicity
ME 534 9
NOT shown for the sake of simplicity.
Chapter 1
Common Op-amp CircuitsCo o Op a p C cu sSumming Amplifier (Mixer): Buffer (Voltage Follower):
e = e
Rf
eo = ei
R1Rn
_
+
+
e1
+
en
RL eo Low-pass Filter:
nR
( ) 1oE s
1
f
i
Ro iR
ie e
=
= − ⋅∑( )( ) ( ) 1
o
iE s RC s=
+
Chapter 1 ME 534 10
Differential Amplifiere e a p e
• Differential amplifier is used to pamplify small signals buried in much larger signals.
• R2 resistances (along with R1s)
ek)vv(v 12RR
o 12 ⋅=−=
R2 resistances (along with R1s) must be equalized to reduce the effect of common mode voltage on the output (vo).
Chapter 1 ME 534 11
p ( o)
Voltage Limiterg• Output of op-amps cannot exceed a certain voltage level Vsat:
o V t is a few volts (usually 2 Volts) lower than the supply voltage (V )o Vsat is a few volts (usually 2 Volts) lower than the supply voltage (Vs).
• One can built a voltage limiter using this important property. To accomplish that, two cascaded op-amp circuits are designed:
o The first one (“Amplifier”) is to amplify ei such that the output at this stage will saturate at theo The first one ( Amplifier ) is to amplify ei such that the output at this stage will saturate at the some desired level.
o The following circuit (“Attenuator”) , which has a reciprocal of the amplifier’s gain, reverts the amplified voltage back.
• As an illustration, assume thatwe would like to limit ei such that
-5 [V] ≤ e ≤ 5 [V]-5 [V] ≤ ei ≤ 5 [V]• Let Vs = 15 [V] and Vsat = 13 [V].• In this case, the gain of the
amplifier is calculated asV t/ei =13/5 = 2 6Vsat/ei,max =13/5 = 2.6
• Hence, we choose R1 = 10 kΩand R2 = 26 kΩ.
Chapter 1 ME 534 12
Analog PID ControllergKd
ddt
D-control Analog computations involved in PID:• Integration (∫dt)
Diff ti ti (d/dt)
Ki
dt
dt+r(t) m(t)
+I-control
• Differentiation (d/dt)• Amplification (by a gain)• Summation (addition, subtraction)
Kp
_
P-control 21 2( 1)( 1)( )
( )d p i
i
K s K s K s sM s KE s s s
τ τ+ + + += =
Transfer Function:
b(t)
Circuit Parameters:
( )( ) ( ) ( )
E s s sE s R s B s= −
1 1 1R CR C
ττ==
Circuit Parameters:
2 2 2
4
1 3 2i
R CRK
R R C
τ =
=
Chapter 1 ME 534 13
Another PID Controller• A more versatile version of the PID
controller can be built by simplyimplementing each control law via aimplementing each control law via aseparate circuit.
• Controller gains can be convenientlyadjusted via R1, R2, and R3.
Control Parameters:
3
4p
RKR
=
Control Parameters:
1 1
1iK
R CK R C
=
= 2 2dK R C=
Chapter 1 ME 534 14
A Multi-purpose PID Controller p p
Chapter 1 ME 534 15
ComparisonpAnalog Control Digital Control
Control computations (such as ∫dt, d/dt, ×, ÷, ±, etc.) are continuous in time.
All computations are performed in distinct time intervals.
Op-amps are used as computing elements.
μPs, DSPs, μCs, PLCs are commonly utilized.
H d i d N t it bl f Fl ibl / il dHardwired – Not suitable for reconfiguration.
Flexible / easily programmed.
Very sensitive to measurement- and Somewhat sensitive to signal process noise. conversion errors, quantization noise,
and round-off / truncation errors.Inexpensive for simple control systems Hardware is inexpensive but control p p ybut can be quite costly for complex systems.
psoftware development tools can be expensive.
Chapter 1 ME 534 16
Signals in Control EngineeringSignals in Control Engineering
1 Continuous time signal1. Continuous-time signal2. Discrete-time signal3. Amplitude-quantized discrete-time signal4 Amplitude-quantized continuous-time4. Amplitude quantized continuous time
signal
Chapter 1 ME 534 17
Type 1: Continuous-timeyp
• Time: t ∈ [0 +∞)Time: t ∈ [0, +∞)• The signal ranges between a lower bound (fmin)
and an upper bound (f ): f ∈ [f f ]and an upper bound (fmax): f ∈ [fmin, fmax ]• By definition, f(t) = 0 when t < 0.
Chapter 1 ME 534 18
Type 2: Discrete-timeType 2: Discrete timef(t) f*(t)
⎨⎧ ∈ TTttf
f,...}2,,0{),(
)(*
⎩⎨⎧
=else
ftf
,0, },,{),(
)(
tT 2T 3T0
• Time: t ∈ {0, T, 2T, ... , kT, ...}• The signal ranges between a lower bound (fmin) g g ( min)
and an upper bound (fmax): f ∈ [fmin, fmax ]
Chapter 1 ME 534 19
Type 3: Amplitude Quantized Discrete-time
Quantization Level:
nmfff
+−
=Δ minmax
Quantization Level:
f nm +
*~( ) , {0, ,...}
( )f tf floor t T
f t f⎧ ⎛ ⎞Δ ⋅ ∈⎪ ⎜ ⎟= Δ⎨ ⎝ ⎠3 f ( )
0,f f
elseΔ⎨ ⎝ ⎠
⎪⎩
T 2T 3T0
f
• Time: t ∈ {0, T, 2T, ... , kT, ...}
Th f th f ti b• The range of the function becomes
},,2,,0,,)1(,{~
* fmfffnfnf ΔΔΔΔ−−Δ−∈ ……
Chapter 1 ME 534 20
Type 4: Quantized Continuous-timeType 4: Quantized Continuous time• Time: t ∈ [0, +∞)Time: t ∈ [0, )
• The range of the function isfunction is
],[ maxmin
~fff =
• Since the transitions of the function at T, 2T, 3T, ... are extremely fast, the function values predominantly reside at the quantized levels.
Chapter 1 ME 534 21
Properties of Digital Control Systems
• All physical quantites are represented by corresponding (binary) numbers with finitecorresponding (binary) numbers with finite length.
• All computations are synchronized and are carried out periodically.p y
• The period in which all these computations are performed is called sampling periodare performed is called sampling period(T).
Chapter 1 ME 534 22
Properties (Cont’d)p ( )
• All quantites in discrete-time domain could be qexpressed as– X(t = kT) ≡ X(k) where k ∈ {0, 1, 2, ...}X(t kT) X(k) where k ∈ {0, 1, 2, ...}– k is called time index.
• Control algorithm is essentially an algeabric• Control algorithm is essentially an algeabric expression (difference equation) which depends on not only the history of error butdepends on not only the history of error but also that of the manipulation):
MN
∑∑==
−⋅+−⋅−=M
jj
N
ii jkebikmakm
01)()()(
Chapter 1 ME 534 23
A General Digital Control SystemPower Disturbance
m(kT) m(t)~ u(t) y(t)e(kT)r(kT)
t
Output Interface
DifferenceEquation
t t t tt ControlAlgorithm
Latch &D/A
t
ErrorCommand Manipulation OutputManipulatedInput
ControlElement Plant
+
_
Clock
b(t)
t
b(kT)
t
~
Sampler &Measurement Sampler &A/D Sensor
Measurement
Control Computer and Software Input
Interface
Digital Domain Analog Domain
• Control elements:M t D i El t i M t– Motor Driver + Electric Motor
– Servo-valve + Hydraulic Cylinder / Motor– Power Converter + Electric Heater
Chapter 1 ME 534 24
Power Converter + Electric Heater
Elements of I/O Interfaces
I SamplerI. SamplerII. Analog-to-Digital (A/D) ConverterIII. LatchIV Digital-to-Analog (D/A) ConverterIV. Digital to Analog (D/A) Converter
Chapter 1 ME 534 25
I) Sampler) p
f*(t)Sampler
f(t)Type 2Type 1
t
T 3T0
Tf(t) f*(t)t
• Samples a continuous-time signal at samplingSamples a continuous time signal at sampling instances.
• Converts effectively an analog signal (Type 1)• Converts effectively an analog signal (Type 1) into a discrete-time one (Type 2).
Chapter 1 ME 534 26
II) A/D Converter)
• It converts a voltage level into a corresponding (binary) number representation at a particular(binary) number representation at a particular instant of time.
Chapter 1 ME 534 27
Properties of A/D Convertersp• Input Voltage Range:
5V U i l 0 +5V5V Unipolar: 0 → +5V5V Bipolar: -5V → +5V10V Unipolar: 0 → +10V10V Unipolar: 0 → +10V10V Bipolar: -10V → +10V
• Resolution:• Resolution:Denotes quantization levelOutput is N-bit binary numberOutput is N-bit binary number
• Conversion time:Time required to convert the voltage intoTime required to convert the voltage into an N-bit binary number
Chapter 1 ME 534 28
A/D Converters (Cont’d)( )
• A/D converters are integrated circuits• A/D converters are integrated circuits designed specifically to do this conversion:
V [V V ]– Vin ∈ [Vmin, Vmax]– Vout0, ..., VoutN ∈ {0, 5 V} (TTL)
• For convenience, output voltage states , p gare represented as binary numbers:– 0 Volt → “0” (low logic level)
5 Volts → “1” (high logic level)– 5 Volts → 1 (high logic level)• For A/D converter chips, prices go up as
– Resolution (and accuracy) increases– Conversion time decreases
Chapter 1 ME 534 29
Unipolar A/D Converterp
• For a unipolar A/D converter (ADC) with 8 bit resolution• For a unipolar A/D converter (ADC) with 8-bit resolution, we have the following ADC output code:
Output Voltage at Pins [V] BinaryNumber
UnsignedIntegerDB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 0 0 0 0 0 0 00000000 00 0 0 0 0 0 0 0 00000000 00 0 0 0 0 0 0 5 00000001 10 0 0 0 0 0 5 0 00000010 20 0 0 0 0 0 5 5 00000011 3
... ... ...5 5 5 5 5 5 5 5 11111111 2555 5 5 5 5 5 5 5 11111111 255
Chapter 1 ME 534 30
Unipolar ADC Output (8-bit)p p ( )Output of ADC
11111111
1111111011111110
00000010
00000011
00000001
00000000 Input Voltage0 V V V V
(Vmin)
Chapter 1 ME 534 31
Bipolar ADC Output (8-bit)p p ( )Note that the ADC output format in bipolar operation isdevice-dependent: Device manufacturers commonlyemploy direct (straight) binary- and/or two’s complementemploy direct (straight) binary and/or two s complementrepresentations.
28V
Vm
ax)
27V
26V
8V
7V
6V
Vm
in)
Chapter 1 ME 534 32
12 (V1212-128
-127
-126(V
Example – A/D Converterp
Consider a 10V unipolar A/D converter with 8 bit (N 8) l ti8-bit (N = 8) resolution.
a) Determine the voltage resolution of this ) gdevice.
b) Find the output representation (as unsignedb) Find the output representation (as unsigned integer) when an input voltage of 3.27 V is applied.applied.
Chapter 1 ME 534 33
Solution – Part (a)( )
Voltage resolution (i.e. quantization level) can be given as
max min| |2N
V VV −Δ =
Hence,
8
|10 0 | 10 39.0625 [ ]2 256
V mV−Δ = = =
2 256
Chapter 1 ME 534 34
Solution – Part (b)( )The corresponding number representation can be simplyexpressed as
3
3.27 8339 0625 10
inVoutput floor floorV −
⎛ ⎞ ⎛ ⎞= = =⎜ ⎟⎜ ⎟Δ ×⎝ ⎠⎝ ⎠
expressed as
39.0625 10VΔ ×⎝ ⎠⎝ ⎠
where floor is a function rounding its argument to thelowest integerlowest integer.
Input Voltage Range [V] Binary # Rep. Unsigned Int. Rep.
[0, 0.0391) 00000000 0[3.2422, 3.2813) 01010011 83[9.9219,9.9609) 11111110 254
[9.9609,10) 11111111 255Chapter 1 ME 534 35
[ , )
Quantization Error (or Accuracy)( y)• A/D conversion
mentioned here leads to a quantization error of one ΔV (or one leastone ΔV (or one least significant bit: LSB) at maximum.maximum.
• Such an quantization error might be gunacceptable for certain applications.
Chapter 1 ME 534 36
Quantization Error (Cont’d)( )• To reduce this error, a
better A/D conversion method is adapted by ADC manufacturers:manufacturers:– A bias of ΔV/2 is internally
added to Vin.in
– Quantization error now ranges between -ΔV/2 and ΔV/2 (or ±½ LSB)±½ LSB).
• Output (code) of the ADC can be expressed ascan be expressed as
output = floor(Vin/ΔV + ½)
Chapter 1 ME 534 37
Input Interfacep
S l
f*(t)~
f*(t)~ Type 3f(t)
f(t)Type 1
Sampler& ADC
tT 3T0
3 ff
f (t)( )
t
• In practice, sampler & ADC are considered to be p , pa single unit:– Input to the unit is an analog voltage varying in time, p g g y g ,– Output is binary number sequence with finite “word”
length.
Chapter 1 ME 534 38
III) Latch)
• Latch holds a binary number during one li i dsampling period.
• It is an integrated circuit which holds the ginput (N-bit digital) signal throughout one sampling periodsampling period. – The output of the device remains the same
d ring this periodduring this period.
Chapter 1 ME 534 39
IV) D/A Converter)
• Converts an N-bit digital signal into a corresponding voltage level:p g g– Complementary operation of A/D converter.
Important properties:• Important properties:– Output Voltage Range:
• 5V unipolar, 5V bipolar, 10V unipolar, 10V bipolar– Resolution (and Accuracy)( y)– Conversion Time
Chapter 1 ME 534 40
Output Interfacep
• Latch and D/A converter (DAC) are rolled into aLatch and D/A converter (DAC) are rolled into a single unit (output interface).
• Output interface oftentimes referred to as• Output interface oftentimes referred to as “Sample and Hold” (S/H) Unit.
Chapter 1 ME 534 41
Errors in Digital Control Systemsg y
Chapter 1 ME 534 42
Control Computerp
• As control computers, there exist a wideAs control computers, there exist a wide variety of choices in practice:
PC + Data Acquisition Board (DAQ)– PC + Data Acquisition Board (DAQ)– PC + Motion Control Card– Microcontroller: Single Control IC– Programmable Logic Controller (PLC)
Chapter 1 ME 534 43
g g ( )
A Simple Control Algorithm p g
1 Fetch sensor value b(k)1. Fetch sensor value b(k)2. Fetch (or generate) command r(k)3. Compute error e(k) = r(k) - b(k)4 Calculate compensation m(k)4. Calculate compensation m(k)5. Output m(k)p ( )6. Wait till end of sampling period7 G t St 17. Go to Step 1
Chapter 1 ME 534 44
Illustrative Examplep• Consider the water
level control system.• Servo-valve (or Prop. en
sor
( pFlow Control Valve):– m(t) is control voltage:Le
vel S
e
• 0 V → qi = 0 lt/s• 5 V → qi = 100 lt/s
S• Sensor:– b(t) is sensor output
voltage:voltage:• 0 V → h = 0 m• 5 V → h = 5 m
Chapter 1 ME 534 45
Control SystemControl
Algorithmr(k) + Latch &
D/A
m(t) qi(t)
qo(t)
Servo-Valve
Water Tank
h(t)m(k)
8-bit / 5Vunipolar
Algorithm_
D/A Valve Tank
ClockT
Data AcquisitionBoard
Sampler & A/D
b(t) Level Sensor
b(k)
PC running ControlPC running Control Program
8-bit / 5Vunipolar
• Control System: PC (w/ RT-OS) + DAQ Desired water level:• Control System: PC (w/ RT-OS) + DAQ• Control Law: Proportional Control• Sampling Time: T = 0.1 sec.p g• D/A Converter: 8-bit / 5V unipolar• A/D Converter: 8-bit / 5V unipolar
Chapter 1 ME 534 46
C Library Functionsy
• Most DAQ board manufacturers provide device• Most DAQ board manufacturers provide device drivers along with high-level language support (i.e. library functions) for free.(i.e. library functions) for free.
• For this example, let us assume that the following functions are available:following functions are available:– read_ADC(): returns water-level as unsigned integer.– write DAC(m): generates output voltage depending _ ( ) g p g p g
on the input argument m. Here, m < 256 is an unsigned integer.
d l th ti b “ ” ili d– pause(n): delays the execution by “n” miliseconds.– init(): initializes the units on the DAQ board.
Chapter 1 ME 534 47
Control Program 1 (ANSI C)g ( )#include <math.h>#include <stdlib.h>#include “control.h”##define K 1.2void main() {float r,dr,e,b,qi; unsigned int m;q gr = 0; dr = 3/3000;init(); /* Initialize */while(1){ /* Infinite loop */b = 5*read_ADC()/255; /* Read sensor */r += dr; if (r>3) r = 3; /* Calculate cmd */e = r – b; qi = K*e; /* P-control law */if (qi < 0) qi = 0; /* 0 <= qi <= 100 */if (qi > 100) qi = 100;m = floor(2.55*qi);it DAC( ) /* O t t */write_DAC(m); /* Output */
pause(100); /* Wait for 100 ms */}
}Chapter 1 ME 534 48
}
Analog P-Controller gR2
_R1
b(t)
• Desired P-gain (K) can be obtained by selecting a
+R1
r(t)m(t) proper R2/R1 ratio.
• Measurement noise t i b(t) i j
R2present in b(t) is a major drawback on performance.
• Generating an arbitrary r(t)
)]()([)( bK R
• Generating an arbitrary r(t) in continuous-time is apparently difficult.)]()([)(
1
2 tbtreKtm RR −=⋅=
apparently difficult.
Chapter 1 ME 534 49
Hysteresis Controly• Another very simple control strategy isAnother very simple control strategy is
hysteresis (a.k.a. “bang-bang” or “on/off”) control.control.
• The power control element (PCE) is either switched fully on or off depending on theswitched fully on or off depending on the magnitude of error:
If error > threshold then PCE is switched on– If error > threshold then PCE is switched on.– If error < -threshold then PCE is switched off.
“th h ld” i ft ti f d t “• “threshold” is oftentimes referred to as “error-band,” “deadband,” or “tolerance.”
Chapter 1 ME 534 50
Hysteresis Control (Cont’d)y ( )
Chapter 1 ME 534 51
Control Program 2 (ANSI C)g ( )#include <math.h>#include <stdlib.h>#include “control.h”##define dh 0.1 /* Define deadband */void main() {float r,dr,e,b; unsigned int m;gr = 0; dr = 3/3000;init(); /* Initialize */write_DAC(255); /* Turn on valve */_while(1) { /* Infinite loop */b = 5*read_ADC()/255; /* Read sensor */r += dr; if (r>3) r = 3; /* Calculate cmd */e = r – b;if (e > dh) m = 255; /* Hit lower bound? */if (e <-dh) m = 0; /* Hit upper bound? */
it DAC( ) /* O t t */write_DAC(m); /* Output */pause(100); /* Wait for 100 ms */
}}
Chapter 1 ME 534 52
}
Questions to be AddressedQuestions to be Addressed
Ho to pick a control la and determine• How to pick a control law and determine its parameters in discrete-time domain?– Stability– Performance objectivesPerformance objectives
• Command tracking• Disturbance rejectionDisturbance rejection
• How to select a proper sampling period?• How about hardware / software design?
Chapter 1 ME 534 53