c_config_scan()

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

Prototype

c_config_scan(board_num, counter_num, mode, debounce_time, debounce_mode, edge_detection, tick_size, mapped_channel)

Parameters

board_num (int)

The number associated with the board when it was installed with InstaCal or created with create_daq_device().

counter_num (int)

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

mode (CounterMode)

lags that control various options. May contain any combination of non-contradictory choices in the "Mode parameter values" section below.

debounce_time (CounterDebounceTime)

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.

debounce_mode (CounterDebounceMode)

Sets the mode of the debounce module to CounterDebounceMode.TRIGGER_BEFORE_STABLE or CounterDebounceMode.TRIGGER_AFTER_STABLE.

CounterDebounceMode.TRIGGER_BEFORE_STABLE:: 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.

CounterDebounceMode.TRIGGER_AFTER_STABLE: 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.

edge_detection (CounterEdgeDetection)

elects whether to detect a rising edge or falling edge. Choices are CounterEdgeDetection.RISING_EDGE and CounterEdgeDetection.FALLING_EDGE.

For counter devices that use channel mapping, if a counter is configured for CounterEdgeDetection.FALLING_EDGE, calling c_in() or c_in_32() for that counter will result in a ULError with the error code ErrorCode.BADCOUNTERMODE.

For counter devices that use channel mapping, if a counter is configured for CTR_FALLING_EDGE, calling c_in() or c_in_32() for that counter will result in a BADCOUNTERMODE error.

tick_size (MccDaq.CounterTickSize)

Sets the tick size, which is the fundamental unit of time for period, pulsewidth, and timing measurements.

mapped_channel

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

Mode parameter values

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

BIT_32Selects a 32-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in_32(). (Using the BIT_32 option with c_in() is not very useful, since the value returned by c_in() is only 16 bits. The effect is that the value returned by c_in() rolls over 65,535 times before stopping.)

Refer to board-specific information for details on how this affects asynchronous reads on a specific device.
BIT_48Selects a 48-bit counter for asynchronous mode. This parameter value only affects c_in_32(), c_in_32(), and c_in_64(). Using the BIT_48 option with c_in() and c_in_32() is not very useful, since the value returned by c_in() is only 16 bits, and the value returned by c_in_32() is only 32 bits. The effect is that the value returned by c_in() rolls over 4,294,967,295 times before stopping, and the value returned by c_in_32() rolls over 65,535 times before stopping.)

Refer to board-specific information for details on how this affects asynchronous reads on a specific device.
CLEAR_ON_READThe counter is cleared after every read.
COUNT_DOWN_OFFThe counter counts up.
COUNT_DOWN_ONThe counter counts down.
DECREMENT_ONAllows the mapped channel to decrement the counter. With this option, the main counter input 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 c_in() or c_in_32(). If a counter is configured for DECREMENT_ON, calling c_in() or c_in_32() for that counter will result in a BADCOUNTERMODE error.
GATE_CLEARS_CTRThe 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.
GATE_CONTROLS_DIRThe 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.
GATE_TRIG_SRCThe 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 c_config_scan() is called.
GATING_ONSelects 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 c_in() or c_in_32. If a counter is configured for GATING_ON, calling c_in() or c_in_32() for that counter will result in a BADCOUNTERMODE error.
INVERT_GATEInverts the polarity of the gate input.
LATCH_ON_MAPCauses 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 c_in() or c_in_32(). If a counter is configured for LATCH_ON_MAP, calling c_in() or c_in_32() for that counter will result in a BADCOUNTERMODE error.
MODULO_N_ONEnables 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.
NO_RECYCLE_ONEnables 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.
OUTPUT_INITIAL_STATE_HIGHSets the initial state of the counter output pin high.
OUTPUT_INITIAL_STATE_LOWSets the initial state of the counter output pin low.
OUTPUT_ONEnables 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 c_load(), c_load_32(), or c_load_64() to set or read the value of the output registers.
RANGE_LIMIT_ONEnables Range Limit counting mode. In Range Limit mode, an upper and lower limit is set, mimicking limit switches in the mechanical counterpart. Use c_load(), c_load_32(), or c_load_64() 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 NO_RECYCLE_ON enabled, the counter freezes whenever the count reaches the value that was loaded into the max limit register. When counting down with NO_RECYCLE_ON 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.
STOP_AT_MAXThe counter will stop at the top of its count. For c_in_32(), the top of the count depends on whether the BIT_32 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.
UPDOWN_ONEnables Up/down counting 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:

