# CConfigScan()

Configures a counter channel. This method only works with counter boards that have counter scan capability.

Member of the MccBoard class.

## Function Prototype

VB .NET

Public Function CConfigScan(ByVal counterNum As Integer, ByVal mode As MccDaq.CounterMode, ByVal debounceTime As MccDaq.CounterDebounceTime, ByVal debounceMode As MccDaq.CounterDebounceMode, ByVal edgeDetection As MccDaq.CounterEdgeDetection, ByVal tickSize As MccDaq.CounterTickSize, ByVal mapCounter As Integer) As MccDaq.ErrorInfo

Public Function CConfigScan(ByVal counterNum As Integer, ByVal mode As MccDaq.CounterMode, ByVal debounceTime As MccDaq.CounterDebounceTime, ByVal debounceMode As MccDaq.CounterDebounceMode, ByVal edgeDetection As MccDaq.CounterEdgeDetection, ByVal tickSize As Integer, ByVal mapCounter As Integer) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo CConfigScan(int counterNum, MccDaq.CounterMode mode, MccDaq.CounterDebounceTime debounceTime, MccDaq.CounterDebounceMode debounceMode, MccDaq.CounterEdgeDetection edgeDetection, MccDaq.CounterTickSize tickSize, int mapCounter)

public MccDaq.ErrorInfo CConfigScan(int counterNum, MccDaq.CounterMode mode, MccDaq.CounterDebounceTime debounceTime, MccDaq.CounterDebounceMode debounceMode, MccDaq.CounterEdgeDetection edgeDetection, int tickSize, int mapCounter)

## Parameters

counterNum

The counter number to configure. This parameter is zero-based, so the first counter number is "0".

mode

Bit fields that control various options. All of the mode settings are MccDaq.CounterMode enumerated constants. Set it to one of the constants in the "mode parameter values" section below.

debounceTime

Used to bypass the debounce mode, or to set a channel's comparator output to one of 16 debounce times. Debounce is used to eliminate switch-induced transients typically associated with electromechanical devices including relays, proximity switches, and encoders.

All of the debounceTime settings are MccDaq.CounterDebounceTime enumerated constants. Set it to one of the constants in the "debounceTime parameter values" section below.

debounceMode

Sets the mode of the debounce module. The debounceMode settings are MccDaq.CounterDebounceMode enumerated constants. Set it to one of the constants in the "debounceMode parameter values" section below.

edgeDetection

Selects whether to detect a rising edge or falling edge. The edgeDetection settings are MccDaq.CounterEdgeDetection enumerated constants. Choices are RisingEdge and FallingEdge.

For counter devices that use channel mapping, if a counter is configured for FallingEdge, calling CIn() or CIn32() for that counter will result in a BADCOUNTERMODE error.

tickSize

Sets the tick size, which is the fundamental unit of time for period, pulsewidth, and timing measurements. All of the tickSize settings are MccDaq.CounterTickSize enumerated constants. Set it to one of the constants in the "tickSize parameter values" section below.

mapCounter

Used to select the mapped channel. A mapped channel is one of the counter input channels other than counterNum that can participate with the input signal of the counter defined by counterNum by gating the counter or decrementing the counter.

## Returns

- Error code or 0 if no errors

### mode parameter values

- Totalize mode

Sets the specified counter to totalize mode. This mode may contain any combination of non-contradictory choices from the following list of options:

