3–370
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
THE INTEGRATOR
As shown in Figure 1. , the integrator consists of a single
resistor and single capacitor. A programmable duty cycle
pulse train from the microcontroller is input to the integrator.
Assuming that the RC time constant of the integrator is
sufficiently long compared to the pulse train’s frequency, the
resulting output which is input to the inverting terminal of the
comparator is a dc voltage that is linearly proportional to the
pulse train’s duty cycle, i.e.:
DC Output Voltage = Pulse Train’s Duty Cycle (%)
5 V
Where the Pulse Train’s Duty Cycle is multiplied by the
pulse train’s logic–level one voltage value which is typically
the same voltage as the microcontroller’s 5 V supply.
Table 3 shows a few examples of Pulse Train Duty Cycles
and the corresponding DC Output Voltage assuming a typical
pulse train logic–level one value of 5 V.
Table 3. Example Pulse Train Duty Cycles and the
Integrator’s Corresponding dc Voltage Output
Pulse Train’s Duty Cycle (%)
0
25
50
75
100
DC Output Voltage (V)
0
1.25
2.5
3.75
5
To establish a stable constant dc voltage at the integrator’s
output, its time constant must be sufficiently long compared to
the frequency of the pulse train. However, the system
resolution and thus performance are directly related to the
pulse train’s frequency. The design of the time constant and
choice of the resistor and capacitor values is discussed in
System Design: Defining and designing for a desired signal
resolution.
COMPARATOR
The LM311 chip is designed specifically for use as a
comparator and thus has short delay times, high slew rate,
and an open–collector output. A pull–up resistor (R6 = 5 k
)
at the output is all that is needed to obtain a rail–to–rail output.
As Figure 1. shows, the pressure sensor’s amplified output
voltage is input to the non–inverting terminal of the op amp and
the integrator’s dc output voltage is input to the inverting
terminal. Therefore, when the pressure sensor’s output
voltage is greater than the integrator’s dc output voltage, the
comparator’s output is high (logic–level one); conversely,
when the pressure sensor’s output voltage is less than the
integrator’s dc output voltage, the comparator’s output is low
(logic–level zero).
An optional resistor, RH is used as positive feedback around
U2 in Figure 1 to provide a small amount of hysteresis to
ensure a clean logic–level transition (prevents multiple
transitions (squegging)) when the comparator’s inputs are
similar in value. The amount of hysteresis increases as the
value of RH decreases. For this design, the value of RH is not
critical but should be on the order of 100 k
.
THE MC68HC05P9 MICROCONTROLLER
The microcontroller for this application requires an output
compare timer channel and one general I/O pin. The output
compare pin is programmed to output the pulse train that is
input to the integrator, and the general I/O pin is configured as
an input to monitor the logic–level of the comparator’s output.
The remainder of this paper discusses the system and
software requirements.
SYSTEM DESIGN: HOW THE SYSTEM WORKS
For any analog sensor voltage output, there’s a pulse train
with a duty cycle that when integrated will equal the sensor’s
output. Therefore, by incrementing via software the pulse
train’s duty cycle from 0% to 100%, there’s a duty cycle that
when integrated will be larger than the sensor’s current
voltage output. When the integrated pulse train voltage
becomes larger than the sensor’s output voltage, the
comparator’s output will change from a logic–level one to a
logic–level zero. This logic–level, in turn, is monitored on the
general I/O pin. The pulse train’s duty cycle creating the
integrated voltage that caused the comparator’s logic–level
transition is the digital representation of the sensor’s voltage.
Thus every sensor analog output voltage is mapped to a
specific duty cycle. This design inherently has outstanding
performance (very stable and accurate) since the digital
representation of the sensor signal is created by the
microcontroller’s digital time base. Also the pressure
measurement, made via software that first increments the
pulse train’s duty cycle and then determines if an edge
transition occurred on the general I/O pin, is straightforward
and easy.
In a calibration routine (discussed below) the sensor’s
output at two known pressures (e.g. zero and full–scale
pressure) can be mapped to two corresponding pulse train
duty cycles. Since the pressure sensor’s output voltage is
linear with the applied pressure, and the integrator’s dc output
voltage is linear with the input pulse train duty cycle, then the
pulse train’s duty cycle that causes the logic–level transition
at the comparator’s output will also be linear with the applied
pressure. Thus by knowing the duty cycles for two known
pressures, a linear interpolation of any duty cycle gives an
accurate measurement of the current pressure. The following
equation is used to interpolate the pressure measurement
where the pressure units are in kPa:
Duty Cycle @ Full–Scale Pressure – Duty Cycle @
Zero Pressure
Full–Scale Pressure in kPa
For example:
At zero pressure, if the pulse train’s duty cycle required to
cause a logic–level transition at the comparator’s output is
25% and at full–scale pressure the pulse train’s duty cycle is
75%, then the current pressure that corresponds to a duty
cycle of 50% (required to obtain the logic–level one to
logic–level zero transition at the comparator’s output) is
Current Duty Cycle – Duty Cycle @ Zero Pressure
Current Pressure =
Current Pressure
50% – 25%
75% – 25%
100 kPa = 50 kPa
Until now, the pulse train has been defined in terms of duty
cycle. However, in practice duty cycle is calculated from the
ratio of the high time to the total period of the pulse train.
Therefore, there is a high time (typically in
μ
s) of the pulse train
that causes the logic–level transition of the comparator’s
output. The interpolation of the current pressure can then be
calculated directly from the high time of the pulse train that is
programmed by the user to be generated by the
F
Freescale Semiconductor, Inc.
n
.