Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure Events That Occur During a Specified Time Period Using Counters

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:
  1. LabVIEW 2012 or compatible.
  2. NI-DAQmx 15.5.1 or compatible.
  3. DAQ device with at least 2 counters.


Steps to Implement or Execute Code:

  1. Select the Physical Channel which corresponds to the counter at which the pulse width measurement takes place and also on the DAQ device.
  2. 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:

  1. 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.
  2. 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:

  1. Select the Physical Channel which corresponds to the counter at which the pulse width measurement takes place and also on the DAQ device.
  2. 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:

  1. 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.
  2. 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:

  1. Creates a channel to measure the width of a digital pulse.
  2. Specifies the input terminal of the signal to measure and the terminal of the timebase to use for the counter.
  3. Sets the number of samples to acquire i.e. continuous samples.
  4. Transition the task to the running state to begin measurement.
  5. 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.
  6. Clears the task and displays any error occurs.

 
Block Diagram Steps - Counter Output:

  1. Creates a channel to generate digital pulses defined by the amount of time the pulse is at a high state.
  2. Programs the hardware as much as possible according to the task configuration.
  3. Wait for the user to click on the Boolean control to initiate start task.
  4. Clears the task and displays any error occurs. 

 

2017-05-31_9-45-31.jpg

 

bd.png

 

 

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