Bit32 | Selects a 32-bit counter for asynchronous mode. This argument value only affects counter resolution for asynchronous calls (CIn(), CIn32(), and CIn64()). Recommended for use only with CIn32(). (Using the Bit32 option with CIn() is not very useful, since the value returned by CIn() is only 16 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping.) Refer to board-specific information for the product you are using for details on how this affects asynchronous reads on a specific device.
Bit48 | Selects a 48-bit counter for asynchronous mode. This argument value only affects counter resolution for asynchronous calls (CIn(), CIn32(), and CIn64()). (Using the Bit48 option with CIn() and CIn32() is not very useful, since the value returned by CIn() is only 16 bits, and the value returned by CIn32() is only 32 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping, and the value returned by CIn32() rolls over 65,535 times before stopping.) Refer to board-specific information for the product you are using for details on how this affects asynchronous reads on a specific device.
ClearOnRead | The counter is cleared after every read.
CountDownOff | The counter counts up.
CountDownOn | The counter counts down.
DecrementOn | Allows the mapped channel to decrement the counter. With this option, the main counter channel will increment the counter, and the mapped channel can be used to decrement the counter. By default, the counter decrement option is set to "off". This mode is not compatible with CIn() or CIn32(). If a counter is configured for DecrementOn, calling CIn() or CIn32() for that counter will result in a BADCOUNTERMODE error.
GateClrsCtr | The gate input clears the counter. By default, the counter is cleared when the gate input is high.
GateControlsDir | The gate input controls the direction of the counter. By default, the counter increments when the gate pin is high, and decrements when the gate pin is low.
GateTrigSrc | The counter starts counting when the gate input goes active. By default, active is on the rising edge. The gate is re-armed when the counter is loaded and when CConfigScan() is called.
GatingOn | Selects gating "on." When "on", the counter is enabled when the mapped channel or the gate pin that is used to gate the counter is high. When the mapped channel/gate pin is low, the counter is disabled but holds the count value. By default, the counter gating option is set to "off." For counter devices that use channel mapping, this mode is not compatible with CIn() or CIn32(). If a counter is configured for GatingOn, calling CIn() or CIn32() for that returns a BADCOUNTERMODE error.
InvertGate | Inverts the polarity of the gate input.
LatchOnMap | Causes the count to be latched by the signal on the mapped channel. By default, the count is latched by the internal "start of scan" signal, so the count is updated each time it's read. This mode is not compatible with CIn() or CIn32(). If a counter is configured for LatchOnMap, calling CIn() or CIn32() for that counter will result in a BADCOUNTERMODE error.
ModuloNOn | Enables modulo-n counting mode. In modulo-n mode, an upper limit is set by loading the max limit register with a maximum count. When counting up, the counter will roll-over to 0 when the maximum count is reached, and then continue counting up. Likewise when counting down, the counter will roll over to the maximum count (in the max limit register) whenever the count reaches 0, and then continue counting down.
NoRecycleOn | Enables non-recycle counting mode. In non-recycle mode, the counter stops counting whenever a count overflow or underflow takes place. Counting restarts when a clear or a load operation is performed on the counter or the count direction changes.
OutputInitialStateHigh | Sets the initial state of the counter output pin high.
OutputInitialStateLow | Sets the initial state of the counter output pin low.
OutputOn | Enables the counter output. By default, the counter output goes high when the counter reaches the value of output register 0, and low when the counter reaches the value of output register 1. Use CLoad, CLoad32, or CLoad64 to set or read the value of the output registers.
RangeLimitOn | Enables range limit counting mode. In range limit mode, an upper and lower limit is set, mimicking limit switches in the mechanical counterpart. Use CLoad, CLoad32, or CLoad64 to set the upper and lower limits – set the upper limit by loading the max limit register, and the lower limit by loading the min limit register. Note that on some devices the lower limit is programmable, but on other devices the lower limit is always 0. When counting up, the counter rolls over to min limit when the max limit is reached. When counting down, the counter rolls over to max limit when the min limit is reached. When counting up with NoRecycleOn enabled, the counter freezes whenever the count reaches the value that was loaded into the max limit register. When counting down with NoRecycleOn enabled, the counter freezes whenever the count reaches the value that was loaded into the min limit register. Counting resumes if the counter is reset or the direction changes.
StopAtMax | The counter will stop at the top of its count. For the CIn32() method, the top of the count depends on whether the Bit32 option is used. If it is, the top of the count is FFFFFFFF hex. If not, the top of the count is FFFF hex. By default, the counter counts upward and rolls over on the 32-bit boundary.
UpDownOn | Enables up/down counting mode.

- Encoder mode

Sets the specified counter to encoder measurement mode. This mode may contain any combination of non-contradictory choices from the following list of options:

