edit
- There are information not included in this main post. Read through the thread for more information on timer calibration and other useful information by cpfers.
- PEU pointed out the TX to be connected to serial port pin 2 instead of 3. This now corrected as circuit ver 1.0a and reflected in this main post. The respective file names are changed with "10a" surfix.
- Slightly modified circuit version 1.1 is posted in the new post below. This is a maintenance change. Circuit files carry "11" surfix.
Introduction
Introducing CPF-LOGGER-Lite: A PIC based simple DIY datalogger for cpfers of all age!
This post is far overdue and I owe a few people, but didn't have time to sit down to write the post. Now I feel the pressure and turn it to the pleasure to present this simple data logger hoping it would benefit many cpfers.
Full source code for both PIC and PC are provided for unlimited modification.
I am not claiming any credit or fame since all the information used are always available in the PIC datasheet and other materials, I just applied only. It suite me for my cpf related logging purpose, but it may not serve you well, I am not offering any warranty for the proper operation. I will not accept any claim against potential data loss or damage to your hardware which may be caused by the use of this logger, either.
For impatient people, here is the zip file of everything in this section.
all files zipped - cpf-logger-lite-all-10a.zip
all files zipped - cpf-logger-lite-all-11.zip
Features <ul type="square">[*]Very simpe logger with minimum parts required [*]4 analog voltage input (1 used for brightness) [*]Attch to PC serial port to collect data [*]Take power from serial port [*]Minimum feature for simple opertion
[*]Not an oscilloscope [*]Not highly accurate (does not replace DMM) [*]Not industrial measurement equipment
[*]Measure 0 - 5V[*]Input impedance max 10K (not so good)[*]Send measured voltage from 4 inputs to PC every second at 9600 baud[*]Each output is average of 128 samplings[*]optional digital low pass filter (enable during compile time)[*]Use TI OPT101 for light measurement (highly linear)[/list]It is meant to provide minimum yet sufficient means to measure the data needed for most logging done by cpfers with minimum parts to build. It is not meant to be used as measuring instruments.
Version
This model is called CPF-Logger-Lite. Lite is added because it is something really light weight with minimum parts and minimum feature. It only has 10 bit ADC which is expanded to 12 bit value with averaging.
I have plan for CPF-LOGGER-Regular which uses 12 bit ADC and also accurate time base using a crystal. Also planned is CPF-LOGGER-Pro with self contained datalogger which will log into its own memory without a PC connected.
Just hope I can find sometime to do all that...
PIC Side
Here is the circuit diagram used. This gif file may not be clear, so the hi resoultion version is added for downloading below or in the all file. You can print or zoom in.
PIC12F675 is running on internal 4MHz clock. The datasheet says it is calibrated to be less than 1% accuracy. The particular PIC I used has about 0.44% time drift and the compensation can be made in the source code.
The power is taken from the PC serial port (DTR and RTS) and regulated to 5V with 78L05. My DMM shows 5.01V, so don't expect it to be industrial grade accuracy.
All voltage inputs are filtered with 4.7K resistor and 0.1uF capacitor since many output from the lights are in pulse form. This resistor also serves as current limiting to the PIC input.
The switch toggles between 1 second data sending or 1/8 second data sending. Sometimes it is desireable to see more rapid data during the adjustment before actual logging.
The serial output is sent to the PC serial port directly through a red led. Most PC serial ports accept the serial data happily even though it is not a true RS-232 signal. The red led indicates the data transmission to PC.
The light is sensed using TI OPT101 chip. Since 5V power is supplied, it produces max 3.5V when the light is saturated. The voltage output is bery linear to the amount of light thrown. I use a piece of plastic to cover the sensor to limit the light input to avoid saturation.
I didn't have time to draw the pcb arrangement, but I believe that those who understand the circuit shall be able to make the pcb themself. I used perforated board.
When it is completed and put into a box, it looks like this.
Here is the source code for the PIC. It is compiled with CCS PCM compiler. For those who doesn't have the compiler, pre-compiled hex file is also provided.
high resolution circuit schematic - cpf-logger-lite-citcuit-10a-hires.gif
source code - cpf-logger-lite-pic.c
pre-complied hex file - cpf-logger-lite-pic.hex
For those who want to get pre-programmed PIC, you may want to contact me or Roberto (
cgapeanut ).
PC Side
I am a legacy programmer and most my programs are meant to run on UNIX machine. Since I don't write MS based Windows program, I did it using CYGWIN environment.
source code - cpf-logger-lite-pc.c
pre-complied exe file - cpf-logger-lite-pc.exe
cygwin runtime library (zipped)
This program displays what comes from the logger through the serial port and capture it to the text file. I use MS Excel to chart.
I was half way through to write a LabView program to display the chart as the data come in, but had to stop due to the time constrain. I am suggesting someone who has programming knowlege to write VB or other programs to do so.
During the logging, the PC displays as this:
<font class="small">Code:</font><hr /><pre>0.00:00:00 1351 0000 0000 0008 1.649 0.000 0.000 0.010 0.000 0.0
0.00:00:01 1596 0000 0000 0008 1.948 0.000 0.000 0.010 0.000 0.0
0.00:00:02 1072 0000 0000 0008 1.309 0.000 0.000 0.010 0.000 0.0
0.00:00:03 0728 0000 0000 0008 0.889 0.000 0.000 0.010 0.000 0.0 </pre><hr />
The first column is the elapsed time since logging start, next 4 columns are the ADC counts followed by converted voltage respectively. The last 2 columns are current flow and the percentage of the light calculated. More note below about them.
The captured format is as follows: It is ready as CSV format for a spreadsheet.
<font class="small">Code:</font><hr /><pre>Time,A1,A2,A3,A4,V1,V2,V3,V4,C,L
0.00:00:00,1229,0000,0000,0008,1.500,0.000,0.000,0 .010,0.000,0.0
0.00:00:01,1241,0000,0000,0008,1.515,0.000,0.000,0 .010,0.000,0.0
0.00:00:02,0706,0000,0000,0008,0.862,0.000,0.000,0 .010,0.000,0.0
0.00:00:03,1333,0000,0000,0008,1.627,0.000,0.000,0 .010,0.000,0.0 </pre><hr />
It has the following command line options.
<font class="small">Code:</font><hr /><pre>
usage: cpf-log [options [parameter]] [log_filename]
options: -h display this text
-p i com port (1)
-b l baud rate (9600)
-r raw output mode (vs processed output)
-c count mode in log file
-t i count between logging in file (1)
-v d reference voltage (5.0)
-a i adc max count (4096)
-l i light adc max count (0)
-s d current sense resistor (0.16) </pre><hr />
I don't have enough time to explain all here, I will have to write a manual for it. But I am sure it is very simple to understand. Most time, you don't need to add an option. Please refer to the source code for actual usage.
Operation
It is just upto the user's imagination. It can simply measure 3 voltages and a brightness level. I usually measure the battery voltage and the brightness from the light for run time charting. Any of input can be used for voltage input.
For current recording, I use 0.16 ohm 1% resistor in series to the battery and measure the voltage of both end of the resistor. This is the smallest resistor I have from an broken DMM. The displayed current is caulated from the voltage difference between input 2 and 3. The resistor value can be set using "-s" option.
For more accurate current logging, MAX471 IC can be used as high side current sensor. It measures the current with internal 35 mili-ohm resistor and opamp, and outputs 500uA current for each A current flow upto 3A. A resistor connected to the output of this IC can set the voltage for each A current. "-S" is planned to set this resistor value.
Here are some loggings done with this logger.
Do I expect a flood of run time charts from now on?
-- dj