I am using a velleman vma347 IR sensor for the purpose of obtaining the speed of a DC motor. When I had connected and programmed the sensor, the rpm seemed to be very high. I then wrote a program to see what comes in (see below) and per pass I get several pulses 3,4,5 depend from time to time, every pass i wait some time. The connection in +5V DC, GND and signal on pin 2. Does anyone know why this is and how I can fix this?
this code works but counts 2x per passage so I guess on a positive and negative flank? When I hold an object between IR connection, it gives 1 pulse. When I remove this I get back 1 pulse.
Many of the low cost hobby sensors have comparators based on the LM393 without any hysteresis feedback, and it is not uncommon to experience multiple interrupts/noise troubles with these basic lm393 comparator modules.
Performance is often improved with a cap between D0 and ground. That solution and other possible circuit mods for hysteresis improved response are discussed here
A software approach for noisy transitions (rising or falling) input using CHANGE interrupt mode. This approach waits for stability in the signal while still using the initial transition for calculations. Also works for a wide range in duty cycle with the input ...
What are you using to break the IR beam and produce pulses? A slotted wheel or similar? How many slots / pulses per revolution? What RPM range? Post a picture.