Example Code

Measure Linear Two Pulse Encoder in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview:
Demonstrate on measuring the position of linear encoder.

Description:
This example returns the position of a linear encoder and then resets each time the Z index is reached. Z index phase is ignored within a
two pulse counter, so it has been removed as an input.

Requirements:
LabVIEW 2012 or compatible.
NI-DAQmx 15.5.1. or comaptible.

Steps to Implement or Execute Code:

  1. Specify the Counter at which the signal will be acquired.
  2. Specify the Decoding Type specifies how to count and interpret the pulses the encoder generates on signal A and signal B. X1, X2, and X4 are valid for quadrature encoders only. Two Pulse Counting is valid only for two-pulse encoders.
  3. Finally, before running the VI, specify the Z Index Value which  is the value to which to reset the measurement and Pulse per Revolution.

Block Diagram Steps:

  1. Creates a channel that uses a linear encoder to measure linear position.
  2. Runs the task to begin acquisition.
  3. Returns the data in terms of position of the encoder.
  4. Check for any error occurs. The loop will stop if it detects an error or when the user presses on the stop button.
  5. Clears the task and displays any error occurs.

Front Panel.PNG

 

2017-05-15_10-52-05.jpg

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

National Instruments
Applications Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.