00694a.pdf

(220 KB) Pobierz
AN694
Ratiometric Sensing Using the PIC16C774
Authors: Steve Bowling
Microchip Technology Inc.
Other useful features of the microcontroller include a
9-bit addressable USART for serial communications
and Master Synchronous Serial Port (MSSP) that sup-
ports the I
2
C™ and SPI™ protocols.
INTRODUCTION
This application note shows how to use the PIC16C774
microcontroller (MCU) in a ratiometric sensing applica-
tion. A block diagram of the application is shown in
Figure 1. The design takes advantage of the advanced
analog peripherals of the PIC16C774, including a
12-bit A/D converter and two on-chip voltage refer-
ences.
FIGURE 1:
BLOCK DIAGRAM FOR APPLICATION CIRCUIT
PIC16C774
V
DD
TEMP
SENS.
RA1/AN1
RB4
RB5
6
LCD Display
4.096 V
RA3/VRH
RC6/TX
Sensor
RC7/RX
RS-232
Instrumentation
Amp
RA0/AN0
RC4/SDA
RC3/SCL
2.048 V
EEPROM
RA2/VRL
©
2000 Microchip Technology Inc.
DS00694A-page 1
AN694
THEORY
Many types of sensors may be used in a ratiometric
sensing application, including those for measuring
force, acceleration, temperature, or position. A pres-
sure sensor has been used here due to its wide avail-
ability and low cost.
Pressure sensors are classified by how they measure
pressure. In general, there are three different types of
pressure measurements; absolute, gauge, and differ-
ential. An absolute pressure sensor has the rear of the
sensor diaphragm connected to a sealed cavity and is
referenced to a near perfect vacuum (0 psi). Because
of this, all measurements made with the sensor will
include the effects of the current atmospheric pressure.
In contrast, the rear cavity of the gauge pressure sen-
sor is vented to the atmosphere. Measurements made
with a gauge sensor are referenced to the current
ambient pressure conditions and the sensor will give a
reading of 0 psi when at rest. The differential pressure
sensor is a special variation of the gauge sensor. The
rear cavity of the differential pressure sensor is con-
nected to an inlet port so the pressure difference
between two points can be measured.
The pressure sensor chosen for this application is a
Lucas Novasensor type (NPC-1210-50G). This sensor
may be used for gauge pressure measurements up to
50 psi. The sensor is constructed using silicon
micro-machining techniques to implant piezoresistive
strain gauge elements in a Wheatstone bridge configu-
ration on a mechanical diaphragm. The resistance of
the piezoresistive elements changes when mechanical
stress is applied to the diaphragm. Pressure sensors
manufactured using silicon piezoresistive elements are
available from many manufacturers and are often
referred to as ‘solid-state’ or IC pressure sensors
because of the process used to manufacture them.
Piezoresistive elements are used in the pressure sen-
sor because of their high sensitivity to applied stress.
However, the elements are also very sensitive to varia-
tions in manufacturing process and temperature. An
uncompensated or ‘raw’ pressure sensor will have
large variations in its output offset and/or sensitivity.
The sensor may also exhibit offset and sensitivity vari-
ations that are a function of temperature. The offset
and sensitivity errors must be compensated using
hardware or software techniques. To simplify the
design process, internally compensated devices are
available that have a specified offset and span over a
given temperature range. The compensated sensor will
typically have requirements for the excitation source.
For example, many internally compensated sensors
must be driven with a constant current source to
achieve the offset, sensitivity and thermal accuracy
given in the specifications. It is always best to check the
sensor manufacturer’s literature for the specific sensor
requirements.
The piezoresistive elements of the pressure sensor are
connected to form a Wheatstone bridge measurement
circuit as shown in Figure 2. The four piezoresistive
elements are arranged on the diaphragm of the sensor
so two of the resistances will increase and the other
two will decrease for a given pressure input. An electri-
cal excitation (V
EXC
) must be applied to the bridge as
shown to produce an output voltage. The bridge pro-
duces an output voltage that is a function of the excita-
tion source and the variation in resistance of the
elements.
FIGURE 2:
WHEATSTONE BRIDGE MEASUREMENT CIRCUIT
R(1-k)
Excitation
Voltage
R(1+k)
V+
R(1+k)
R(1-k)
V-
DS00694A-page 2
©
2000 Microchip Technology Inc.
AN694
In general, a voltage source or current source may be
used to excite the bridge.
The variable
k
in Figure 2 is the change in resistance
normalized to a value of 1. Assuming the bridge excita-
tion source is a voltage, and applying the rules for volt-
age division, the differential output of the bridge is given
by:
The measurement result obtained with an A/D con-
verter is a comparison of input voltage to the A/D refer-
ence voltage. Specifically, the input voltage is divided
by the reference voltage to obtain the conversion result
and is given by:
EQUATION 2: CONVERSION RESULT
A/D R
ESULT
=
EQUATION 1: DIFFERENTIAL OUTPUT
V
O
= V+ - V- =
V
EXC
R(1-k)
R(1+k)
(
R(1+k) + R(1-k)
)
(
R(1+k) + R(1-k)
)
(
V
IN
V
REF
)
• F
ULL
-S
CALE
If the expression for the sensor output,
V
O,
is substi-
tuted for
V
IN
, the expression for the A/D result
becomes:
EQUATION 3: RATIOMETRIC A/D RESULT
This formula reduces to:
A/D R
ESULT
=
V
O
= V
EXC
• k
(
k• V
EXC
V
REF
)
• F
ULL
-S
CALE
The factor,
k,
becomes the output sensitivity of the
bridge normalized to an excitation of 1 volt. Since the
output sensitivity of a Wheatstone bridge circuit is a
function of its excitation source, the source must be sta-
ble over time and temperature.
When an A/D converter is used to measure a bridge
sensor output, errors due to drift of the excitation
source can be eliminated by using the A/D converter
reference as the source of excitation for the sensor
bridge. This type of measurement is called ratiometric.
Figure 3 shows the basic schematic diagram for a rati-
ometric measurement.
For a ratiometric measurement,
V
EXC
= V
REF
;
therefore, the terms cancel and the expression
for the A/D result reduces to:
A/D R
ESULT
= k • F
ULL
-S
CALE
This formula shows that the ratiometric measurement
result is only a function of the sensor gain and the
full-scale result of the A/D converter. The effects due to
drift of the excitation source have been eliminated.
FIGURE 3:
RATIOMETRIC MEASUREMENT USING AN A/D CONVERTER
Excitation
Voltage
Instrumentation
Amplifier
IN
V
REF
-
V
REF
+
©
2000 Microchip Technology Inc.
DS00694A-page 3
AN694
The output of the pressure sensor is a small differential
voltage superimposed on a large common mode volt-
age. To provide a usable signal, the amplifier should
provide high differential gain with a high common mode
rejection ratio (CMRR). The amplifier should also have
a high input impedance to avoid loading the sensor.
The classic three op-amp instrumentation amplifier
topology shown in Figure 4 has these properties and is
a good choice to amplify the output of the pressure sen-
sor.
Assuming the third op-amp is configured for unity gain
as shown in Figure 4, the gain of the instrumentation
amplifier is determined by resistors R
F
and R
G
and is
given by:
To allow bipolar measurements, an offset voltage can
be connected at the non-inverting input of the third
op-amp. This is especially useful in single-supply
designs.
Many semiconductor manufacturers offer complete
instrumentation amplifiers in a single IC package with
the topology shown in Figure 4. These devices offer the
advantages of reduced parts count and higher perfor-
mance due to precise component matching. For these
devices, the user typically only needs to provide the
external gain resistor to complete the circuit. Depend-
ing on the application, an instrumentation amplifier con-
structed of individual op-amps may still be desirable
because of reduced parts cost.
EQUATION 4: AMPLIFIER GAIN
A=1+2 •
R
F
R
G
FIGURE 4:
THREE OP-AMP INSTRUMENTATION AMPLIFIER
V
IN
-
+
-
R
F
R
-
R
G
R
F
R
R
-
+
R
V
OUT
V
IN
+
+
V
OFS
DS00694A-page 4
©
2000 Microchip Technology Inc.
AN694
PCB LAYOUT
The hardware for the sensor application must be imple-
mented so it is possible to get 12 noise-free bits of mea-
surement resolution. Since the application PCB must
carry both digital and analog signals, special consider-
ations must be made to reduce the effects of noise on
the A/D conversion results. High-frequency switching
noise generated by digital circuits will easily find its way
into the analog signal conditioning circuitry, corrupting
the measurement results. A well designed PCB should
minimize the effects of conducted noise and radiated
noise.
Conducted paths allow noise to propagate into sensi-
tive areas of the circuit through PCB traces and circuit
elements. Conducted noise paths can be controlled by
using proper decoupling and bypassing techniques. To
control conducted noise, the designer should ensure
that noise currents are given the lowest possible
impedance along the desired route back to the power
supply.
In contrast, a radiated noise path is produced when
noise is coupled into unwanted circuit areas by some
airborne means. These airborne paths are produced by
stray capacitances and resistances formed by the
physical orientation of circuit elements and PCB traces.
A good power supply is essential to minimize noise in
the analog circuits. The power for the application
should be provided by a linear supply. Although a
switching power supply has obvious benefits, the
switching noise present on the output negates the
advantages. Central ground and power nodes should
be established near the power supply on the PCB.
A ground plane is essential for noise reduction in the
analog signal conditioning circuit, because signals are
referenced to this ground. The ground plane has two
purposes. First, the ground plane gives the lowest
impedance possible back to the central ground point for
return currents. Without the ground plane, it is easy for
common mode noise voltages to be developed due to
the series resistance and inductance in the ground cir-
cuit traces. Secondly, the ground plane provides shield-
ing for sensitive circuits and PCB traces.
The analog ground plane should be separated from the
digital ground plane, if one is present, and the two
ground planes should only connect at the power sup-
ply. If a two-layer PCB construction is used for cost sav-
ings, one side of the PCB can be dedicated to a ground
plane. The ground plane should encompass the PCB
areas that contain the analog signal conditioning cir-
cuits and should have minimal interruptions due to sig-
nal traces.
If a digital ground plane is not implemented, a ‘star’
topology should be used to connect individual IC’s to
the central ground. Care should be taken not to con-
nect the grounds between individual IC’s, which could
form a ground loop. The digital ground traces should be
two to three times the width of signal traces to minimize
series resistance and inductance.
A power plane is not essential, particularly in applica-
tions that require 12 bits of accuracy or less. However,
special precautions do need to be taken. First, power
traces should be two to three times the width of signal
traces and a ‘star’ connection topology should be
implemented. Second, proper power supply decou-
pling techniques should be used. Separate analog and
digital supply busses should be established on the
PCB. These two busses should only connect at the
power supply. The analog power supply bus is decou-
pled from the main supply using a series 10Ω resistor
and two shunt capacitors. This decoupling circuit
ensures that noise currents induced on the digital sup-
ply bus will not be conducted into the analog supply.
Decoupling capacitors should be installed near the
power pin of all IC’s on the PCB. Two capacitors should
be used at each location — a larger electrolytic capac-
itor and a smaller ceramic capacitor. Typical application
values for these capacitors are 10 µF and 0.1 µF,
respectively. The smaller capacitor is installed closest
to the power supply pin and provides effective bypass-
ing at higher frequencies. The larger electrolytic capac-
itor is used for local energy storage.
Physical distance is one of the best methods for reduc-
ing the effects of radiated noise in a circuit. Conse-
quently, the analog circuits should be located away
from the MCU and other digital circuits on the PCB for
this application. The designer should also check the
layout to verify the orientation of sensitive analog signal
traces. In general, these traces should be kept as short
as possible. Long runs of analog signal traces parallel
to digital signal traces should be avoided. Stray capac-
itance that is a function of trace width and physical sep-
aration of the traces will couple digital signals into the
analog signal path.
HARDWARE
A schematic of the complete pressure measurement
circuit has been included in Appendix B. Separate ana-
log and digital power supply busses have been estab-
lished in the circuit. The PIC16C774 has separate
analog and digital supply pins that have been con-
nected to the appropriate supply bus. The PIC16C774
is operated at 4 MHz using a crystal. A 16 x 2 character
LCD module is connected to PORTD of the MCU. I/O
pin RE0 is used to control the LED backlight on the
LCD module. Two pushbuttons are connected to pins
RB4 and RB5 for data entry. A serial EEPROM is con-
nected to the MSSP module for storage of the calibra-
tion values.
The pressure sensor includes an internal resistor, R
G
,
used as the gain setting resistor of the instrumentation
amplifier. The purpose of the resistor is to normalize the
©
2000 Microchip Technology Inc.
DS00694A-page 5
Zgłoś jeśli naruszono regulamin