0% found this document useful (0 votes)
2 views19 pages

Lecture37interfacing Issues

Uploaded by

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

Lecture37interfacing Issues

Uploaded by

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

Interfacing Issues

 Three basic modes :


 1. Continuous dedicated monitoring of the sensor by
the microprocessor
 2. Polling the sensor
 3. Interrupt mode
Continuous mode
 Microprocessor is dedicated for use with the sensor (or actuator)
 Its output is monitored by the microprocessor continuously
 The microprocessor reads the sensor’s output at a given rate
 Depending on the application, the microprocessor may actually
drive the sensor

 Supply it with power

 Supply a specific waveform

 Store and transmit data

 Etc.
 Output is then used to act, display, etc.
 Example: a digital thermometer
Poling mode
 Sensor (actuator) operates as if the microprocessor did not exist.
 Its output is monitored by the microprocessor at specific intervals
 Typically the microprocessor does not participate in the
functioning of the sensor (or actuator)
 The microprocessor reads the sensor’s output at a given rate or
intervals - poling
 Output is then used to act as indicated by the program stored in
the microprocessor
 Example: alarm system in a home:

 Multiple sensors and actuators

 The microprocessor polls each sensor and actuator for its status.

 Takes action according to data gathered and its programmed functionality
Interrupt mode
 Microprocessor is in sleep mode or doing something else
 Outputs of the sensor are not being processed
 Upon a given event, the microprocessor wakes up through one of its
interrupt options
 The sensor activates the interrupt
 Example: automatic lights upon entry

 A sensor detects entry

 An interrupt is sent to a microprocessor

 The microprocessor wakes up to perform its function
 Interrupt mode is particularly useful with battery oprated devices.
Notes:
• Interrupts can be timed
• Interrupts can be issued by sources other than the sensor
• The microprocessor may be involved in other functions, separate from the sensor,
such as control of an actuator
• Feedback from actuators may also be used to perform interrupts
General Interfacing
Requirements
 Microprocessor input interfacing requirements
 Microprocessor output requirements
 Errors introduced by microprocessors
Interfacing requirements
 Input Interfacing Requirements
 Signal level
 Impedance and matching
 Response, frequency
 Signal conditioning
 Signal scaling
 Isolation
 Loading
 Output Interfacing Requirements
 Same as for input, plus:
 Power levels
Input signal levels
 Basic signal level: zero to Vdd
dd
 Must scale signals as necessary
 No dual polarity signals
 Must translate/scale as necessary to avoid dual polarity
 Direct reading or A/D depending on type of input
 Can read voltages only
 AC or DC
 Currents can be measured indirectly through voltage drop
on resistors
 May need to amplify or attenuate signals
 Limitations in frequency
Impedance
 P are high input impedance devices
 ~ 1 - 10 M
 Input current - < 1 A.
 Ideal for direct connection of low impedance sensors (magnetic,
thermistors, thermoelectric, etc.)
 High impedance sensors (capacitive, pyroelectric, etc.) must be
buffered. This can be done using:
 Voltage followers
 FET amplifiers
Example
Interfacing a current sensor: AA microprocessor
microprocessor needs
needs to
to measure
measure the
the current
current supplied
supplied by
by aa
power
power supply
supply in
in aa device
device asas part
part of
of itsits energy
energy management
management system
system and and to
to compute
compute andand display
display the
the status
status
of
of the
the battery
battery powering
powering it.it. The
The power
power supplysupply operates
operates from
from aa car
car battery
battery andand is
is expected
expected toto supply
supply up
up to
to
500 mA at a constant voltage of 5 V to a load. The current needs to be monitored and
500 mA at a constant voltage of 5 V to a load. The current needs to be monitored and displayed digitally displayed digitally
using
using aa microprocessor.
microprocessor. The The microprocessor
microprocessor operatesoperates at
at 55 V,
V, has
has aa 1212 bit
bit A/D
A/D converter
converter and
and we
we require
require
that
that the
the system
system be be capable
capable ofof sensing
sensing in in two
two ranges.
ranges. In
In Range
Range A, A, itit must
must bebe capable
capable ofof measuring
measuring inin
increments
increments ofof 10
10 mA.
mA. In
In Range
Range B B itit must
must bebe capable
capable of
of measuring
measuring in in increments
increments of of 0.5
0.5 mA.
mA.

