I recently conducting some experiments and obtained the following pulse train from one of the sensors. I want to count the pulses with attachInterrupt() function.
I was wondering if this pulse train (see the figure) can be counted. The reason I am asking this questions is because I am concerned about the peak value of the voltage (~ 4V) and it has also got some noise.
Of course, I can test it by doing the experiment on an Arduino board itself, but I am seeking opinion on this forum so that if it can not be read then I will need some suggestions from you guys on how to filter this so that Arduino can read this.
I was wondering if this pulse train (see the figure) can be counted. The reason I am asking this questions is because I am concerned about the peak value of the voltage (~ 4V) and it has also got some noise.
It can be counted but that signal is not clean and will produce bad counting.Interrupts are very fast and that ripple will provoke some false counting.
Perhaps that noise is just a debouncing problem, from where are you reading that pulse?
Is it a button or a sensor?
You could use a Schmitt Trigger to smooth the signal and turn it in a pure square wave ready to be applied in the interrupt pin
See this:
I am getting the signal from a VR Crank Sensor --> NI 9752 module (Product Documentation - NI). I will look into Sch. Trigger. Do you think 4V, instead of 5V will generate the interrupt?
Do you think 4V, instead of 5V will generate the interrupt?
Yes it will trigger the interrupt.If you decide to use the Schmitt Trigger then the output of it will be 5V, so it's ok.
Are you just using the VR Crank Sensor alone or do you have that module NI 9752 ?
Well... VR sensor outputs a sinusoidal-like output . So I cannot use that directly in Arduino. So I am sending VR sensor output to NI 9752 module mounted on an NI cRIO controller and the module filters the VR output as a pulse. I am planning to send this output off NI 9752 module to Arduino.
That's correct.
So get a Schmitt Trigger and test the results or compare the signal with a scope.
If you see no spikes then you could try to count the pulses.
It is possible to do some spike rejection in software. If you know the maximum expected shaft speed (that gives you the minimum pulse width) then use a pin change interrupt and measure the time between the pin going high and then going low, if it's below the expected minimum pulse width then assume it's a spike and don't count it. I have used a similar system when measuring OOK RF signals.