Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6210 Quadrature Counter.

I am using Labview 8.2 with a USB-6210 module.

 

I would like to hook a quadrature encoder to my counter. The counter will count up or down depending on encoder direction. I am not using an index so the counter will continue to count up/down as long as the encoder is in motion.

 

I would like to be able to grab the counter value using an external hardware pulse while the encoder is still in motion and the counter is still accumulating.

 

Any help will be appreciated.

 

Thanks

 

Brian

0 Kudos
Message 1 of 4
(3,874 Views)

I think I have something that appears to be working.

 

Using the DAQ assistant I created a counter input/position/linear.

I selected linear because I want to know the distance traveled by the encoder.

 

Daq assistant settings.

 

Configuration:

 

Linear position

Index disabled

Decoding type – X2

Acquisition Mode – Continuous Samples

Samples to read – 1

Rate(Hz) – 1K  (I am not sure what this means??)

 

 

Advanced Timing:

 

Sample clock – External

Clock Source  - PFI3 (Trigger Signal)

 

I am sure there is a better way to do this but this seems to work.

 

Thanks

 

Brian

0 Kudos
Message 2 of 4
(3,867 Views)

Hello Brian,

Thanks for contacting National Instruments. 

The DAQ Assistant is a great place to get started with a DAQmx based application.  But you are right; there is more measurement power available by using the full DAQmx API. 

The NI Example Finder, located in LabVIEW under Help -> Find Examples, contains many shipping examples for DAQmx.  The path Hardware Input and Output -> DAQmx -> Counter Measurements -> Position contains several examples for reading encoder position.  The example Meas Angular Position-Buffered-Cont-Ext Clk reproduces the behavior of the DAQ Assistant that you are using. 

By setting the acquisition mode to continuous, you add the functionality of a circular buffer into your code.  Whenever an external trigger occurs, in this case on PFI3, the current encoder position is latched into a hardware buffer.  This data is then transferred to the PC using DMA or Interrupts.  The number of samples to read specifies the number of samples that are pulled from the PC buffer at a time. 

The rate you have specified is the maximum expected sample clock rate of the external clock that you have connected.  As a result you are saying that your external trigger will not occur faster than 1 kHz. 

Getting Started with NI-DAQmx and Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications are great places for starting to program with DAQmx. 

Please post back if you have any questions. 

Regards,
Browning G
FlexRIO R&D
0 Kudos
Message 3 of 4
(3,860 Views)

Hi, Browning G,

Thanks for the great links and info on what these settings mean it makes sense to me now.

I looked around the web site and didn’t find anything but I was in a hurry.

As a test I used the encoder index as my external trigger so I could verify I was getting the proper count when triggered.

I must say these forums have helped me quite a bit.

Thanks again.

Brian

 

0 Kudos
Message 4 of 4
(3,853 Views)