In my previous blog post, I was testing the wind vane potentiometer replacement and was getting some weird results. I was getting errors like NO SPI DEVICE FOUND, weak magnetic field, and generally not being reliable. Part of the problem was a solder bridge between pins 2 and 3 on the MLX90316 PCB (J1) header and it so happens that pin 2 goes to ground when the reed switch closes which messes up (technical term 🙂 ) the SS (slave select) signal from the MCU. No wonder I was getting NO SPI DEVICE! Also, after shortening the shaft length of the windvane, I can now adjust the distance from the magnet to MLX angle sensor so more complaints about weak magnetic field. Now, on to the anemometer testing. I am currently trying to use a hardware debounce circuit (shown) and it WAS working and counting the pulses from the reed switch pretty consistently.

But it’s weird that a shorter RC time constant debounce circuit works better than a longer one. The RC time constant that seems to work better is 100 uS; if I change the capacitor to, say, a 100nF (1ms time contstant), then I get more contact bounce interrupts…weird Not what I would expect. I was using a NO (Normally Open) pushbutton switch, not a reed switch so maybe that’s the issue. So, I found a small reed switch and tested with that. The switch is about the same size as the one in the 034B anemometer, I think, so the bounce time should be about the same. Below is a pic from my scope the switch bounce. After numerous activations of the switch using a small magnet I found the maximum bounce time to be no more than 300 uSec (microseconds). I am sorta puzzled why a time constant of 100 uSec works better than, say, 300 uSec. Most of the time the bounce time was like 100 uSec, but occasionally it would be much more but I never saw anything over 300 uSec. So now I’m experimenting with software debounce, an example of which I found on Particle.IO forum that appears to work really well. Better than a hardware debounce scheme, but I might try using both methods.