The
The microprocessor
microprocessor cannot
cannot measure
measure current
current directly.
directly. AA small
small resistance
resistance R R is
is inserted
inserted inin series
series with
with the
the
ground
ground conductor
conductor andand the
the voltage
voltage onon this
this resistor
resistor isis measured
measured by by the
the microprocessor
microprocessor usingusing it’s
it’s A/D
A/D
converter
converter (Fig.
(Fig. 12.8).
12.8). The
The converter
converter cancan resolve
resolve down
down to to 5V/2
5V/2 == 1.22
12
12
1.22 mV.
mV. That
That means
means thatthat to
to sense
sense up up to
to
500 mA in increments of 10 mA we need 50 increments of 1.22 mV. That is,
500 mA in increments of 10 mA we need 50 increments of 1.22 mV. That is, the maximum voltage drop the maximum voltage drop
across
across the
the sensing
sensing resistor
resistor isis 50*1.22
50*1.22 == 61
61 mV.
mV. The
The resistor
resistor is
is RR == 0.061/0.5 0.122 .
0.061/0.5 == 0.122 .
In
In Range
Range B, B, we
we must
must be be able
able toto measure
measure 500/0.5
500/0.5 == 1,000
1,000 increments
increments of of 1.22
1.22 mV mV each.
each. That
That means
means the the
voltage
voltage across
across the
the sensing
sensing resistor
resistor must
must bebe 1.22
1.22 VV and
and the
the resistance
resistance must must bebe R 2.44 .
R == 2.44 .
The
The resistance
resistance inin range
range A A is
is acceptable,
acceptable, that
that for
for Range
Range B B is
is not.
not.
Instead,
Instead, the
the resistor
resistor is
is selected
selected as as R 0.122 
R == 0.122  and
and aa non-inverting
non-inverting operational
operational amplifier
amplifier with
with aa gain
gain of
of 20
20
is
is added
added asas shown
shown inin Fig.
Fig. 12.8b.
12.8b. This
This boosts
boosts thethe maximum
maximum voltage
voltage at at the
the microprocessor’s
microprocessor’s input input to
to
0.061*20 = 1.22 V. Using the configuration in Fig. 12.8b, the gain is
0.061*20 = 1.22 V. Using the configuration in Fig. 12.8b, the gain is (see Eq. 11.7): (see Eq. 11.7):

Fig. 12.8
Response and frequency
 Most sensors are slow devices
 Can be interfaced directly
 No concern for response and frequency range
 Some sensors are part of oscillators
 Frequencies may be quite high
 Need to worry about proper sampling by the microprocessor
 Example: 10 mHz P, cycle time of 0.4 s. (most processor divide
the clock frequency by a factor - 4 in this case)
 Any operation such as reading an input requires n cycles, say n=5
 Effective frequency: 0.5 MHz
 Sampling cannot be done at rates higher than about 250 kHz
 Any sensor producing a signal above this frequency will be read
erroneously
Response and frequency
 Some solutions:
 Divide the sensor’s frequency
 Reduces sensitivity
 Must be done externally to the P
 F-V converter
 Introduces conversion errors
 Must be done externally
 External frequency counter at input
 Use output of the counter as input to P.
 Expensive
 Faster microprocessors
Example
Quartz crystal microbalance:: Consider
Consider aa microbalance
microbalance resonating
resonating at
at 18
18 MHz
MHz with
with aa sensitivity
sensitivity of
of
55 ng/Hz/cm
ng/Hz/cm22.. The
The sensor
sensor is is used
used to
to sense
sense the
the mass
mass of
of substances
substances coated
coated on
on the
the electrode.
electrode. With
With an
an
electrode
electrode area
area of
of 1.5
1.5 cm
cm ,, the
22
the sensor
sensor is
is used
used to
to measure
measure mass
mass up
up to 100 g.
to 100 g. (see
(see Section
Section 8.7).
8.7).

