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 |
BYTE dscQMMMeasurePeriod(DSCB board, BYTE frequency, DWORD* periods);
Name | Description |
---|---|
board | The handle of the board to operate on |
frequency | The desired reference frequency to use for the measurement. See the table below. |
periods | Pointer to a variable to hold the result of the measurement |
Error code or 0.
Macro | Value | Reference Period |
---|---|---|
QMM_SOURCE_F1_4MHZ | 11 | .25µs |
QMM_SOURCE_F2_400KHZ | 12 | 2.5µs |
QMM_SOURCE_F3_40KHZ | 13 | 25µs |
QMM_SOURCE_F4_4KHZ | 14 | .25ms |
QMM_SOURCE_F5_400HZ | 15 | 2.5ms |
This page was last modified 12:17, 12 Feb 2004.
Copyright (c) 2004 Diamond Systems. All Rights Reserved.