ViStatus niSync_MeasureFrequency (ViSession vi, ViConstString sourceTerminal, ViReal64 duration, ViReal64* actualDuration, ViReal64* measuredFrequency, ViReal64* error);
Measures the frequency of the signal at the specified terminal for a specified duration. The terminal you specify with sourceTerminal must contain a digital signal for the function to operate.
The following time-based timing and synchronization devices are compatible with Measure Frequency:
When using niSync_MeasureFrequency with a PXI-6683(H) or other time-based device, timestamping is used to measure the frequency. The function will measure timestamps until you have acquired timestamps that have an actualDuration greater than or equal to the specified duration. If timestamps are not detected or not enough timestamps are detected due to a slow signal or a decimationCount that is too high, the function may encounter an error. Generally, you should have a timestamp within every second to avoid this error.
![]() |
Note The maximum signal you can measure using this function is 22.7 MHz. |
The decimationCount parameter is only necessary on PXI-6683(H) and other time-based devices. In order to set the decimationCount accurately, you should have a general idea of what range (Hz, kHz, MHz) the signal to be measured occupies.
Only PFI and PXI_Trig lines can be used as the sourceTerminal on time-based devices.
For the most accurate measurement, the board clock for the time-based device you are trying to measure should be set to free running. If you are synchronizing to GPS, IRIG, or a PTP protocol like 1588, the function may encounter an error or the result may be unreliable.
When you are measuring frequency with this function using a time-based device, you may encounter a software buffer overflow error. This means that there is not enough memory to store the recorded timestamps when measuring frequency. You can take one or more of the following actions to resolve a software buffer overflow error:
The following signal-based timing and synchronization devices are compatible with Measure Frequency:
Using a signal-based device and niSync_MeasureFrequency, you can measure the frequency of the device's oscillator, an external clock connected to a front panel input, or a full speed or divided synchronization clock.
When measuring the frequency on a signal-based device, you must set the duration in multiples of 100 nanoseconds, i.e. a multiple of the PXI_Clk10 period. If the duration is not a multiple of the PXI_Clk10 period, it will be coerced to the closest multiple and returned in the actualDuration parameter.
Name | Type | Description |
---|---|---|
vi | ViSession | The session handle that you obtain from niSync_init. The handle identifies a particular instrument session. |
sourceTerminal | ViConstString | This input specifies the source terminal of the signal to measure.
Valid Values: NISYNC_VAL_PFI0 (Default Value) NISYNC_VAL_PFI1 NISYNC_VAL_PFI2 NISYNC_VAL_PFI3 NISYNC_VAL_PFI4 NISYNC_VAL_PFI5 NISYNC_VAL_PFILVDS0 NISYNC_VAL_PFILVDS1 NISYNC_VAL_PFILVDS2 NISYNC_VAL_PXITRIG0 NISYNC_VAL_PXITRIG1 NISYNC_VAL_PXITRIG2 NISYNC_VAL_PXITRIG3 NISYNC_VAL_PXITRIG4 NISYNC_VAL_PXITRIG5 NISYNC_VAL_PXITRIG6 NISYNC_VAL_PXITRIG7 NISYNC_VAL_PXISTAR0 NISYNC_VAL_PXISTAR1 NISYNC_VAL_PXISTAR2 NISYNC_VAL_PXISTAR3 NISYNC_VAL_PXISTAR4 NISYNC_VAL_PXISTAR5 NISYNC_VAL_PXISTAR6 NISYNC_VAL_PXISTAR7 NISYNC_VAL_PXISTAR8 NISYNC_VAL_PXISTAR9 NISYNC_VAL_PXISTAR10 NISYNC_VAL_PXISTAR11 NISYNC_VAL_PXISTAR12 NISYNC_VAL_PXISTAR13 NISYNC_VAL_PXISTAR14 NISYNC_VAL_PXISTAR15 NISYNC_VAL_PXISTAR16 NISYNC_VAL_PXIEDSTARC0 NISYNC_VAL_PXIEDSTARC1 NISYNC_VAL_PXIEDSTARC2 NISYNC_VAL_PXIEDSTARC3 NISYNC_VAL_PXIEDSTARC4 NISYNC_VAL_PXIEDSTARC5 NISYNC_VAL_PXIEDSTARC6 NISYNC_VAL_PXIEDSTARC7 NISYNC_VAL_PXIEDSTARC8 NISYNC_VAL_PXIEDSTARC9 NISYNC_VAL_PXIEDSTARC10 NISYNC_VAL_PXIEDSTARC11 NISYNC_VAL_PXIEDSTARC12 NISYNC_VAL_PXIEDSTARC13 NISYNC_VAL_PXIEDSTARC14 NISYNC_VAL_PXIEDSTARC15 NISYNC_VAL_PXIEDSTARC16 NISYNC_VAL_OSCILLATOR NISYNC_VAL_CLKIN |
duration | ViReal64 | Specifies the length of time, in seconds, to measure the frequency. Set a longer duration to return a more accurate frequency measurement. The duration should be a multiple of the PXI_Clk10 signal period. That is, it should be specified in multiples of 100 ns. If the duration is not a multiple of the PXI_Clk10 period, it will be coerced to the closest multiple. Default Value: 0.00000100 seconds |
actualDuration | ViReal64 | Returns the actual duration, in seconds, that the function measured the frequency of the signal at the specified terminal. If the value you enter in duration is not a multiple of the PXI_CLK10 period, the actualDuration will be the closest multiple of 100 ns. |
measuredFrequency | ViReal64 | Returns the frequency, in Hz, measured at the specified terminal. THe measurable frequency range is dependent on the hardware; refer to the hardware's documentation to determine the frequency range of any given terminal. |
error | ViReal64 | Returns the margin of error calculated for the frequency measurement. The formula used to calculate the error is:
error = [ (10M / base_freq) ] / [actual_duration] where base_freq refers to the base frequency and actual_duration refers to the output of the actualDuration parameter. |