Closed loop control- controllers BITS Pilani Pilani Campus
Transfer function An op amp amplifies as per its gain If G= 10--- A 2mV i/p 20 mV However, for many systems the relationship between the output and the input is in the form of a differential equation
We cannot just divide the output by the input because the relationship is a differential equation and not a simple algebraic equation. We can, however, transform a differential equation into an algebraic equation by using what is termed the Laplace transform
We then define the relationship between output and input in terms of a transfer function, this stating the relationship between the Laplace transform of the output and the Laplace transform of the input.
We might be interested how a system defined by the differential equation G(t) respond to a external change causing variable Y(t), Where response is captured by X(t)
Introduction Laplace Transformation Time domain unknown f(t), d/dt, Diff Eqs
Frequency domain unknown F(s), Alg Eqs
Solve Differential Equations
Solve Algebraic Equations
Time domain known f(t)
Frequency domain known F(s)
Inverse Laplace Transform
The Laplace Transform The Laplace Transform of a function, f(t), is defined as;
L[ f (t )] F ( s) f (t )e dt st
Eq A
0 The Inverse Laplace Transform is defined by
1
L [ F ( s )] f (t ) *notes
1
j
Eq B F ( s ) e ds
2 j j
ts
The Laplace Transform Transform Pairs: f(t)
F(s)
(t )
1
1 u( t ) ____________________________________ s 1 st e sa 1 t s2 n! n t s n 1 f (t )
F ( s)
The Laplace Transform Transform Pairs: f(t) te
at
n at
t e
sin( wt ) cos( wt )
F(s) 1
s a 2 n! ( s a )n 1 w s2 w2 s s2 w2
The Laplace Transform Transform Pairs: f(t)
e
at
sin(wt )
e at cos(wt ) sin(wt ) cos(wt )
F(s)
w (s a)2 w 2 sa 2 2 (s a) w s sin w cos s2 w2 s cos w sin 2 2 s w
The Laplace Transform Common Transform Properties: f(t)
f (t t )u (t t ), t 0 0 0 0 f (t )u (t t ), t 0 0 e at f (t ) d n f (t ) dt n tf (t ) t
f ( )d 0
F(s) t s e o F (s) t s e o L[ f (t t ) 0 F (s a) s n F ( s ) s n 1 f (0) s n 2 f ' (0) ... s 0 f n 1 f (0)
dF ( s ) ds
1 F (s) s
Example . A force in newtons (N) is given below. Determine the Laplace transform.
f (t ) 50u (t ) 50 F (s) s 11
Example . A voltage in volts (V) starting at t = 0 is given below. Determine the Laplace transform.
v(t ) 5e
2 t
sin 4t
4 V ( s ) L[v(t )] 5 2 2 ( s 2) (4) 20 20 2 2 s 4s 4 16 s 4s 20 12
Example . Determine the inverse transform of the function below. 200 V (s) 2 s 100 10 V ( s ) 20 2 2 s (10)
v(t ) 20sin10t 13
Controls
• Open loop- either on or off • Closed loop- run based on the error(desired-actual)
Control modes • Two step mode • Proportional mode (P) • Derivative mode (D) • Integral mode (I) • Combination mode (PI, PD, PID) • Controller can achieve these modes- pneumatic, analog electronic circuits involving OPAMPS, programming microprocessor.
The Bang-Bang Controller • Push back, against the direction of the error • with constant action u
• Error is e = x - xset
Bang-Bang Control in Action
• Optimal for reaching the setpoint • Not very good for staying near it
Proportional control
Proportional Control
A proportional controller attempts to perform better than the On-off type by applying power in proportion to the difference in temperature between the measured and the set-point. As the gain is increased the system responds faster to changes in set-point but becomes progressively underdamped and eventually unstable. The final temperature lies below the set-point for this system because some difference is required to keep the heater supplying power.
Kp= O(s)/E(s) Kp is transfer function of the controller
Electronic proportional control
Vo= Reference signal Ve = error signal Vout = signal to actuator
Proportional controller for temperature control
Step Response From: U(1) 1.4
While selecting Kp remember Kp high instability
1.2
0.8
Kp low is high steady state error
0.6
K=300
0.4
0.2
0 0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Time (sec.)
Step Response From: U(1) 1 0.9 0.8 0.7 0.6 To: Y(1)
0
Amplitude
To: Y(1)
Amplitude
1
0.5
K=100
0.4 0.3 0.2 0.1 0 0
0.2
0.4
0.6
0.8
1
Time (sec.)
1.2
1.4
1.6
1.8
2
Derivative control
Derivative control
TF= KD s Derivative control give no response for steady state input
They give large signal for random changes such as noise They are never used alone P+D
PD controller
Proportional, Derivative Control
Derivative time constant
Integral control
Integral Control
Integral control not used alone P+I=PI
PI control
Proportional + Integral Control
Integral time constant
Proportional Control
Integral Control
Proportional + Integral Control
PID controller
Proportional + Integral + derivative Control PID
PID controller using OPAMP
Proportional+Integral+Derivative Control
Although PD control deals neatly with the overshoot and ringing problems associated with proportional control it does not cure the problem with the steady-state error. Fortunately it is possible to eliminate this while using relatively low gain by adding an integral term to the control function which becomes
The Characteristics of P, I, and D Controllers Note that these correlations may not be exactly accurate, because Kp, Ki, and Kd are dependent of each other. In fact, changing one of these variables can change the effect of the other two. For this reason, the table should only be used as a reference when you are determining the values for Ki, Kp and Kd.
Response
Rise Time
Overshoot
Settling Time
SS Error
KP
Decrease
Increase
Small Change
KI
Decrease
Increase
Increase
Eliminate
KD
Small Change
Decrease
Small Change
Decrease
Decrease
44
Tips for Designing a PID Controller
1.
Obtain an open-loop response and determine what needs to be improved
2.
Add a proportional control to improve the rise time
3.
Add a derivative control to improve the overshoot
4.
Add an integral control to eliminate the steady-state error
5.
Adjust each of Kp, Ki, and Kd until you obtain a desired overall response.
Lastly, please keep in mind that you do not need to implement all three controllers (proportional, derivative, and integral) into a single system, if not necessary. For example, if a PI controller gives a good enough response (like the above example), then you don't need to implement derivative controller to the system. Keep the controller as simple as possible.
Digital controller
A digital controller working 1 Samples the measured value. 2 Compares it with the set value and establishes the error. 3 Carries out calculations based on. the error value and stored values of previous inputs and outputs to obtain the output signal. 4 Sends the output signal to the DAC. 5 Waits until the next sample time before repeating the cycle.
Analog vs digital controller • In digital • KP, KD, KI can be altered in software • And even when the process is going on In analogSeparate controllers are required for controlling each output Digital controller does this a multiplexer- time sharing
Programming a PID for digital controller
Communication
Basic elements of communication • Sender- Channel- Receiver • Tx(Transmitter)-C- Rx (Receiver) • Channel
• Copper wire (Cat 6e : 1Gb/s , 100 m one stretch) • Fiber optics ( 10Gb/s, 2000 m in one strech) • WirelessBluetooth (2.4GHz, 2Mb/s, 100 m) Wifi (2.4 GHz, 200 Mb/s, 46-94 m) ,mobile network (Towers) satellite radio waves etc
Bandwidth and range As frequency increases speed increases range decreases
Modes of communication • Analog Analog systems are less tolerant to noise, make good use of bandwidth, and are easy to manipulate mathematically. However, analog signals require hardware receivers and transmitters that are designed to perfectly fit the particular transmission. • Digital The primary benefit of digital signals is that they can be handled by simple, standardized receivers and transmitters, and the signal can be then dealt with in software (which is comparatively cheap to change).
• Bit Rate: It is the number of bits that are transmitted (sent/received) per unit time. • Clock skew and cross talk
Factors Limiting Parallel Communication • Speed: Superficially, the speed of a parallel link is equal to bit rate*number of channels. In practice, clock skew reduces the speed of every link to the slowest of all of the links. • Cable length: Crosstalk creates interference between the parallel lines, and the effect only magnifies with the length of the communication link. This limits the length of the communication cable that can be used. •
Advantages of serial communication • Clock skew between different channels is not an issue (for unclocked asynchronous serial communication links). • A serial connection requires fewer interconnecting cables (e.g. wires/fibers) and hence occupies less space. The extra space allows for better isolation of the channel from its surroundings. • Crosstalk is not a much significant issue, because there are fewer conductors in proximity. • Cost
How data is communicated in serial • Parallel from microcontroller-> Buffer (stored in parallel)- (MSB first or LSB first)-Buffer--- another microcontroller •;
(PISO) (ParallelIn Serial Out)
Rx TX pins
Serial Transmission Modes • Asynchronous Data Transfer • Data Transfer is called Asynchronous when data bits are not “synchronized” with a clock line, i.e. there is no clock line at all • PROTOCOL: start(0)_8data_parity(0/1)_stop(1)
Serial Transmission Modes • Synchronous Data Transfer • Synchronous data transfer is when the data bits are “synchronized” with a clock pulse.
Few more terminology • Rx and TX
Baud rate • Unit is bits/sec • Baud rate and data transfer rate can be different • Ex to transfer A-96 ASCII • 1 start bit+ 8 data bit+ 1 parity+1 stop bit= 11 bits out of which 8 are for data • Two serial devices must be set to same buad rates • Ex: 2400, 4800, 9600, 19200, 38400 etc.
If more than 1 device • Address will also be required
Serial protocol standards • Asynchronous • • • •
RS-232 – Recommended Standard 232 RS-422, RS-485 Ethernet Universal serial bus (USB)
• Synchronus • SPI – Serial Peripheral Interface (Full duplex) • I2C – Inter-Integrated Circuit (Half duplex)
UART and USART • UART • stands for Universal Asynchronous Receiver Transmitter, whereas • UART • stands for Universal Synchronous Asynchronous Receiver Transmitter.
RS 232 cables
Another wiring
RS-232 • Standard for transfer of characters across copper wire • Produced by EIA • Full name is RS-232-C • RS-232 defines serial, asynchronous communication • Serial - bits are encoded and transmitted one at a time (as opposed to parallel transmission) • Asynchronous - characters can be sent at any time and bits are not individually synchronized
Start, Stop Bits
•z
RS-232 transmission example
74
Synchronic serial transmission • SPI • I2C
Serial Peripheral Interface • What is it? • Basic SPI • Capabilities Serial Peripheral Interface
• Protocol
http://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/ SPI_single_slave.svg/350px-SPI_single_slave.svg.png
• Pros and Cons • Uses
76
What is SPI? • Serial bus protocol • Fast, easy to use, and simple • Very widely used • Not “standardized”
77
SPI Basics • A 4-wire communications bus • Typically communicate across short distances • Supports • Single master • Multiple slaves
• Synchronized • Communications are “clocked”
78
SPI signal functions
• MOSI – carries data out of master to slave • MISO – carries data out of slave to master • Both MOSI and MISO are active during every transmission
• SS# (or CS) – unique line to select each slave chip • SCLK – produced by master to synchronize transfers
79
Two bus configuration models
Master and multiple independent slaves http://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/SPI_three_sla ves.svg/350px-SPI_three_slaves.svg.png
80
I2C communication
Inter-Integrated Circuit • Developed and patented by Philips for connecting low speed peripherals to a motherboard, embedded system or cell phone • Multi-master, two wire bus , up to 100 kbits/sec • • • •
One data line (SDA) One clock line (SCL) Master controls clock for slaves Each connected slave has a unique 7-bit address
TCP/IP protocol
Important components • Server • Host • Network interface card (MAC no.) • Hub • Switch • Router • Modem • repeater
MAC address
W
Hub • Broadcast to all • Less port • Divide bandwidth
TCP/IP
TCP and UDP • • • • • • • •
TCP Used in file transfer, browsing slow Acknowledgement Full data transfer assured Resends data Segmentation- big to small Sequencing- arranging different packet • Error correction
• UDP • Live stream video eg skype session, interactive session • Fast • No acknowledgement • Full data transfer not assured • Ex. Voice cracking, missing words
IP header