Example Code

Gated Pulse Generation With On The Fly Configuration

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 using digital pulse to gate the generation of digital pulse generation from another counter and measure the digital pulse generated using an Analog Input channel.

Description:
Use this example to generate and view a gated counter output signal as well as changing the frequency and duty cycle of both pulses on the fly.  
You will need a DAQ device with at least two counters and one analog input channel.  On your connector block, connect the CTR1 Out terminal to the CTR0 Gate. Connect the CTR0 Out to AI1.  Be sure the Pause Trigger Source is directed to the PFI line of your CTR0 Gate.  When modifying the CTR0 output frequency try to use integer multiples of 10 in order to avoid the pause trigger carrying over a high value which will result in a high value output on the entire signal between burst pulses.

Requirements:

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


Steps to Implement or Execute Code:

  1. Specify all the control values on the front panel.
  2. Run this VI.
  3. Monitor the measured pulse from the indicator.


Block Diagram Steps:

  1. Creates two Counter Output channels; one is to be the gate of the other counter output channel and creates an Analog Input Voltage channel to measure the generated pulse.
  2. Specifies digital level to be the trigger type of signal to pause the task, the name of the terminal where the digital signal will be used as the source of the Pause Trigger and the digital edge at which the task will pause.
  3. Sets the channels to be continuously generating or acquiring data.
  4. Transitions the tasks to running state to begin acquisition and generation.
  5. Checks if the counter output tasks are ready for new values and update. Read the analog waveform and stop loop if button is pressed or any error occurs.
  6. Clears the task and displays any error occurs.

Front Panel.PNG

 

2017-05-31_14-10-51.jpg

 

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

National Instruments
Applications Engineer

Visit ni.com/gettingstarted for step-by-step help in setting up your system.

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