DscQMMMeasurePeriod

Universal Driver Documentation
This function measures the period of an input signal by counting the number of pulses of a known reference frequency which occur between two successive rising edges of the input signal. The input signal is connected to Gate 5 (pin 15), and the counting frequency is selected by frequency. The accuracy of the measurement is equal to the period of the chosen reference frequency.

The function operates as follows: Counter 5's output is preset low. On the first rising edge of the input signal, Counter 5 will begin to count edges of the reference frequency, and on the second rising edge its count will be transferred into its hold register. The contents of the hold register are returned in the parameter periods and represents the number of edges, or periods, of the reference frequency equal to a single period of the input signal. Note that since only the rising edge of the input signal is used to control Counter 5, the input signal's duty cycle is irrelevant. Also note that the function waits for the first rising edge before beginning the measurement. This adds to the total execution time for the function.

If the signal's period is too long, Counter 5 will reach its maximum count of 65535 and its output will toggle high. In this case the function will return error code DE_QMM_OVERFLOW, and periods will be set to 0. To correct this situation, select the next slower count frequency and repeat the procedure in this fashion until no error code is returned.

The longest period which can be measured using this function is 65,535 x the period of the chosen reference frequency. In the case of 400Hz, the slowest option, the longest period is 163,837ms, or 2 mins. 44 secs. Since the fastest reference frequency is 4MHz, the smallest period which can be captured is greater than the period of this frequency, or 0.25µs. However the measurement error will increase substantially as the period of the input signal approaches this lower limit.

Measuring the period of a fast input signal is more accurately done by measuring the frequency instead with dscQMMMeasureFrequency() and taking the reciprocal.

The period of the input signal is calculated by the formula: Period = periods * reference period

The function will return DE_QMM_OVERFLOW if a measurement overflow occured. Otherwise it will return DE_NONE .

Table of contents

Function Definition

BYTE dscQMMMeasurePeriod(DSCB board, BYTE frequency, DWORD* periods);

Function Parameters

NameDescription
boardThe handle of the board to operate on
frequencyThe desired reference frequency to use for the measurement. See the table below.
periodsPointer to a variable to hold the result of the measurement

Return Value

Error code or 0.

QMM Source Frequency Table

MacroValueReference Period
QMM_SOURCE_F1_4MHZ11.25µs
QMM_SOURCE_F2_400KHZ122.5µs
QMM_SOURCE_F3_40KHZ1325µs
QMM_SOURCE_F4_4KHZ14.25ms
QMM_SOURCE_F5_400HZ152.5ms


This page was last modified 12:17, 12 Feb 2004.
Copyright (c) 2004 Diamond Systems. All Rights Reserved.