- Overview
- Data Processing & Plotting
This is a project based on one of my Bath University project week studies:
The objective of this project week is to build a simple wind turbine and convert some of the wind energy into electrical energy. You will have to test different mini wind turbine designs to assess which one is the best to harvest energy in different wind conditions. It is a competition; the best wind turbine—the one harvesting the most energy for a specific wind condition that we will reveal near the end of the week—will win.
In short, our task was to build the most efficient wind turbine. We then ran tests in a controlled environment and calculated the results based on the data collected. I took this project to the next level and automated a lot of the calculations using MATLAB.
We were handed many parts to build a mini wind turbine. Mainly, we were given:
- 3 fans of different sizes: Each fan had a different blade diameter, allowing us to explore how rotor size influences the amount of air intercepted and, consequently, the electrical power generated. Larger blades captured more wind energy but required greater torque to spin efficiently, while smaller ones spun faster but generated less power.
- 3 different generators: A brushed DC motor consists of a rotating armature wound with coils, stationary magnets, and a commutator with brushes. When powered, the stationary magnets create a magnetic field, which interacts with the magnetic field generated by the current flowing through the armature. This interaction generates a torque that causes the armature to rotate.
- 3 different capacitors: A capacitor stores energy and releases it to smooth out the fluctuations in the voltage.
- A 47kΩ resistor: It will be used to help limit the current.
- Gears and Shaft Assembly: The shaft is used to secure the blade and transmit the motion to the gears, which, in turn, increase the speed at which the motor is being rotated.
From there, we followed the assembly instructions below for the motor and housing:
and for the turbine blades:
We relied on a wind tunnel to run our project in a controlled environment to collect accurate data:
The wind tunnel is a vital tool that simulates various wind conditions under controlled settings, enabling a thorough evaluation of how different wind speeds affect the energy harvesting capability of your turbines.
The testing setup includes the following:
- Wind Tunnel which is controlled through the measurement software to simulate wind at a range of speeds.
- Mast base which is used to hold the wind turbine.
- Wind sensor which measures the wind speed inside the wind tunnel.
- Oscilloscope that can be used to view and save the waveform of the electrical signal generated.
- Measurement software that uses the readings from your circuit (on the breadboard) and input from the wind sensor to output a CSV file that includes tabulated values of voltage at a range of wind speeds.
It's important to note that the test setup produces the following CSV format (no header):
- Column 1 → wind speed, m/s
- Column 2 → voltage across the load, V
- Each row corresponds to a fixed sampling period (default 4 s).
The data automation can be found in the MATLAB project directory. It processes voltage–speed logs from the wind-turbine rig to estimate energy harvested under different design setups and wind speeds, and then plots the results so you can pick the most suitable setup for a target speed.
- Calculate energy per speed bin for each CSV (one CSV ≈ one setup/test run).
- Aggregate results into
summary_data.xlsx(Sheet1). - Summarize winners and totals in
summary_data.xlsx(Sheet2). - Plot total energy harvested vs. wind speed for all setups.
.
├── data/ # put your CSV logs here
│ ├── T4_RED_L22_C68.csv
│ ├── T5_RED_L22_C100.csv
│ ├── T6_RED_L22_C47.csv
│ ├── T7_BLUE_L22_C68.csv
│ └── ... (other CSV files)
├── MATLAB_AUTOMATE.m # batch runner
├── MATLAB_CALCULATOR.m # computes and updates sheets
├── MATLAB_PLOTTER.m # plots multi-line graph
├── summary_data.xlsx # spreadsheet with results
├── graph.png # plot (generated)
└── WindEnergyProject.prj
Place one CSV per setup/test run. Filenames can be any valid name; the file base name becomes the column title in the spreadsheet.
Open MATLAB_AUTOMATE.m to override defaults if needed:
R_load_ohm = 47e3; % load resistance (ohms)
dt_per_row_s = 4.0; % sampling period per row (s)
binWidth_mps = 0.20; % total speed-bin width (m/s) -> ±0.10 around each bin centreThe bin centres are read from column 1 of
summary_data.xlsx(Sheet1). If the file does not exist yet, the calculator initializes a typical range (e.g., 2–6 m/s). You can edit these later and re-run.
In MATLAB, set the current folder to the project root and run:
run('MATLAB_AUTOMATE.m')What it does:
- Deletes any existing
summary_data.xlsx(clean start). - Iterates over
data/*.csv, runningMATLAB_CALCULATOR.mon each file. - Rebuilds Sheet2 (winners & totals) from Sheet1.
- Calls
MATLAB_PLOTTER.mto creategraph.png. - Prints the final Sheet1 to the console.
summary_data.xlsx- Sheet1: per-speed energies (J) for each setup (one column per CSV).
- Sheet2:
- BySetup: total/mean energy, number of speeds with data, max and speed-at-max, ranked by total.
- PerSpeed winners: best setup and energy for each speed.
- Parameters: R, dt, bin width used (for auditability).
graph.png: multi-line plot of energy vs. speed.
Wind speed is not perfectly constant during a run. To compare designs fairly, we group measurements into speed bins (e.g., “the 3 m/s bin covers 2.9–3.1 m/s”). This:
- keeps “3 m/s” data together even with small measurement jitter;
- prevents a setup that happened to see more high-speed moments from looking unfairly better;
- lets you choose the best setup for a specific test speed once it’s announced.
Bin centres come from the first column in Sheet1 (labelled Speed), and we use a window of ±(binWidth/2) around each centre (default ±0.10 m/s).
From each voltage sample, we estimate power using the load resistor:
To get energy within a bin, we add up power over time using the trapezoid rule on consecutive samples that both lie inside the bin:
where
Important: we do not draw trapezoids across gaps where the speed jumps out of the bin (no “bridging”). This counts only energy truly produced while the wind was around that bin’s speed.
-
Per-speed winner: for each speed bin, the setup with the largest
$E(s)$ is the best choice if your test is run at that speed. - Overall “most efficient”: we rank setups by total energy across all speeds available:
This answers: “Which setup tends to harvest the most energy across the tested range?”
We also store the mean across speeds (Mean_J) and the max and its speed (Max_J, Speed_at_Max) to give more context.
We leave missing speeds as NaN and only plot the points that exist. We do not replace missing data with zeros—otherwise, a gap could be misread as a “measured zero”.


