Interfacing with inspeed anemometer

I am currently researching how I can interface my inspeed anemometer to my arduino. I have been googling a few ideas that I had, but I am still not clear on what is the best approach and more importantly there are a few things regarding the coding that are confusing me.

Basically the anemometer gives out a pulse once per revolution and apparently the windspeed in 2.5mph per pulse per Hz.

Anyway my ideas of implementing the interface were in order of preference:

1) Using the onboard counter to count the number of pulses on a regular basis over a 3 second intervals

2) Use an interrupt to count the pulses

3) Poll the pin.

So regarding the onboard counter I couldn't find much info on how to initialize them and actually use them. I found one page where the code is confusing me and I can't find any info on how to use the functions in the library. Does anyone know what functions I can use to configure and use the onboard counter as I think this could be the best approach for me.

The interrupts approach is probably also an option. As I have more sensors to interface to, I don't want interrupts being triggered all the time and possibly affecting the timing on other interfaces. I was looking at a way of disabling interrupts and only enabling them for say a 3 second period when I wanted to check the windspeed. I saw some examples of this and a function cli(); but I cannot find info on the arduino page regarding this function. Is this the manner in which interrupts can be disabled? If I am unable to get the counter working this too could be a viable option if I was able to enable and disable interrupts when I wanted (perhaps even simpler than using the counter)

The polling technique would be the easiest and a method that I could implement straight away, but it has its disadvantages and I would like to understand how to use the counters or interrupts before resorting to that.

I'd be interested to hear the thoughts of anyone on the above methods, which would be best etc and also if anyone could shed some light on enabling disabling interrupts and using the counters I'd be very grateful.

Many thanks for the help

There are much easier ways to do what you want. You can use pulseIn to measure the duration of your anemometer pulses. The wind speed in MPH will be the value from pulseIn times 25 divided by 10000000

You can set pulseIn to timeout at 2 seconds (20000000) and if you get this value you can assume the wind speed is effectively 0.

But if you really want to use the low level hardware to do the measurements, have a look at Input Capture in the ATmega datasheet. This uses a 16 bit timer to measure the pulse width in hardware. But other then the learning opportunity, I don't think there is anything to gain from the much greater learning curve needed for this approach.

Didn’t we do this one a couple of weeks ago?

pulseIn() will only give you the duration of the HIGH or LOW pulse from the anemometer. You need the period of the squarish wave coming from the anemometer. Unfortunately, in the case of this sensor, the waveform is not very symmetrical so you can't just double the HIGH or LOW value.

The sensor signal will have to be debounced and then the period could be measured any number of ways with the Arduino.

With my anemometer, the duration of the off pulse is proportional to the speed, but if you wanted to get the on and off time you could alternate between HIGH and LOW readings from pulseIn. This would actually measure every other revolution but unless the wind speed was fluctuating at an alarming rate , I would expect the readings to be useful.

If this is the same Vortex anemometer we were discussing the other day, then it has a reed switch and magnet. In that case, the on/off ratios are definitely not consistent.

Reed switches have a very non-linear response time with respect to the magnet speed. What happens is that for low speeds the reed closes for a period relatively proportional to magnet speed. At some speed related to the size of the switch and the strength of the magnet the switch stays closed for a relatively constant time per period while the open time is proportional to speed. That has to do with contact mass and momentum. As the speed increases the closed time starts to be more proportional to period and then at some point it drops out all together.

A simple R-C-diode + Schmidt-trigger circuit works pretty well for reed switch de-bouncing, in my experience.

Thank you for the responses so far. I did see a post here before using the pulseIn function, but I suppose to help me learn I was interested in trying to do something with the timers or interrupts. I'd be also interested to hear if anyone has experience using these features. Maybe they could point me in the right direction.

The pulseIn method is an option and I am very grateful for the suggestions and the help but I am also interested in exploring these other methods.

Many thanks for the help