Example Code

Encoder Correlated DIO

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
This example demonstrates how to count digital events on a digital port of an M-Series card using correlated DIO. 
 
Description
This program correlates a digital input task to the analog input sample clock, creating a buffered hardware timed acquisition on a digital port.  The program then compares samples from each port to the previous sample, and a change in a digital line increments a count value in software.
 
Steps to implement or execute code
To implement this example:
  1. Set the physical channel
  2. Define the encoder setting
  3. Define the timing parameter
  4. Run the VI
  5. (Optional) Turn on the Highlight Execution to see the flow of the VI

To execute this example:

  1. Install the required software.
  2. Connect the DAQ hardware
  3. Confirm the connection with the MAX with TestPanel
  4. Open the VI and refer the Implement Steps


Requirements
Software
LabVIEW 2012 or compatible
NI-DAQmx 16.0 or compatible

Hardware
cDAQ with C series or compatible

 

2017-10-29_12-40-44.jpgBD.png

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

Thank You
Eric Reid
National Instruments
Motion R&D

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

Comments
Todd S.
NI Employee (retired)
on

thanks for posting!  could you please rename your attachment to include the LabVIEW version? "_lvXX.zip" would be fine.

Todd S.
LabVIEW Community Manager
National Instruments
Joji
NI Employee (retired)
on

Does this handle the Z channel?

Joji
Eric_R
NI Employee (retired)
on

Hi Buddy, great question! This VI currently does not support a Z axis that you may see on quadrature encoders for indexing. My recommendation would be to change the Encoder Split VI and add the logic for edge detection to quadrature-split.

-Eric


Thank You
Eric Reid
National Instruments
Motion R&D