NI Home > Community > NI Discussion Forums
Reply
Member
MikeStebbins
Posts: 16
0 Kudos
Accepted Solution

Quadrature encoder counting erratically

Hello,

 

I am trying to use LabVIEW 9.0 and a USB-6212 DAQ to measure the angular displacement of a rotary quadrature encoder (US Digital model E2) attached to a stepper-driven linear actuator.

 

Using the VI linked to below and the default PFI pins on the DAQ, I can get the Angle indicator in the VI to change, but with two problems.  

http://forums.ni.com/attachments/ni/170/144774/1/QuadratureEncoderM-Series.vi 

 

1.  The only way that I can guarantee that the Angle indicator stays at a constant value with the VI running and with the stepper motor not moving is to turn off the power supply to the encoder.  In other words, when 5V power is supplied to the encoder, the Angle indicator sometimes stays constant at some value and sometimes increases, even though the stepper motor is not moving.  I added a waveform chart that displays the Angle to see the output easier.

 

2.  With the stepper motor moving, no matter if it moves CW or CCW, the angle indicator is only increasing (counting up).  Changing the direction of the motor displacement doesn't decrease the angle.

 

I've checked the DAQ pins that I'm using: A = PFI 3, Z = PFI 4, and B = PFI 11 with ctr 1.  I've tried both ctr0 and ctr1 with the same results.  I've used a multimeter to check the outputs of A, B and Z on the encoder output with the stepper motor at various displacements, and I'm getting ~+5V sometimes and ~0V sometimes, telling me that the encoder, which is brand new, seems to be switching from high to low.  

 

Does this sound like the kind of behavior that might be caused by noise in the signals?  If so, that shouldn't have anything to do with the Angle only increasing, correct?  To get the Angle to decrease, do I need to change something in the VI?

 

Thank you very much for any assistance you can give.

 

 

Member
MikeStebbins
Posts: 16
0 Kudos

Re: Quadrature encoder counting erratically

A quick update.  

 

Yesterday, I removed the wires that I had between the quad encoder output leads and the DAQ and hooked the ~12" long leads out of the encoder directly to the DAQ to eliminate as much potential signal noise as I easily could.  I hooked up the encoder's A and B channels to AI 1 and AI 2 and set up a simple voltage measuring VI.  The included ppt slide shows the resulting waveforms when the stepper motor is stationary and when the motor is in motion.  

 

Before I started moving the motor, there is certainly some noise in both the red and black curves (I'm not sure which is A and which is B).  Could this be enough noise to confuse the digital pulse counter when it is connected to the appropriate PFI channels (as I describe in the original post)?  I've looked in the user's manual for the tolerance on a digital signal, but I am not finding anything.  The waveforms that occur when the stepper is in motion look as they should, so I'm still confused on why the VI included in the OP counts up constantly, whether the stepper is in motion or not.

 

Thanks again for any help, suggestions, or additional diagnostics I might perform. 

 

Mike

Active Participant
Kyle_A.
Posts: 424

Re: Quadrature encoder counting erratically

Hi Mike,

 

From what you describe, I feel the symptom of the counter never counting down is a side effect of the issue where the counter continually counts up while not moving.  This definitely sounds like a noise issue, and there are some small but noticable spikes in your AI graphs you provided.  Basically, as long as Signal A (Source) leads Signal B (AUX), then the counter counts up.  This is for X1 encoding, which I assume you are using.  Look here at Figure 5, under the X1 Encoding section for how that encoding reads your signals:

 

18995i94118260FF03A4E2

 

Your signal connections that you describe are correct, so it is going to be a matter of getting rid of the issue where the counter increments on its own which I believe will resolve your other issues.  Take a look at these links to see if adding filters on the counter inputs internal to the card helps the measurement:  Enable Digital Filtering for M Series  Enabling the Digital Debounce Filters for TIO Devices in NI-DAQmx

Kyle A.
National Instruments
High Speed Digital I/O Product Support Engineer - R&D
Trusted Enthusiast
Trusted Enthusiast
JB
Posts: 2,651
0 Kudos

Re: Quadrature encoder counting erratically

A little test :

 

  1. Disconnect the B channel of the encoder from the counter.
  2. Connect the B counter input to a GND pin of the DAQ board.
  3. Rotate the encoder. What is the direction of the counter ?
  4. Disconnect the B counter input from GND and connect it to the +5V pin of the DAQ board.
  5. Rotate the encoder. The direction of the counter should be opposite.
Member
MikeStebbins
Posts: 16
0 Kudos

Re: Quadrature encoder counting erratically

Kyle A: Enabling a digital debounce filter to both the A and B channel (see enclosed block diagram) seems to have fixed the problem.  As you suspected, once the counter stopped counting arbitrarily due to the noisy signal, it also started counting up and down.  Thank you for your help, it's much appreciated!

 

JB: Thanks for your response.  I didn't actually try it out since the first suggestion took care of the problem.

 

Mike Stebbins

 

 

Member
yesil16
Posts: 13
0 Kudos

Re: Quadrature encoder counting erratically

When i use the attachment which i sent in the data part on front panel it gives me 0 1 0 1 values continuously but i want to take values increased from 0 to 360 degrees and then again 0 to 360. i use incremental encoder ( 360 pulses for per revolution ) and USB DAQ 6215 and use the A input as wiring to PFI0. By the way i need to know where is the bottom dead center and top death center of engine. Thx for helping

Member
yesil16
Posts: 13
0 Kudos

Re: Quadrature encoder counting erratically

it is the VI