There
There are
are two
two options
options that
that can
can be
be pursued.
pursued. One
One is
is to
to measure
measure the
the absolute
absolute frequency,
frequency, the
the other
other to
to
measure
measure onlyonly the
the change
change inin frequency.
frequency.
The
The first
first option
option isis not
not practical
practical with
with aa microprocessor.
microprocessor. The
The base
base frequency
frequency (zero
(zero mass)
mass) is
is 18
18 MHz
MHz which
which
corresponds
corresponds to to aa cycle
cycle of
of 55.55
55.55 ns.
ns. To
To measure
measure this
this frequency
frequency directly
directly would
would require
require aa clock
clock cycle
cycle much
much
shorter
shorter than
than this
this and
and such
such microprocessors
microprocessors do do not
not exist.
exist. Further,
Further, the
the change
change inin frequency
frequency for
for the
the largest
largest
mass
mass measured
measured is is only:
only:

An
An alternative
alternative is is shown
shown in in Fig.
Fig. 12.10.
12.10. Two
Two identical
identical crystals
crystals are
are set
set into
into oscillations
oscillations and
and the
the frequency
frequency of of
the 2 nd is subtracted from the 1 st
nd st. The result is a zero frequency. Now one sensor is used as the sensing
the 2 is subtracted from the 1 . The result is a zero frequency. Now one sensor is used as the sensing
sensor,
sensor, saysay the
the 11stst.. The
The output
output will
will change
change from
from zero
zero toto 13,333
13,333 Hz
Hz for
for change
change inin mass
mass from
from zero
zero to 100 g.
to 100 g.
The
The shortest
shortest time
time thatthat needs
needs to
to be
be measured
measured is is that
that of
of one
one cycle
cycle or 75 s
or 75 s (1/13,333
(1/13,333 == 75x10
75x10 ).-6
-6
). A
A 1010 MHz
MHz
clock
clock cycle (0.1 s/cycle)
cycle (0.1 s/cycle) wouldwould allow
allow accurate
accurate determination
determination of of the
the cycle
cycle time
time of
of the
the input
input frequency.
frequency. The The
time
time is
is measured
measured using using thethe process
process outlined
outlined in
in Example
Example 12.3.
12.3. Sensitivity
Sensitivity is
is 133.33
133.33 Hz/g
Hz/g and
and is is linear.
linear. The
The
microprocessor
microprocessor can of course display the output in the proper units by scaling the time measured using, for
can of course display the output in the proper units by scaling the time measured using, for
example
example aa lookup
lookup table table stored
stored in
in EEPROM.
EEPROM.

Fig. 12.10
Input signal conditioning
 Offset
 Primarily for DC levels
 Can be offset up or down
 Usually done to remove the DC level
 Sometimes needed to remove negative polarity.
 AC signals may sometimes be coupled through capacitors to
eliminate DC levels
 Example
 Thermistor: 500 at 20ºC
 Varies from 400 to 900 for temperatvures between 0 ºC and 100ºC

Fig. 12.11
Offset
 At 20ºC
 V = (12/1500)*500 = 4 V
 At 0ºC
 V = (12/1400)*400 = 3.428 V
 At 100ºC
 V = (12/1900)*900 = 5.684 V
 V varies between 3.428V and 5.684V
 5.684V is above the 5V operati ng voltage of the microprocessor
 Some solutions
 Remove 3.428V through an inverting amplifier
 Reduce the source voltage from 12V to, say 6V. This will change the
range to 1.714V to 2.842V
 Increase the resistor from 1000 to, say, 1500. This will reduce the
output and will vary from 2.526V to 4.5V
Offset - other solutions
 For AC signals
 Use of capacitors
 Only appropriate if signal is unipolar

 Bi-polar signals produce negative signals
 Rectification

 Bridge connection
 Battery must be floating
 Output: 0V at 0ºC to 2.3V at 100ºC.
 Offset of arbitrary value can be added
 Done by changing the value of lower-left resistor
 For example, a 1V offset is added to the output by reducing
