# USB-CTR Series

The USB-CTR Series includes the following hardware:

- USB-CTR04
- USB-CTR08

The USB-CTR Series support the following features.

## Counter Input

UL: cbCClear(), cbCIn(), cbCIn32(), cbCIn64(), cbCInScan(), cbCLoad(), cbCLoad32(), cbCLoad64(), cbCConfigScan()

UL for .NET: CClear(), CIn(), CIn32(), CIn64(), CInScan(), CLoad(), CLoad32(), CLoad64(), CConfigScan

Python for Windows: c_clear(), c_in(), c_in_32(), c_in_64(), c_in_scan c_load(), c_load_32(), c_load_64(), c_config_scan()

Note: Counters on these devices are zero-based (the first counter number is "0").

Rate

Up to 8 MB/s. The sample rate is dependent on the sample size:

- 16-bit (2 bytes): 4 MS/s
- 32-bit (4 bytes): 2 MS/s
- 64-bit (8 bytes): 1 MS/s

CounterNum

USB-CTR04: 0 to 3

USB-CTR08: 0 to 7

Options

BACKGROUND, BLOCKIO, CONTINUOUS, CTR16BIT, CTR32BIT, CTR64BIT, EXTCLOCK, EXTTRIGGER, HIGHRESRATE, NOCLEAR, RETRIGMODE, SINGLEIO

Use cbSetTrigger()/SetTrigger()/set_trigger() to program the trigger for rising edge, falling edge, or the level of the digital trigger input (TTL).

Mode

- TOTALIZE: CLEAR_ON_READ, COUNT_DOWN_ON, GATE_CLEARS_CTR, GATE_CONTROLS_DIR, GATE_TRIG_SRC, GATING_ON, INVERT_GATE, NO_RECYCLE_ON, OUTPUT_INITIAL_STATE_HIGH, OUTPUT_ON, RANGE_LIMIT_ON
- PERIOD: PERIOD_MODE_GATING_ON, PERIOD_MODE_INVERT_GATE, PERIOD_MODE_X1, PERIOD_MODE_X10, PERIOD_MODE_X100, PERIOD_MODE_X1000
- PULSEWIDTH: PULSEWIDTH_MODE_GATING_ON, PULSEWIDTH_MODE_INVERT_GATE
- TIMING: TIMING_MODE_INVERT_GATE

When using PERIOD, PULSEWIDTH, and TIMING modes, note that the initial period is dependent upon the frequency of the signal being measured, a signal is required in order to latch data into the register, and the first sample in a scan is always zero, since it is not data that has been latched by the measured signal.

RegNum

USB-CTR08: LOADREG0 to LOADREG7, MINLIMITREG0 to MINLIMITREG7, MAXLIMITREG0 to MAXLIMITREG7, OUTPUTVAL0REG0 to OUTPUTVAL0REG7, OUTPUTVAL1REG0 to OUTPUTVAL1REG7

USB-CTR04: LOADREG0 to LOADREG3, MINLIMITREG0 to MINLIMITREG3, MAXLIMITREG0 to MAXLIMITREG3, OUTPUTVAL0REG0 to OUTPUTVAL0REG3, OUTPUTVAL1REG0 to OUTPUTVAL1REG3

LoadValue

0 to 264 – 1

The Visual Basic signed integers guidelines apply when using cbCIn() or CIn() for values greater than 32,767 and when using cbCIn32() or CIn32() for values greater than 2,147,483,647.

Visual Basic does not handle values larger than 32-bit. Try to avoid using larger values, or use Visual Basic .NET.

## Timer Output

UL: cbPulseOutStart(), cbPulseOutStop()

UL for .NET: PulseOutStart(), PulseOutStop()

Python for Windows: pulse_out_start(), pulse_out_stop()

TimerNum

0 to 3

Frequency

0.023 Hz to 48 MHz

DutyCycle

0 to 1, non-inclusive

InitialDelay

0 to 44.73 sec

IdleState

IDLE_LOW, IDLE_HIGH

PulseCount

0 to 232 – 1. Refer to the 32-bit values using a signed long data type discussion for additional information on using signed long data types.

Set to 0 to continuously generate pulses until PulseOutStop() is called.

Options

Reserved for future use

## Triggering

UL: cbSetTrigger()

UL for .NET: SetTrigger()

Python for Windows: set_trigger()

This function applies to theEXTTRIGGER scan option.

Note: For gate counter triggering, refer to the cbConfigScan() Mode arguments GATE_CONTROLS_DIR, GATE_CLEARS_CTR, and GATE_TRIG_SRC.

TrigType

Digital triggering: TRIGHIGH, TRIGLOW, TRIGPOSEDGE, TRIGNEGEDGE

## Digital I/O

##### Configuration

UL: cbDConfigBit(), cbDConfigPort()

UL for .NET: DConfigBit(), DConfigPort()

Python for Windows: d_config_bit(), d_config_port()

PortNum

AuxPort

PortType

AuxPort

##### Port I/O

UL: cbDIn(), cbDOut(), cbDInScan()

UL for .NET: DIn(), DOut(), DInScan()

Python for Windows: d_in(), d_out()

PortNum

AuxPort (eight bits, bit-configurable)

DataValue

0 to 255

Options

