LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder Z Pulse Counter input measure RPM

Solved!
Go to solution

I have an PXIe-6341 DAQ card in a PXIe-1082 chassis. I have an RLS ABZ encoder which I would like to use to obtain RPM by counting the Z pulses.

 

I have wired the Z pulse into a counter in the 6341.

 

I have used the CI Period NI DAQmx function and taken 1/T to get frequency (using CI Freq seems to gives terrible results)

 

which works except I am getting large spikes in the data. The spikes are random and are sometimes within the range of possible values which makes a simple cut off filter not possible. I have tried a median filter but to no avail as the spikes can last for about 3 or 4 samples.

 

I would like to understand why these spikes happen in the first place. I am going to use this as the feedback for a PID controller so the spikes will be very intrusive.

 

spikes.PNG

Counter.PNG

 

 

Any help would be greatly appreciated.

0 Kudos
Message 1 of 5
(1,506 Views)

I've run into this kind of thing before and it can get pretty difficult to solve.  You're probably getting some kind of noise "glitch" coupled in with your encoder signal which can occasionally look like a legit digital transition, leading to incorrect period measurements.

 

I see you've already added digital filtering to your task, but it didn't fully solve your problem.  You could stand to set a much longer minimum pulse width and probably remove the anomaly around 8500 RPM, but I wouldn't count on being able to suppress the two anomalies at ~5500 RPM while allowing the normal ~5200 RPM periods.

 

Eventually, you're going to find that you need to fight this noise at its source.  And it may not be trivial to identify that source.  And after identification, suppression isn't necessarily easy either.  Things like switching power supplies and brush DC motors tend to emit a good bit of high frequency noise that can be hard to suppress.

 

You'll want to take a good hard look at your grounding strategy, proximity of your encoder signal wires to other current-carrying wires, the degree to which your encoder cable is vulnerable to noise (for example, is there shielding?  is the shield grounded at only one end?), and more.

 

Sorry, no definite answer.  Sometimes noise is just difficult.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 5
(1,464 Views)

Thank you Kevin for your reply.

 

I'm a bit confused as well. The thing is is that I can use the CI Angular Encoder Task to log the angular position with the Z reset enabled and it works flawlessly even at very high RPMs. How come this is possible and yet the Z pulse in isolation is causing issues.

 

What's also interesting is that it gets even worse If I run a wire from the Zpulse terminal in the 6341 to another counter in the same 6341:

 

spikes2.PNG

 

I am considering some kind of case structure+ shift registers with a conditional output to only allow values which are within +-200 RPM of the previous accepted value. 

 

 

0 Kudos
Message 3 of 5
(1,298 Views)

When you use the quadrature-based encoder measurement modes, a digital glitch will often have no net effect.  During the very brief time the signal transitions to the wrong state and then back to the right one, the count register briefly increments or decrements to be off by 1 and then goes immediately back to the correct count again.   That's one of the advantages of using quadrature.

 

So with that in mind, maybe you could consider calculating RPM from a quadrature position task.  At present, you're somewhere in the neighborhood of 6000 RPM.  That's 100 revs/sec and thus 100 Hz sampling when you measure periods of the Z-index signal.

 

You could instead configure a 2nd counter to pulse at 100 Hz and use it as a precise sample clock for your position task.  You'll likely get more quantization error, but it may still be "small enough".   You can be off by 1 count out of 1 rev worth of quadrature counts.  For example suppose your encoder has 256 cycles each for A and B (so it can resolve 1024 quadrature positions per rev).  Your quantization error would be 1 part in 1024 or ~0.1%

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 5
(1,226 Views)
Solution
Accepted by topic author Lazer723

Just for anyone else that might have this problem with the Zpulse spuriously triggering.

 

It turned out to be an electrical issue, I put a 120 Ohm resistor across the Z input to the 6341 counter and GND, thus a proper high impedance termination. This worked incredibly well to remove random triggering.

0 Kudos
Message 5 of 5
(546 Views)