maximum interrupt frequency

Hello,

I'd like to hook my arduino to a cheap anemometer (wind speed meter) which simply closes a magnetic reed switch on every revolution. The meter is calibrated so one revolution per second = 2.5MPH of wind speed. I'd like to code the arduino to have an interrupt for the reed switch closing where it would simply increment a counter. My question is this. If the wind is blowing hard, say 50MPH or even a gust of 60MPH, that would mean the switch is closing 24 times per second, or every ~41ms. Do you think the arduino can break out to the interrupt, increment the count, and come back and be ready to handle the next interrupt in 41ms? Also, do you think the arduino would even see the switch closing at this speed?

I'd be willing to offload this counting to an IC if anyone knows of one that's through-hole and either i2c or 1-wire. I don't want to use up 8 or more arduino pins just for this, the arduino is doing more than just this. Maxim made a counter for a while but it's not "recommended" anymore and it was surface mount anyway.

Thanks for any advice.

Keep the interrupts simple (i.e. just increment a counter and return) and 45ms is no problem.

41ms is no problem. However, mechanical switches (including reed switches) may "bounce" and cause you problems.

(for reference, the timer interrupt that drives millis() is once every 1.024ms, and the serial port running at 38400kbps generates an interrupt about every 250us.)

Great info....thanks so much.

Yeah, I was worried about the bounce, and moreso the fact that the switch would be closed for such short time that the arduino wouldn't even see it. They sell this same anemometer with a bicycle computer that does essentially the same thing as I want the arduino to do, but I want an easy interface with a computer, hence the arduino. I'm thinking if a bicycle computer can do it, the arduino should be able to, but then again, they might be using a specialized IC to do the counting. I haven't found one to use yet.

Thanks again.

Why not use an opto switch, no contact bounce with that. Here is a picture of one I made earlier (June 85) :-

http://www.doc.mmu.ac.uk/STAFF/A.Wiseman/Acorn/BodyBuild/BB_85/BBC27.TIFF

Yeah, I know....making it myself though was something I wanted to try to avoid. I kind of know my limitations that way :slight_smile: I'd rather buy one already made if at all possible. I'll look around for one with an opto switch, that's a good suggestion. Wonder if it'll put it out of the price range, these things get expensive fast....thanks again.

I would like to make one but I want to measure the speed and send the data to computer. I am very new on this and I need some kind of code for it. Can someone share the code for it? I have the opto switch with rod with plastic easter egg. I dont know how to read the opton and send the data to computer to tell me the speed. I want to make the graph on excel for the speed and time like what the speed in the morning and noon and evening.

I'd be glad to help with the code (I'm assuming you're here because you have an arduino ready to go). The tough thing from my perspective, and there's probably some easy science to it if you search, is knowing what speed of wind in km/h or miles/h or whatever unit you'd like corresponds to one rotation of your anemometer per unit time. So you need to figure out that one rotation per second of your anemometer = X km/h of wind speed. Once you have that, the code will be fairly straight forward.

what speed of wind in km/h or miles/h or whatever unit you'd like corresponds to one rotation of your anemometer

Work out the circumference of your anemometer call it C. Then if it goes round once per second the wind is going at C units per second.
Just multiply up to get C into miles and time in hours.

This will be very close to the true speed, however there is a drag factor of something like 0.95 to account for the friction in the barrings but without a wind tunnel it's difficult to calibrate. Anyway it's probably accurate enough without it.

without a wind tunnel it's difficult to calibrate.

Put it on a long stick and hang it out a car window? I've seen that method used; not sure how accurate it is.

-j