Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Debouncing an RPM signal

Hello,

I'm measuring RPM on an small engine with an RPM range of ~600 to ~6000 (10-100 Hz).  Often I get a "bounced" (?) RPM
figure like 171,931.   I'd like to debounce this signal.  I'm using a DAQ Assistant to read the RPM.   What widget should sit between my
DAQ Assistant and my "Write to Measurement File" objects to properly filter this?

I'm running LabVIEW 8.2 using a NI USB-6210 data acquisition device.

Thanks in advance!

-mt

0 Kudos
Message 1 of 9
(7,329 Views)

Hi mtaylor,

I understand that you are receiving some high frequency spikes in your signal that you would like to remove. I think the best remedy for the problem would be to figure out what is causing these spikes and how you can fix the problem in hardware. For a discussion on removing glitches or adding a debounce filter to a digital signal, please see the KnowledgeBase article linked here.

From what it sounds like, you are reading frequency using a counter input task and converting the frequency value into an RPM value. If you are reading continuous samples, you should have an array of values depending on the number of samples you are reading each time. If this is the case, you will have to actually check each value in the array to see if it falls within the range you are expecting (i.e. 10-100 Hz). If the value is above the expected range, you can simply coerce it to the maximum value you expect to receive. To do this, you can place a For Loop on your block diagram and pass the array into it. You will then use the In Range and Coerce function (found under Programming » Comparison on the Functions palette) and set a maximum and minimum value. Any value in the array that falls outside the expected range will be coerced. Please see the attached screenshot for an example of this. Also, please note that this solution will coerce out of range values, but it does not solve the problem completely. I would strongly suggest looking into the source of these glitches and how you can remove them in the hardware. Hope this helps,



Message Edited by dansch on 06-08-2008 11:21 PM
Daniel S.
National Instruments
0 Kudos
Message 2 of 9
(7,305 Views)
Thanks for help Dansch!

My RPM is coming off a magnetic pickup spec'd for the engine I'm measuring.  I don't believe there's anything
particularly wrong with it other than, like most switches, it's glitchy when it switches.  I'd like to handle this in
software if possible.

The article you pointed me to recommends that I "[configure] a counter for retriggerable pulse generation".
It's not obvious to me how this is done.  I've set up the counter in a DAQ Assistant function.  There's nothing I can
find showing how to set the minimum pulse width for this property. Any more clues would be much appreciated!

-mt
0 Kudos
Message 3 of 9
(7,290 Views)
Oops... should have addressed the second part of your post!

If I understand you correctly, I could manipulate the data stream to say that any value that is above the expected max. is set to
the max., below the min., set to the min.  For example, the 171,931 RPM value in my original post would be coerced to
6000 RPM.  If this is what it does for me, I'm not interested in it as I'd just be generating bogus data.  I'd rather
do  what that page you pointed me to  purports to do.  Thanks for the code tho and it helped me undertand better how to
manipulate the data.

-mt
0 Kudos
Message 4 of 9
(7,287 Views)
Hi mt,

The method listed for removing glitches from the digital signal will actually use another counter on your device. Thus you will be using two counters; one to filter your signal by outputting pulses you specify and another to read frequency in the same way that you are already doing it. The only difference is that you are now reading frequency from the signals being output by the first counter, which are set to have a pulse width of the original signal plus the glitches. In this way, the glitches are filtered out and the signal is debounced.

When using the DAQ Assistant for counter output, you can set the high time and low time of the pulse in the Settings tab. Unfortunately, the DAQ Assistant does not directly support retriggerable pulse generation. However, there is a LabVIEW example using the DAQmx API that can be found in the Example Finder (Help » Find Examples) under Hardware Input and Output » DAQmx » Generating Digital Pulses » Gen Dig Pulse-Retriggerable.vi. This example configures a task for CO Pulse Ticks (relative to the timebase used as the counter source), but can easily be changed to CO Pulse Time. You can then set the high time (pulse width) and low time (delay) inputs to correspond to the pulse you would need. The example then configures the start trigger to be the gate of the counter where your signal to filter will be connected, and sets this start trigger to be retriggerable using the DAQmx Property Node. The counter will output a pulse whenever it receives a start trigger, which, in this case, means whenever it sees a digital pulse on the gate (corresponding to your signal). When configured correctly, you should output a pulse each time the counter receives an input pulse, only you can control the width (and therefore quality) of this output pulse. Finally, you will need to create another counter task just as before, and connect the output of the first counter to the second counter to read the frequency. Hope this helps,
Daniel S.
National Instruments
Message 5 of 9
(7,254 Views)
I'll see if I can implement that.  thx! -mt
0 Kudos
Message 6 of 9
(7,235 Views)

i am facing the similar scenario!!! i am havng a magnetic pick-up with a screw fixed on rotating shaft.. i hav been trying to solve this problem but with no luck.! can anyone please post their 

successful VIs?

thanks

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 7 of 9
(5,683 Views)

Hi Crackjack, 

 

Have you tried the example vi mentioned above and adjusting it to your application?  

Regional Account Manager
NI
0 Kudos
Message 8 of 9
(5,669 Views)

Hi CrackJack,

 

Is the issue that you are picking up duplicate edges (i.e. "bounces")?  Most of the newer NI DAQ products support Digital Debouncing Filters on the PFI lines.  You can find more information about the filter in your appropriate hardware manual (e.g. X Series User Manual). 

 

If you are using a device that supports filtering, you can configure it through DAQmx Property Nodes.  If not, the retriggerable pulse generation mentioned earlier in the thread might be a possible workaround.  External conditioning is also a possible solution if the other options are not suitable.

 

 

Best Regards,

John Passiak
0 Kudos
Message 9 of 9
(5,660 Views)