# CFreqIn()

Measures the frequency of a signal. This method can only be used with 9513 counters. This method uses internal counters #5 and #4.

Member of the MccBoard class.

## Function Prototype

VB .NET

Public Function CFreqIn(ByVal signalSource As MccDaq.SignalSource, ByVal gateInterval As Integer, ByRef count As Short, ByRef freq As Integer) As MccDaq.ErrorInfo

Public Function CFreqIn(ByVal signalSource As MccDaq.SignalSource, ByVal gateInterval As Integer, ByRef count As System.UInt16, ByRef freq As Integer) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo CFreqIn(MccDaq.SignalSource signalSource, int gateInterval, out short count, out int freq)

public MccDaq.ErrorInfo CFreqIn(MccDaq.SignalSource signalSource, int gateInterval, out ushort count, out int freq)

## Parameters

signalSource

Specifies the source of the signal to calculate the frequency from.

The signal to be measured is routed internally from the source specified by signalSource to the clock input of counter 5. On boards with more than one 9513 chip, there is more than one counter 5. Which counter 5 is used is also determined by signalSource. Set it to one of the constants in the "signalSource parameter values" section below.

The value of signalSource determines which chip will be used. CtrInput6 through CtrInput10, Freq6 through Freq10 and Gate6 through Gate9 indicate chip two will be used. The signal to be measured must be present at the chip two input specified by signalSource.

Note: The gating connection from counter 4 output to counter 5 gate must be made between counters 4 and 5 of this chip (refer to the Notes section below). Refer to board-specific information to determine valid values for your board.

gateInterval

Gating interval in milliseconds (must be > 0). Specifies the time, in milliseconds, that the counter will count. The optimum gateInterval depends on the frequency of the measured signal. The counter can count up to 65,535.

If the gating interval is too low, then the count will be too low and the resolution of the frequency measurement will be poor. For example, if the count changes from 1 to 2 the measured frequency doubles.

If the gating interval is too long, the counter will overflow and a FreqOverFlow error will occur.

This method will not return until the gateInterval has expired. There is no background option. Under Windows, this means that window activity will stop for the duration of the call. Adjust the gateInterval so this does not pose a problem to your user interface.

count

The raw count.

freq

The measured frequency in Hz.

## Returns

- An ErrorInfo object that indicates the status of the operation.
- count - Count that the frequency calculation is based on.
- freq - Measured frequency in Hz

### signalSource parameter values

All of the signalSource settings are MccDaq.SignalSource enumerated constants. To set a variable to one of these constants, you must refer to the MccDaq object and the SignalSource enumeration (for example, variable = MccDaq.SignalSource.CtrInput1, variable = MccDaq.SignalSource.Gate1, etc.).

One 9513 chip (Chip 1 used): | CtrInput1 through CtrInput5
Gate1 through Gate4
Freq1 through Freq5
Two 9513 chips (Chip 1 or Chip 2 used): | CtrInput1 through CtrInput10
Gate1 through Gate 9 (excluding gate 5)
Freq1 through Freq10
Four 9513 chips (Chips 1- 4 may be used): | CtrInput1 through CtrInput20
Gate1 through Gate19 (excluding gates 5, 10, and 15)
Freq1 through Freq20

## Notes

- This method requires an electrical connection between counter 4 output and counter 5 gate. This connection must be made between counters 4 and 5 on the chip specified by signalSource.
- C9513Init() must be called for each chipNum that will be used by this method. The values of foutDivider, foutSource, compare1, compare2, and timeOfDay are irrelevant to this method and may be any value shown in the C9513Init() method description.
- If you select an external clock source for the counters, the gateInterval, count, and freq settings are only valid if the external source is 1 MHz. Otherwise, you need to scale the values according to the frequency of the external clock source.
- For example, for an external clock source of 2 MHz, increase your gateInterval setting by a factor of 2, and also double the count and freq values returned when analyzing your results.