From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Update Digital Pulses from Multiple Counter Output Channels On The Fly

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 how to change the digital pulses generated from Counter Output while the VI is running.

Description:
This example is an augmentation of an existing piece of code posted in a Developer Zone tutorial that outputs on a single channel.  This example demonstrates how to change the frequency and duty cycle of multiple pulse trains on multiple physical channels in DAQmx while a task is running.  In this new revision, property nodes are used to set the physical output channel of each counter, in addition to checking each counter for a TRUE value on RdyForNewVal using the ActiveChans property node before updating duty cycle and frequency information. Please note: On certain hardware, different counter resources must be selected for each channel.

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

Steps to Implement or Execute Code:

  1. Specify the Channel Parameters prior to running this VI. Co.Pulse.Term control is to define on which terminal to generate pulses.
  2. Run this VI.
  3. You may regulate the controls under the On The Fly Settings tab to change the duty cycle and frequency of generated pulses of both terminals.


 Block Diagram Steps:

  1. Create a two Counter Output channels to produce digital pulses.  If the Idle State for the pulses is set to low, the state of the lines will begin low and remain low after the generation is stopped.
  2. Use the DAQmx Timing VI (Implicit) to configure the duration of the pulse generation.
  3. Configure output terminals for the two Counter Outputs.
  4. Call the Start VI to arm the counter and begin the pulse train generation.
  5. Use a DAQmx Channel Property Node to determine if counters are both ready for a new value.
  6. Update the counter frequencies and duty cycles using the DAQmx Write VI.
  7. Call the Clear Task VI to clear the Task and then check for warnings/errors.

 

Front Panel.PNG

 

bd.png

 

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

Regards,
Chris Elliott
x36772

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