the lower left resistor to 285.7
Example
Adding DC offset to a sensor signal: AA high
high temperature
temperature programmable
programmable thermostat
thermostat is
is built
built
around
around aa microprocessor
microprocessor using
using aa platinum
platinum RTD.
RTD. The
The resistance
resistance ofof the
the RTD
RTD is 240 
is 240  at
at 20
20 ºC
ºC and
and has
has aa
temperature
temperature coefficient
coefficient of
of resistance
resistance of
of 0.003926
0.003926 /ºC
/ºC at
at 00 ºC.
ºC. The
The thermostat
thermostat isis required
required to
to switch
switch off
off at
at 350
350 ºC
ºC
and switch on at a temperature lower than the switch off temperature. The microprocessor operates
and switch on at a temperature lower than the switch off temperature. The microprocessor operates at 5 V and at 5 V and
uses
uses the
the internal
internal comparator
comparator andand internal
internal reference
reference voltage
voltage toto accomplish
accomplish the
the necessary
necessary function.
function. We
We assume
assume
the
the microprocessor
microprocessor hashas aa fixed
fixed reference
reference voltage.
voltage.

A
A possible
possible implementation
implementation is is shown
shown inin Figure
Figure 12.14a
12.14a (next
(next slide)
slide) A
A bridge
bridge is
is used
used as
as itit allows
allows adjustment
adjustment of
of
the
the voltage
voltage at at the
the positive
positive comparator
comparator pin.
pin. The
The negative
negative pin
pin is
is connected
connected internally
internally to
to the
the reference
reference voltage.
voltage.
We
We need to set the reference voltage so that the comparator switches from off to on at 350 ºC. To do so
need to set the reference voltage so that the comparator switches from off to on at 350 ºC. To do so we
we
must first calculate the resistance of the RTD at 350 ºC. From Eq.
must first calculate the resistance of the RTD at 350 ºC. From Eq. (3.4): (3.4):

The
The voltage
voltage at
at point
point A
A at
at 350ºC
350ºC is:
is:

The
The voltage
voltage at at point
point B
B is
is 2.5
2.5 VV because
because R R11 and
and R R22 are
are both
both equal
equal to 240 .
to 240 . The
The difference,
difference, 3.4315
3.4315 –– 2.5
2.5 ==
0.9315
0.9315 V is the voltage at the positive input pin of the comparator. The internal reference must be set to
V is the voltage at the positive input pin of the comparator. The internal reference must be set to this
this
value.
value. But,
But, the
the possible
possible values
values for
for reference
reference at at the
the negative
negative input
input to
to the
the comparator
comparator cancan only
only be
be set
set in
in
increments
increments of of 5/16
5/16 == 0.3125
0.3125 V. V. The
The closest
closest value
value isis 3*0.3125
3*0.3125 == 0.9375.
0.9375. This
This may
may be
be close
close but
but not
not close
close
enough
enough – the thermostat will not operate at the required temperature. We set the reference at 3*0.3125 ==
– the thermostat will not operate at the required temperature. We set the reference at 3*0.3125
0.9375
0.9375 V V and
and thethe offset
offset at
at 0.9375
0.9375 –– 0.9315
0.9315 == 0.006
0.006 V. V.
This
This is
is done
done by by reducing
reducing the
the voltage
voltage atat point
point BB by
by the
the offset
offset value
value to
to 2.5
2.5 –– 0.006
0.006 == 2.494
2.494 V.
V.
Example (cont.)
To
To do
do so
so we
we write:
write:

