Example Code

Updating Pulse Configuration 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 generating continuous pulses using Counter Output channel.

Description:
This example shows on reconfiguring the duty cycle and frequency of the pulses while the VI is running by wiring a local variable of the control to the input Data terminal of the DAQmx Write task in a while loop.

Requirements:

  1. LabVIEW 2012 or compatible.
  2. NI-DAQmx 15.5.1 or compatible.


Steps to Implement or Execute Code:

  1. Select the physical channel which corresponds to which counter output the signal will be generated.
  2. Enter other control values to define the pulses.


Block Diagram Steps:

  1. Creates a channel to generate digital pulses with user-defined frequency and duty cycle.
  2. Continuously generates the duty cycle samples using the internal timebase. The samples per channel is programmatically set to have the same number of element in the Duty Cycle and Frequency array.
  3. Sets the buffer size to the number of samples to generate. This overrides the automatic output buffer allocation that DAQmx performs.
  4. Writes new pulse frequency and duty cycle pairs to a counter output task that contains a single channel. Automatically start the task on the first iteration. By wiring -1 to the timeout terminal, this VI will wait indefinitely for the samples.
  5. Clears the running task and displays any error occurs.

2017-06-08_10-33-01.jpg

 

2017-06-08_10-33-29.jpg
 

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

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.

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