Wind & Wet

Arduino data logger - Software

The Arduino software is required to collect from the currentand voltage ADC inputs and the wind and frequency digital inputs. I wanted a simple output data format so used comma separated value (CSV) text and streamed this back to a laptop PC over the USB link where it could be written straight to a file. The file can then be easily viewed in any spread sheet.

I also needed a means of controlling the system so used the same text format commands to start and stop collection. This made it possible to control the collection by typing commands into the Arduino serial monitor and view the data in the output screen. While this made development and use easier the down side of this approach is there is a greater overhead formatting and transmitting the data compared to a binary format. In the end I wrote a simple GUI in the Processing language to control the Arduino, display the data and manage the CSV files.

The ADC inputs (voltage and current) are rectified AC so I wanted the sampling of these to be as fast as possible. The output power is the product of the current and voltage so ideally this should be calculated for each sample. The average current, voltage and power needs to accumulated and reported every time a data point is required.

The frequency measurements are calculated by timing the number of rotations in a given period. The count and time measurements are driven from an interrupt generated when the digital input changes state. When a report is required the frequency is calculated from the difference between the first and last interrupt times divided by the number of interrupts.

The readings from the ADCs and frequency calculation are the raw input values and need to be adjusted to get the calibrated reading. The raw values are used in a polynomial (e.g. Y=A+Bx+Cx2+Dx3+...) where x are the raw values, the coefficients A,B,C,D, etc are the calibration values and Y is the calibrated (cooked?) result. The coefficients can be found by taking a number of samples in a spread sheet and generating a linear or polynomial trend line with equation.

Initially, the data sampling was made in the software main loop and timed using delays to poll for the next collection cycle. I tried various collection rates but typically the ADCs sampled at 2m/s intervals and data was reported every second with the ADC data samples being averaged. The problem with this was that the calculation, formatting and sending of the data was taking up several sample cycles. I then changed the code so the sampling was driven from an interrupt handler driven from the hardware timer (see Arduino timer3 library). The ADC's were simply read and the data put into a FIFO (First in first out) buffer. The FIFO buffers were read and data processed in the main programme loop. Using this method the ADC sampling could be run at 2ms interval (500 per second) without over running the FIFO buffers. Changing the interval to 1m/s (1000 per second) resulted in data being lost.

There are a large number of additional data values that can be derived from the four channels of data. These could be added during the post processing of the CSV file in a spread sheet but it is quite useful to generate them at run time so they can be monitored. This causes an additional load on the Arduino processor and transmission to the PC but was a convenient point to do the processing. The channels and data collected so far are below. It is very easy to add or remove channels in the Arduino sketch so these might be removed if I want to reduce the size of the the output files in future.

  • Time stamp
    1. Time from start of Arduino board (seconds)
  • DC Current
    1. Average raw ADC value
    2. Average calibrated value(Amps)
    3. RMS calibrated value(Amps)
  • DC Voltage
    1. Average raw ADC value
    2. Average calibrated value(Volts)
    3. RMS calibrated value(Volts)
  • AC Frequency
    1. Calculated frequency value(Hertz)
    2. Calibrated frequency (e.g. AC current to turbine frequency)(Hertz)
    3. Calibrated frequency * 60 (RPM)
  • Wind speed
    1. Calculated frequency value(Hertz)
    2. Calibrated wind speed(m/s)
    3. Change in speed since last collection (m/s)
    4. Wind power - The air density and area of the turbine need to be input for the calculation (watt)
  • Generator power - This requires the voltage and current samples and the resistance of the alternator circuit.
    1. Output power (voltage * current) (Watts)
    2. Input power(approx) = output power + resistance * current2(Watts)
  • Efficiency - This requires the wind power and generator power samples.
    1. Total efficiency - Generator output power / wind power
    2. Turbine efficiency - Generator input power / wind power
  • Turbine statistics - This requires the wind speed and frequency samples and turbine radius.
    1. Tip speed - rotation speed * circumference (m/s)
    2. Tip speed ratio (TSR) - tip speed / wind speed

The top of a sample output file is below. The header contains the channel and line information and the calibrations used. Below this is the data items taken at second intervals.

CHANNELHDR,Id,Name,Lines,Active lines,order,cal[0],cal[1],cal[2],cal[3]
CHANNEL,1,Current DC,3,3,2,3.62500000,-0.00367000,0,0
CHANNEL,2,Voltage DC,3,3,2,0.09056200,0.03398700,0,0
LINECHANNELNAME,Time,Current DC,Current DC,Voltage DC,Voltage DC,Power,Power,Frequency,Frequency,Frequency,Wind,Wind,Wind,Wind,Efficiency,Efficiency,Turbine,Turbine,
LINENAME,Cooked,Raw,Cooked,Raw,Cooked,Power out,Power in,Raw,Hz,RPM,Raw,Speed,Delta,Power,P(out)/P(wind),P(in)/P(wind),Tip speed,TSR,

The software is currently being modified and refined as the system is used so no download is available. If you would like a cut of the code please drop me an email and I'll send the latest version.

I do not warrant the correctness of this content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted the terms of use. Copyright © 2024. All Rights Reserved. Privacy policy