BACKGROUND, BLOCKIO, CONTINUOUS, EXTCLOCK, EXTTRIGGER, HIGHRESRATE, RETRIGMODE, SINGLEIO

##### Bit I/O

UL: cbDBitIn(), cbDBitOut()

UL for .NET: DBitIn(), DBitOut()

Python for Windows: d_bit_in(), d_bit_out()

PortType

AuxPort

BitNum

0 to 7 on AuxPort

## DAQ Input

UL: cbDaqInScan(), cbDaqSetTrigger()

UL for .NET: DaqInScan(), DaqSetTrigger()

Python for Windows: daq_in_scan(), daq_set_trigger()

Rate

Digital: Up to 4 MS/s

Counter: Up to 4 MS/s

Options

BACKGROUND, BLOCKIO, CONTINUOUS, EXTCLOCK, EXTTRIGGER, HIGHRESRATE, NOCLEAR, RETRIGMODE, SINGLEIO

ChanTypeArray

DIGITAL8, PADZERO, CTRBANK0 to CTRBANK3 (0 to 3 for the USB-CTR04, 0 to 7 for the USB-CTR08)

ChanArray

AuxPort, when ChanTypeArray is set to DIGITAL8

0, when ChanTypeArray is set to PADZERO.

0 to 3 (USB-CTR04) or 0 to 7 (USB-CTR08), when ChanTypeArray is set to CTRBANKx

TrigEvent

START_EVENT

TrigSource

TRIG_EXTTL

TrigSense

RISING_EDGE, FALLING_EDGE, ABOVE_LEVEL, BELOW_LEVEL, HIGH_LEVEL, LOW_LEVEL

## Event Notification

Functions

UL: cbEnableEvent() cbDisableEvent()

UL for .NET: EnableEvent() DisableEvent()

Python for Windows: enable_event(), disable_event()

Event types

UL, Python for Windows: ON_END_OF_INPUT_SCAN, ON_END_OF_OUTPUT_SCAN

UL for .NET: OnEndOfInputScan, OnEndOfOutputScan

## Configuration

This hardware supports device detection with the API. Refer to the InstaCal, API Detection, or Both? section for information about whether to use InstaCal or the API to detect and configure hardware.

#### InstaCal

Factory serial number

Listed as Factory Serial No. (read only)

Identifier

Identifier text box

Hardware version

Listed as Firmware Version (read only)

Listed as FPGA Version (read only)

#### Programmable API Functions

Factory serial number

UL: cbGetConfigString()

ConfigItem = BIDEVSERIALNUM

UL for .NET: GetDeviceSerialNum()

Python for Windows: get_config_string()

config_item = DEVSERIALNUM

Identifier

UL: cbGetConfigString(), cbSetConfigString()

ConfigItem = BIUSERDEVID

maxConfigLen = up to 64 characters

UL for .Net: GetUserDeviceId(), SetUserDeviceId()

Python for Windows: get_config_string(), set_config_string()

config_item = USERDEVID

max_config_len = up to 64 characters

Hardware version

UL: cbGetConfigString()

ConfigItem = BIDEVVERSION

DevNum = VER_FW_MAIN

DevNum = VER_FPGA

UL for .NET: GetDeviceVersion()

Type = VersionType.FW_MAIN

Type = VersionType.FPGA

Python for Windows: get_config_string()

config_item = DEVVERSION

dev_num = MAIN

dev_num = FPGA

## Hardware considerations

##### Channel count

For input scans, the count must be set to an integer multiple of the number of channels or a BADCOUNT error is returned.

##### Sampling and update rates

Sampling and update rates are system-dependent. A data overrun/underrun may occur with higher sampling rates when using BACKGROUND and CONTINUOUS modes. To avoid this use a larger buffer/count.

##### HIGHRESRATE

Specify the HIGHRESRATE scan option to acquire data at a high resolution rate. When specified, the rate at which samples are acquired is in "samples per 1,000 seconds per channel".

##### Channel array details when using cbDaqInScan()/DaqInScan()

When using this function, each counter bank (CTRBANK0-3) of the USB-CTR Series counters are treated as individual 16-bit channels by default. When read, the first bank will count up to 216, then roll over to 0, and the following bank will increment by 1.

If data is to be presented as the total count of a 32-bit counter, the value from the second bank should be shifted by 16 (or 1 * 216 using the previous example) and added to the result of the first bank. If the other two banks are to be used in the same way, they should be shifted by 32 and 48, respectively.

To avoid shifting the data, you can use the optional method of storing the data in buffers created using WinBufAlloc32() for up to 32-bit data, or WinBufAlloc64() for up to 64-bit data, rather than using the standard WinBufAlloc(). Then, when the data is transferred using WinBufToArray32() or WinBufToArray64(), the result will be a single value comprised of the value of each channel shifted appropriately. This optional method eliminates the need to shift data, but you need to compensate for each sample being returned, as the result of combining each channel with the previous channel is affected as follows:

- For 32-bit data, the number of samples returned will be 1/2 the number of samples requested.
- For 64-bit data, the number of samples returned will be 1/4 the number of samples requested.

##### PERIOD, PULSEWIDTH, and TIMING counter modes

When using Period, PulseWidth, and Timing modes, note that the initial period is dependent upon the frequency of the signal being measured, a signal is required in order to latch data into the register, and the first sample in a scan is always zero, since it is not data that has been latched by the measured signal.