hi and thanks for helping me out on this one.
this is exactly how i originally wrote my program when the sensor was a hall effect sensor. unfortunately, and it is out of my control. i now have to make it work with a reed switch and it is failing because of the bounce in the reed switch. i am unaware of away to accurately debounce the reed switch in the interrupt. what makes me think it is failing is that when i know the wind is somewhere between 10-20mph i'll have a max gust reading of 150mph or so which i know is not correct. i feel like i need to have the main loop do the debounce by polling the pin(which has the pullup resistor turned on) and when it detects an edge do a 50 microsecond delay and then check if it is still LOW, if it is then record the time then wait for next edge record the time and do the math as you suggested. then i would like to at an accurately spaced 1 second interval send the data to the computer. the reason to use the boards clock for the 1 second interval is that i feel that it will be more accurate than a software timer that is at the mercy of all kinds of other things going on in the users computer. my display needs to update once per second and the board very nicely gives me a data available event once per second. this is of course when i was doing what you suggested and had a nice little delay(1000) in the main loop and was getting time between pulses in my interrupt handler.
also here is the math stuff. anything longer than 2500 milliseconds(1.0MPH) is garbage and anything faster than 12-13 milliseconds is not needed. (1000/2500)*2.5 or (1000/12)*2.5
i don't know how else to explain the bogus readings with the reed switch other than bounce.
I am still open to any suggestions that you may have.
also as a side project i also need this whole thing to work as a field data logger sending data to a usb flash drive and my preliminary tests on that show some random bad writes and my guess is that an interrupt is happening during a write that is causing the write message to get screwed up. so the thought there was to have a all the disk communication happen in a timer interrupt so that there is no interrupts to interrupt the writing to disk. so i feel like no matter what i need to learn how to use timers. what are your thoughts on this?
also besides trying to get this project off the ground i am very interested in learning about micro controller programing and i feel that learning the ins and outs of timers is just another area that i should know
below is a sample of my attachInterrupt Handler
thetime = millis();
if (thetime - lastpulse >= 13) //this is my debounce check
timediff = (thetime - lastpulse);
lastpulse = thetime;
if (thetime - lastpulse < 0 ) // this is an attempt to deal with the millis() rollover problem every nine hours
// record the time for the next pulse to measure against but don't do the math because it won't make sense
lastpulse = thetime;
thanks for your help