By
By selecting
selecting one
one resistance,
resistance, say
say R =300 ,
R11=300 , we
we get
get R 298.56 .
R22 == 298.56 . A
A more
more practical
practical solution
solution is
is to
to use
use aa
variable
variable resistor
resistor (potentiometer),
(potentiometer), say 500 
say aa 500  potentiometer
potentiometer andand adjust
adjust itit so
so that
that the
the voltage
voltage atat point
point BB
(center
(center tap tap of
of the
the potentiometer)
potentiometer) isis 2.494
2.494 V.
V.
IfIf the
the temperature
temperature goesgoes down,
down, we we want
want the
the thermostat
thermostat to to switch
switch back
back at
at aa lower
lower temperature.
temperature. ThisThis isis done
done
by lowering the reference voltage one step, that is to 0.9375 – 0.3125 = 0.625 V (in software)
by lowering the reference voltage one step, that is to 0.9375 – 0.3125 = 0.625 V (in software) and allowing and allowing
the
the comparator
comparator to to switch
switch to
to low
low when
when that
that reference
reference voltage
voltage is
is reached.
reached. Since
Since point
point BB is
is at
at aa voltage
voltage of of
2.494
2.494 V, V, and
and switching
switching will
will occur
occur at
at 0.625
0.625 V,
V, the
the voltage
voltage atat point
point AA must
must be be 2.494
2.494 ++ 0.625
0.625 == 3.119
3.119 V. V. The
The
RTD
RTD resistance
resistance therefore
therefore must
must be:
be:

Using
Using now
now Eq.
Eq. (3.4)
(3.4) with
with T
T as
as unknown:
unknown:

That
That is,
is, the
the electronic
electronic thermostat
thermostat will
will switch
switch off
off at
at 350
350 ºC
ºC and
and on
on at
at 203.63
203.63 ºC.
ºC. The
The flowchart
flowchart in
in Fig.
Fig. 12.14b
12.14b
shows
shows how
how this
this can
can be
be achieved
achieved in
in software.
software.

Fig. 12.14
Scaling

 Scaling the input to a microprocessor pin can be achieved:

 By amplification

 Operational amplifiers

 By attenuation

 Operational amplifiers

 Resistance dividers

 Transformers (for AC)

 Amplifiers are preferable

 Dividers introduce errors

 Transformers are noisy and big

 Example: voltage divider

 The thermistor is fed from a 12V source with a 1000  resistor in series to produce the
desired current in the thermistor.

 The voltage on the thermistor when its resistance is 900  is 5.68V

 The voltage divider shown, reduces the output to 1.5V to 2.298V for the range of
resistances of the thermistor but:

 Reduces sensitivity and changes the current in the thermistor

 Another option is to increase the 1000  resistor to, say, 1500 .
Signal isolation
 Isolation
 Isolation between
between sensors
sensors or
or actuators
actuators and
and the
the microprocessor
microprocessor isis sometimes
sometimes need
need
 When
Whenthey
theyoperate
operateat
atdifferent
differentvoltage
voltagelevels
levels
 For
Forsafety
safetyreasons
reasons(such
(suchas ascontrol
controlof
ofhigh
highvoltages
voltagesto
toan
anactuator)
actuator)
 When
When the microprocessor, the sensor orthe
the microprocessor, the sensor or theactuator
actuatorcannot
cannotshare
sharethe
thesame
sameground
ground
 Two
 Two basic
basic methods
methods
 Transformers
Transformers

 Usually
Usuallyavoided
avoided––transformers
transformersare
arebig,
big,heavy
heavyand
andexpensive
expensive

 Limited in frequency – transformers do not work well at low frequencies
Limited in frequency – transformers do not work well at low frequenciesor
orat
athigh
highfrequencies
frequencies––must
mustbe
bedesigned
designedfor
forthe
thefrequency
frequencyrange
rangeof
ofthe
theapplication
application
 Optical
Optical isolation
isolation (to
(to sensors
sensors or or actuators)
actuators)
 The
The common
common choice
choice forfor signals
signals
 The
The signal
signal modulates
modulates the the light
light intensity
intensity of
of the
the LED
LED
 The
The phototransistor
phototransistor reconstructs
reconstructs the the signal
signal
 Can be used at low and high frequencies
Can be used at low and high frequencies
 High
High isolation
isolation (at
(at least
least aa few
few kV)
kV)
 Simple
Simple and
and inexpensive
inexpensive components
components

You might also like