Some time ago I decoded to make a simple general purpose Data Logger with the following parameters for the project.
- it should have very simple design that should be doable by most amateurs
- the Data Logger should write the data in a SD memory card in simple text files
- minimum 2 ADC channels
- simple to use and simple settings
- energy efficient
- low cost
I think I managed to fulfill all my requirements and the prototype is quite good. So I am going to describe the design and also I am attaching the firmware for anybody who wishes to make his own Data Logger.
it should have very simple design that should be doable by most amateurs
The both schematics represent the same design but the second schematic has only the bare minimum of components for the proper functioning of the Data Logger. All components are available at most electronic stores in standard DIP sizes which are easy to assemble.
In the second schematic what is missing is the power supply LED diode. Also the P-channel MOSFET, which switches on and off the 3.3v regulator is missing, so the 3.3v power supply is always on. I removed the four ADC input low-pass filters and the protecting diodes. So if you are not using those diodes you should make sure that the input signal doesn’t exceed 5v or you are risking damaging the PIC microcontroller.
The power supply consists of a 5v and 3.3v rails. The 3.3v rail powers the SD memory card. You can use any 5 and 3.3v voltage regulators or other solution but keep in mind that according the specifications the SD memory cards can draw up to 200mA depending on the models.
the Data Logger should write the data in a SD memory card in simple text files
This Data Logger works with SD memory cards, formatted with FAT16, hence the maximum card size is 4GB.
The firmware keeps record of the total number of completed tests/records and assigns new serial number to the next test/record. At the beginning of each record, the Data Logger creates two new text files in the SD card. The first one is D_x.TXT (x = test serial number) which will hold the ADC readings from the four channels. The second file is S_x.TXT (x = test serial number) which will hold system status information like events and/or errors during the test.
If any of these files already exist, they will be appended and not deleted.
minimum 2 ADC channels
The Data Logger has four 12b ADC inputs
simple to use and simple settings
To set up the Data Logger all you have to do is to create a text file called ADC.TXT and copy it in the SD memory card. This Data Logger set up parameters should be written at the beginning on the first line of this file and should be separated by a semicolon – for example “100;200;0;”.
- The first parameter is the sampling time, which is expressed in milliseconds. The minimum sampling time is 5ms (200 samples per second) and the maximum is 99999999ms. In this example the time period between sampling the inputs is 100ms.
- The second parameter is the total number of samples to be taken. “0” means no limit. Otherwise it could be between 1 and 99999999.
- The third parameter is the energy conserving mode. “0” switches is it off and “1” switches it on. If the sampling time is less than 30sec, this parameter will be ignored. See further down for more detailed explanation.
The logical flow chart:
– After powering on, the Data Logger will check if the SD card is inserted and everything is OK with the card. It will also check the settings in the ADC.TXT file. If there is a problem then the SD LED will stay solid on. If there is no problem the SD LED will blink several times while reading and creating the new files on the card and will turn off showing that the Data Logger is ready to start the data recording.
– Press the button to start the data record. While using the SD memory card, the SD LED will blink showing that it is unsafe to remove the card or to power down the Data Logger with risk for damaging the currently used data files. If the SD LED is off then it is safe to power down the Data Logger or to remove the SD memory card.
– Press the button again at any time to stop the data acquisition. If the total allowed number of samples has already been taken then the Data Logger will power down and all future command will be ignored until you reset the power.
*At any time: If the SD LED stays solid on this means that there is a problem either with the card or the settings. For more information check the corresponding file in the memory card.
** The PW LED will always turn on for 100ms every 4 seconds (short blink every 4 seconds) indicating that the power supply is ok and the microcontroller is working properly.
The total energy consumption depends on both the SD memory card and the Data Logger. While I have no control how much current the memory card will draw I have control on when it will be switched on and the speed of the Data Logger so I came with the following three power schemes.
- If the sampling time is less than 2 seconds, the Data Logger and the memory card are always on. The Data Logger consumption is about 20mA and memory card depends on the model.
- If the sampling time is more than 2 seconds, then the Data Logger is always on and the SD memory card will be switched on for about a second only when new data is to be written. The rest of the period the SD card power supply is switched off.
3. Energy conserving mode (if the sampling time is less than 30sec, this parameter will be ignored) – between every data record the SD memory card will be switched off and the microcontroller will stop using the crystal resonator while using the lower speed internal resonator. The higher speed crystal and SD memory card will be switched on only for about a second every time a new sample is taken and has to be written in the memory card. This will allow the total consumption to be as low as 5mA during samples. However there is a tradeoff. The internal oscillator is factory calibrated but it is much more temperature dependent than the crystal. The factory calibration is done for 25 degrees and depending on the external temperature this could result in +-5% timing deviation as opposite to the 0.002% if the crystal resonator is used all the time.
In my design I used common parts that can easily be found in most electronic stores and the total cost is about $6 to $8. The only thing is that you will need a DIY or off-the-shelf PIC programmer to flash the firmware. However if there is a need, a simple PIC programmer (6-8 components) can be made from few spare parts and using the PC serial port you can program the microcontroller.
This Data Logger can be made from DIP size parts and on any prototype board but I decided to draw a new SMD PCB for the project. I am attaching the PCB GERBER files, as well as the MCU firmware and few sample files with the settings, status and data information.