gpio interrupt - reading tacho problem
Posted: Tue Mar 02, 2021 11:38 am
Hi,
I've connected PC fan tacho to IO pin 2 (with pullup from 3.3v) and wanted to count pulses. Here the code:
But the interrupt is triggered too many times... There are about 38 pulses per second, but the interrupt seems to be triggered about 100 times per second.
And yes, I know the tacho pules are no revolutions.
Any suggestions?
I've connected PC fan tacho to IO pin 2 (with pullup from 3.3v) and wanted to count pulses. Here the code:
Code: Select all
wifi.setmode(wifi.NULLMODE, false);
gpio.mode(2, gpio.INT);
tacho_2 = 0
gpio.trig(2, "down", function()
tacho_2 = tacho_2 + 1
end)
function start()
print("tacho ".. tacho_2 .. "\n");
tacho_2 = 0
end
tmr.create():alarm(1000, tmr.ALARM_AUTO, start)
But the interrupt is triggered too many times... There are about 38 pulses per second, but the interrupt seems to be triggered about 100 times per second.
And yes, I know the tacho pules are no revolutions.
Any suggestions?