circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 140 March 2002
Spy-Size Event Logger

 


byJeff Bachiochi

Mission Possible

You’re going set this module up to log movement through a doorway. This is an "enter only" doorway, so you’ll log traffic in one direction only. A reflective IR device presently mounted in the doorframe has relay contacts that close whenever its beam is broken. The contacts are easily wired to produce a gated 5-VDC pulse, which you can connect to the INT event input pin of the ’1678.

Before I get into this short example, there is one other small matter. You built a serial-to-I2C converter to be able to talk to any I2C device. It would be nice to have an application that made talking to this specific device a bit easier. I wrote this application in GWBASIC to talk to the converter using a COM port (I still find many uses for Microsoft’s DOS Basic). The application has three functions, read, write, and dump. This application is menu-driven and allows reading from and writing to DS1678 registers. Unlike using, say, HyperTerminal, this program provides a smart front end, which displays information about the registers and not just the values that are stored there. You don’t have to think about what value to store in which register, you just choose menu selections, which will be interpreted into (hopefully) the correct register and value data. The dump retrieves the log memory and creates a data file containing the values for use in a spreadsheet.

To set up the registers properly for a mission, you must follow these steps. First, display the RTC registers (0–7) and change the present date and time if necessary. For this project, you are not using the alarm, so these registers do not need to be set. Next, display the control register and toggle the trigger and duration interval selections to choose the appropriate event-triggering edge and count increment time. I use falling edge triggering and 1-s count increments. I also clear RO to prevent a rollover should I get more than 1024 events before I stop the mission.

To clear the memory I need to set the CLR bit. When this bit is set, the application immediately stores the control register and asks if you wish to also set the CM bit (in the status register). You must set this bit immediately after setting the CLR bit, otherwise the CLR bit is cleared and you cannot clear memory without repeating the process. This is a security measure implemented within the DS1678 to prevent unintentional erasure of data. Displaying the status will now show "MEM CLR set," meaning the CLR bit is not cleared again as the process has taken place. Only with the memory cleared can you start a mission.

There are two ways to begin a mission. If the MIP bit is set (with memory cleared) a mission begins immediately (as if there was an event). If the ME bit is set, the mission waits for an event to start the mission. At this point, the DS1678 module is ready to be connected to the event source. The event must present at least 2.2-V input to look like a logic-zero-to-logic-one transition.

When the logging mission is finished, you can remove the data logger’s event source and reconnect the logger to the serial-to-I2C converter. Now you can run the BASIC application program and interrogate the logger. Changing any register will halt the mission. Not only does this discourage tampering, but also the device is immediately ready to give up its logged data.

One of the user selections of the BASIC application program is to dump the logged data. This not only goes to the screen, but also to a .TXT file in "event number elapsed count since last event" format. To make sense of this you must also know two things, the RTC values at mission start (time stamp in registers 48–55) and the duration interval (from control register 15).

To find the time of the first event, take the duration interval (1 s, 1 min., or 1 h) and multiple it by the "elapsed count since last event." Obviously, this gives the time passed since the last event. Add this to the time stamp of the previous event to get the actual time the event occurred. I imported the .TXT file into Microsoft Access and was able to produce a plot that shows a timeline of event occurrences as shown in Figure 5.

(Click here to enlarge)

Figure 5—The Microsoft Access plot of logged data shows the majority of the activity taking place from 8 a.m. to 5 p.m. The overnight hours do not reflect any activity.