Overview:
Demonstrates on measuring angular position of a quadrature encoder at the Counter Input channel using digital pulses generated by the Counter Output as the source clock.
Description:
The encoder position is measured on the counter's default A, B, and Z input terminals (refer to section IV, I/O Connections Overview, below for more information).
Note: For buffered position measurement, an external sample clock is necessary to signal when a sample should be inserted into the buffer. This is set by the Sample Clock Source control.
This example is set up to use the other counter available in the device to provide the external clock.
Requirements:
- LabVIEW 2012 or compatible.
- NI-DAQmx 15.5.1 or compatible.
Instructions:
- Select the Physical Channel which corresponds to the counter at which the angular position of the encoder will be measured.
- Enter all the control values under Counter Input tab to specify how the counter input channel measures position.
Samples to Read control will determine how many samples are read each time the while loop iterates.
- Set the Counter Output channel as the clock source.
Note: An external sample clock must be used. Counters do not have an internal sample clock available.
- Run this VI and monitor the Acquired Data indicator to verify the encoders angular position.
Block Diagram Steps:
- Create a Counter Input channel to measure the Encoder angular position.
- Call the DAQmx Timing VI (Sample Clock) to configure the external sample clock timing parameters.
- The Sample Clock Source determines when a sample will be inserted into the buffer.
The 100kHz, 20MHz, and 80MHz timebases cannot be used as the Sample Clock Source. The Edge parameter can be used to determine when a sample is taken.
- Call the Start VI to arm the counter and begin measuring position. The counter will be preloaded with the Initial Angle.
- For continuous measurements, the counter will continually read all available data until the Stop button is pressed on the front panel.
- Call the Clear Task VI to clear the Task.
- Use the popup dialog box to display an error if any.




**This document has been updated to meet the current required format for the NI Code Exchange.**
Kyle A.
National Instruments
Senior Applications Engineer