Introduction
This is the second part in a series of posts on constructing a data logger. The first part provided analog voltage logging capability to SD card. This part 2 now extends the design to include time-stamping capability.
This is what the assembled data logger looks like:
As a quick test, here is a video showing a light dependent resistor (LDR) that was connected up to the analog input pin (Launchpad connector J2 pin 2) and data logged. (There is a lamp facing the LDR so the video is flooded with light unfortunately). By plugging into the serial port and running PuTTY or any other terminal software, the user can observe the logged values:
Here is what got recorded into a text file onto the SD card. Information is logged every second. Each line contains the time, date and analog value. The first line also contains the temperature (the RTC chip has a built-in temperature sensor, and temperature is logged every minute - the code needs to truncate decimal places of course - I forgot to do this).
01:05:58, WED 23/7/2014, 3428, 29.000000 01:05:59, WED 23/7/2014, 3433 01:06:00, WED 23/7/2014, 3455 01:06:01, WED 23/7/2014, 3462 01:06:02, WED 23/7/2014, 3476 01:06:03, WED 23/7/2014, 3475 01:06:04, WED 23/7/2014, 3482 01:06:05, WED 23/7/2014, 3479 01:06:06, WED 23/7/2014, 3477 01:06:07, WED 23/7/2014, 2423 01:06:08, WED 23/7/2014, 903 01:06:09, WED 23/7/2014, 887 01:06:10, WED 23/7/2014, 877 01:06:11, WED 23/7/2014, 871 01:06:12, WED 23/7/2014, 1691 01:06:13, WED 23/7/2014, 1952 01:06:14, WED 23/7/2014, 1959 01:06:15, WED 23/7/2014, 1807 01:06:16, WED 23/7/2014, 3467 01:06:17, WED 23/7/2014, 3469 01:06:18, WED 23/7/2014, 3463 01:06:19, WED 23/7/2014, 2283 01:06:20, WED 23/7/2014, 839 01:06:21, WED 23/7/2014, 811 01:06:22, WED 23/7/2014, 807 01:06:23, WED 23/7/2014, 3435 01:06:24, WED 23/7/2014, 3437 01:06:25, WED 23/7/2014, 3433 01:06:26, WED 23/7/2014, 3425
The information can be directly imported into Excel or other software.
Hardware Implementation
This project is built around a Tiva LaunchpadTiva Launchpad. In part 1 the SD card functionality was implemented by soldering on a SD card holder to the underside of stripboard. Now for part 2, the photo below shows the real time clock that was added on the other side:
For simplicity the chosen RTC chip was a DS3231S DS3231S device. It doesn’t need many additional components apart from a few resistors and one capacitor. Although the RTC chip is surface mount, it is a large device and therefore easy to solder with a small tipped soldering iron and a breakout board. The backup cell was a 3V Lithium coin cell (CR2032) in a coin cell holder coin cell holder.
The completed RTC circuit is shown below:
Software Implementation
The software reuses the effort from part 1, and adds the capability to be able to set and retrieve time/date information from the real time clock using the I2C bus. The source code is attached below.
The menu implementation is quite simple, it just expects an attribute and a value for most commands.
If the user holds down a button on the LaunchPad while powering up the board, a blue LED will light. Connecting to the USB serial port and hitting enter will then display this menu:
Hello Commands: time (displays the current time) hr xx (00-23) min xx (00-59) sec xx (00-59) day x (1=SUN, 2=MON, 3=TUE, 4=WED, 5=THU, 6=FRI, 7=SAT) date xx (01-31) month xx (01-12) year xxxx (2014-2099)
Once the user has made any configuration changes, the LaunchPad can be power-cycled to exit the menu.
Here is a video of the menu interaction:
Summary
By implementing an easy-to-use RTC chip, the functionality of the logger has been greatly improved. Note that although it currently records just one analog channel, a few code changes would allow additional analog recording channels if desired. I2C sensors could be interfaced too. That’s the subject of a later blog post.
Source Code
A copy of the source code is attached below (see part 1 for details on what to do with the files to run the code), but see github for the version controlled source code for this project.
Top Comments