Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Using USB-6001 DAQ for reading digital encoder



I am trying to read digital encoder using USB-6001. Channel A and Channel B are being read by DI pins (1.1 and 2.0). Idea is to determine the phase difference between two channel. Based on its sign (positive phase or negative phase), direction of motion will be determined and counts will be incremented or decremented accordingly.


Challenge being faced: USB-6001 has only one counter pin but I require two of them to determine the position and the direction. Therefore, I decided to make use of its digital pins. 



VI logic : Rising edges are being detected from each signal and rising edge index is stored in an array (as suggested in this post). Difference of first index can be thought of as phase difference. Positive value of the difference of index indicates positive phase (A leads B--> positive direction).


The VI(attached) is not outputting the result as expected. I seek help for figuring out flaw in logic and rectify it. Any alternate approach for reading a digital encoder using USB-6001 will also be helpful. 


Thank you in anticipation.

0 Kudos
Message 1 of 7

The alternate approach for reading your encoder is NOT to try to do it with the counter or digital inputs of your USB-6001.  It really isn't suitable for the job.


You *might* be able to use 2 AI channels and some post-processing if your encoder pulse rates are slow enough.   Would it be an option to tie up your analog inputs for this task?



-Kevin P

0 Kudos
Message 2 of 7

Hi Kevin_Price,


Yes, I do have 2 vacant AI Channels.  The encoder I wish to read is a linear encoder with resolution of 50 pulses/mm .  It may have to read maximum 20,000 pulses/sec at some point of our application.  


Please explain the approach you are suggesting. 


Thank you.

0 Kudos
Message 3 of 7

The approach would be very similar to what you planned with Digital inputs, just be careful how you define your transitions.  It isn't always as clear-cut to identify them with analog values.  I can only comment on your general description though, I can't open the code as I'm still on LV 2016.


However, your USB-6001 samples at 20 kHz max for a single channel so it'll be 10 kHz (or a bit less) for two channels.  Nyquist theorem says you'd need a minimum sample rate of 40 kHz to capture all the transitions of a 20 kHz square wave.  In real life you'd prefer an even higher sample rate.


So we're back to what I said before -- the 6001 is *not* a suitable DAQ device for your needs because your encoder pulse rates are too fast.



-Kevin P

0 Kudos
Message 4 of 7

Hi Kevin P,


Thank you for your advice.

Also, I've attached the  VI compatible with LV 2016 for your reference. 



0 Kudos
Message 5 of 7

Is it doable using NI-9401 module attached to a cRIO-9035 ?



0 Kudos
Message 6 of 7

@U_TTT wrote:

Is it doable using NI-9401 module attached to a cRIO-9035 ?



Yes, it most definitely is - we do it frequently.

0 Kudos
Message 7 of 7