Pages: [1]   Go Down
Author Topic: Interfacing Anemometer  (Read 2445 times)
0 Members and 1 Guest are viewing this topic.
Minneapolis, MN
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduinotecture
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I purchased a weather station from spark fun and am having difficulty getting consistent readings. I figured the best way to explain the issues I am having would be to make a quick video.  I am using Zitron's code from the following post:

http://www.arduino.cc/playground/Main/ReadingRPM


[media]http://www.youtube.com/watch?v=dRZ8Z3nZ2dA[/media]

Weather station from Sparkfun:

http://www.sparkfun.com/commerce/product_info.php?products_id=8942

And the code:

Code:
//-----------------------------------------------

 volatile byte rpmcount;

 unsigned int rpm;

 unsigned long timeold;

 void setup()
 {
   Serial.begin(9600);
   attachInterrupt(0, rpm_fun, RISING);

   rpmcount = 0;
   rpm = 0;
   timeold = 0;
 }

 void loop()
 {
   if (rpmcount >= 20) {
     //Update RPM every 20 counts, increase this for better RPM resolution,
     //decrease for faster update
     rpm = 30*1000/(millis() - timeold)*rpmcount;
     timeold = millis();
     rpmcount = 0;
     Serial.println(rpm,DEC);
   }
 }

 void rpm_fun()
 {
   rpmcount++;
   //Each rotation, this interrupt function is run twice
 }

//-----------------------------------------------


Thank you!!!
Logged

Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Reed switch contacts bounce.  Sometimes a lot.

Rather than using fan RPM code as your example,  you should look for projects like home-made bicycle computers,  that are also likely to use reed switch inputs,  and have periods more like that of the anemometer.

Also do some googling for "switch debounce circuit" to get some ideas for cleaning up your anemometer input.  You may still decide to do it all in software,  but there are some cheap and simple ways of getting rid of nearly all the "bogus" pulses in hardware.

Ran
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You may also want to consider adding some 1-Wire chips to your weather set up. Not "trivial", but not impossible, either.

There are some very nice temperature sensor chips.

But what made me think of 1-Wire is that there is a 1-Wire counter chip which would take a LOT of work out of monitoring that anemometer.

Once you have one 1-Wire chip in your setup, adding more is easy... they all share one pair of wires.

There are many weather recording enthusiasts on the web using 1-Wire at the heart of their systems. A starting point...

http://www.arunet.co.uk/tkboyd/e1didx.htm

As for bounce: It is a real problem, but I've had several reed switch based anemometers connect directly to the 1-Wire counter over the years (and to rain tipper reed switches, for that matter) without having to do anything special about bounce. Maybe the counter has bounce-ignoring circuits. Not sure. But I know I can connect reed switches to that counter without hassle.
« Last Edit: February 02, 2010, 01:35:53 pm by tkbyd » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is the 1-wire chip you are referring to has been discontinued. I have the same setup and using interrupts for both the speed and rain and at higher speeds seeing some really odd high readings for wind speed and was wondering what was going on.
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
... chip has been discontinued...

All the more reason to buy a counter module quickly!

http://www.hobby-boards.com/catalog/product_info.php?products_id=43

(The extra charge for assembled and tested is worth it in my opinion... but isn't it nice to have a choice! Support this supplier... with whom I am not connected, by the way.)
Logged

Minneapolis, MN
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduinotecture
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the help everyone.

The anemometer is working great! The debouncing circuit solved my issues:


Here is my current schematic:



And the code:

Code:
volatile byte count;

unsigned int duration;

unsigned long timePrevious;

float windSpeed = 0;

int windVein = 0;

void setup()
{
  Serial.begin(9600);
  attachInterrupt(0, arduino_anemometer, RISING);

  count = 0;
  duration = 0;
  timePrevious = 0;
}

void loop()
{
  
  windVein = (analogRead(windVein));
  if (count >= 1) {
    duration = (millis() - timePrevious);
    timePrevious = millis();
    count = 0;
    windSpeed = (1492/duration);
    Serial.print(windSpeed,DEC);
    Serial.print(" MPH");
    Serial.print(",");
    Serial.println(windVein);
  }
}

void arduino_anemometer()
{
  count++;
}
Logged

Pages: [1]   Go Up
Jump to: