Control a Wind Turbine Direction thanks to a program

Hi, to begin with, thanks for your future answers,
Our project is to give our small Wind Turbine the better direction possible influenced by the wind direction to optimise the productivity of our project.

So for the material we have:
-common Arduino card + Shield if needed

Thanks for your future answers

Louis.

Did you ask any question and I missed it?

The common way to make the turbine have the best direction into the wind is giving it a tail with a vertical fin. Used for a few hundred years....

3 Likes

A lot more description is needed, There are wind turbines that are vertical and respond the same to wind from any direction.

Looks like that wind vane only indicates 8 different directions, each represented by a different resistor. They recommend a 10k pull-up resistor and that should give the following analog input values:

int GetWindDirection(const byte vanePin)
{
  int vane = analogRead(vanePin);
  if (vane < 769) return 315; // North-West
  if (vane < 803) return 225; // South-West
  if (vane < 830) return  45; // North-East
  if (vane < 855) return 270; // West
  if (vane < 875) return 135; // South-East
  if (vane < 908) return   0; // North
  if (vane < 938) return  90; // East
  return 180; // South
}
2 Likes

+1 for @Railroader suggestion. Why introduce complexity when a simple solution has existed for 100's of years?

1 Like

How will you force the turbine to turn to the most productive direction? You have not listed any type of motor or other device.

We are contacting you to clarify our request for assistance.

We are students, and we have to carry out a project for our course. We have to build a wind turbine.

Our project is divided into two parts:

  • A safety part: an anemometer indicates the wind speed to the Arduino board, if this speed exceeds a fixed speed limit, our servo-motor rotates 90°. This part has already been done.

  • An optimization part, where this time we use a wind vane, which works like a potentiometer, and the idea is to make our engine follow the direction of the wind. It is for this part that we contact you.

Concretely, the weather vane has 8 directions, each corresponding to a different resistance value. So it's a different voltage that is sent back to the Arduino board. We need help because we are totally new to Arduino programming, and we would like help in making a program that allows us to rotate the motor in the direction that our wind vane indicates to us.

I attach below the program that we have:

#include <EnableInterrupt.h>     // https://www.arduino.cc/reference/en/libraries/enableinterrupt/

#include <Servo.h>

 

unsigned long displayTimer = millis();     // Tempo pour affichage

 

#define anemometrePin A2     // Pin ou est connecté l'anémomètre

 

float anemometreKmH = 0.0;     // Vitesse du vent

const float anemometreKmHimpuls = 2.4;     // KmH par impulsion

volatile int anenometreImpulsions = 0;     // Compteur d'impulsions 1/sec = 2.4 kmH

 

unsigned long anemometreTempoStart= millis();     // Début periode de comptage

int anemometreTempo= 2;     // Période de comptage 2sec.

 

#define servoAnemoPin A0     // Pin ou est connecté le servo (Ex pluvio)

int servoPositionBas = 20;     // Position bas en degrés

int servoPositionHaut = 110;     // Position haut en degrés

 

Servo servoAnemo;  // creation de l'objet servo

int servoPosition = 0;     // Position actuelle

const float servoActionLimite = 5.0;     // Limite d'action

 

void setup()

{

  Serial.begin(9600);

 

  pinMode(anemometrePin, INPUT_PULLUP);

  enableInterrupt(anemometrePin, anemImpulsionMesure, RISING);

 

  servoAnemo.attach(servoAnemoPin);  // Attacher le servo sur la pin servoAnemoPin

 

  Serial.println("\nProchaine mesure dans " + String(anemometreTempo) + " secondes");

  servoAnemo.write(servoPositionBas);

}

 

void loop()

{

  if (millis() - anemometreTempoStart >= (anemometreTempo*1000))     // Toutes les anemometreTempo millisecondes

  {

    anemometreKmH = ((float)anenometreImpulsions * anemometreKmHimpuls)/(float)anemometreTempo;

 

    Serial.print("Vitesse " + String(anemometreKmH) + " km/h");

 

    anenometreImpulsions = 0;

    anemometreTempoStart = millis();

   

    if (anemometreKmH <= servoActionLimite)

    {

      servoPosition = servoPositionBas;

    }

    else if (anemometreKmH > servoActionLimite)

    {

      servoPosition = servoPositionHaut;

    }

    Serial.println("\tServo = " + String(servoPosition));

    servoAnemo.write(servoPosition);

  }

}

