Virus scan in progress. Please wait to download attachments.
Overview: This VI demonstrates on measuring the rotation of an incremental quadrature encoder using the DAQ-STC counter on E-series DAQ cards.
Description: Connect phase A of the encoder to the SOURCE of counter 0 and connect phase B to DIO 6 which is the Up/Down line for counter 0. If you configure Counter 0 for Hardware Up/Down counting, Counter 0 counts up when the Up/Down line is high and down when the Up/Down line is low. If counting on the rising edge of phase A, the Up/Down line will be high when rotating clockwise (CW) and low when rotating counter-clockwise (CCW).
Requirements: LabVIEW 2012 or compatible. NI-DAQmx 15.5.1 or compatible. DAQ-STC counter.
Steps to Implement or Execute Code:
Define the Counter Input channel to be used for measurement, the edges of the input signal to increment or decrements the count and also the encoder resolution.
Ensure that the maximum value of the Position indicator is similar to the Encoder Resolution. You may change the maximum value just by double-clicking the indicator.
Run this VI and monitor the indicators to know the position, total revolutions and total distance of the encoder.
Block Diagram Steps:
Creates a channel to count the number of rising or falling edges of a digital signal.
Runs the configured task.
Returns data from the Counter Input terminal in terms of number of edges of the pulse.
The DAQ-STC counters are 24-bit up/down counters which include three input signals (SOURCE, GATE and UP_DOWN) and two output signals (OUT and INTERRUPT). Wire the result of the logic AND of hexadecimal constant (800000) and the data from the encoder to the Case Selector to check 8 most significant values of the acquired data to determine the direction of rotation. Value of 1 means that the encoder is rotating to the opposite direction. Hence, add the data read from the encoder by a negative 24-bit constant by using logic OR. The green LED indicates the rotation to the opposite direction. When the encoder rotates to the positive direction, this code will directly convert the data read from the encoder to Long Integer and computes the total distance covered, current position and total revolutions.
Displays the Total Distance, Position and Total Revolutions of the encoder.
Stops and clears the task. Then, displays any error that occurs.
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.