Example Code

Measure Continuous Signal for the Duty Cycle with Counter

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
The example is to demonstrate the measurement of the duty cycle of a signal using the counter of the DAQ Hardware

Description:
This is a simple VI to show how to acquire the measured signal and also determine the duty cycle using the counter. Leveraging the DAQmx and DAQ hardware, we could access the counter input pin and acquire the signal continuously and also calculate the duty cycle of it.

Steps to Implement or Execute Code:
To implement this example:

  1. Define the Physical Channels of the counter
  2. (Optional) Set the value of the parameters as needed
  3. Run the VI
  4. (Optional) Turn on the Highlight Execution to see the flow of the VI


To execute this example:

  1. Install the required software.
  2. Connect the DAQ hardware that supports the Counter features
  3. Confirm the connection with the MAX with TestPanel
  4. Open the VI and refer the Implement Steps


Requirements
Software
LabVIEW 2012 or compatible
NI-DAQmx 9.0 or compatible

Hardware
cDAQ with C series Counter Input Module

Additional Notes:

  • The counter will measure pulses on the input terminal of the counter specified in the Physical Channel I/O control.  In this example the pulse width will be measured on the default input terminal on ctr0.  For more information on the default counter input and output terminals for your device, open the NI-DAQmx Help, and refer to Counter Signal Connections found under the Device Considerations book in the table of contents.

 

fp.PNG

 

bd.PNG

 

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

Ben

National Instruments
Certified LabVIEW Associate Developer
Certified TestStand Developer

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

Comments
Todd S.
NI Employee (retired)
on

Great stuff.  I added "LabVIEW" as a tag so it would show up on the front page.

Todd S.
LabVIEW Community Manager
National Instruments