NI-DAQmx: Measure Semi Period in .NET
Overview
This example demonstrates how to measure semi period on a Counter Input Channel. The Edge, Minimum Value and Maximum Value are all configurable. This example shows how to measure semi period on the counter's default input terminal (refer to section IV, I/O Connections Overview, below for more information), but could easily be expanded to measure semi-period on any PFI, RTSI, or internal signal. Semi-period measurement differs from pulse width measurement in that it measures both the high and the low pulses of a given signal. So for every period, two data points will be returned.
Instructions for running
- Select the physical channel which corresponds to the counter you want to use to measure semi-periods on the DAQ device.
- Enter the maximum and minimum value to specify a range for your unknown semi-periods.
Note: It is important to set the maximum and minimum values of your unknown semi-period as accurately as possible so the best internal timebase can be chosen to minimize measurement error. The default values specify the range that can be measured by the counter using the 20MHzTimebase. Use the GenDigPulseTrain_Continuous example to verify that you are measuring correctly on the DAQ device.
Steps
- Create a counter input channel using Task.CIChannel.CreateCISemiPeriodChannel. It is important to set the maximum and minimum values of your unknown period as accurately as possible so the best internal timebase can be chosen to minimize measurement error. The default values specify a range that can be measured by the counter using the 20MHzTimebase.
- Call the CounterReader.BeginReadSingleSampleDouble method to arm the counter and begin measuring.
- Call the Task.Dispose method to stop the task and de-allocate any resources used by the Task.
- Handle any DaqExceptions and display a message box if there are errors.
I/O Connections Overview
This example will perform a measurement on the default terminal(s) of the
counter specified. The default counter terminal(s) depend on the type of
measurement being taken. In this example the two edge separation will be
measured on the default input terminals 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.
Requirements
Filename: meas_semi_period.zip
Software Requirements
Language(s): C#, Visual Studio .NET, Visual Basic .NET
Hardware Requirements
Hardware Group: Multifunction DAQ (MIO), Counter/Timers (TIO)
Driver: NI-DAQmx 8.6
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
