memory) functions as our storage. The I/O
expansion bus is configured to accept an analog
input signal and digitize it using the PIC24F ADC.
This I/O expansion is also configured with a serial
port to download data logger storage contents
to a PC. We will use the Hyper Terminal
program on the PC to see the data logger in
action and store the results in files. Once data
is stored in a PC file system, we are able to do
analysis and data plotting using standard PC
office tools (like excel spreadsheet programs).
There are several LEDs that run from the I/O
expansion bus for data logger indication activities:
a red LED flashes when storage is updated; and
a green LED flashes once a second to indicate
the RTCC clock has been set and is active.
Data Logger Operation
■ FIGURE 2.
Data Logger
Menu Operation.
A data logging application allows for interaction with
the operator for control and to view status changes. In our
case, we are going to implement a menu driven system. In
fact, all the functionality we need is implemented through
a series of menus and action/status screens. The main menu
has options to set up a data log, initiate a capture, and then
view data all using pushbuttons SW1 to SW4. From here, a
user navigates through the menus to where action and status
screens reside. No matter where a user ends up, in all cases
he/she can recover and work their way back to the Main Menu.
As with any new instrument or appliance, the best way to get
familiar with it is to try it. A data logger project is available
off the Nuts & Volts website ( www.nutsvolts.com) or KibaCorp
site ( www.KibaCorp.com) complete with commented source
code for this particular experiment. The menu driver for this
experiment is contained in the MAIN.C function of the code.
What is the Data, and How is it
Stored and Retrieved?
Okay, we understand the operation, but what is the
■ FIGURE 3. Data
Storage and Retrieval.
data and how does the data logger store and retrieve it?
The logger stores an analog value. It uses the ADC library
(we learned earlier) and configures pin 1 of the I/O
expansion bus to function as an analog input. Any analog
input at this pin between 0 to + 3. 3 VDC will be converted
to 10 bits and be represented as a decimal number from 0
to 1023. The logger will store this value along with the
current data and time from the RTCC. Conversion can be
set at different rates — the fastest being every 10 seconds
and the slowest being once a year. All together, we end
up with 16 ASCII characters for data, 16 ASCII characters
for time, and four ASCII characters for a date —- that’s a
total of 40 characters of data per event.
To store this efficiently, we compress the 40 ASCII
character data events into a smaller eight byte record
using a few tricks. These “tricks” amount to replacing the
month with numbers, using only the last two numbers of
the year and decade, stripping each ASCII character of its
most significant common four-bit header, and then
retaining the remaining least significant four bits (nibble)
and “packing” these nibbles into bytes. We have 32 KB of
storage with our on-board Experimenter EEPROM. With
this smaller eight byte record, we can store a total of
4,095 events or records in our EEPROM (reserving an
■ FIGURE 4. Logging Rates and Capacity.
June 2010 29