Controller and Communication PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 94

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 Frequency domain


unknown f(t), d/dt, Diff Eqs unknown F(s), Alg Eqs

Solve
Differential Solve
Equations Algebraic
Equations

Time domain Frequency domain


known f(t) 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

  j
1

1
L [ F ( s )]  f (t )  F ( s ) ts
e ds Eq B
2 j   j
*notes
The Laplace Transform
Transform Pairs:
f(t) F(s)
 (t ) 1
1
u( t ) ____________________________________
f (t ) F ( s)

s
 st 1
e
sa
1
t
s2
n n!
t
s n 1
The Laplace Transform
Transform Pairs:
f(t) F(s)
 at 1
te
s  a 2
n  at n!
t e
( s  a )n 1
w
sin( wt )
s2  w2
s
cos( wt )
s2  w2
The Laplace Transform
Transform Pairs:
f(t) F(s)
 at w
e sin(wt )
(s  a)2  w 2
sa
e at cos(wt )
(s  a)  w
2 2

s sin  w cos
sin(wt   )
s2  w2
s cos  w sin
cos(wt   )
s w
2 2
The Laplace Transform
Common Transform Properties:

f(t) F(s)

t s
f (t  t )u (t  t ), t  0 e o F (s)
0 0 0
t s
f (t )u (t  t ), t  0 e o L[ f (t  t )
0 0
e  at f (t ) F (s  a)
d n f (t )
s n F ( s )  s n 1 f (0)  s n  2 f ' (0)  ...  s 0 f n 1 f (0)
dt n
dF ( s )
tf (t ) 
ds
t
1
 f ( )d s
F (s)
0
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.
2 t
v(t )  5e sin 4t
4
V ( s )  L[v(t )]  5 
( s  2)  (4)
2 2

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

1.2 While selecting Kp remember


1 Kp high instability
Amplitude 0.8

To: Y(1)
0.6
Kp low is high steady state
K=300
error
0.4

0.2

0
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

Amplitude

To: Y(1)
0.5

0.4
K=100
0.3

0.2

0.1

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

Time (sec.)
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 SS Error


Time
Small
KP Decrease Increase Change Decrease

KI Decrease Increase Increase Eliminate

Small Small
KD Change Decrease Decrease Change

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 analog-
Separate 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)
• Wireless-
Bluetooth (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 un-
clocked 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
http://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/
SPI_single_slave.svg/350px-SPI_single_slave.svg.png

• Protocol

• 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 80
ves.svg/350px-SPI_three_slaves.svg.png
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 • UDP
• Used in file transfer, browsing • Live stream video eg skype session,
• slow interactive session
• Acknowledgement • Fast
• Full data transfer assured • No acknowledgement
• Resends data • Full data transfer not assured
• Segmentation- big to small • Ex. Voice cracking, missing words
• Sequencing- arranging different
packet
• Error correction
IP header

You might also like