09-03-2008 07:24 PM
Hello all,
I have been taking some encoder measurements with a US digital E2 incremental encoder (http://www.usdigital.com/assets/general/74_e2_datasheet_4.pdf), and I am having a lot of trouble with controlling the encoder count direction. I am using a M-series PCI-6251 with labview 8.0.I have contacted the manufacturer for help and they have mentioned that the problem of count direction may be affected by the format of encoders output. They said that the encoder outputs a 2-bit binary gray code, which gives a digital incremental output of 00,01, 11, 10, 00, 01, 11, 10, 00 and so on in one direction and an output of 00, 10, 11, 01, 00, 10, 11, 01, 00 etc if it spins the other direction.I am assuming that currently, my VI’s are not able to distinguish the two different patterns of the output from the encoder, so the count direction is always specified in one direction. US digital has suggested some solutions to the problem, all of which involve the purchase of an external chip or device that can convert these signals to either up/down count signals or a proportional analogue voltage. But I was wondering if anybody had some ideas or example VI’s that could help me solve the problem I am having with decoding and analysing the signal to specify count direction without having to purchase these extra components?
Thanks for your time, it is greatly appreciated
Joe
09-04-2008 02:43 AM - edited 09-04-2008 02:44 AM
Hello Joe,
the PCI-6251 has a build-in counter.
Create a DAQmx task for counting position (linear or angular), start the task and read the value when you need it.
Search in the DAQmx help or in the example finder for 'counter measurements' and 'position measurements'
For me the '2-bit binary gray code' is a simple A/B encoder signal, which can be wired directly to the PCI-6251.
Hope this helps.
Uli
09-04-2008 10:59 AM
Hi Joe,
The two examples Uli pointed to should be perfect for you and count both up and down like you wish. You can also refer to the DevZone: Quadrature Encoder Measurements: How-To Guide for more information on quadrature encoders. The "2-bit gray code" you refer to are simply the A and B signals of a quadrature encoder. Let us know if you have more questions.
09-05-2008 12:15 AM
Thanks for the info guys, it has been useful in narrowing down my problems – but they still linger….
I have been able to set up a few Daqmx tasks that can read my encoder signals, but I have been unable to rectify the problem of externally controlled count direction. After some research I think that my problems stem from the fact that both my A & B signals are being sent to the DAQ through the one digital line, so I am unable to separate them to the two counter channels.
I am saying this as I had set up a digital read task and I can read some form or response on port0 line 7, which I am assuming is my ‘A signal’. However I cannot find any other signal on any other port or line, so I am therefore unable to find my ‘B signal’ to specify direction.
Am I on the right track here? I am worried that I am not addressing the problem correctly.
Perhaps I should simply be focussing more on locating the second signal
Thanks again Joe
09-05-2008 02:48 AM - edited 09-05-2008 02:49 AM
Hello Joe,
the attached picture shows the pin-out of the E2 encoder.

The PCI-6251 uses Pin 37 (PFI8) as input A and Pin 45 (PFI10) as input B for counter 0.
So connect Pin3 (encoder) with Pin 37 (PCI-6251) and Pin5 (encoder) with Pin45 (PCI-6251).
To use the hardware counter of PCI-6251 you use 'DAQmx Create Channel' Vi and create a 'CI Angular Encoder'. Configure the VI to use counter 0 and to use 'X4' as decoding type. The counter then can count up and down on it own.
If you read the value of the counter in your program, you get a position in tick counts or meters or whatever you cofigured.
Hope this helps,
Uli