Pages: [1]   Go Down
Author Topic: Wind Visualiser Project  (Read 759 times)
0 Members and 1 Guest are viewing this topic.
Newcastle Upon Tyne
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all.

First of all, thanks for any guidance/help throughout this project; it is all very much appreciated. My project is a visual and auditory experience that will be part of an exhibition in may next year. The idea is that through projections and sounds, the viewer/listener will be able to see and hear my abstract interpretations of the wind. This will be achieved via the use of Processing and Arduino.

At the moment, I am currently working on learning Processing and getting the arduino wired up and working, by 10/11/12 I aim to get the arduino part of the project fully functional. For wind input, a Vortex Wind Speed Sensor is used in conjunction with an arduino uno. The sensor itself is essentially a reed switch. When the reed switch contacts, 5V is diverted to ground which triggers an interrupt on pin 3. Below is a sketch of how the circuit will work:



The circuit fully wired up:



To test my circuit, I took code from a previous weather station project. I am currently getting serial readings, so I know my circuit works. If I let the wind sensor (reed switch) stop spinning however,it breaks: It will for example read 20 mph, then continuously read 0mph unless I reset the Arduino. I am wanting to strip down this code to its core functionality, as I won't really need to precisely measure wind speed: rather just 4 or 5 states of wind velocity. Before I do this I need to figure out why the counter isn't resetting after it reads 0. Please could someone explain to me what is wrong with the code below that stops wind speed being measured.

Code:
#define uint unsigned int
#define ulong unsigned long

#define PIN_ANEMOMETER 3 // Digital 3

// How often we want to calculate wind speed
#define MSECS_CALC_WIND_SPEED 5000

volatile int numRevsAnemometer = 0; // Incremented in the interrupt
ulong nextCalcSpeed; // When we next calc the wind speed
ulong time; // Millis() at each start of loop().

//=======================================================
// Initialize
//=======================================================
void setup() {
Serial.begin(9600);
pinMode(PIN_ANEMOMETER, INPUT);
digitalWrite(PIN_ANEMOMETER, HIGH);
attachInterrupt(0, countAnemometer, FALLING);
nextCalcSpeed = millis() + MSECS_CALC_WIND_SPEED;
}

//=======================================================
// Main loop.
//=======================================================
void loop() {
time = millis();

if (time >= nextCalcSpeed) {
calcWindSpeed();
nextCalcSpeed = time + MSECS_CALC_WIND_SPEED;
}
}

//=======================================================
// Interrupt handler for anemometer. Called each time the reed
// switch triggers (one revolution).
//=======================================================
void countAnemometer() {
numRevsAnemometer++;
}

//=======================================================
// Calculate the wind speed, and send to serial port.
// 1 rev/sec = 2.5 mph
//=======================================================
void calcWindSpeed() {
int x, iSpeed;
// This will produce mph * 10
// (didn't calc right when done as one statement)
long speed = 25000;//2.5 mph * 1000
speed *= numRevsAnemometer;
speed /= MSECS_CALC_WIND_SPEED;
iSpeed = speed; // Need this for formatting below

Serial.print("Wind speed: ");
x = iSpeed / 10;
Serial.print(x);
Serial.print('.');
x = iSpeed % 10;
Serial.print(x);
Serial.print(" mph,  ");

numRevsAnemometer = 0; // Reset counter


}

Resources used so far:
http://www.audon.co.uk/weather_sensors/vortex.html
http://openenergymonitor.org/emon/node/44 (code found in comments section that i've used to test the sensor)
http://timeinventorskabinet.org/wiki/doku.php/windclocks/anemometer
http://arduino.cc/forum/index.php?topic=116144.0
http://community.cosm.com/arduino/anemometer
http://www.qsl.net/on7eq/projects/arduino_davis.htm
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting project.

I don't know if it's your bug, but this line jumped out at me:

Code:
int x, iSpeed;

Shouldn't they be unsigned long, since speed is?

-br

Edit: never mind, I see they are the scaled output.

Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2592
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pin 3 is interrupt 1: http://arduino.cc/en/Reference/AttachInterrupt
Logged

Newcastle Upon Tyne
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


thanks for the quick reply, its appreciated. Just tested it and it works as intended now.

For anyone interested in this project: I will keep this thread updated with my progress. I imagine I will come across more issues at some point.
Logged

Pages: [1]   Go Up
Jump to: