Example Code

Linear Position Measurement Using Counter Input

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:
Demonstrates on measuring the position of linear encoder.

Description:
This example returns the position of a linear encoder then resets each time the Z index is reached.

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

Steps to Implement or Execute Code:
  1. Specify the counter at which the signal will be acquired.
  2. Specify other controls on the front panel which define how to count and interpret the pulses the encoder generates.
  3. Run this VI.
  4. Measured position will be displayed on the waveform chart.


Block Diagram Steps:

  1. Creates a channel that uses a linear encoder to measure linear position.
  2. Sets the sample clock source and other necessary timing parameters.
  3. Runs the task to begin acquisition.
  4. Returns the data in terms of linear encoder position.
  5. Clears the task and displays any error occurs.
2017-05-31_10-04-55.jpg
 
2017-05-31_10-05-19.jpg
 
 
**This document has been updated to meet the current required format for the NI Code Exchange.**
ColeR
Field Engineer

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