ENCODER_MODE_BIT_16Selects a 16-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32 and c_in_64(). Recommended for use only with c_in().
ENCODER_MODE_BIT_32Selects a 32-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32 and c_in_64(). Recommended for use only with c_in_32(). Using the ENCODER_MODE_BIT_32 option with c_in() is not very useful, since the value returned by c_in() is only 16 bits. The effect is that the value returned by c_in() rolls over 65,535 times before stopping.
ENCODER_MODE_BIT_48Selects a 48-bit counter for asynchronous mode.This parameter value only affects c_in(), c_in_32 and c_in_64(). Recommended for use only with c_in_64(). (Using the ENCODER_MODE_BIT_48 option with c_in() and c_in_32() is not very useful, since the value returned by c_in() is only 16 bits, and the value returned by c_in_32() is only 32 bits. The effect is that the value returned by c_in() rolls over 4,294,967,295 times before stopping, and the value returned by c_in_32() rolls over 65,535 times before stopping.)
ENCODER_MODE_CLEAR_ON_Z_ONSelects "clear on Z" on. The counter is cleared when the index (Z input) goes active. By default, the "clear on Z" option is off, and the counter is not cleared.
ENCODER_MODE_LATCH_ON_ZSelects 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.
ENCODER_MODE_MODULO_N_ONEnables 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.
ENCODER_MODE_NO_RECYCLE_ONEnables 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.
ENCODER_MODE_RANGE_LIMIT_ONEnables 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 c_load(), c_load_32(), or c_load_64(). The lower limit is always 0. When counting up, the counter freezes whenever the count reaches the value that was loaded into the max limit register.
ENCODER_MODE_X1Sets the encoder measurement mode to X1.
ENCODER_MODE_X2Sets the encoder measurement mode to X2.
ENCODER_MODE_X4Sets the encoder measurement mode to X4.

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

PERIOD_MODE_BIT_16Selects a 16-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in.
PERIOD_MODE_BIT_32Selects a 32-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in_32. Using the PERIOD_MODE_BIT_32 option with c_in() is not very useful, since the value returned by c_in() is only 16 bits. The effect is that the value returned by c_in() rolls over at 65,535 times before stopping.
PERIOD_MODE_BIT_48Selects a 48-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in_64(). Using the PERIOD_MODE_BIT_48 option with c_in() and c_in_32() is not very useful, since the value returned by c_in() is only 16 bits, and the value returned by c_in_32() is only 32 bits. The effect is that the value returned by c_in() rolls over 4,294,967,295 times before stopping, and the value returned by c_in_32()) rolls over 65,535 times before stopping.
PERIOD_MODE_GATING_ONSelects 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 c_in() or c_in_32(). If a counter is configured for PERIOD_MODE_GATING_ON, calling c_in() or c_in_32() for that counter will result in a BADCOUNTERMODE error.
PERIOD_MODE_INVERT_GATEInverts the polarity of the gate input.
PERIOD_MODE_X1The measurement is latched each time one complete period is observed.
PERIOD_MODE_X10The measurement is latched each time 10 complete periods are observed.
PERIOD_MODE_X100The measurement is latched each time 100 complete periods are observed.
PERIOD_MODE_X1000The measurement is latched each time 1000 complete periods are observed.

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

PULSEWIDTH_MODE_BIT_16Selects a 16-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in().
PULSEWIDTH_MODE_BIT_32Selects a 32-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in_32(). Using the PULSEWIDTH_MODE_BIT_32 option with c_in() is not very useful, since the value returned by c_in() is only 16 bits. The effect is that the value returned by c_in() rolls over 65,535 times before stopping.
PULSEWIDTH_MODE_BIT_48Selects a 48-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in_64(). Using the PULSEWIDTH_MODE_BIT_48 option with c_in() and c_in_32() is not very useful, since the value returned by c_in() is only 16 bits, and the value returned by c_in_32() is only 32 bits. The effect is that the value returned by c_in() rolls over 4,294,967,295 times before stopping, and the value returned by c_in_32() rolls over 65,535 times before stopping.
PULSEWIDTH_MODE_GATING_ONSelects 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 c_in() or c_in_32(). If a counter is configured for PULSEWIDTH_MODE_GATING_ON, calling c_in() or c_in_32() for that counter will result in a BADCOUNTERMODE error.
PULSEWIDTH_MODE_INVERT_GATEInverts the polarity of the gate input.

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

TIMING_MODE_BIT_16Selects a 16-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in().
TIMING_MODE_BIT_32Selects a 32-bit counter for asynchronous mode. This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in_32(). Using the TIMING_MODE_BIT_32 option with c_in() is not very useful, since the value returned by c_in() is only 16 bits. The effect is that the value returned by c_in() rolls over 65,535 times before stopping.
TIMING_MODE_BIT_48Selects a 48-bit counter for asynchronous mode.This parameter value only affects c_in(), c_in_32(), and c_in_64(). Recommended for use only with c_in_64. Using the TIMING_MODE_BIT_48 option with c_in and c_in_32 is not very useful, since the value returned by c_in() is only 16 bits, and the value returned by c_in_32() is only 32 bits. The effect is that the value returned by c_in() rolls over 4,294,967,295 times before stopping, and the value returned by c_in_32() rolls over 65,535 times before stopping.
TIMING_MODE_INVERT_GATEInverts the polarity of the gate input.