|
Issue
98, September 1998
Smart
Rockets - Data Acquisition in Model Rocketry
by
Tom Consi & Jim Bales
Start
Introduction to Model
Rocketry
Rocket Science 101
Control & Data Logging The
Accelerometer
Software Power
System Construction
Launch Control Box
Results
Future Developments
Software
& Sources
SOFTWARE
The code was written in PIC
assembly language. We used Microchips MPASM assembler
and PICStart 16C programmer as development tools. A block
diagram of the software is shown in Figure
4.
On powerup or after coming
out of a reset, the software initializes the I/O facilities
and internal resources of the PIC (DIO, ADC, SPI interface,
USART, and Timer 0). The USART operates at 9600 bps, and
the SPI clock runs at 1 MHz.
The program then polls RB0,
which is normally high. A trigger signal pulls RB0 low
and causes the program to check the mode and execute the
appropriate code. After the selected mode executes, the
program loops back to polling RB0 for another trigger
signal (see Figure 4a).
Mode A is the real-time data-acquisition
portion of the program. It is entered if pin RB0 is jumpered
low. The ADC is read during an interrupt service routine
that is governed by Timer 0, which provides an interrupt
every millisecond, thus setting the data-acquisition rate
(see Figure 4b).
How data is acquired is dictated
by the behavior of the Xicor 25F128 serial flash-memory
chip. It receives data in 256-bit packets via its SPI
interface and stores it in one 32-byte sector of its flash
memory.
Transferring 256 bits takes
only about a quarter of a millisecond at an SPI clock
rate of 1 MHz. The programming operation, however, takes
10 ms. Fortunately, this occurs automatically after the
bits are received and it requires no further intervention
of the PIC.
The program in mode A reads
the ADC 32 times at a 1-kHz rate, storing these values
in 32 bytes of buffer RAM on the PIC chip. Between the
thirty-second and thirty-third A/D conversions, it shoots
the contents of the buffer to the Xicor chip through the
SPI.
It then proceeds to fill
the buffer RAM again. During the 32 ms that the buffer
is being refilled, the Xicor chip has plenty of time to
write the data it just received into its flash memory.
In addition to sending acceleration
data, the PIC sends the sector address that indicates
where to store the data in the Xicor chip. The sector
address is incremented after every SPI transfer.
This cycle repeats itself
256 times until 8 KB of data are stored on the Xicor chip.
The program then ends mode A and goes back to polling
the trigger pin.
The Xicor chip holds up to
16 KB of data. But, we found that 8 KB of data, corresponding
to 8 s of time, was enough to capture a rocket flight
from launch to recovery phase.
Triggering the system in
mode B presumes that a host computer is connected to the
USART of the PIC via the interface box. The PIC reads
a single byte from the Xicor chip, converts it to a three-byte
ASCII decimal number, and transmits it to the host computer
(see Figure 4a).
Each transmitted number is
appended with the ASCII codes for carriage return ($0D)
and line feed ($0A). This cycle repeats itself until all
8 KB of data are transmitted to the host.
The user must set the host
computer to accept this ASCII stream before the PIC is
triggered into mode B. There is no handshaking between
the PIC and the host. As with mode A, on termination of
mode B, the program loops back to polling the trigger
input.
In the field, we used a laptop,
running a terminal emulator set in screen-capture mode,
as the host computer. The captured file is a 1-column
? 8192-row matrix of ASCII decimal numbers.
As soon as the rocket was
recovered and the data uploaded to a laptop, we plotted
the data to ensure that the system worked properly. Thus,
we could correct problems on site, instead of discovering
them back in the lab. Being able to read the data in the
field using a simple editor more than offset the extra
time needed to transfer ASCII as opposed to binary data.
|