Example Code

Divide Down an Encoder Signal or an External Clock by an Integer Value using One Counter in DAQmx

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 VI is designed to generate a rising edge at a frequency that is specified by dividing down from an incoming signal.
It does so by counting the rising edges of an incoming signal and outputting a pulse when the specified number of edges have been counted (i.e. a specified divisor).
An example application is taking a 3600 tick encoder and generating a sample clock that samples every 10th tick such that the encoder appears to be a 360 tick encoder.

Description
The VI uses a CO Pulse Ticks task to output a pulse based on a certain number of low ticks and high ticks after a certain number of rising edges are counted on the input line.
The task is made continuous so that it repeats until the task is stopped.

Requirements
LabVIEW 2013 or compatible.
NI-DAQmx 15.5.1 or compatible.

Steps to Implement or Execute Code:

  1. Ensure that the inputs are correctly configured such as which counter to use and which PFI line the input signal is on. Also, how many High and Low Ticks the input signal would be generated before the Counter Output will output a pulse.
  2. Run this VI.

Block Diagram Steps:

  1. Creates a channel to generate digital pulses defined by the number of timebase ticks that the pulse is at a high state and the number of timebase ticks that the pulse is at a low state.
  2. Configures the Sample Clock and the sample mode to Continuous Sample.
  3. Runs the configured task.
  4. Loop continuously until the user presses the Stop button and check for errors every 100 ms using the DAQmx Is Task Done VI.
  5. Clears the task and displays any error that occurs.

Front Panel.PNG

 

2017-05-12_16-35-38.jpg

 

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

Ryan P.
CLA

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