|
Issue
99, October 1998
X-Y Graphing Data
Logger
by
Alberto Ricci Bitti
Start
Machine
Muscle
Using
Componentware
Low-Power
Guys
Flash
Risc Glue
The Graphic
Engine
Casio
Protocol
Main
Code
Inside
The Box
Setting
up the Casio
First
Graph
Modeling
The Data
Broader
Vision
Software,
References & Sources
MAIN CODE
The software copes with communication
protocols over a serial line, combining sleep mode and
watchdog techniques to achieve minimal power consumption,
low-power ADC driving, and data conversion to the Casio
format.
Complete packet templates
are stored in data tables in program memory. At this point,
I found RETLW invaluable.
Only segments with variable
values are replaced by real data read from the ADC in
real time. Most parts of the input packet are ignored,
and only the variable name is stored to select the right
ADC input. When issuing Receive(X), you can specify any
other variable name to select a different input.
Even the simpler communication
protocol must deal with errors and interruptions. To keep
program overhead low, I set up the watchdog timer to reset
the device if it waits for an answer from the calculator
for more than 2 s.
Once reset (and for most
of the time), the device is left in sleep mode. Its
awakened by another WDT timeout or by receiving a character.
In the former case, the device
goes back into sleep mode. In the latter case, the LED
flashes, the ADC awakens, and the communication flow restarts.
When the micro sleeps, the
ADC is left in full power-down mode. The shutdown pin
is a three-level selection input, and the MAX186 sleeps
with that pin at 0.
It is awakened by putting
the pin in a high impedance state, which is done long
before the conversion starts to let the voltage reference
capacitor charge completely.
The MAX186 input can be reconfigured
to bipolar input mode (with input spanning from Vref/2
to +Vref/2) or pseudodifferential input mode by changing
the command word that is ORed in the ReadADC code segment.
Figure 3 shows
the signals involved and how the control word is made.
The Casio needs variables
in BCD format with separated exponent digits. The most
significant digits come first. The BCD conversion and
the bit-banging serial-port routines are derived from
public-domain Microchip libraries.
|