3–372
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
Important Note:
Very small and very large high times (assuming a fixed
period) are typically unattainable due to the finite amount of
time it takes to generate the pulse train on the output compare
pin. This amount of time will vary depending on the
microcontroller’s clock speed and the latency of the actual
software routines implemented. Thus the sensor’s analog
voltage to which the integrator’s dc voltage is compared must
be within the possible ranges of voltages created by the
integrator’s input pulse train — i.e. the sensor’s zero pressure
offset voltage must be greater than the smallest voltage
created by the integrator (corresponding to the pulse train’s
smallest possible high time) and the sensor’s full scale output
voltage must be less than the largest voltage created by the
integrator (corresponding to the pulse train’s largest possible
high time).
After establishing the frequency of the pulse train, the RC
time constant for the integrator can be determined and the
resistor and capacitor value can be chosen. The RC time
constant should be long compared to the period of the pulse
train so that a stable dc voltage (very little ripple due to the
capacitor’s charging and discharging) is obtained at the output
of the comparator.
Follow these steps to design the RC time constant and
integrator’s component values. The design example’s
calculations are presented simultaneously.
For the resolution desired, determine the number of volts
(typically mV) that corresponds to the least significant bit (one
timer count). For this design example, 8–bit resolution (256
timer counts) over the desired pressure sensor span
corresponds to
# of
mV
timer count
Desired Pressure Sensor Span (V)
Number of Timer Counts
4 V
256 timer counts
15.6 mV
timer count
Therefore the stability of the integrator’s output voltage
should be less than 15.6 mV (least significant bit). Choosing
an RC time constant that allows a ripple of approximately
one–fourth of the least significant bit is sufficient
(approximately 3.9 mV).
The most ripple occurs at a 50% duty cycle pulse train. For
this design the entire period is 640
μ
s. 50% duty cycle
indicates a high time (and low time) of 320
μ
s. Furthermore,
the capacitor should discharge no more than approximately
3.9 mV (defined as
V) over the 320
μ
s. The following
equation is used to calculate the value for RC:
t
RC
V(t) = Vinitial –
V = Pulse Train Logic–level one value
Duty Cycle
e
where Vinitial = Pulse Train Logic–level one value
Duty Cycle
and
V is the voltage discharge of the capacitor.
Solving for RC:
t
V(t)
ln
Pulse Train Logic–level one value
320
s
2.5 V – 3.9 mV
5 V 50%
Duty Cycle
RC = –
ln
0.205 s
Finally, choose the values of the resistor and capacitor. A
typical resistor value is on the order of a tens of k
. The
resistor’s value can be higher (hundreds of k
) but care must
be taken to avoid increased thermal noise.
For this design, the resistor value is chosen to be 49.9 k
(1% resistor). The capacitor’s value is readily calculated to be
C
0.205 s
49.9 k
4.1
F
Choose the values of the resistor and capacitor so that the
actual time constant is equal to or greater than the calculated
time constant.
Note: Be aware that temperature variations can create
errors in the system (thus reducing system performance);
therefore, be sure to use low temperature coefficient resistors,
capacitors, etc.
SYSTEM DESIGN: STEP–BY–STEP PROCEDURE
FOR PRESSURE MEASUREMENT AND
CALIBRATION
To measure pressure (note: there are other measurement
algorithms that can be performed that in some cases may be
more acceptable (see below, Additional notes)):
1. Start with a pulse train with the minimum high time
feasible with the system’s microcontroller. Pulse train
should run at a frequency equal to or less than the
frequency calculated above.
2. Make sure the general I/O pin’s input is high (sensor’s
output voltage is greater than the integrator’s output
voltage).
3. Increment the high time of the pulse train by one timer
count.
4. Check the general I/O pin to see if its input is low
(sensor’s output voltage has become less than the
integrator’s output voltage).
5. If the general I/O pin is reading a logic–level zero, store in
memory the high time of the pulse train as the current
pressure high time reading that created the logic–level
transition in the comparator’s output.
6. If the general I/O pin is reading a logic–level one, go back
to step 3 and repeat.
7. Using the equation “Current Pressure = .......” shown
above, calculate the current pressure (assuming the
system has already been calibrated).
8. Repeat steps 1 through 7 for additional pressure
measurements.
To calibrate the system:
At zero and full scale pressures, perform the above 8 step
pressure measurement routine. Store the appropriate pulse
train high times corresponding to zero and full scale pressure.
These high times will be used to calculate the current pressure
as mentioned in Step 7 above.
SOFTWARE EXAMPLES TO GENERATE PULSE
TRAIN ON OUTPUT COMPARE TIMER CHANNEL
The following software examples are written in assembly
language for the MC68HC05P9 (the code is applicable to any
HC05 series microcontroller with TCMP pin).
F
Freescale Semiconductor, Inc.
n
.