Lecture 3 Slides New
Lecture 3 Slides New
Control Components
Lecture 4
Computers in Control Systems
• Control multivariable processes
• Support Sensors Nonlinearities
• Performs complex control algorithms
• Networking allows large process-control
Review of Digital Numbers
(0.23)10 ( 1 4 5 ) 10 (10010001)2
0.23
0.46 0 145
0.92 0 72 1
1.84 1 36 0
1.68 1
1.36 1 18 0
0.72 0 9 1
1.44 1 4 0
0.88 0
2 0
.. ..
.. .. 1 0
0 1
(0.00111010)2
1. Comparators
2. DAC: Digital-to-Analog Converter
3. ADC: Analog-to-Digital Converter
Comparators
Hysteresis Comparator
Hysteresis Comparator
VL
Digital-to-Analog Converters (DACs)
N
Reference V out VR
n
Voltage 2
01 Latch New Input
or
Input Binary Word (n Bits)
V out 2 1
b1 2
2
b2 2
3
b3 2
4
b4 V R
Analog b 4 least b 1 most
Output
Voltage 0000 ... 0 2
V out ( minimum )
n
VR 0
2
1111 ... 1 2 2 1
n
V out ( maximum )
n
VR n
VR
2 2
0000 ... 1 2 1
V out ( Resolution )
n
VR n
VR
2 2
For Bipolar DAC
N 1
Supply: ± 12V ±18V V out n
VR VR
2 2
Example: DAC Characteristic
8-bit DAC with a 10.0V reference has an input of
010011102 or 4EH. Find Vout. Also find the maximum output
and its resolution.
01001110 2 78 10
N 78
V out n
VR 8
(10 V ) 3.0469V
2 2
2 1
8
V out maximum 8
V R 9.9609V
2
1
V out resolution 8
V R 0.0039V
2
Example: DAC Characteristic
10-bit bipolar DAC with VR=5.0V. Find the output for
binary inputs 04FH and 2A4H. Find Vout. What digital input
gives zero output.
N 1
For Bipolar DAC V out n
VR VR
2 2
79 5 . 0V
V out 04F H
10
5 . 0V 2.1142578V
2 2
676 5 . 0V
V out 2A4 H
10
5 . 0V 0 . 80078 V
2 2
N 5 .0V
V out ? 10
5 .0V 0
2 2
N 512 10 1000000000 2
DAC Implementation Vo
V out 2
1
b1 2
2
b2 2
3
b3 2
4
b4 V R
b1 b2 b3 b4
V out V R
2 4 8 16
DAC Implementation Vo
0 1 0 0 VR
Let N = 0100 b1=0 b2=1 b3=0 b4=0 V out V R
2 4 8 16 4
0 Vo Va 0
V o V a
R R
VR Va 0 Va Va 0
V R 4 V a
2R 2R R
VR
Vo
4
Analog-to-Digital Converters (ADCs)
Power Supply Voltages
If we use V R 2
1
V R 0.00195V/ C 0.002V/
o o
V out Resolution 10
C
2
ADC Implementation : Successive Approximation
Example : 4 bit ADC b 4 b 3 b 2 b1
V in 3 . 217 V , V R 5 . 0 V
1000 2
1.Try b 1 1 4
5 . 0 V 2 . 5 V V in
2
Let b 1 1
1100 2
2.Try b 2 1 4
5 . 0 V 3 . 75 V V in
2
Let b 2 0
1010 2
3.Try b 3 1 4
5 . 0 V 3 . 125 V V in
2
Let b 3 1
1011 2
4.Try b 4 1 4
5 . 0 V 3.4375 V V in
2
Let b 4 0
b 1 b 2 b 3 b 4 2 1010 2
V1
ADC Implementation : Dual Slope
V 2 t
V 1 t
1
T
V in T Example :
V 1 t V dt V 1
R 100 K , C 0 . 01 F
in
RC 0
RC
1
t
V in T VRt V R 10 . 0 V , T 10 ms , V in 6 . 8 V
V 2 t V 1 V R
dt 0
RC RC RC V in
t T
0
t VR
V in VR
T
Conversion Time Consequences
Vin
VR
V n
2
ADC
time
t c
V dV VR
t 2 c
n
dt
Example: Conversion Time Consequences
V in 5 . 0 sin t
dV VR 5 .0
n 10 244 . 41 V sec
in
6
dt 2 c 2 20 10
5 . 0 cos t 244 . 41 V sec
5 . 0 244 . 41 V sec
48.83 rad sec
f 7 . 8 Hz
Sample and Hold
Sample and Hold
1 R off R VF
f in f c Discharge Time Constant D C
2 R s R ON C R off R VF
V in VR
Discharge Rate
D 2 c
n
VC
D 2 c
n
VR
Frequency Based Converters
Count Time
2 1
n
Tc
f m ax
Output Value
N f Tc
Example: Frequency Based Converters
Sensor output frequency (2.0 to 20KHz). Signal must
be converted to 8 Bit Signal. Find the Count Time Tc.
Output Range.
2 1
8
Tc 0 . 01275 sec
20 , 000
N m in
f T c 2 , 000 Hz 0 . 01275 sec 25 . 5 25 00011001
N m ax
11111111
Frequency Based Converters ICs
LM331 555
Rs 1 V in 1
f out f out
R L R t C t 2 . 09 0 . 693 R A 2 R B C
Example: Frequency Based Converters ICs
Light Sensor Resistor change (from 36 to 4 KΩ) as light
Intensity change (from 1.6 to 10 W/m2).
Design 10 Bit / 555 as frequency converter with count
time = 10 ms, what is the frequency range. Given that
for 555: f 1 0 . 693 R 2 R C
out A B
2 1 1
n 10
2
Tc f m ax 102 , 300 Hz
f m ax 0 . 001
Let R B
2 .2 K
N m in
f T c 20 , 042 0 . 001 200 . 42 200 11001000
Data Acquisition System (DAS)
Special hardware used to provide input/output signal
for computer based systems
Data BUS
Address BUS
Control BUS
V1
V2
Analog
D0 - Dn
V3 Vin ADC
MUX
V4
SC EOC RD
Command Processor
Data Latch
Vout
DAC
DAS
Data Acquisition
System
Sampling
Time
Time
Time
1
f sampling 10 f max
T
Parallel Port (IEEE1284)
DB25 Connector
Parallel Port
Parallel Port (IEEE1284) S4 S5 S6 S7 D7 D6 D5 D4 D3 D2 D1 D0 C0
13 12 11 10 9 8 7 6 5 4 3 2 1
G7 G6 G5 G4 G3 G2 G1 G0 C3 C2 S3 C1
25 24 23 22 21 20 19 18 17 16 15 14
34
Getting Port Address (DOS)
35
Getting Port Address (Windows)
Control Panel / Administrative Tools / Computer Management / Device Manager
/ Ports
LPT1
LPT2
LPT3
0x0378
36
Programming Parallel Port
• In DOS
– outp, inp at “io.h”
– outportb, inportb at “dos.h”
• In Windows
– Inp32, Outp32 using “inpout32.dll”
37
Program Example (Windows)
#pragma comment(lib,"inpout32.lib")
//Write
Out32(ControlAddress, Control | (1<<5)); //Set Direction bit with 1
Out32(DataAddress,WriteData);
//Read
Out32(ControlAddress, Control & ~(1<<5)); //Set Direction bit with 0
ReadData = Inp32(DataAddress);
return 0;
} 38
ADC HW/SW Alternative
Vin
Vtest
8 Bit DAC Vout
D0 - D7
- +
Comparator
05V
D0 - D7 S4
Paralle Port
39
ADC HW/SW Alternative
#include "windows.h"
#pragma comment(lib,"inpout32.lib")
while(1)
{
ReadData = 0;
for(int i=7;i>=0;i--)
{
ReadData |= (1<<i);
Out32(ControlAddress, Control | (1<<5));
Out32(DataAddress,ReadData);
Sleep(10);
Status = Inp32(StatusAddress);
if( (Status&(1<<4)) == 0) ReadData &= ~(1<<i);
}
} 40
}
Advanced ADC HW/SW Alternative
Vin
S/H
Vtest
8 Bit DAC Vout
D0 - D7
- +
Comparator
05V
D0 - D7 S4 C2
Paralle Port
41
ADC
Vin
SC
RD
D0 - D7
D0 - D7 C1 S4 C0
Paralle Port
ADC Software
short DataAddress =0x0378,StatusAddress =0x0379,ControlAddress =0x037A;
unsigned char ReadData , Status, Control = 0;
Out32(ControlAddress, (1<<0)|(1<<1));
while(1)
{
Out32(ControlAddress, (0<<0)|(1<<1));
Sleep(10);
Out32(ControlAddress, (1<<0)|(1<<1));
Sleep(10);
while(1)
{
Status = Inp32(StatusAddress);
if( (Status&(1<<4)) == 0 ) break;
}
Out32(ControlAddress, (1<<0)|(0<<1));
Sleep(10);
Out32(ControlAddress, (1<<0)|(1<<1));
Sleep(10);
ReadData = Inp32(DataAddress);
} 43
ADC/DAC
Vout Vin
SC
8 Bit DAC
Data Latch
8 Bit ADC EOC
RD
D0 - D7
C2 D0 - D7 C1 S4 C0
Paralle Port
Actual DAC (DAC0800)
Actual DAC(DAC0800)
Actual ADC (ADC0804)
Example 1
Tests show that the output of a position sensor is 12 mV/mm, but there is 60 Hz
noise on the output of a constant 5 mV rms. The sensor output impedance is 2.5
kΩ.
This sensor is to measure a work piece motion, which oscillate between -10 mm
and +10mm with period of 1.5 sec.
The position is to be interfaced to a 12-bit bipolar offset binary ADC with a 5.0 V
reference. Design the interface system such that -10 mm corresponds to 000H
and +10 mm corresponds to FFFH.
a. With no filter, determine how many bits are being toggled by noise (i.e., are
lost to any real data)
b. With no filter, reevaluate the effect of noise on the ADC output, and
determine how many bits represent real data.
Solution
Vn(rms)=5mV
Va Vb
Noise
Rs=2.5kΩ D0-D11
SC
-10mm 10mm ADC D
Period 1.5 sec
000FFF
Vs
Motion
12mV/mm
Sensor Sensor VR
Circuit
5V
N VR
Vb
Solution 2
n
2
0 5
D 000 V b n
2 . 5V
2 2
2 12
1 5
D FFF V b n
2 . 4988 V
2 2
Vs Distance 12
Distance ( 10 mm 10 mm )
Vs ( 120 mV 120 mV )
Sensor circuit
V a ( 120 mV 120 mV )
Assum e no noise
V b ( 2 . 5 V 2 . 4988 V )
Signal Conditioni ng
D ( 000 FFF
ADC
H H
)
V b mV a
b
b -0.001 0 , m 20.828
Solution
V n ( p p ) V n ( rms )
2 5 mV 1 . 414 7.071mV
0 . 147
124 7 Bits up
12 Bit ADC
12
or down
5 2
1 1
If filter is used f noise 60HZ f signal 0 . 667 HZ
T 1 .5
2
V out 60
For filter let 1 1 0 . 05 f c 3
V in f
c
noise
2
V out 0 . 667 m
For signal 1 1 0 . 976 new m 21 . 34
V in
signal
3 0 . 976
Solution
Example 2
A temperature sensor circuit produces 20mV/oC.
53
Solution
V H 20 mV 200 C 4 V
o
V L 20 mV 190 C 3 . 8 V
o
V on 12 V
V off
0V
V H V ref V ref 4 V
R R
V L V ref V on 3 . 8 V 4 V 12 V 0 . 0166
R f
R f
R 500 500
0 . 01666
R f
30000 30 K