# Control Wind Turbine with stepper motor and Arduino uno

Dear Everybody

I am doing a project with Arduino Uno in wind energy,
I have designed a wind turbine with pitch control mechanism.
This mechanism is using a stepper motor connected with bevel gear and three pinion gears
The stepper motor is located at the hub of the wind turbine and connected directly to the bevel gear and pinions, the pinions are connected with the blades
The blades are rotating as the stepper motor starts and the angle of attack with the wind is changing.
The stepper motor is connecting with slip ring going through the turbine generator then connected with Arduino. I want to control the stepper motor using the Arduino.

The Arduino Uno is connecting with H-bridge L298 and I will connect stepper driver CWD556 later to control the motor.

The ratio between the gears is 1:3

My generator connecting with this turbine is Ginlong GL-PMG 1500
http://www.ginlong.com/en/pro_detail/mid/3/tid/36/id/36.html
The current max is 30A the voltage max is 70V

The stepper motor is 57HS22 which has 2.2NM
I have Current sensor ACS712, And Voltage divider, And RPM sensor E18-D80NK
I am trying to develop the code right now

The scenario:

I want the stepper motor to move 7 steps each step 2 degrees at the blades angle (that means from 14 degree to 0 at the blades)
At each step the stepper reads the current and the voltage then calculates the power and also read the rpm each second for one minute (means 60 reading for one min) then take the average of the power and the rpm. After that move to the next step (which is 12 degree at the blades angle) and repeat the same process.
After reading the 7 averages move back to the step associated with the highest power (I will take the rpm for the data only)
Then repeat this process of searching for the highest power each 5 min.

The Code:

``````#include <Stepper.h>

const float DEGREE =  1.8;
const int StepsPerRevolution = 1;
//gear ratio 1:2
float steps = 0.5; // half degree = 0.9 // step number = 10
float anglelimit = 5*DEGREE;//9degrees
float next;

Stepper myStepper(StepsPerRevolution, 8,9,10,11);

float Voltage;
float Current;
float Power = 0.0;
float maxPower = 0.0;
float RPM;
float VoltageDivider;
float CurrentSensor;
float RPMSensor;

int i = 0;
int index;
int maxposition;
float total = 0;
float averages[8];
int pot;

void setup()
{

myStepper.setSpeed(1 * 60);

}

void loop(){
scanpositions();
myStepper.step(-1 * steps * (14- 2*maxposition));

delay(5*60*1000);

}

void  scanpositions()
{
for(  index = 0; index <8; index++)
{

for(i=1; i<=60; i++)
{

Voltage = VoltageDivider * 70 / 3.8;
Current = CurrentSensor * 30 / 5;

Power = Current * Voltage + Power;
RPM = RPMSensor;
delay(1000);
}
averages[index] = Power / 60;  //average power

if (maxPower <  averages[index]){

maxPower = Power;
maxposition = index;
}

myStepper.step(steps*next); //next position

}
// power = 0
}
``````

I want to check the code, and I am trying to read from rpm sensor but I do not know the way to control it and read from it.
and I am trying to find a way to collect the data to a text file outside Arduino.

Thank you very much

First - please modify your Post and use code tags (the button ‘</>’)

``````so your code looks like this
``````

HumamARDUINO:
I want the stepper motor to move 7 steps each step 2 degrees at the blades angle (that means from 14 degree to 0 at the blades)
At each step the stepper reads the current and the voltage then calculates the power and also read the rpm each second for one minute (means 60 reading for one min) then take the average of the power and the rpm. After that move to the next step (which is 12 degree at the blades angle) and repeat the same process.
After reading the 7 averages move back to the step associated with the highest power (I will take the rpm for the data only)
Then repeat this process of searching for the highest power each 5 min.

Are you building an experimental system that is powered by a steady flow of air produced by some sort of wind tunnel?
OR
Are you designing something to work in the outdoors with the natural airflow?

AFAIK the natural airflow varies very quickly - which would seem to require a much faster response from your system than an adjustment every minute.

Also AFAIK the usual control system is one which maintains a constant RPM by varying the load - however that is probably more important for an AC grid-connected system which must maintain the correct phase relationship with the grid.

How are you planning to match the load to the changing angle of attack and the changing wind speed? That sounds complex.

Stepper motors are very inefficient and may consume a significant proportion of the generated power. A simple DC motor with a worm gear may be more suitable as it will hold position without any power.

…R

First, thank you for response

This is experimental system not for the outdoors and it is off-grid as well.

I am trying to develop the code to do that task, later on I may change the motor.

I am still trying to develop my programming, i am trying to collect the data to outside arduino and to connect the rpm senor but still i do not have an idea how to do that?

Hi,

Also AFAIK the usual control system is one which maintains a constant RPM by varying the load - however that is probably more important for an AC grid-connected system which must maintain the correct phase relationship with the grid.

Sorry the wind turbines do not turn synchronized with the grid, they operate at maximum efficiency, then supply a DC bus, which is inverted synchronously into the grid.

Tom.... :)

TomGeorge:
they operate at maximum efficiency, then supply a DC bus, which is inverted synchronously into the grid.

Thanks Tom. Now that you say it that makes obvious sense.

…R

HumamARDUINO:
I am still trying to develop my programming, i am trying to collect the data to outside arduino and to connect the rpm senor but still i do not have an idea how to do that?

Break your learning into small pieces. Write a program to collect data from a rotation sensor (perhaps a hall effect sensor or an optical sensor - or maybe an encoder) and display the data in the Serial Monitor. To start with just rotate the device by hand, or with a small slow motor - an electric screwdriver might be convenient.

…R

Robin2: Break your learning into small pieces. Write a program to collect data from a rotation sensor (perhaps a hall effect sensor or an optical sensor - or maybe an encoder) and display the data in the Serial Monitor. To start with just rotate the device by hand, or with a small slow motor - an electric screwdriver might be convenient.

...R

OK then after display the data in the serial monitor i need to copy the data to a text file outside arduino program how can i do that?

HumamARDUINO:
OK then after display the data in the serial monitor i need to copy the data to a text file outside arduino program how can i do that?

Get it working with the serial monitor first, and only then worry about other stuff.

If you use another terminal program such as puTTY instead of the Serial Monitor you can get it to save the data to a file - assuming that is all you require.

…R

Robin2: Get it working with the serial monitor first, and only then worry about other stuff.

If you use another terminal program such as puTTY instead of the Serial Monitor you can get it to save the data to a file - assuming that is all you require.

...R

I did display some data to Arduino serial monitor now, could inform me how to connect the puTTY to arduino now or if you have some example

Hi, How will you know the initial pitch position when you start? The stepper does not know where it is when you start.

Tom.... :)

HumamARDUINO: I did display some data to Arduino serial monitor now, could inform me how to connect the puTTY to arduino now or if you have some example