0% found this document useful (0 votes)
25 views54 pages

Lecture 3 Slides New

Uploaded by

Badaboody TV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views54 pages

Lecture 3 Slides New

Uploaded by

Badaboody TV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Digital Signal Conditioning

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

(10010001)2 = 1*27 + 0*26 + 0*25 + 1*24 + 0*23 + 0*22 + 0*21 + 1*20


= 1*128 + 0*64 + 0*32 + 1*16 + 0*8 + 0*4 + 0*2 + 1*1
= 145

(0.0011101)2 = 0*2-1 + 0*2-2 + 1*2-3 + 1*2-4 + 1*2-5 + 0*2-6 + 1*2-7


= 0*0.5 + 0*0.25 + 1*0.125 + 1*0.0625 + 1*0.03125 + 0*0.015625 + 1*0.0078125
= 0.2265 ≈ 0.23
Review of Digital Numbers

(0)10 = (0000)2 = (0)16 (10011101)2 = ( 1001 1101 )2 = (9D)16


(1)10 = (0001)2 = (1)16
(2)10 = (0010)2 = (2)16
(3)10 = (0011)2 = (3)16 (A7)16 = (10100111)2
(4)10 = (0100)2 = (4)16
(5)10 = (0101)2 = (5)16
(6)10 = (0110)2 = (6)16
(7)10 = (0111)2 = (7)16
(8)10 = (1000)2 = (8)16
(9)10 = (1001)2 = (9)16
(10)10 = (1010)2 = (A)16
(11)10 = (1011)2 = (B)16
(12)10 = (1100)2 = (C)16
(13)10 = (1101)2 = (D)16
(14)10 = (1110)2 = (E)16
(15)10 = (1111)2 = (F)16
Review of Digital Logic
A B + AC + A C B
Review of Digital Logic
A B + AC + A C B
Tri-State Buffers
Converters

Translate digital information


to analog and vice-versa

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
01 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

10 End of Conversion

Output Binary Word (n Bits)


BinaryOutp ut  N    b1 b 2 b 3 ... b n  2

 b1 b 2 b 3 ... b n  2
n
V R  V in
2
1
V in  Resolution   n
VR
2

Reference 01 Latch New Output


Voltages

10 Start Conversion


Analog-to-Digital Converters (ADCs)
Example: ADC Characteristic
A Digital-Temperature sensor provides 0.02V/oC, range
(0100 oC), resolution 0.1oC. Find VR , n.
C 0 C
o o
100
  1000  1024  2  n  10
10
Number of levels o
0 .1 C
Maximum Output 
 0.02V/
o

C  100
o

C  2 . 0V
N 1111111111 2 1023
V out  maximum   2 . 0V  n
VR  10
VR  V R  V R  2.002
2 2 1024

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

10 Bit ADC. VR=5.0V. Tc=20 μs. V in  5 . 0 sin  t 

What is the maximum frequency.

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 

102 , 300  1 0 . 693   4 K   2  2 K    C  C  0 . 0018  F


f m in  1 0 . 693   36 K   2  2 K    0 . 0018  F  20 , 042 Hz

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

Least D0 In/Out Data 0 S0 In Unused C0 Out Strobe

D1 In/Out Data 1 S1 In Unused C1 Out LineFeed

D2 In/Out Data 2 S2 In IRQ C2 Out Initialize

D3 In/Out Data 3 S3 In Error C3 Out Select

D4 In/Out Data 4 S4 In Select C4 Out IRQ Enable

D5 In/Out Data 5 S5 In PE C5 Out Direction

D6 In/Out Data 6 S6 In ACK C6 Out Unused

Most D7 In/Out Data 7 S7 In Busy C7 Out Unused

Data Register Status Register Control Register


ADDRESS ADDRESS+1 ADDRESS+2

Common ADDRESS value 0x0278 or 0x0378


Default Parallel Port Address
• Common Address Values
– Data: 0x378, Status:0x379, Control:0x37A
– Data: 0x278, Status:0x279, Control:0x27A
– Data: 0x3BC, Status:0x3BD, Control:0x3BE

34
Getting Port Address (DOS)

0x03BC 0x0378 0x0278 0x9F00

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")

short _stdcall Inp32(short PortAddress);


void _stdcall Out32(short PortAddress, short data);

int main(int argc, char* argv[])


{
short DataAddress = 0x0378;
short StatusAddress = DataAddress + 1;
short ControlAddress = DataAddress + 2;
unsigned char Control = 0;
unsigned char WriteData = 0xAC;
unsigned char ReadData;

//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

05V

D0 - D7 S4
Paralle Port

39
ADC HW/SW Alternative
#include "windows.h"
#pragma comment(lib,"inpout32.lib")

short _stdcall Inp32(short PortAddress);


void _stdcall Out32(short PortAddress, short data);

void main(int argc, char* argv[])


{
short DataAddress =0x0378,StatusAddress =0x0379,ControlAddress =0x037A;
unsigned char ReadData , Status, Control = 0;

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

05V

D0 - D7 S4 C2
Paralle Port

41
ADC
Vin

SC

8 Bit ADC EOC

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
000FFF
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

        7.071  2 0.828    147 . 3 mV


Signal Conditioni ng

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.

It is required to turn on the alarm if the temperature


reaches 200oC and turned off if the temperature goes
below 190oC.

Design the alarm circuit. Know that the alarm requires 12 V


to be ON.

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 

You might also like