DscQMMMeasureFrequency

Universal Driver Documentation
This function uses counters 4 and 5 to measure the frequency of a TTL-level signal. The input signal can be connected to any of the nine sources listed below. In order for this function to run, Counter 4 output (pin 12) must be wired externally to Counter 5 gate (pin 15). Otherwise, the program will hang.

The output of Counter 4 is initially high, and the output of Counter 5 is initially low. Counter 4's output will remain high for the duration specified in interval. The frequency is measured by using Counter 5 to count the number of rising edges of the input signal which occur during this measured time interval, and the count is returned in pulses. Counter 5 is gated by the output of Counter 4, so it counts for a known period of time. If the measurement period is too long, Counter 5 will reach its maximum count of 65535, its output will toggle high, and the function will return an error code of DE_QMM_OVERFLOW. Thus the programmer has both a hardware and a software indication of overflow. In this case use the next smaller measurement interval and try again, continuing in this fashion until no error code is returned.

The entire procedure lasts exactly as long as the specified measurement interval. For the longest interval (10 seconds), the computer may appear to have hung; however, it is simply in a monitoring loop waiting for Counter 4's output to toggle low, and it will return to the calling program as soon as this event occurs.

The fastest measurable frequency is limited by the 9513 chip specifications to 7MHz; specifying a measurement interval of 1 ms for a 7MHz input frequency will yield a count of 7000, well within the 65535 count limit. The slowest measurable frequency depends on the allowable error tolerance, since the edge count could be off by 1 due to alignment of the input edges with the measurement interval.

Measuring the frequency of a very slow signal is more accuratly done by measuring the period with dscQMMMeasurePeriod() and taking the reciprocal.

The frequency of the input signal is derived from the formulas

Frequency = pulses / Measurement period or Frequency = pulses * Measurement frequency

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

Table of contents

Function Definition

BYTE dscQMMMeasureFrequency(DSCB board, BYTE interval, BYTE source, WORD* pulses)

Function Parameters

NameDescription
boardThe handle of the board to operate on
intervalDesired measurement time interval. See the table below.
sourceSource signal to measure. See the table below Note that Gate 5 is not a valid choice since it is used by the function.
pulsesPointer to a variable that will contain the number of pulses

Return Value

Error code or 0.

QMM Interval Table

Macro
QMM_INTERVAL_1MS_1KHZ
QMM_INTERVAL_10MS_100HZ
QMM_INTERVAL_100MS_10HZ
QMM_INTERVAL_1S_1HZ
QMM_INTERVAL_10S_01HZ

QMM Source Table

Macro
QMM_SOURCE_SRC1
QMM_SOURCE_SRC2
QMM_SOURCE_SRC3
QMM_SOURCE_SRC4
QMM_SOURCE_SRC5
QMM_SOURCE_GATE1
QMM_SOURCE_GATE2
QMM_SOURCE_GATE3
QMM_SOURCE_GATE4


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