Page 132 - Embedded Microprocessor Systems Real World Design
P. 132
of 65,232. The timer is 16 bits wide, so this is not a problem, but it is very close to
the 65,535 upper limit of the counter.
What happens at 125°C if we take the accuracy of the sensor itself into account?
The MAX6576 has a typical accuracy of 35°C at 125"C, but the maximum error is
+5"C. This means that, at 125"C, the output may actually indicate up to 130°C. At
130°C, the output period is 16126ms. This corresponds to a count value of 66,052,
which means the timer we are using would roll over from 65,535 to zero while sam-
pling. The actual count that would be captured would be 517, indicating a much
lower temperature than the MAX6576 is actually sensing.
There are several solutions to this specific problem: The timer prescaler could
be changed, the configuration of the MAX6576 could be changed, or even the
microprocessor crystal could be changed. You could leave the hardware as-is and
handle the error in software by detecting the rollover. The important point is to
perform this type of analysis when you use timers in microprocessor designs.
Another issue that arises from this example is that of sampling time. The system
can only sample the temperature at a rate equal to the period of the output. As the
temperature goes up, the time between samples also goes up. If several samples
need to be averaged, the sampling rate goes down proportionally. While a worst-
case sample time of 16ms is probably not unreasonable for a temperature mea-
surement system, an analysis of the effects of sample time should be performed in
cases where the input rate of a signal affects it.
Motor Control Say you have a DC motor that is part of a microprocessor control
system. The motor has an encoder that produces 100 pulses per revolution, and
the microprocessor must control the speed of the motor from 10RPM to 2000RPM.
Some undefined external source provides a command to the microprocessor to set
motor speed.
At lORPM, the microprocessor will get pulses from the motor encoder at the fol-
lowing frequency:
Rev Pulses 1 Min Pulses
10- x 100- x -- -
- 16.6-
Min Rev 60 Sec Sec
A similar calculation results in a frequency of 3333.33 pulses/sec at 2000RPM. If
the input capture hardware is configured to generate an interrupt when the input
pulse occurs, then the processor will get an interrupt every 60ms at lORPM, and
every 300 ps at 2000 RPM.
Say we want to calculate motor speed by using a microcontroller with input
capture capability to measure the time between encoder pulses. If the input capture
is measured with a 1MHz reference clock, then the input capture registers will
contain 1 MHz/16.6Hz or 60,024 at 10RPM. Similarly, the registers will contain a
value of 300 at 2000RPM.
Hardware Design 2 113