//     Traitement de l'interrupt

void anemImpulsionMesure()

{

  anenometreImpulsions ++;

}

I also send you the information on the sensors, given by the site that sells the products (sorry the site is in French), as well as photos of the assembly, for the connections.
I thank you in advance for your time.

1 Like

Again, how will this happen and how will you power the motor. The motor MUST hold the position while the wind tries to make it move, so power must be continuous.

Start by performing an analogRead() on the input from the resistance ladder. Determine the values read at the different directions. When you know the value of each direction, you can set up some tolerances. Once you can easily differentiate each of the 8 direction readings, you will be ready to move on the actions you want to take for each reading.

EDIT: See @johnwasser reply #5.

1 Like

...or a worm gear, designed so that it is self-locking, can be used, in which case power need not be continuous.

Other gear systems, such as one with a high reduction ratio, can be self-locking.

1 Like

But neither of those designs will be able to move the turbine fast enough to keep up with the wind.

Maybe, maybe not. Depends on the (unstated) design criteria.

And how far their devices are away from buildings, trees, etc.

Thanks for posting the code.

Since we do not have your setup, and for development, I'd simulate the wind with something like:

void simulateWind(void){
  // per https://forum.arduino.cc/t/control-a-wind-turbine-direction-thanks-to-a-program/962692

  const unsigned long interval = 100UL;
  static unsigned long last = -interval;
  static int tick = 0;
  static float speed = 0;
  static float direction = 0;
  const float vaneResistanceK[] ={64.4,39.2,99.7,54.4,119.4,33.8,47.1,27.2};
  const float vanePullupK = 10;
  int dirIndex;
  float simImpulsions = 0;
  if(millis() - last >= interval){
    if( tick == 0 ){ //choose a different direction 
       speed = 0.1*random(0,1000);
       direction = random(0,359);
       Serial.print("simulateWind: ");
       Serial.print(speed);
       Serial.print("km/h, ");
       Serial.print(direction);
       Serial.println("°");
    }
    // update simulation time
    tick = (tick + 1) % (30000/interval) ; // every 30 seconds... 
    last += interval;
    // update sensors with simulated data:
    dirIndex = floor(direction/45);
    simImpulsions += speed * interval/ 1000 /anemometreKmHimpuls;
    noInterrupts();
    anenometreImpulsions += floor(simImpulsions);
    interrupts();
    simImpulsions -= floor(simImpulsions);
    // windvane pot per https://forum.arduino.cc/t/control-a-wind-turbine-direction-thanks-to-a-program/962692/5
    simAnalogPin= 1023*vaneResistanceK[dirIndex]/(vaneResistanceK[dirIndex]+vanePullupK);
  }
}

and post it in into a functional Wokwi like this, for folks to play with:

A smart system would not attempt to respond to every little twitch of the wind vane from turbulence caused by trees, buildings, etc. Some form of smoothing should be used.

Their vane is quite crude and can only indicate 45 degree sectors, so their control system needs to be able to nicely[*] handle the condition when the "average" wind is near the transition between two sectors and the vane switches between the two sectors every few milliseconds or seconds.

[*] "nicely" = holds the turbine near the average direction and doesn't try to swing it 45 degrees with each vane transition between sectors.

1 Like

All true, but we are dealing with a middle school class project.

It will be an interesting and fun challenge for them!

First of all, we thank you for all your answers, we are indeed still in school and our project should not be sophisticated but should just meet the specifications.
Our wind turbine should only be oriented according to the wind direction without worrying about other disturbances like the environment.

All this to say that we are looking for a simple program that just makes the wind turbine turn in the direction indicated by the wind vane.

We are sorry we have no knowledge in Arduino, can you help us to make this program?


Our montage