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
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
}
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.
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.
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.
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?