• RTCCSet() — This function
writes changed times and
dates to the clock registers.
• RTCCProcessEvents () —
This function grabs the
current time from the RTCC
and translates it into strings.
It must be called periodically
to refresh the time and date
strings _time_str and
_date_str. Each string is 16
ASCII characters.
The above functions work
directly with the RTCC without
the advantage of using the
LCD and pushbuttons — which
would make working with the
RTCC a lot easier. You could
view the current clock setting
on the display and selectively
change fields and get instant
feedback on the results.
Because of this, I recommend
that you use the following
functions to set the clock and
alarm instead. These functions make extensive use of the
LCD and pushbuttons. To operate these, you must first call
the library function RTCCInit (). The two functions we will
discuss use the RTCC library, but reside outside of it in
MAIN.C.
■ FIGURE 8. Data
Logger Hook-up.
time setting in ASCII and allows the operator to accept
or make changes to the RTCC using the display and
pushbuttons.
• Set ALARM (alarm) — This function initializes the alarm
functions of the RTCC and sets the alarm (for the data
logger, we referred to this as rate) based on the value
passed as alarm. It is called during the rate setting
menu. It sets as follows:
• if (alarm = 0), then alarm every 10 seconds.
• Button SW1: Toggles between the clock set mode
and clock accept mode. Hitting the SW1 twice in
accept mode exits the function with the RTCC set
to the displayed time.
• Button SW2: If in clock setting mode, it increments
the current data field.
• Button SW3: If in clock setting mode, it decrements
the current data field.
• Button SW4: Advance to the next allowable data field.
Implementing a Serial Interface
Once the alarm is set, this function will then enable
the RTCC to interrupt the PIC24F once the alarm
condition is met. The RTCC interrupt performs the
function of collecting all the data for the record and then
storing the record in EEPROM. It runs continuously until a
total of 4,095 records are stored or until the operator
elects to shut the alarm interrupts off (using menus) before
the full 4,095 count is reached.
• clock_Setup () — This routine displays the current RTCC
To connect the Experimenter data logger to a PC, a
serial port is required. The port uses one of the two internal
Universal Asynchronous Receiver Transmitters (UART) in
the PIC24F and connects the transmit and receive pins to
pin 9 and pin 8 of the I/O expansion bus. Why bother with
this connection? Well, the data logger only does a single
log session at a time. It stores this nonvolatile data from the
logging session. However, if you initiate a new session, then
this data will be written over — that is where the PC comes
in. We don’t need to lose our data, just simply transfer it
to the PC with its larger file system and analytic tools, and
store and study the data there. As a stand-alone, the data
logger will allow you to examine the stored data under the
menu operation. However examining all 4,095 records
manually using pushbuttons to scroll through will be tedious!