Example Code

Counter Output: 4 PWM Sequential Waveforms with Dynamic Duty Cycle Updates 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:
Demonstrates on generating finite pulses with different duty cycles.

Description:
In this example, the code will generate a sequence of waveforms, one after another with a small delay in between. Each waveform will have a frequency as specified at the Frequency control and a duty cycle specified in Duty Cycle Array. This example highlights the use of DAQmx Channel >> CO.Pulse.DutyCycle property node which allows the user to dynamically update the duty cycle of the generated waveform.

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


Steps to Implement or Execute Code:

  1. Specify all control values on the front panel corresponding to the physical channel at which the digital pulses will be generated and the configuration of the pulses.
  2. Run this VI.


Block Diagram Steps:

  1. Creates a counter output channel.
  2. Sets the number of samples to generate.
  3. Transitions the task to running state to begin generation.
  4. Waits for the generation to complete.
  5. Stops the task and returns it to the state it was in before DAQmx Start Task VI.
  6. Once all pulses with different duty cycle have been generated, clears the task and display any error occurs.

Front Panel.PNG

 

BD.PNG

**This document has been updated to meet the current required format for the NI Code Exchange.**
Mikhail
RF Toolkits, Product Support Engineer
National Instruments

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

Comments
mysticfree
Member
Member
on

Those delays are killing me. Is there any way to build the duty cycles along with how long each duty cycle will last and then send it to the DAQmx as one object?