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.

RUNHDR,1323773465484,40,20
CHANNELHDR,Id,Name,Lines,Active lines,order,cal[0],cal[1],cal[2],cal[3]
CHANNEL,0,Time,3,2,2,0.00000000,0.00100000,0,0
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
CHANNEL,3,Power,3,3,2,0.00000000,1.00000000,0,0,4.800,1.400
CHANNEL,5,Frequency,15,7,2,0.00000000,0.25000000,0,0
CHANNEL,6,Wind,31,27,2,0.52329999,0.82139999,0,0,0.454,1.200
CHANNEL,7,Efficiency,3,3,2,0.00000000,1.00000000,0,0
CHANNEL,8,Turbine,3,3,2,0.00000000,1.00000000,0,0,0.380
LINEDATASTART
LINECHANNELID,0,1,1,2,2,3,3,5,5,5,6,6,6,6,7,7,8,8,
LINECHANNELNAME,Time,Current DC,Current DC,Voltage DC,Voltage DC,Power,Power,Frequency,Frequency,Frequency,Wind,Wind,Wind,Wind,Efficiency,Efficiency,Turbine,Turbine,
LINEID,1,0,1,0,1,0,1,0,1,2,0,1,3,4,0,1,0,1,
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,
LINEDATAEND
DATA,462.788,992.136,0.000,329.624,11.293,0.000,0.000,24.194,6.048,362.903,2.970,2.963,-0.039,7.081,0.000,0.000,14.441,4.874,
DATA,463.789,993.358,0.000,328.744,11.264,0.000,0.000,23.324,5.831,349.854,2.593,2.653,-0.310,5.083,0.000,0.000,13.922,5.247,
DATA,464.788,960.610,0.100,336.150,11.515,1.203,1.574,29.970,7.493,449.550,4.921,4.566,1.913,25.904,0.046,0.061,17.889,3.918,
DATA,465.788,879.924,0.396,353.368,12.100,5.061,7.347,39.880,9.970,598.205,6.336,5.728,1.162,51.141,0.099,0.144,23.805,4.156,
DATA,466.789,846.330,0.519,364.120,12.466,6.836,10.221,43.744,10.936,656.155,7.260,6.486,0.759,74.277,0.092,0.138,26.111,4.026,
DATA,467.788,860.868,0.466,365.336,12.507,6.147,9.036,42.490,10.623,637.352,6.780,6.092,-0.394,61.542,0.100,0.147,25.362,4.163,
DATA,468.789,840.760,0.539,372.374,12.746,7.265,10.867,44.776,11.194,671.642,6.404,5.784,-0.308,52.665,0.138,0.206,26.727,4.621,
DATA,469.788,888.904,0.363,365.966,12.529,4.770,6.741,39.918,9.980,598.772,5.780,5.271,-0.513,39.867,0.120,0.169,23.827,4.520,
DATA,470.789,946.614,0.151,353.148,12.093,1.907,2.514,33.199,8.300,497.988,4.242,4.007,-1.264,17.518,0.109,0.144,19.817,4.945,
DATA,471.788,974.882,0.047,341.930,11.712,0.572,0.714,28.656,7.164,429.842,3.571,3.457,-0.551,11.244,0.051,0.064,17.105,4.948,
DATA,472.788,958.816,0.106,342.368,11.727,1.289,1.647,30.785,7.696,461.768,5.165,4.766,1.309,29.468,0.044,0.056,18.375,3.855,
DATA,473.789,934.248,0.196,347.178,11.890,2.431,3.241,33.966,8.492,509.491,4.625,4.323,-0.444,21.983,0.111,0.147,20.274,4.690,
DATA,474.788,935.588,0.191,347.700,11.908,2.374,3.158,34.000,8.500,510.000,4.348,4.095,-0.228,18.685,0.127,0.169,20.295,4.956,
DATA,475.789,936.136,0.189,347.716,11.908,2.349,3.124,33.898,8.475,508.475,5.411,4.968,0.874,33.376,0.070,0.094,20.234,4.073,
DATA,476.788,952.844,0.128,343.240,11.756,1.560,2.014,31.600,7.900,474.006,4.831,4.491,-0.477,24.661,0.063,0.082,18.862,4.200,
DATA,477.789,948.790,0.143,343.436,11.763,1.744,2.269,32.132,8.033,481.986,4.167,3.946,-0.546,16.721,0.104,0.136,19.180,4.861,
DATA,478.788,967.050,0.076,338.778,11.605,0.912,1.154,29.502,7.375,442.523,3.774,3.623,-0.323,12.943,0.070,0.089,17.610,4.861,
DATA,479.789,981.106,0.024,333.834,11.437,0.288,0.360,26.946,6.737,404.192,2.994,2.983,-0.640,7.222,0.040,0.050,16.084,5.393,
DATA,480.788,988.058,0.000,331.372,11.353,0.000,0.000,25.458,6.365,381.874,2.662,2.710,-0.273,5.416,0.000,0.000,15.196,5.608,
DATA,481.788,990.926,0.000,330.380,11.319,0.000,0.000,24.704,6.176,370.553,2.331,2.438,-0.272,3.944,0.000,0.000,14.746,6.048,
DATA,482.789,974.038,0.050,333.830,11.436,0.598,0.759,28.056,7.014,420.842,3.530,3.423,0.985,10.919,0.055,0.070,16.747,4.892,
DATA,483.788,937.008,0.186,342.694,11.738,2.288,3.068,33.268,8.317,499.022,6.054,5.496,2.073,45.198,0.051,0.068,19.858,3.613,
DATA,484.789,870.980,0.429,358.568,12.277,5.568,8.148,41.123,10.281,616.851,7.209,6.445,0.948,72.862,0.076,0.112,24.547,3.809,
DATA,485.788,775.748,0.778,381.194,13.046,10.810,17.250,51.000,12.750,765.000,8.073,7.154,0.709,99.666,0.108,0.173,30.442,4.255,
DATA,486.789,779.108,0.766,390.168,13.351,10.865,17.191,51.360,12.840,770.393,8.316,7.354,0.200,108.256,0.100,0.159,30.657,4.169,
DATA,487.788,816.110,0.630,388.050,13.279,8.862,13.524,48.096,12.024,721.443,7.759,6.897,-0.457,89.296,0.099,0.151,28.709,4.163,
DATA,488.788,755.156,0.854,403.190,13.794,12.523,20.053,54.326,13.581,814.889,8.467,7.478,0.581,113.811,0.110,0.176,32.427,4.336,
DATA,489.789,759.124,0.839,407.634,13.945,12.434,19.788,54.348,13.587,815.217,8.105,7.181,-0.297,100.793,0.123,0.196,32.440,4.517,

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 © 2017. All Rights Reserved. Privacy policy