Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

What is a proper way to connect B terminal of a quadrature encoder given that NI PCI 6251 and NI ELVIS are used

I am a graduate student at UT Asutin.  
I am a Teaching Assistant for a Mechatronics class. My student needs to use two angular quadrature encoders simulaneously.  

Our DAQ board is NI 6251 with NI ELVIS terminal box;btw NI6251 has two counters. We are using LabView 8.0 and the virtual channel that we are using is  angular position.

I made a VI that works fine with one quadrature encoder in some sense.  
My wiring is as follows:
A input  terminal-> PFI8 (Ctr0 Scr), X input terminal-> PFI9(Ctr0 Gate), B input terminal-> [PFI3(Ctr1 Scr) or PFI4(Ctr1 Gate) or PFI14(Freq out)].  The reason why I said "some sense" is because the B input should be connected (by default )to PFI10(Ctr0 Aux). But NI ELVIS's PFI10 equilvalent pin is automatically set to "Reserved" Pin, which is an output pin not an input one. So I made some trial and error to figure out that PFI3, 4 or 14 can be used instead. Interestingly Ctr1_out terminal (note; not Ctr0_out) also can be used even though it is an output terminal.  

The real question is that what is the proper way to connect the B input terminal considering my DAQ setting? I don't want to touch the Ctr1 pins (Ctr1 Scr, Gate, or Out) or Freq out(PFI14).

I tried to set the B input terminal to PFI1, 2, 5,6, or 7, it worked misteriously at times but not always. Btw I always use "DAQ channel node(Write mode)" to set the B input terminal.

If I can find the right way to connect the B input, I may find the way to use the second quadrature encoder simultaneously

Thank you

Sincerely,  

Jaewon Choi.
0 Kudos
Message 1 of 9
(6,538 Views)

Hi Jaewon,

From what I understand, you are trying to use two angular quadrature encoders on an NI-ELVIS with a 6251 using LabVIEW. The issue arises because the B terminal for ctr0 is designated as RESERVED and is an output only line.

It is possible to assign the counter terminals to different lines. To do this, right click on your block diagram, then select and place Measurement I/O » NI-DAQmx » Channel Node. Place the channel node before the DAQmx Start Task.vi and wire the task and error terminals appropriately. Then left click on the channel node and select Counter Input » Position » B Input » Terminal. This is shown in the picture below. Change the terminal to be writable by right clicking on the channel node and selecting Change All To Write. Finally, create a terminal constant by right clicking on the input terminal to the CI.Encoder.BInputTerm property and selecting Create » Constant, then select choose one of the available PFI lines from the drop down list. This process can be used to change any of the counter terminals.


Please post back if you have any questions. Have a great day!

Message Edited by ryan_d on 10-30-2007 04:41 PM

Ryan D.
District Sales Manager for Boston & Northern New England
National Instruments
Message 2 of 9
(6,517 Views)
I have already tried the exact solution that you posted.
As mentioned in the original post, I assigned PFI 1, 2, ... 7 as B input using DAQ channel VI (Write Mode).
It worked sometimes but not always in the same computer; I mean it doest not work at the first trial. but it worked sometimes after many trials.
I really don't know why ?  I tried so many times.
 
 
Sincerely, Yours
 
Jaewon Choi
0 Kudos
Message 3 of 9
(6,514 Views)

Hi Jaewon,

It sounds like the channel node is not getting executed every time the task runs, since you say that it routes inconsistently. Is your channel node executing every time you run your task? Is it in a case statement or any other control structure? If you can, please post a screen shot of your code. Doing this will let me see exactly how you’ve configured the counter and will help me better understand why the signal is not routing correctly.

Also, can you try your counter application with another break out terminal to test that the signals are getting routed correctly? This will help me determine if NI-ELIVS or your DAQ card is the problem.

Thanks!

Ryan D.
District Sales Manager for Boston & Northern New England
National Instruments
0 Kudos
Message 4 of 9
(6,501 Views)
First of all, thank for your time and effort 
 
Here is my code in the attachment (Encoder Pic.jpg)
 
Sincerely, Yours
 
Jaewon Choi.
 
 
 
 
0 Kudos
Message 5 of 9
(6,491 Views)

The picture quality is not so good.

I attach the original file.

Sincerely, Yours

Jaewon Choi

0 Kudos
Message 6 of 9
(6,489 Views)
Hi Jaewon,

I'm able to get the attached VI to work on an NI-ELVIS with my PCI-6251 (M-Series DAQ). I use CTR0_Source for my A terminal and PFI7 for my B terminal. Please try this VI and double check your connections.

Please post back if you have any questions. Have a great weekend!
Ryan D.
District Sales Manager for Boston & Northern New England
National Instruments
0 Kudos
Message 7 of 9
(6,463 Views)

Hi there

 

I have the same problem,i run your cods and the counter is always incrementing ... even if i rotate the disk anticlockwise,  and with Position control  lab 2 from NI i can not run it .....

Also  the Problem is that (channel A=PFI8) is incrementing both direction always incrementing

and channel B= PFI10 is always 0 .

Any idea??

Thanx

0 Kudos
Message 8 of 9
(4,800 Views)

Hi aswwwa-

 

     By default, X4 decoding is chosen as the decoding type.  This specifies that the counter will increment on the rising ir falling edge of either signal A or B.  What you need is either X1 or X2 decoding.  Here is an excerpt from the DAQmx Help:

 

Quadrature Encoders

 

Quadrature encoders, or angular encoders, cause two signals to pulse while a shaft in the encoder rotates. These signals are signal A (also called channel A) and signal B (also called channel B). Signal A and B are offset by 90°, which determines the direction the encoder moves. For instance, in a quadrature encoder, if signal A leads, the encoder rotates clockwise. If signal B leads, the encoder rotates counter clockwise.

Counters on M Series, C Series, NI-TIO devices support three types of decoding for quadrature encoders: X1, X2, and X4. With X1 decoding, when signal A leads signal B, the counter increments on the rising edge of signal A. When signal B leads signal A, the counter decrements on the falling edge of signal A.

 

With X2 decoding, the same behavior holds as with X1, except the counter increments and decrements on both rising and falling edges of signal A.

 

Similarly, with X4 decoding, the counter increments and decrements on both rising and falling edges of both signal A and signal B. X4 decoding is more sensitive to position, but is also more likely to provide an incorrect measurement if there is vibration in the encoder.

 

Many encoders also use z indexing for precise determination of a reference position.

 

 

I hope this information helps.  Best of luck with your application!

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 9
(4,746 Views)