jhughes1010 / weather

30 stars 17 forks source link

Wind sensor seems to be incorrect #10

Open tkoeberl opened 2 years ago

tkoeberl commented 2 years ago

Hi,

the wind sensor seems to work like expected and gives me some values, but we had the last couple of days a storm here. The maximum what the sensor measured was about 18 km/h. That really can't be true (Tree's have fallen ;) ) If I got it correct the wind sensor is connected to D14. D14 is configured with an interrupt to count the turns.

What could be the reason for this?

thanks, -thomas

jhughes1010 commented 2 years ago

On the TODO list. I need to review, but the circuit may need to be redesigned for proper de-bounce (getting electromechanical input into the electronics world). I put in a software based ignore of 10mS to eliminate some of the chatter, but need to scope it out again. The solution was a short term band-aid and I'm aware of the issue.

jhughes1010 commented 2 years ago

If you are bored, please send a scope plot of D14 pin and what it looks like while the wind cup is spinning. We can certainly re-evaluate the software debounce/ignore time. This would help us understand if we can reduce the 10mS reliably.

jhughes1010 commented 2 years ago

@tkoeberl If you do not have access to a scope or are not a scope user, you can certainly play with the "ignore" number. Change the highlighted number from 10 to 5 and see if the wind measurement seems stable or not. This snippet is from wind.ino

image
tkoeberl commented 2 years ago

@jhughes1010 looks like I'mm not a scope user, as I don't know what it is. I already changed that number to 40 as an test after finding some different values via google.

jhughes1010 commented 2 years ago

changing from 10 to 40 is most likely going the wrong direction. You've now increased the ignore time. It will top out at lower wind speeds and start to give incorrect answers more easily. I'll look at this with my oscilloscope when I get set back up after moving.

tkoeberl commented 2 years ago

If I got it correct, the rebounce is like "double switching". That means to me I want to ignore the second switch if it happened in a short time frame. Regarding the spec of the anemometer, one switch per second means 2.4 km/h. 1sec = 1000 ms. If you now use 10ms as the filter criteria the fastest wind speed which can be measured is: 240 km/h. The max I measured was 18km/h. Maybe my issue is different? I already added a debug message to the function windTick. Should I see something in the serial terminal if the IRAM_ATTR is triggered in deepSleep mode?

jhughes1010 commented 2 years ago

Debounce can produce more than double switching, many more. The cap in the the weather station circuit helps. Dirty little secret: The Anemometer has 2 magnets, not one. You are about to commit the cardinal sin of interrupts by placing an output statement inside an ISR. Outputs are insanely slow relatively speaking and your output will cause you to miss counting events.

Not sure if you've seen my past info on the subject. https://jameshughes.atlassian.net/wiki/spaces/WSV/pages/1874460729/Software+Explanation+and+Overview#Wind-Speed-Measurement

I'll lookl at all this in a few weeks when my shop is set back up. Please be patient ;)

tkoeberl commented 2 years ago

patience is a bit hard for me ;)

jhughes1010 commented 2 years ago

Thomas Krebs and I went on a grand side quest to get low power consumption well understood. There are still a couple things I want to validate, correct, or fine tune. Wind measurement in general needs an upgrade, and there is a plan for that.

jhughes1010 commented 2 years ago

I wanted to comment on your last statement about wind measurement and deep sleep. The code is currently configured to do instantaneous measurements while awake, not count revolutions while in deep sleep at this time.

tkoeberl commented 2 years ago

okay, that is only measures if "sleepless" explains a lot

tkoeberl commented 2 years ago

I'll try to play around with different values <10ms.