EncoderModeBit16 | Selects a 16-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn().
EncoderModeBit32 | Selects a 32-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn32(). (Using the EncoderModeBit32 option with CIn() is not very useful, since the value returned by CIn() is only 16 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping.)
EncoderModeBit48 | Selects a 48-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn64(). (Using the EncoderModeBit48 option with CIn() and CIn32() is not very useful, since the value returned by CIn() is only 16 bits, and the value returned by CIn32() is only 32 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping, and the value returned by CIn32() rolls over 65,535 times before stopping.)
EncoderModeClearOnZOn | Selects "clear on Z" on. The counter is cleared when the index (Z input) goes active. By default, the "ClearOnZ" option is off, and the counter is not cleared.
EncoderModeLatchOnZ | Selects the Encoder Z mapped signal to latch the counter outputs. This allows the user to know the exact counter value when an edge is present on another counter.
EncoderModeModuloNOn | Enables Modulo-N counting mode. In Modulo-N mode, an upper limit is set by loading the max limit register with a maximum count. When counting up, the counter will roll-over to 0 when the maximum count is reached, and then continue counting up. Likewise when counting down, the counter will roll over to the maximum count (in the max limit register) whenever the count reaches 0, and then continue counting down.
EncoderModeNoRecycleOn | Enables Non-recycle counting mode. In Non-recycle mode, the counter is disabled whenever a count overflow or underflow takes place. The counter is re-enabled when a clear or a load operation is performed on the counter
EncoderModeRangeLimitOn | Enables Range Limit counting mode. In Range Limit mode, an upper and lower limit is set, mimicking limit switches in the mechanical counterpart. The upper limit is set by loading the max limit register with the CLoad, CLoad32, or CLoad64 functions. The lower limit is always 0. When counting up, the counter rolls over to min limit when the max limit is reached. When counting down, the counter rolls over to max limit when the min limit is reached. When counting up with EncoderModeNoRecycleOn enabled, the counter freezes whenever the count reaches the value that was loaded into the max limit register. When counting down with EncoderModeNoRecycleOn enabled, the counter freezes whenever the count reaches the value that was loaded into the min limit register. Counting resumes if the counter is reset or the direction changes.
EncoderModeX1 | Sets the encoder measurement mode to X1.
EncoderModeX2 | Sets the encoder measurement mode to X2.
EncoderModeX4 | Sets the encoder measurement mode to X4.

- Period mode

Sets the specified counter to period measurement mode. This mode may contain any combination of non-contradictory choices from the following list of options:

PeriodModeBit16 | Selects a 16-bit counter for asynchronous mode. This argument value only affects counter resolution for asynchronous calls (CIn(), CIn32(), and CIn64()). Recommended for use only with CIn().
PeriodModeBit32 | Selects a 32-bit counter for asynchronous mode. This argument value only affects counter resolution for asynchronous calls (CIn(), CIn32(), and CIn64()). Recommended for use only with CIn32(). (Using the PeriodModeBit32 option with CIn() is not very useful, since the value returned by CIn() is only 16 bits. The effect is that the value returned by CIn() rolls over at 64k 65,535 times before stopping.)
PeriodModeBit48 | Selects a 48-bit counter for asynchronous mode. This argument value only affects counter resolution for asynchronous calls (CIn(), CIn32(), and CIn64()). Recommended for use only with CIn64(). (Using the PeriodModeBit48 option with CIn() and CIn32() is not very useful, since the value returned by CIn() is only 16 bits, and the value returned by CIn32() is only 32 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping, and the value returned by CIn32() rolls over 65,535 times before stopping.)
PeriodModeGatingOn | Selects gating "on." When "on", the counter is enabled when the mapped channel or the gate pin that is used to gate the counter is high. When the mapped channel/gate pin is low, the counter is disabled but holds the count value. By default, the counter gating option is set to "off." For counter devices that use channel mapping, this mode is not compatible with CIn() or CIn32(). If a counter is configured for PeriodModeGatingOn, calling CIn() or CIn32() for that returns a BADCOUNTERMODE error.
PeriodModeInvertGate | Inverts the polarity of the gate input.
PeriodModeX1 | The measurement is latched each time one complete period is observed.
PeriodModeX10 | The measurement is latched each time 10 complete periods are observed.
PeriodModeX100 | The measurement is latched each time 100 complete periods are observed.
PeriodModeX1000 | The measurement is latched each time 1000 complete periods are observed.

- PulseWidth mode

Sets the specified counter to Pulsewidth measurement mode. This mode may contain any combination of non-contradictory choices from the following list of options:

