# Analog Input Hardware

All devices with analog inputs support the cbAIn()/ AIn()/a_in(), and cbAInScan()/ AInScan()/a_in_scan() functions. If using an expansion device, refer to specific hardware information for information regarding whether scanning functions are supported.

When hardware paced A/D conversion is not supported, cbAInScan()/ AInScan()/a_in() loops through software paced conversions. The scan executes at the maximum speed possible. The speed varies with CPU speed. The only valid option in this case is CONVERTDATA.

### Concurrent Analog Input and Output

Concurrent analog input and output scans are supported on devices with both paced analog inputs and outputs. These devices allow operations with analog input functions (cbAInScan()/ AInScan() and cbAPretrig()/APretrig()) and analog output functions (cbAOutScan()/AOutScan()) to overlap without having to call cbStopBackground()/StopBackground() between the start of the input and output scans.

## Trigger Support

#### Digital Trigger

If trigger support is "Polled gate" (as opposed to "Hardware"), you implement a trigger by gating the on-board pacer; doing so disables the on-board pacer. The trigger input is then polled continuously until the trigger occurs. When the trigger occurs, the software disables the gate input so that the pacer is not affected when the trigger returns to its original state. Acquisition continues until the requested number of samples is acquired. There are two side effects to this type of trigger:

- The polling portion of the function does not occur in the background, even if the BACKGROUND option is specified (although the actual data acquisition occurs).
- The trigger does not necessarily occur on the rising edge. Acquisition can start at any time after the function is called if the trigger input is at "active" level. For this reason, it is best to use a trigger that goes active for a much shorter time than it is inactive.

#### Analog Trigger

Set up the trigger levels for an analog trigger using the cbSetTrigger() function /SetTrigger() method, and pass the appropriate values to the HighThreshold and LowThreshold arguments.

For most devices that support analog triggering, you can calculate the HighThreshold and LowThreshold values by passing the required trigger voltage level and the appropriate Range to the cbFromEngUnits() function/FromEngUnits() method.

However, for some devices, you must manually calculate HighThreshold and LowThreshold. If a device requires manual calculation, that information is included in the Trigger information for the specific product in this section. The procedure for manually calculating these values is described in the cbSetTrigger() function/SetTrigger() method sections of the Universal Library Function Reference.

### Pretrigger Implementations

You can implement pretrigger functionality through software or hardware. These two methods have different limitations and requirements. Most Measurement Computing products with pretrigger capability are implemented in hardware.

- When pretrigger functionality is implemented in hardware, the buffer created using cbWinBufAlloc() must be large enough to hold 512 samples more than the requested TotalCount. The trigger location is tracked by a counter on the device. When the trigger condition is met, data is acquired and the library functions return the actual number of pretrigger points that were acquired. When run in BACKGROUND mode, the cbGetStatus() function typically shows CurCount rise to the value of PretrigCount and remain there while CurIndex cycles from 0 to TotalCount continuously until the trigger is received.
- When pretrigger functionality is implemented in software, the additional space in the buffer is not required. The trigger location is tracked by software. Any triggers that occur before the number of samples defined by the pretrigger count argument are ignored. When run in BACKGROUND mode, the cbGetStatus() function will typically show CurCount at a value of 0 and CurIndex at a value of –1 until the trigger is received. They will then rise from PretrigCount to TotalCount.

## Sampling Rate using SINGLEIO

When transfering data using SINGLEIO mode, the maximum analog sampling rate is dependent on the speed of the computer in which the device is installed. In general the max rate is between 5 kHz and 50 kHz. An OVERRUN error will occur if the requested speed cannot be achieved. Data will be returned, but there may be gaps in the data. Some devices only support SINGLEIO mode, so the maximum rate attainable with these devices is system-dependent.