Overview:
Demonstrates on measuring the pulse widths within a finite period.
Description:
This example demonstrates on measuring the pulse widths on a Counter Input Channel by using secondary counter i.e. Counter Output pulse as the gate. The Counter Output will generate a pulse with the specified period of high time everytime the user clicks on the "Take Sample" button. On the other hand, the Counter Input will count the edges within the high time of the single pulses generated.
Requirements:
- LabVIEW 2012 or compatible.
- NI-DAQmx 15.5.1 or compatible.
- DAQ device with at least 2 counters.
Steps to Implement or Execute Code:
- Select the Physical Channel which corresponds to the counter at which the pulse width measurement takes place and also on the DAQ device.
- Enter the Maximum and Minimum Value to specify the range of the pulse width to be measured.
Note: It is important to set the Maximum and Minimum Values of the unknown pulse width as accurately as possible so the best internal timebase will be chosen to minimize measurement error.
The default values specify a range that can be measured by the counter using the 20MhzTimebase. Use the Gen Dig Pulse Train-Continuous example to verify that you are measuring correctly on the DAQ device.
I/O Connections Overview:
- External wiring from the PFI Output pin of the Counter Output is NOT required, should you specify the Counter Timebase as CtrXXInternalOutput. If your DAQ device does not support internal routing, external wiring is required.
- The pulse width is measured on the PFI pin specifed at the Pulse Width Input Terminal control. Wire the signal to be measured to the terminal.
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.
Instructions:
- Select the Physical Channel which corresponds to the counter at which the pulse width measurement takes place and also on the DAQ device.
- Enter the Maximum and Minimum Value to specify the range of the pulse width to be measured.
Note: It is important to set the Maximum and Minimum Values of the unknown pulse width as accurately as possible so the best internal timebase will be chosen to minimize measurement error.
The default values specify a range that can be measured by the counter using the 20MhzTimebase. Use the Gen Dig Pulse Train-Continuous example to verify that you are measuring correctly on the DAQ device.
I/O Connections Overview:
- External wiring from the PFI Output pin of the Counter Output is NOT required, should you specify the Counter Timebase as CtrXXInternalOutput. If your DAQ device does not support internal routing, an external wiring is required.
- The pulse width is measured on the PFI pin specified at the Pulse Width Input Terminal control. Wire the signal to be measured to the terminal.
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.
Block Diagram Steps - Counter Input:
- Creates a channel to measure the width of a digital pulse.
- Specifies the input terminal of the signal to measure and the terminal of the timebase to use for the counter.
- Sets the number of samples to acquire i.e. continuous samples.
- Transition the task to the running state to begin measurement.
- Checks for the number of samples available to read. If there is sample in the buffer, read the data and display them on the Pulse Width indicator.
- Clears the task and displays any error occurs.
Block Diagram Steps - Counter Output:
- Creates a channel to generate digital pulses defined by the amount of time the pulse is at a high state.
- Programs the hardware as much as possible according to the task configuration.
- Wait for the user to click on the Boolean control to initiate start task.
- Clears the task and displays any error occurs.


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