{"id":1114,"date":"2015-01-10T22:36:09","date_gmt":"2015-01-10T22:36:09","guid":{"rendered":"http:\/\/www.blog.exrockets.com\/blog\/?p=1114"},"modified":"2019-03-14T18:22:03","modified_gmt":"2019-03-14T18:22:03","slug":"simple-diy-pic-micro-data-logger-with-sd-card-and-4ch-12b-adc","status":"publish","type":"post","link":"http:\/\/www.blog.exrockets.com\/blog\/simple-diy-pic-micro-data-logger-with-sd-card-and-4ch-12b-adc\/","title":{"rendered":"SIMPLE DIY PIC-MICRO DATA LOGGER WITH SD CARD AND 4CH 12B ADC"},"content":{"rendered":"<p><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/TOP.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1115\" src=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/TOP.jpg\" alt=\"TOP\" width=\"1366\" height=\"1243\" srcset=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/TOP.jpg 1366w, http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/TOP-300x273.jpg 300w, http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/TOP-1024x932.jpg 1024w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p><em>Update Note<\/em>: As mentioned the SD card should be 2GB or less and formatted as FAT16. Due to addressing restrictions the SD card should contain only one partition, created as <strong>PRIMARY PARTITION <\/strong>with no unallocated space before the partition. Please note that some SD cards come with partitions, created as logical partitions and need to have their partitions recreated as mentioned previously.<\/p>\n<p>Some time ago I decoded to make a simple general purpose Data Logger with the following parameters for the project.<\/p>\n<ul>\n<li>it should have very simple design that should be doable by most amateurs<\/li>\n<li>the Data Logger should write the data in a SD memory card in simple text files<\/li>\n<li>minimum 2 ADC channels<\/li>\n<li>simple to use and simple settings<\/li>\n<li>energy efficient<\/li>\n<li>low cost<\/li>\n<\/ul>\n<p>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.<\/p>\n<p><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/TOP1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1123\" src=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/TOP1.jpg\" alt=\"TOP1\" width=\"288\" height=\"548\" \/><\/a><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/BOT.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1124\" src=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/BOT.jpg\" alt=\"BOT\" width=\"288\" height=\"548\" \/><\/a><\/p>\n<blockquote><p>it should have very simple design that should be doable by most amateurs<\/p><\/blockquote>\n<p><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/sch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1117\" src=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/sch.png\" alt=\"sch\" width=\"219\" height=\"546\" \/><\/a><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/sch_s.png\">\u00a0\u00a0 <img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1118\" src=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/sch_s.png\" alt=\"sch_s\" width=\"239\" height=\"490\" \/><\/a><\/p>\n<p>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.<\/p>\n<p>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\u2019t exceed 5v or you are risking damaging the PIC microcontroller.<\/p>\n<p>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.<\/p>\n<blockquote><p>the Data Logger should write the data in a SD memory card in simple text files<\/p><\/blockquote>\n<p>This Data Logger works with SD memory cards, formatted with FAT16, hence the maximum card size is 4GB.<\/p>\n<p>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.<\/p>\n<p>If any of these files already exist, they will be appended and not deleted.<\/p>\n<blockquote><p>minimum 2 ADC channels<\/p><\/blockquote>\n<p>The Data Logger has four 12b ADC inputs<\/p>\n<blockquote><p>simple to use and simple settings<\/p><\/blockquote>\n<p>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 &#8211; for example \u201c100;200;0;\u201d.<\/p>\n<ol>\n<li>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.<\/li>\n<li>The second parameter is the total number of samples to be taken. \u201c0\u201d means no limit. Otherwise it could be between 1 and 99999999.<\/li>\n<li>The third parameter is the energy conserving mode. \u201c0\u201d switches is it off and \u201c1\u201d switches it on. If the sampling time is less than 30sec, this parameter will be ignored. See further down for more detailed explanation.<\/li>\n<\/ol>\n<p>The logical flow chart:<\/p>\n<p><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/FC_EN.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1122\" src=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/FC_EN.jpg\" alt=\"FC_EN\" width=\"547\" height=\"527\" srcset=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/FC_EN.jpg 547w, http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/FC_EN-300x289.jpg 300w\" sizes=\"auto, (max-width: 547px) 100vw, 547px\" \/><\/a><\/p>\n<p>&#8211; 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.<\/p>\n<p>&#8211; 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.<\/p>\n<p>&#8211; 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.<\/p>\n<p>*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.<\/p>\n<p>** 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.<\/p>\n<blockquote><p>energy efficient<\/p><\/blockquote>\n<p>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.<\/p>\n<ol>\n<li>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.<\/li>\n<li>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.<\/li>\n<\/ol>\n<p>3. Energy conserving mode (if the sampling time is less than 30sec, this parameter will be ignored) \u2013 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.<\/p>\n<blockquote><p>low cost<\/p><\/blockquote>\n<p>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.<\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/PCB.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1129\" src=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/PCB.jpg\" alt=\"PCB\" width=\"2759\" height=\"1097\" srcset=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/PCB.jpg 2759w, http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/PCB-300x119.jpg 300w, http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/PCB-1024x407.jpg 1024w\" sizes=\"auto, (max-width: 2759px) 100vw, 2759px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/SIMPLE_SD_DATA_LOGGER_FIRMWARE.zip\">SIMPLE_SD_DATA_LOGGER_FIRMWARE.ZIP<\/a><br \/>\n<a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/SIMPLE_SD_DATA_LOGGER-CADCAM.zip\">SIMPLE_SD_DATA_LOGGER &#8211; CADCAM.ZIP<\/a><br \/>\n<a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/ADC.txt\">ADC.TXT<\/a><br \/>\n<a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/D_0.txt\">D_0.TXT<\/a><br \/>\n<a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/S_0.txt\">S_0.TXT<\/a><\/p>\n<p><a href=\"http:\/\/www.blog.exrockets.com\/blog\/wp-content\/uploads\/2015\/01\/ADDITIONAL_FIRMWARE_2520_2550_2580.zip\">ADDITIONAL_FIRMWARE_2520_2550_2580.ZIP<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update Note: As mentioned the SD card should be 2GB or less and formatted as FAT16. Due to addressing restrictions the SD card should contain only one partition, created as PRIMARY PARTITION with no unallocated space before the partition. Please note that some SD cards come with partitions, created as logical partitions and need to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"gallery","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1114","post","type-post","status-publish","format-gallery","hentry","category-electronics","post_format-post-format-gallery"],"_links":{"self":[{"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/posts\/1114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/comments?post=1114"}],"version-history":[{"count":13,"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/posts\/1114\/revisions"}],"predecessor-version":[{"id":2332,"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/posts\/1114\/revisions\/2332"}],"wp:attachment":[{"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/media?parent=1114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/categories?post=1114"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.blog.exrockets.com\/blog\/wp-json\/wp\/v2\/tags?post=1114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}