Issue
140 March 2002
Spy-Size
Event Logger
byJeff
Bachiochi
Event
Group
This
last group is the working registers for the Event Logging
mode of the DS1678. The first eight registers get written
following the first event of the mission (logging session).
They are a copy (time stamp) of the RTC registers reflecting
the exact time of the mission’s first event. The time
each event occurs is based on this start time. Time between
events (the logged data) is the elapsed time from the
last event. Logged data consists of a two-byte elapsed
time count. Each count is equal to the configuration set
in the control register (bits 4 and 5, see Figure 4).
This makes a minimum count of one equal to 1 s, 1 min.,
or 1 h.
Naturally
you want to pick the resolution that best fits your minimum
time between events. Events will be logged even if they
occur at a rate quicker than the chosen resolution. This
would be data logged with an elapsed time count of zero.
For instance, if you chose hour increments of the elapsed
time counter and events happened every 15 min., you might
see three logs of zero elapsed time counts and one log
with one count. Independent of logging, which consists
of saving and clearing the elapsed time counter (ETC),
the RTC is in charge of incrementing the ETC on a time
match determined by the duration interval bits in the
control register.
On
the other hand, you must also pay attention to maximum
times, which are 65,535 times the resolution. Therefore
the maximum ETC for the second’s duration interval is
65,535 s, or 18.2 h. If your event happens once per day,
the elapsed time count will overflow (and roll over to
zero). So again you can see the importance of choosing
a resolution that fits both your minimum and maximum times
among events.
Following
the time stamp registers (48–55) is the event zero elapsed
time from last event counter 2-byte register (56–57).
At the beginning of the mission, this register pair is
written with zeros. This designates the first event and
the start of a mission. If the RO bit is set (allowing
rollovers), this register pair will hold an elapsed time
count since the last event (event 1024) after the rollover
has occurred. (This is one way of determining a rollover.
But, as indicated, an ETC of zero is possible.)
The
next three registers (58–60) hold a 3-byte count of the
number of events that have been logged since the mission
began. Ordinarily this register would increment to 1024
and the logger would be full of data. However, you have
no real idea when this might occur, so even if you’ve
configured the logging to stop at 1024 events (the maximum),
the DS1678 can continue counting events even if it can
no longer log them.
So
far I haven’t discussed the logging memory, in fact, you
may have noticed it isn’t shown in any of the previous
figures. That’s because you don’t have direct access to
the logging memory. You can’t write to it, only the event
logger can. This prevents data tampering. Any attempt
to access the data halts the mission and locks in the
data. After it’s been halted, the only way to begin a
mission is to clear the memory and start from scratch.
Following
the ETC register pair is an address register pair. This
register pair (63–64) points to the next logging memory
address or the location where the ETC will be stored on
the next event. Initially it will point to address zero
(2047 being the last logging memory address prior to rollover).
The 2-byte ETC count will be stored at the pointer at
the next event and the pointer will be incremented (two
consecutive bytes for each 2-byte ETC value). When RO
equals one and a rollover occurs, not only is the ETC
stored in register pair 56–57, which was zero, but a new
RTC sample is stored in the time stamp registers (48–55).
Events will continually be logged, overwriting the oldest
data with new.
Even
though you are prevented from writing to the logging memory,
there must be a way to retrieve the logged data. The last
three registers (65–68) hold the key. The first two registers
are an address pointer pair enabling the user to read
the logging memory. The last register will hold the data
pointed to by the first two address registers. The address
pointer will automatically increment for multiple reads
to the data register (43), so you can skip having to continually
write the address to read multiple data bytes. When you’re
pointing to the address of interest, you can read as many
multiple bytes as you wish. Note multiple byte reads are
not supported in the simple serial-to-I2C converter in
this project, so you’ll have to update the address for
each read.