PulseWidthModeBit16 | Selects a 16-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn().
PulseWidthModeBit32 | Selects a 32-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn32(). (Using the PulseWidthModeBit32 option with CIn() and CIn32() is not very useful, since the value returned by CIn() is only 16 bits, and the value returned by CIn32() is only 32 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping, and the value returned by CIn32() rolls over 65,535 times before stopping.)
PulseWidthModeBit48 | Selects a 48-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn64(). (Using the PulseWidthModeBit48 option with CIn() and CIn32() is not very useful, since the value returned by CIn() is only 16 bits, and the value returned by CIn32() is only 32 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping, and the value returned by CIn32() rolls over 65,535 times before stopping.)
PulseWidthModeGatingOn | Selects gating "on." When "on", the counter is enabled when the mapped channel or the gate pin that is used to gate the counter is high. When the mapped channel/gate pin is low, the counter is disabled but holds the count value. By default, the counter gating option is set to "off." For counter devices that use channel mapping, this mode is not compatible with CIn() or CIn32(). If a counter is configured for PulseWidthModeGatingOn, calling CIn() or CIn32() for that returns a BADCOUNTERMODE error.
PulseWidthModeInvertGate | Inverts the polarity of the gate input.

- TIMING mode

Sets the specified counter to timing mode. This mode supports the following option:

TimingModeBit16 | Selects a 16-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn().
TimingModeBit32 | Selects a 32-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn32(). (Using the TimingModeBit32 option with CIn() is not very useful, since the value returned by CIn() is only 16 bits. The effect is that the value returned by CIn() rolls over at 64k 65,535 times before stopping.)
TimingModeBit48 | Selects a 48-bit counter for asynchronous mode. This argument value only affects CIn64(), CIn32(), and CIn(). Recommended for use only with CIn64(). (Using the TimingModeBit48 option with CIn() and CIn32() is not very useful, since the value returned by CIn() is only 16 bits, and the value returned by CIn32() is only 32 bits. The effect is that the value returned by CIn() rolls over 4,294,967,295 times before stopping, and the value returned by CIn32() rolls over 65,535 times before stopping.)
TimingModeInvertGate | Inverts the polarity of the gate input.

### debounceTime parameter values

Debounce500ns | Sets the counter channel's comparator output to 500 ns.
Debounce1500ns | Sets the counter channel's comparator output to 1500 ns.
Debounce3500ns | Sets the counter channel's comparator output to 3500 ns.
Debounce7500ns | Sets the counter channel's comparator output to 7500 ns.
Debounce15500ns | Sets the counter channel's comparator output to 15500 ns.
Debounce31500ns | Sets the counter channel's comparator output to 31500 ns.
Debounce63500ns | Sets the counter channel's comparator output to 63500 ns.
Debounce127500ns | Sets the counter channel's comparator output to 127500 ns.
Debounce100us | Sets the counter channel's comparator output to 100 us.
Debounce300us | Sets the counter channel's comparator output to 300 us.
Debounce700us | Sets the counter channel's comparator output to 700 us.
Debounce1500us | Sets the counter channel's comparator output to 1500 us.
Debounce3100us | Sets the counter channel's comparator output to 3100 us.
Debounce6300us | Sets the counter channel's comparator output to 6300 us.
Debounce12700us | Sets the counter channel's comparator output to 12700 us.
Debounce25500us | Sets the counter channel's comparator output to 25500 us.
DebounceNone | Disables the debounce feature.

### debounceMode parameter values

TriggerBeforeStable | Use this mode when the input signal has groups of glitches and each group is to be counted as one. The trigger before stable mode will recognize and count the first glitch within a group but reject the subsequent glitches within the group if the debounce time is set accordingly. In this case the debounce time should be set to encompass one entire group of glitches.
TriggerAfterStable | This mode rejects glitches and only passes state transitions after a specified period of stability (the debounce time). This mode is used with electromechanical devices like encoders and mechanical switches to reject switch bounce and disturbances due to a vibrating encoder that is not otherwise moving. The debounce time should be set short enough to accept the desired input pulse but longer than the period of the undesired disturbance.

### tickSize parameter values

Tick20ns | Sets the counter channel's tick size to 20 ns.
Tick20pt83ns | Sets the counter channel's tick size to 20.83 ns.
Tick200ns | Sets the counter channel's tick size to 200 ns.
Tick208pt3ns | Sets the counter channel's tick size to 208.3 ns.
Tick2000ns | Sets the counter channel's tick size to 2000 ns.
Tick2083pt3ns | Sets the counter channel's tick size to 2083.3 ns.
Tick20000ns | Sets the counter channel's tick size to 20000 ns.
Tick20833pt3ns | Sets the counter channel's tick size to 20833.3 ns.