# Voltage Logger with SD card

Just finished my new small project.
This is simple stand-alone voltage logger with SD card! No computer or tablet is required, cheap and easy to use tool.

Features:
– 8 input channels 0V to 3.3V,
– sample time: 0.5 ms … 5000 ms (5 sec), 0.2 Hz … 2 kHz,
– configurable calibration coefficients (zero and gain),
– configurable moving average filter for oversampling and resolution enhancement,
– all the settings are stored in configuration text file on the SD card.

Internal ADC is used for measurements and SDIO mode for SD card (FAT32 and up to 32Gb supported). This is open source and open hardware project: GitHub repository

Here is some test results for illustration of operation and measurement accuracy.

The picture of first prototype:

### DC measurements

Histogram of ADC codes for 0V measurement:

mean = 2.2471, stdev = 2.2171

Histogram of ADC codes for 3V measurement (from Li-ion cell):

mean = 3741.2, stdev = 3.9101

Then, the zero and gain calibration was performed to get measurement result in volts. Here is example of configuration file ADC.txt. The channel 1 is enabled, 0.5 ms sample time.

```sample 0.5

ch1_en 1

ch1_zero 2.247096239442946
ch1_gain 0.0008018788553247611

timestamp 1```

Input DC voltage histogram:

And recorded voltage plot:

Then it is possible to estimate SNR of DC measurement based on equation $SNR = 20 \log_{10} \dfrac{mean}{stdev}$ and corresponding effective number of bits: $SNR = 6.02 n + 1.76$

mean = 3.0000, stdev = 0.0030, SNR = 60.0160, n = 9.6771

To enhance accuracy and resolution, oversampling with moving average filter is implemented:
$x_{avg} := x_{avg}\dfrac{N-1}{N} + x \dfrac{1}{N}$

where N is configurable filter order.

Here is configuration ADC.txt file for N=2 moving average filter applied to channel 1:

```sample 0.5

ch1_en 1

ch1_zero 2.247096239442946
ch1_gain 0.0008018788553247611
ch1_filt 2

timestamp 1```

Input DC voltage histogram:

And recorded voltage plot:

Obtained accuracy results: mean = 2.9998, stdev = 0.0017, SNR = 65.0610, n = 10.5151

Same testing was performed for N=4 filter order:

Obtained accuracy results: mean = 2.9998, stdev = 0.0011, SNR = 68.7229, n = 11.1234

Thus, using three-sigma rule, the accuracy without filtering is 10 mV (0.3% of full scale), but with order 2 filter accuracy is 5 mV (0.15% of full scale), and with order 4 average filtering is 3.3 mV (0.1% of full scale).

### AC measurements

For testing of dynamic performance and recording of AC signals, all channels were connected to the signal generator. The moving average filter of order N was assigned to channel #N. And following configuration file used:

```sample 0.5

ch1_en 1
ch2_en 1
ch3_en 1
ch4_en 1
ch5_en 1
ch6_en 1
ch7_en 1
ch8_en 1

ch1_zero 2.247096239442946
ch1_gain 0.0008018788553247611
ch1_filt 1

ch2_zero 2.247096239442946
ch2_gain 0.0008018788553247611
ch2_filt 2

ch3_zero 2.247096239442946
ch3_gain 0.0008018788553247611
ch3_filt 3

ch4_zero 2.247096239442946
ch4_gain 0.0008018788553247611
ch4_filt 4

ch5_zero 2.247096239442946
ch5_gain 0.0008018788553247611
ch5_filt 5

ch6_zero 2.247096239442946
ch6_gain 0.0008018788553247611
ch6_filt 6

ch7_zero 2.247096239442946
ch7_gain 0.0008018788553247611
ch7_filt 7

ch8_zero 2.247096239442946
ch8_gain 0.0008018788553247611
ch8_filt 8

timestamp 1```

50 Hz pulses.

Recorded with various filter orders:

50 Hz sin wave.

Recorded with various filter orders:

5 Hz pulses.