Top ↑
USB Software Reference Manual
V3.14

Introduction

This manual acts as a reference for the USB function driver, “AIOUSB”, and other provided software drivers and utilities that apply to our non-serial-port USB products.

Serial products simply appear as “COM” ports and are operated using the built-in Windows serial interfaces, and thus programming for them is documented by Microsoft.

How To Use This Reference

First, read the entirety of this introduction.

Next, read the source code of one of our sample programs in the programming language of your choice, and refer to this manual for the description of each API used, if needed.

Because the AIOUSB driver is shared among all of our USB products, not all of the API information in this manual will apply to your specific hardware.

In addition to providing a quick reference table at the start of each API function, certain quick-reference or pertinent facts will be presented below the table, giving you valuable insight into the quirks or pitfalls you may encounter.

Here’s a breakdown of what each category description in the table means:

Digital Inputs
TTL / CMOS / LVTTL (DI), and Isolated Input (IDI, II) types all included here. AIOUSB treats all boolean inputs generically as “bits”. Contrast with Buffered DI, DO, DIO, below.
Digital Outputs
TTL / CMOS / LVTTL and Isolated Output (RO, IDO) types are all included here. AIOUSB treats all boolean outputs generically as “bits”. Contrast with Buffered DI, DO, DIO, below.
Analog Inputs
All inputs using “Analog-to-Digital Converter” chips. These boards accept analog signals (voltage, current), and create data the computer can use. Note there are two sub-types of Analog Inputs, those belonging to analog input devices (the USB-AIx family), and those inputs provided as a convenience on otherwise non-analog-input products. Most API functions in this category only apply to the USB-AIx family of devices.
Analog Outputs
All outputs that produce analog signals, including voltage and current. Note there are two sub-types of Analog Outputs in our current USB product lineup: Waveform and DC. Most API functions in this category only apply to the “Waveform” capable USB-DA12-8A.
Buffered DI, DO, DIO
“High-Speed” digital “Bus” devices. This category applies only to boards that use “bulk” USB to achieve speeds higher than the ~4000/second transaction rate would otherwise allow, namely the USB-DIO-16H family.
Counter Timers
This category applies to counter-timer and other frequency devices, such as the ever-popular 8254. Generally used to count, measure, or produce frequencies or pulse trains. The USB-AIx analog input products also include a counter-timer of this type, to time acquisition.

Note: many models are “Multi-Function” and use API functions from more than one of these categories, and some specific API functions apply to all devices.

How To Use The AIOUSB Driver

AIOUSB provides a standard interface for all Data Acquisition USB devices. Each specific USB device will use a subset of the driver calls listed below, based on its specific capabilities and needs.

USB devices are plug-and-play. Every time the driver detects a new USB device it assigns it a new, unused, Device Index. This is a temporary id, and will be different each time any given hardware device is detected.

.dll, header, and .lib file locations

The AIOUSB API Library is contained in the AIOUSB.dll file. This DLL is provided in both 32-bit and 64-bit versions, and is installed automatically to the correct directories based on the version of Windows being used.

"Header" files are in C:\Users\Public\Documents\ACCES\{packagename}\Win32\Driver.SRC\AIOUSB\Headers\ and includes language-specific convenience wrappers for C (AIOUSB.h), Visual Basic 6 (AIOUSB.bas), Visual Basic .NET (AIOUSB.vb), Delphi (AIOUSB.pas), and C# (AIOUSB.cs).

For those languages that link with .lib files they are located in the C:\Users\Public\Documents\ACCES\{packagename}\Win32\Driver.SRC\AIOUSB\C Libraries\ folder.

When Using A Single USB Device — Ever

You can choose to ignore the specific Device Index assigned by the driver, and instead refer to the device by the constant “diOnly” (FFFFFFFD hex). This value tells the driver “Whichever Device Index exists, that's the one I want to talk with”. Most of our sample programs operate this way.

Please note: this is the simplest way to code, but it is not very future-proof. If you need to add a second device years later, you'll need to change your code.

When You Are Using, Or Might Someday Use, More Than One Device

In all other cases the best practice is to assign each device a unique BOARD ID by writing a known BYTE value into location “0” of the user-accessible “Custom EEPROM”.

Run the provided eWriter.exe utility to set this “BOARD ID” byte, or write your own application using the CustomEEPROMWrite() function.

Avoid using FF hex or 00 hex as your BOARD IDs, as units can ship from the factory with these values.

Using a BOARD ID allows you to perform field-replacement of units by configuring the replacement board's ID to the same as the unit it is replacing. The software doesn't need to be informed.

Once you've written the BOARD ID into each unit, you use GetDeviceByEEPROMByte() to resolve the unique-and-unchanging BOARD ID into a detection-order-variable Device Index.

Your application may have code such as the following:

#define BOARD_ID_UUT    (0x01) // value written into location zero in EEPROM for UUT
#define BOARD_ID_ATE_AO (0x40) // value written into location zero in EEPROM for AO board
#define BOARD_ID_ATE_AI (0x80) // value written into location zero in EEPROM for AI board

enum { UUT, ATEANALOGOUTPUTS, ATEANALOGINPUTS, SOMEOTHERDEVICE };

// DeviceIndex is a global array of UInt32
DeviceIndex[UUT] = GetDeviceByEEPROMByte(BOARD_ID_UUT);
DeviceIndex[ATEANALOGOUTPUTS] = GetDeviceByEEPROMByte(BOARD_ID_ATE_AO);
DeviceIndex[ATEANALOGINPUTS] = GetDeviceByEEPROMByte(BOARD_ID_ATE_AI);

or, to make your code more or less readable:

diUUT = GetDeviceByEEPROMByte(BOARD_ID_UUT);
diATE_AO = GetDeviceByEEPROMByte(BOARD_ID_ATE_AO);
diATE_AI = GetDeviceByEEPROMByte(BOARD_ID_ATE_AI);

You would then pass the appropriate variable as the Device Index parameter to the AIOUSB API function calls. For example:

SN_UUT = GetDeviceSerialNumber(diUUT);
status = DACSetBoardRange(diATE_AO, 0);
status = ADC_GetChannelV(diATE_AO, ChannelNumber, &Volts);

About Error/Status Return Values

Return values are Microsoft-defined “Win32” error codes. The full list of Windows error codes is in <winerror.h> (or similar Microsoft-provided reference).

ERROR_SUCCESS (equal to 0) means no error occurred.

If the USB device has been unplugged, functions will return ERROR_DEVICE_REMOVED (equal to 1617 decimal). Call ClearDevices() to clear this condition. If this state is cleared and the board is not reconnected, the error returned is ERROR_FILE_NOT_FOUND (equal to 2). You can also get ERROR_FILE_NOT_FOUND if you pass invalid filenames or paths to the API.

ERROR_BAD_TOKEN_TYPE (1349 decimal) is returned if you call an API function that is not supported by the device. For example, calling "ADC_GetScanV()" on a Digital I/O board; calling DIO_StreamOpen() on an isolated input/relay output board; or calling ADC_GetFastScanV() on a board that has a few auxiliary analog inputs but is a model primarily designed for DAC or DIO features.

and can also be found on the web.

The set of error codes the AIOUSB DLL can produce is the combined set called out in our AIOUSB.DLL source code (provided) plus anything Microsoft's lower-level code decides to throw our way.

Functions For All I/O Types

This group of API calls can be used on any device, returning useful information about the device, dealing with various status, warning, or error conditions, talking with the onboard EEPROM, and more.

Functions You Call At Initialization

GetDeviceByEEPROMByte()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Determines the assigned Device Index of a device in a deterministic way, especially if you're controlling more than one device in the same system. It finds the device with the specified “board ID” at address 0x000 in the custom EEPROM area. “Board ID” is arbitrary, but you should avoid 0x00 and 0xFF, since those can match uninitialized EEPROMs.

For a larger “board ID”, and/or one at an arbitrary location, use GetDeviceByEEPROMData().

Delphi function GetDeviceByEEPROMByte(Data: Byte): LongWord; cdecl;
Visual C unsigned long GetDeviceByEEPROMByte(unsigned char Data);
C# UInt32 GetDeviceByEEPROMByte(Byte Data);
Arguments:
Data
A single byte, generally treated as a “user board ID”, previously written into a device using CustomEEPROMWrite(), eWriter.exe, or other application software.
Returns:

The current device index of the device with matching “user board ID”.

If there aren't any matching devices, returns FFFFFFFF hex. If there are multiple matching devices, returns the first one's device index (0-31) and sets the last error code to ERROR_DUP_NAME. If there's one matching device, returns its device index and sets the last error code to ERROR_SUCCESS. (You can get the last error code with the Win32 API call GetLastError().)

GetDeviceByEEPROMData()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Finds a device based on custom EEPROM data. Like GetDeviceByEEPROMByte(), except that it can look for more than a single byte, and at any location in the custom EEPROM area. Deterministically translates from non-volatile EEPROM-stored data into a Device Index.

Delphi function GetDeviceByEEPROMData(StartAddress, DataSize: LongWord; pData: PByte): LongWord; cdecl;
Visual C unsigned long GetDeviceByEEPROMData(unsigned long StartAddress, unsigned long DataSize, unsigned char *pData);
C# UInt32 GetDeviceByEEPROMData(UInt32 StartAddress, UInt32 DataSize, [In] Byte[] pData);
Arguments:
StartAddress
The address of the beginning of the block to look for in the custom EEPROM area.
DataSize
The number of consecutive bytes to look for in the EEPROM.
pData
A pointer to the block of data to look for, generally treated as a “user board ID”, previously written into a device using CustomEEPROMWrite, eWriter.exe, or other application software.
Returns:

The current device index of the device with matching “user board ID”.

If there aren't any matching devices, returns FFFFFFFF hex. If there are multiple matching devices, returns the first one's device index (0-31) and sets the last error code to ERROR_DUP_NAME. If there's one matching device, returns its device index and sets the last error code to ERROR_SUCCESS. (You can get the last error code with the Windows API call GetLastError().)

GetDevices()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Optional if you know you'll only ever have one device in your system at a time.
Purpose:

Returns a bit-map of which Device Indices were detected by the driver. This does not return one device index; it returns a pattern of bits indicating all valid device indices.

Most applications using a single device can skip this call. Use diOnly (0xFFFFFFFD) as your Device Index instead.

GetDeviceByEEPROMByte() is the preferred discovery mechanism, and GetDevices() is being phased out.

Delphi function GetDevices: LongWord; cdecl;
Visual C unsigned long GetDevices(void);
C# UInt32 GetDevices();
Returns:

Returns a 32-bit bit-mask. Each bit set to "1" indicates an AIOUSB device was detected at a device index corresponding to the set bit index. For example, if the return is 0x00000104, then device indices 2 and 8 were found.

Returns 0 if no devices are found (which may mean the device is not installed properly, or your AIOUSB.DLL version is older than your driver suite).

QueryDeviceInfo()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Optional if you know you'll only ever have one model in your system at a time.
Purpose:

This function provides various data about the device at a given Device Index.

It is common to call this function with “null” for most parameters. Most applications need only the device index and pPID, simply to verify which device type is present at the device index given. The additional parameters allow a more user-friendly experience if your program supports multiple device types.

Delphi function QueryDeviceInfo(DeviceIndex: LongWord; pPID: PLongWord; pNameSize: PLongWord; pName: PChar; pDIOBytes, pCounters: PLongWord): LongWord; cdecl;
Visual C unsigned long QueryDeviceInfo(unsigned long DeviceIndex, unsigned long *pPID, unsigned long *pNameSize, char *pName, unsigned long *pDIOBytes, unsigned long *pCounters);
C# UInt32 QueryDeviceInfo(UInt32 DeviceIndex, out UInt32 pPID, ref UInt32 pNameSize, out String Name, out UInt32 pDIOBytes, out UInt32 pCounters);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pPID
Pointer to PID (“Product ID”), a number indicating which hardware device was found at the specified device index. Each device has a model-specific Product ID, see the hardware manual for your devices. This variable is set by the function, and does not need to be initialized prior to use. You can pass “null” if you don't need to know the PID.
pNameSize
Pointer to NameSize. Pass in the length of your Name buffer (in bytes) to prevent buffer overruns, and the function will set this to the actual name length. If your buffer is too small, the Name data will be truncated. You can pass “null”.
pName
Pointer to Name, a byte array variable. This is an array of characters, not a null-terminated string. The length of the string is passed back via pNameSize. Set by the driver to the model name of the specified device. You can pass “null”.
pDIOBytes
Pointer to DIOBytes. Set by the driver to the number of digital input/output byte-groups. You can pass “null”.
pCounters
Pointer to Counters. Set by the driver to the number of 8254-style counter/timer groups. You can pass “null”.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

GetDeviceSerialNumber()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Provides the on-board "key" serial number. (This serial number is not related to the serial number on the physical label of the device.)

For recognizing which device to use, the GetDeviceByEEPROMByte() function is generally superior, both to allow for field replacement and to simply use smaller board IDs. However, the GetDeviceSerialNumber() or GetDeviceBySerialNumber() function may be used in DRM-like situations, where transparent field replacement is undesirable.

Delphi function GetDeviceSerialNumber(DeviceIndex: LongWord; var pSerialNumber: Int64): LongWord; cdecl;
Visual C unsigned long GetDeviceSerialNumber(unsigned long DeviceIndex, unsigned __int64 *pSerialNumber);
C# UInt32 GetDeviceSerialNumber(UInt32 DeviceIndex, out UInt64 pSerialNumber);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pSerialNumber
Pointer to an 8-byte (64-bit) value to fill with the serial number.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

GetDeviceBySerialNumber()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Determines the assigned index of a device, based on its serial number. The GetDeviceByEEPROMByte() function is generally superior, both to allow for field replacement and to simply use smaller board IDs. However, the GetDeviceBySerialNumber() function may be used in DRM-like situations, where transparent field replacement is undesirable.

Delphi function GetDeviceBySerialNumber(SerialNumber: Int64): LongWord; cdecl;
Visual C unsigned long GetDeviceBySerialNumber(unsigned __int64 SerialNumber);
C# UInt32 GetDeviceBySerialNumber(UInt64 SerialNumber);
Arguments:
SerialNumber
A variable with the serial number of the desired device.
Returns:

The index of the desired device, or diNone if the desired device isn't present.

ResolveDeviceIndex()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Returns a device index from 0-31 corresponding to the “predefined constant” passed in, or FFFFFFFF hex if it can't be resolved.

Delphi function ResolveDeviceIndex(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long ResolveDeviceIndex(unsigned long DeviceIndex);
C# UInt32 ResolveDeviceIndex(UInt32 DeviceIndex);
Arguments:
DeviceIndex
Pass in diOnly or diFirst.
Returns:

Returns the actual, detected, device index that the parameter is interpreted as.

Note: 

This function is provided primarily for use during debugging.

Functions You Call At Deinitialization

AIOUSB_CloseDevice()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Applies to every device, but is rarely useful.
Purpose:

Explicitly closes handles to a device.

Delphi function AIOUSB_CloseDevice(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long AIOUSB_CloseDevice(unsigned long DeviceIndex);
C# UInt32 AIOUSB_CloseDevice(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Necessary in version 8.xx of the AIOUSB driver package (WinUSB) to support multi-process programming. Deprecated for that use as of 9.xx (CyUSB) AIOUSB drivers, but still supported.

ClearDevices()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Closes handles and clears records of unplugged devices.

Use this function to clear out the “ghost” device indices. Typically called when a device removal has been detected, either by the “Windows Message” method, or because API functions are returning “ERROR_DEVICE_REMOVED” or “ERROR_FILE_NOT_FOUND”.

Delphi function ClearDevices: LongWord; cdecl;
Visual C unsigned long ClearDevices(void);
C# UInt32 ClearDevices();
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Other Common Functions

In general CustomEEPROMWrite() and CustomEEPROMRead() can be used at any time in your application, but most applications will not need to.

CustomEEPROMWrite()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Writes to the user-accessible EEPROM.

If you write a one unique byte to StartAddress zero, then you can use GetDeviceByEEPROMByte() to robustly determine the device index of your devices. Refer to GetDeviceByEEPROMByte() for more information.

EWriter.exe is provided to perform this and other EEPROM functions, so your code doesn't have to.

Delphi function CustomEEPROMWrite(DeviceIndex: LongWord; StartAddress: LongWord; DataSize: LongWord; Data: Pointer): LongWord; cdecl;
Visual C unsigned long CustomEEPROMWrite(unsigned long DeviceIndex, unsigned long StartAddress, unsigned long DataSize, void *pData);
C# UInt32 CustomEEPROMWrite(UInt32 DeviceIndex, UInt32 StartAddress, UInt32 DataSize, [In] Byte[] Data);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
StartAddress
Number from 0x000 to 0x1FF of the first EEPROM byte you wish to write to.
DataSize
Number of custom EEPROM bytes to write. The last custom EEPROM byte is 0x1FF, so StartAddress plus DataSize can't be greater than 0x200.
Data
Pointer to the start of a block of bytes to write to the custom EEPROM area.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

CustomEEPROMRead()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Reads data previously written by CustomEEPROMWrite() or application software.

Devices are shipped with zeroes in all custom EEPROM bytes, so using all-zeroes as a special "no data written" value is recommended(but not required).

Delphi function CustomEEPROMRead(DeviceIndex: LongWord; StartAddress: LongWord; var DataSize: LongWord; pData: Pointer): LongWord; cdecl;
Visual C unsigned long CustomEEPROMRead(unsigned long DeviceIndex, unsigned long StartAddress, unsigned long *DataSize, void *pData);
C# UInt32 CustomEEPROMRead(UInt32 DeviceIndex, UInt32 StartAddress, ref UInt32 DataSize, [Out] Byte[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
StartAddress
Number from 0x000 to 0x1FF of the first EEPROM byte you wish to write to.
DataSize
Number of custom EEPROM bytes to read. The last custom EEPROM byte is 0x1FF, so StartAddress plus DataSize can't be greater than 0x200.
pData
Pointer to the start of a block of bytes to write to the custom EEPROM area.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Tech Support Functions

Most applications will never need to use these functions. They exist for use as directed by our tech support.

AIOUSB_UploadD15LoFirmwaresByPID()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Uploads .HEX firmware files to devices that show up with “(D15 Lo)” in Device Manager. This can be used to delayed-load the usual firmware, or to load a custom firmware. In any case, .HEX firmware files are usually only provided by tech support.

A script looks something like this:

0040=C:\Dev\DebugReport\USB_8040.hex
0140=C:\Dev\DebugReport\USB_8140.hex

For each “(D15 Lo)” device found, if its PID is in the script and a valid .HEX firmware file is at the matching path in the script, then that firmware is uploaded to that device. A later entry with the same PID overrides any earlier entries. The top bit in the script PIDs is ignored, so you can specify the regular PID instead of the “(D15 Lo)” PID if you prefer, for example 8140 instead of 0140.

Delphi function AIOUSB_UploadD15LoFirmwaresByPID(pFirmScript: PAnsiChar): LongWord; cdecl;
Visual C unsigned long AIOUSB_UploadD15LoFirmwaresByPID(char *pFirmScript);
C# UInt32 AIOUSB_UploadD15LoFirmwaresByPID([In] Char[] pFirmScript);
Arguments:
pFirmScript
A pointer to a null-terminated Windows-1252(ANSI) string, which is a multiline table of “Hex PID=Firmware File Path” pairs. Lines are delimited with CR, or LF, or CRLF.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Digital Input / Output

Overview

Our driver supports two broad classes of Digital I/O: “Fast” or “Buffered” DIO, and “Slow” or “Normal” DIO.

“Normal” DIO on the USB bus means not-more-than 4000 transactions per second. Buffered DIO is described in the “Buffered DIO” section, and refers to digital bits capable of 8 to 40 MHZ — or even faster — operations. Buffered DIO boards have both kinds of DIO on them, so you will need to refer to both sections, and the DIO_Configure… family of functions is used with both kinds of boards.

I/O Groups

Digital I/O (DIO) generally consists of several groups of 8 TTL/CMOS digital pins capable of being configured as either input or output, but only as a group.

Many devices act very similar to the venerable 8255 device, wherein the unit provides a 50-pin IDC header with 24 digital I/O lines often called Port A, Port B, and Port C, compatible with OPTO-22 module racks. Other devices may only provide two 8-bit ports, called Port 0 and Port 1, or, each bit may be selectable on a bit-by-bit basis as either input or output.

Each collection of pins able to be configured for input or output, but only together, is referred to as an “I/O Group”.

Most devices of this type provide TTL/CMOS compatible pins. Other devices may provide three-volt signals, called 3.0VDC, 3.3VDC, or LVTTL, via either jumper selection, software selection, or factory option.

Regardless of the number of I/O Groups or TTL / CMOS / LVTTL voltages of the pins, these types of digital bits are referred to as “TTL DIO”, “standard DIO”, or simply “DIO”.

Relays as DIO

Alternately, Digital Outputs may refer to solid-state relay or electro-mechanical relay outputs, while Digital Inputs may refer to optically- or electrically- isolated digital input bits. In both cases the voltage and current ranges far exceed the standard TTL/CMOS / LVTTL capability of “standard DIO”, and may be referred to collectively as “isolated digital bits”, “Isolated DIO”, “IDIO”, or “IIRO”. Further, inputs of these types may be called “IDI”, “II”, or “Isolated Inputs”, while outputs may be referred to as “IDO”, “RO”, or “Isolated DO”.

The API (Application Programming Interface) provided by AIOUSB.dll is a single, unified collection of functions to talk to all of these flavors of digital inputs and outputs, denoted by functions beginning with “DIO_”.

One stark difference between DIO and IDIO is the contrast in “I/O Groups”. IDIO pins do not belong to any I/O Groups. Each isolated digital bit, be it input or output, is fixed to that state, and cannot be changed from one to the other.

Another difference is the useful speed of the bits. DIO bits can be read or driven as fast as the USB bus allows; generally one transaction (input or output) every 250µsec under optimum conditions. IDO and RO bits could be driven at the same speeds, but because of the high-current drive, high-voltage capability, and / or electro-mechanical nature of the outputs, the fastest an output can usefully be driven is limited to once every 5 milliseconds or so. Similarly, isolated inputs, because of the isolation and (optional) filtering, rarely respond to input changes lasting less than ten milliseconds.

This distinction becomes an important factor when using functions such as DIO_WriteAll(). On a typical DIO board you very clearly have n I/O Groups, each of which has a byte, which you pass to DIO_WriteAll in an array, with each byte being the next group's data.

On IDIO / IIRO boards you still have the array of bytes, but do not know which bytes are the inputs or outputs.

In all cases outputs come first in the array for IDIO / IIRO devices. Conceptually this is because outputs usefully have two functions: output and read back, while inputs only usefully read. In addition, the The USB-IIRO-xx and USB-IDIO-xx families have two bytes for outputs and two bytes for inputs, even for 8-bit and input-only models.

Regardless of DIO vs IDIO, the outputs are always safe to read from and will return the latest data written; the inputs are safe to write to, and will simply ignore any data written.

DIO Functions You Call At Initialization

DIO_Configure()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
The structure format changes based on how many bytes of data the device family supports.
Purpose:

Configures Digital Input/Output “I/O Groups” for use as input or as output digital bits, and set the state of any output bits. On some products can globally enable/tristate all DIO bits.

Delphi function DIO_Configure(DeviceIndex: LongWord; Tristate: ByteBool; pOutMask: Pointer; pData: Pointer): LongWord; cdecl;
Visual C unsigned long DIO_Configure(unsigned long DeviceIndex, unsigned char bTristate, void *pOutMask, void *pData);
C# UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, ref UInt32 OutMask, ref UInt32 Data);
UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, ref Int16 OutMask, Byte[] Data);
UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, Byte[] OutMask, Byte[] Data);
UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, ref Byte OutMask, ref Byte Data);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
bTristate
TRUE causes all bits on the device to enter tristate (high-impedance) mode. FALSE removes the tristate. The tristate is changed after the remainder of the configuration has occurred. All devices with this feature power-on in the "tristate" mode at this time.
pOutMask
A pointer to array of bits; one bit per “I/O Group”. Each "1" bit in the array indicates that the corresponding “I/O Group” of the device is to be configured as output.
pData
A pointer to an array of bytes. Each byte is copied to the digital output ports on the device before the ports are taken out of tristate. Any bytes in the array associated with ports configured as input are ignored.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

In this context “I/O Group” means “a group of one or more DIO bits for which a single direction control bit determines the input vs output state for all the bits in the group.”

Most devices use 1 bit per 8 DIO pins; others use 1 bit per DIO pin. Other groupings are possible: the USB-DIO-16H family has 4 "I/O Group" bits; one for the 8-bit group A, one for the 4-bit group B, and one each for the 3-bit groups C and D.

When more than one bit is in each group, “I/O Groups” are often referred to as “Ports”. In these cases, the length of the array pointed to by pData should be the same number of bytes as the number of “I/O Group” control bits, even if a specific “I/O Group” contains fewer than 8 bits - significant bits are LSB aligned, and extra bits are ignored.

However, in the “one bit per group” case (USB-DIO-32I, for example), pData is effectively an array of bits, not bytes, as each bit is copied onto the output bits in a 1-to-1 fashion.

The sizes of the out mask and data for some specific DIO boards are as follows:

 USB-DIO-32USB-DIO-32IUSB-IIRO-xxUSB-Dxx16AUSB-DIO-96USB-AIx
Out Mask1 byte4 bytes1 byte1 byte2 bytes1 byte
Data4 bytes4 bytes4 bytes4 bytes12 bytes2 bytes

DIO_ConfigureEx()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
The USB-DIO-16A family has only two tristate groups, “A”, and “all other digital ports”.
Purpose:

Configure Digital Input/Output “I/O Groups” for use as input or as output digital bits, and set the state of any output bits. On some products can globally enable/tristate all DIO bits.

Please refer to DIO_Configure for additional information.

Delphi function DIO_ConfigureEx(DeviceIndex: LongWord; pOutMask: Pointer; pData: Pointer; pTristateMask: Pointer): LongWord; cdecl;
Visual C unsigned long DIO_ConfigureEx(unsigned long DeviceIndex, void *pOutMask, void *pData, void *pTristateMask);
C# UInt32 DIO_ConfigureEx(UInt32 DeviceIndex, Byte[] pOutMask, Byte[] pData, Byte[] pTristateMask);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pOutMask
A pointer to array of bits; one bit per “I/O Group”. Each "1" bit in the array indicates that the corresponding “I/O Group” of the device is Output.
pData
A pointer to an array of bytes. Each byte is copied to the digital output ports on the device before the ports are taken out of tristate. Any bytes in the array associated with ports configured as input are ignored.
pTristateMask
A pointer to array of bits; one bit per “Tristate Group”. Each "1" bit in the array indicates that the corresponding “Tristate Group” of the device is to be tristated.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DIO_ConfigureMasked()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
The structure format changes based on how many bytes of data the device family supports.
Purpose:

Performs some to all of the same operations as DIO_ConfigureEx, in a process-safe (and thread-safe) manner. It can write to a single bit or a single byte without changing anything else, it can change the tristates and output values without changing the direction, etc. This function provides the most flexible "total control" over digital bits, and is thus the most complex digital function to use.

Delphi function DIO_ConfigureMasked(DeviceIndex: LongWord; pOuts: Pointer; pOutsMask: Pointer; pData: Pointer; pDataMask: Pointer; pTristates: Pointer; pTristatesMask: Pointer): LongWord; cdecl;
Visual C unsigned long DIO_ConfigureMasked(unsigned long DeviceIndex, void *pOuts, void *pOutsMask, void *pData, void *pDataMask, void *pTristates, void *pTristatesMask);
C# UInt32 DIO_ConfigureMasked(UInt32 DeviceIndex, [In] Byte[] pOuts, [In] Byte[] pOutsMask, [In] Byte[] pData, [In] Byte[] pDataMask, [In] Byte[] pTristates, [In] Byte[] pTristatesMask);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pOuts
A null pointer, or a pointer to an array of bits; one bit per “I/O Group”. For each bit that's "masked in" by the pOutsMask array, a "1" indicates that the corresponding “I/O Group” of the device is Output, while a "0" similarly indicates Input. A null pointer indicates Input, on all bits "masked in".
pOutsMask
A null pointer, or a pointer to an array of bits; the same size as for pOuts. For each bit in the array, "1" indicates that the corresponding bit of the pOuts array is "masked in" and controls the direction of an “I/O Group”, while a "0" similarly indicates that the corresponding bit of the pOuts array is "masked out" and ignored. If both pOuts and pOutsMask are null pointers, then all bits are "masked out". If pOutsMask is a null pointer but pOuts points to an array, then all bits are "masked in".
pData
A pointer to an array of bytes. Each bit that's "masked in" by the pDataMask array is copied to the digital output ports on the device, before the ports are taken out of tristate. Any bytes in the array associated with ports configured as input are ignored, and any output bits "masked out" by pDataMask are unchanged. A null pointer indicates "1" (logic high), on all bits "masked in".
pDataMask
A null pointer, or a pointer to an array of bytes; the same size as for pData. pDataMask controls pData the same way pOutsMask controls pOuts. If both pData and pDataMask are null pointers, then all bits are "masked out". If pDataMask is a null pointer but pData points to an array, then all bits are "masked in".
pTristates
A null pointer, or a pointer to array of bits; one bit per “Tristate Group”. For each bit that's "masked in" by the pTristatesMask array, a "1" indicates that the corresponding “Tristate Group” of the device is to be tristated, while a "0" similarly indicates enabled(un-tristated). A null pointer indicates enabled, on all bits "masked in".
pTristatesMask
A null pointer, or a pointer to an array of bits; the same size as for pTristates. pTristatesMask controls pTristates the same way pOutsMask controls pOuts, except that a null pointer always indicates all bits are "masked in".
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Please refer to DIO_Configure for additional information.

DIO_ConfigureMasked is the most complex and most powerful of the DIO_Configure… functions, and can also work like DIO_Write… but more powerful. In general, decide what you want to control and put "1"s in the mask array for that, and leave everything else "0" or a null pointer. It may be easiest to understand from some examples:

  • With all null pointers, DIO_ConfigureMasked enables(untristates) everything, without making any other changes. In the usual case the tristate feature is only used during boot, and DIO_ConfigureMasked is optimized for this case.
  • In order to write to all digital outputs(and enable them), pass null pointers for every parameter except pData, and pass the new output state in the pData array. If you don't want to enable(un-tristate) the digital bits in the process, then also pass an array of all "0" for pTristatesMask.
  • In order to write to a single bit of digital output(and enable), pass null pointers for every parameter except pData and pDataMask; for pDataMask, pass an array with all "0" except for a "1" in the single bit to write; for pData, put the bit state to write in the corresponding bit position.
  • In order to control a single “I/O Group” while leaving the rest to be controlled by other programs, keep around arrays for pOutsMask, pDataMask, and pTristatesMask that have "1" for the desired portion of the digital bits, then adjust the arrays for pOuts, pData, and pTristates as desired.

DIO Functions: "Slow"

Overview

These functions operate the Digital I/O bits "transactionally" across the USB bus. Each USB packet / transaction takes a minimum of 250µs, so the maximum theoretical Digital Output update rate, and the max Digital Input polling rate, is 4000Hz.

"Slow" digital bits support the full set of USB Firmware Evolution 2.0 features, unless otherwise noted.

DIO_WriteAll()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Write to all digital outputs on a device. Bits written to ports configured as “input” will be ignored.

This is the most efficient method of writing to digital outputs, because it consumes one USB transaction, regardless of the number of bits on the device.

Delphi function DIO_WriteAll(DeviceIndex: LongWord; pData: Pointer): LongWord; cdecl;
Visual C unsigned long DIO_WriteAll(unsigned long DeviceIndex, void *pData);
C# UInt32 DIO_WriteAll(UInt32 DeviceIndex, ref UInt32 Data);
Arguments:
DeviceIndex
The Index of the device to control; generally either diOnly or a specific device's device index.
pData
A pointer to the first element of an array of bytes. Each byte is copied to the corresponding output byte. Bytes written to ports configured as inputs are ignored. The number of bytes in the pData array needs to be the same as described for “pData” under DIO_Configure.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DIO_Write8()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Write to a single byte-worth of digital outputs on a device.

Bytes written to ports configured as “input” are ignored.

Delphi function DIO_Write8(DeviceIndex, ByteIndex: LongWord; Data: Byte): LongWord; cdecl;
Visual C unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data);
C# UInt32 DIO_Write8(UInt32 DeviceIndex, UInt32 ByteIndex, Byte Data);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
ByteIndex
Number of the byte you wish to change.
Data
One byte. The byte will be copied to the port outputs. Each set bit will cause the equivalent port bit to be set to "1".
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Warning: 

This function is usually implemented in the DLL: the DLL remembers the most recently written DIO data for all ports, and merges the byte sent to DIO_Write8(), then sends the actual hardware a DIO_WriteAll() command. Therefore:

  • Do not use this function simultaneously to control digital bits on a single device from multiple processes, use DIO_ConfigureMasked instead.
  • This function will give unexpected results unless you call DIO_WriteAll or DIO_Configure… first.

DIO_Write1()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
This function will give unexpected results unless you call DIO_WriteAll or DIO_Configure… first.
Purpose: Write to a single digital output bit on a device.
Delphi function DIO_Write1(DeviceIndex, BitIndex: LongWord; Data: ByteBool): LongWord; cdecl;
Visual C unsigned long DIO_Write1(unsigned long DeviceIndex, unsigned long BitIndex, unsigned char bData);
C# UInt32 DIO_Write1(UInt32 DeviceIndex, UInt32 BitIndex, Byte Data);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BitIndex
Number of the bit you wish to change.
bData
TRUE will set the bit to "1", FALSE will clear the bit to "0".
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Bits written to ports configured as “input” are ignored.

On the USB-IIRO-xx and USB-IDIO-xx families, the outputs are bits 0-15; the inputs are bits 16-31. This is true even for 8-bit models, and models with only inputs. E.g. the USB-II-8's first input bit is located at BitIndex 16.

Warning: 

This function is usually implemented in the DLL: the DLL remembers the most recently written DIO data for all ports, and merges the bit sent to DIO_Write1(), then sends the actual hardware a DIO_WriteAll() command. Therefore, do not use this function simultaneously to control digital bits on a single device from multiple processes.

Also, on boards that do not need a DIO_Configure() call before outputs are operational, make sure to call DIO_WriteAll() at least once, to initialize the DLL's memory. You can call DIO_Configure() instead of DIO_WriteAll(), and doing so helps future-proof your code for compatibility with other devices.

DIO_ReadAll()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
The most efficient method of reading digital inputs.
Purpose: Read all digital bits on a device, including read-back of ports configured as “output”.
Delphi function DIO_ReadAll(DeviceIndex: LongWord; pData: Pointer): LongWord; cdecl;
Visual C unsigned long DIO_ReadAll(unsigned long DeviceIndex, void *pData);
C# UInt32 DIO_ReadAll(UInt32 DeviceIndex, out UInt32 pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first element of an array of bytes. Each port will be read, and the reading stored in the corresponding byte in the array.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

The number of bytes in the pBuffer array needs to be the same as described for “pData” under DIO_Configure. This operation consumes one USB transaction, regardless of the number of bits on the device.

The USB-IIRO-xx and USB-IDIO-xx families' inputs are bytes 2 and 3; the outputs' readback are bytes 0 and 1 in the array. This is true even for 8-bit models, and models with only inputs. E.g. the USB-II-8's input byte is located at Data[2].

DIO_Read8()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
The driver performs a ReadAll and returns the selected byte.
Purpose: Read one byte of digital data from the device.
Delphi function DIO_Read8(DeviceIndex, ByteIndex: LongWord; pData: PByte): LongWord; cdecl;
Visual C unsigned long DIO_Read8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char *pData);
C# UInt32 DIO_Read8(UInt32 DeviceIndex, UInt32 ByteIndex, out Byte pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
ByteIndex
Number of the byte you wish to read.
pData
A pointer to one byte. The byte will contain the reading or readback from the port specified by ByteIndex. Each set bit indicates the equivalent port bit read as "1".
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

The USB-IIRO-xx and USB-IDIO-xx families' inputs are bytes 2 and 3; the outputs are bytes 0 and 1. This is true even for 8-bit models, and models with only inputs. E.g. the USB-II-8's first input byte is located at ByteIndex 2.

DIO_Read1()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
The driver performs a ReadAll and returns the selected bit.
Purpose: Read one bit of digital data from a device.
Delphi function DIO_Read1(DeviceIndex, BitIndex: LongWord; pData: PByte): LongWord; cdecl;
Visual C unsigned long DIO_Read1(unsigned long DeviceIndex, unsigned long BitIndex, unsigned char *pData);
C# UInt32 DIO_Read1(UInt32 DeviceIndex, UInt32 BitIndex, out Byte pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
BitIndex
Number of the bit you wish to read.
pData
Pointer to one byte; will be set to “1” or “0” to indicate the state of the bit read (or readback).
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

On the USB-IIRO-xx and USB-IDIO-xx families, the inputs are bits 16-31; the outputs are bits 0-15. This is true even for 8-bit models, and models with only inputs. E.g. the USB-II-8's first input bit is located at BitIndex 16.

DIO_ConfigurationQuery()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Normally your program will simply “remember” what it last sent to “DIO_Configure…”.
Purpose:

Determine DIO port direction and tristate-related information about the device found at a specific device index.

Delphi function DIO_ConfigurationQuery(DeviceIndex: LongWord; pOutMask: Pointer; pTristateMask: Pointer): LongWord; cdecl;
Visual C unsigned long DIO_ConfigurationQuery(unsigned long DeviceIndex, void *pOutMask, void *pTristateMask);
C# UInt32 DIO_ConfigurationQuery(UInt32 DeviceIndex, [Out] Byte[] pOutMask, [Out] Byte[] pTristateMask);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pOutMask
A pointer to the first element of an array of bytes; one byte per 8 ports or fraction. Each bit in the array will be set to "1" if the corresponding port is an output, or "0" if it's an input.
pTristateMask
A pointer to the first element of an array of bytes; one byte per 8 tristate groups or fraction. Each bit in the array will be set to "1" if the corresponding tristate group is in tristate (high-impedance) mode, or a "0" if not.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

This function is not yet implemented on all devices. Please consult with the factory if you need to use it.

DIO Functions: "Waveform"

Overview

Our driver supports two broad classes of Digital I/O: “Fast” or “Buffered” DIO, and “Slow” or “Normal” DIO.

This section refers exclusively to “Buffered” DIO. “Normal” DIO is described in the “Digital Input / Output” section, and refers to digital bits capable of operation from DC to 4kHz transaction rate.

Buffered DIO boards have both kinds of DIO on them, so you will need to refer to both sections, and the DIO_Configure family of functions is used in either case.

Buffered Digital I/O is currently supported only on the USB-DIO-16H family of products.

This product family can input, output, or either, at continuous speeds of at least 8MHz per 16-bit word, and burst speeds in excess of 40MHz (for the depth of the onboard FIFO).

To use the fast digital bits, issue DIO_Configure(), DIO_StreamOpen(), DIO_StreamSetClocks(), loop while calling DIO_StreamFrame(), and when finished call DIO_StreamClose().

DIO_StreamOpen()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Configure a USB-DIO-16H family device's high-speed digital bus for use as input or output. The high-speed digital bus provided by this family is “Dual Simplex”: it can only operate as output, or input. Although the USB-DIO-16H and USB-DIO-16A can switch the highspeed bus from input to output mode, or output to input, this process is not designed to occur in the course of normal data flow, thus the port is not classified as “Half Duplex”.
Delphi function DIO_StreamOpen(DeviceIndex: LongWord; bIsRead: LongBool): LongWord; cdecl;
Visual C unsigned long DIO_StreamOpen(unsigned long DeviceIndex, unsigned long bIsRead);
C# UInt32 DIO_StreamOpen(UInt32 DeviceIndex, UInt32 bIsRead);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
bIsRead
Boolean. TRUE will open a stream for reading, FALSE will open a stream for writing.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Call DIO_ConfigureEx() and DIO_StreamSetClocks() as well, before sending/receiving data using DIO_StreamFrame().

DIO_StreamClose()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Terminate the buffered input or output operation on a USB-DIO-16H family device.
Delphi function DIO_StreamClose(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long DIO_StreamClose(unsigned long DeviceIndex);
C# UInt32 DIO_StreamClose(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

For best results, should be called before your application closes.

DIO_StreamSetClocks()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Configure the highspeed port for external or internal clock source, and, if internal, the frequency thereof.
Delphi function DIO_StreamSetClocks(DeviceIndex: LongWord; var pReadClockHz, pWriteClockHz: Double): LongWord; cdecl;
Visual C unsigned long DIO_StreamSetClocks(unsigned long DeviceIndex, double *pReadClockHz, double *pWriteClockHz);
C# UInt32 DIO_StreamSetClocks(UInt32 DeviceIndex, ref Double pReadClockHz, ref Double pWriteClockHz);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pReadClockHz
A pointer to an IEEE double-precision value indicating the desired frequency of an internal read clock.
pWriteClockHz
A pointer to an IEEE double-precision value indicating the desired frequency of an internal write clock.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Use "0" to indicate “External clock mode”.

The Read and Write clock variables will be modified to indicate the Hz rate to which the unit will actually be configured: not all frequencies you can specify with a IEEE double can be achieved by the frequency generation circuit. Our DLL calculates the closest achievable frequency. If you're interested, you can consult the LTC6904 chipspec for details, or the provided source for the DLL.

The slowest available frequency from the onboard generator is 1kHz; the fastest usable is 40MHz (the limit of the standard FIFO); the fastest useful for non-burst operation is ~8MHz (the streaming bandwidth limit of the USB→digital interface logic and code is 8MHz minimum, often as high as 12MHz if your computer is well optimized.)

DIO_StreamFrame()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
If opened as input, the FramePoints must be a multiple of 256 or you will generate error 31 “ERROR_GEN_FAILURE”.
Purpose: Send or Receive “fast” data across the DIO bus.
Delphi function DIO_StreamFrame(DeviceIndex, FramePoints: LongWord; pFrameData: PWord; var BytesTransferred: DWord): LongWord; cdecl;
Visual C unsigned long DIO_StreamFrame(unsigned long DeviceIndex, unsigned long FramePoints, unsigned short *pFrameData, unsigned long *BytesTransferred);
C# UInt32 DIO_StreamFrame(UInt32 DeviceIndex, UInt32 FramePoints, [In, Out] Byte[] pFrameData, out UInt32 ByteTransferred);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
FramePoints
Number of WORD-sized points to stream.
pFrameData
Pointer to the beginning of the block of data you wish to stream.
BytesTransferred
Pointer to a DWORD that will receive the amount of data actually transferred, in BYTEs.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

This function is used for either input or output operation. “Stream” can be interpreted “upload,” “write,” “read,” “download,” “send,” “receive,” or any similar term.

Counter / Timers

An Important Note About The CTR_8254 Family Of Functions

Each of these functions is designed to operate in one of two addressing modes. The parameter “BlockIndex” refers to 8254 chips, each of which contains 3 “Counters”. CounterIndex refers to the counters inside the 8254s. In the primary addressing mode you specify the block and the counter. In the secondary addressing mode, you specify zero (0) for the block, and consider the counters to be addressed sequentially. That is, BlockIndex 3, CounterIndex 1 can also be addressed as BlockIndex 0, CounterIndex 10. The equation to determine the secondary, or sequential, CounterIndex given the primary or block values is as follows (they simply count consecutively):

CounterIndexSequential = BlockIndex * 3 + CounterIndexPrimary

CounterIndex values associated with BlockIndex 0 are compatible with either addressing mode, there is no need to tell the driver which addressing mode you wish to use.

Specific, Common, Counter / Timer Tasks

Frequency Generation
To generate a frequency using an 8254 wired in the “standard” way, use CTR_8254StartOutputFreq(). Refer to that function for more information.
Event Counting
To count up to 65535 events per 8254 wired in the standard way, mode counter 1 in mode 1, mode counter 0 in mode 0, and load counter 0 with “0”. Make sure to not load any count value into counter 1. Read counter 0 to determine the number of times it has decremented since the last time you read it.

CTR_8254Mode()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Configure the mode of operation for a specified counter.
Delphi function CTR_8254Mode(DeviceIndex, BlockIndex, CounterIndex, Mode: LongWord): LongWord; cdecl;
Visual C unsigned long CTR_8254Mode(unsigned long DeviceIndex, unsigned long BlockIndex, unsigned long CounterIndex, unsigned long Mode);
C# UInt32 CTR_8254Mode(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt32 Mode);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BlockIndex
Index of the 8254 chip you wish to control. See note at the beginning of this section.
CounterIndex
Index of the 8254 counter you wish to control. See note at the beginning of this section.
Mode
A number from 0 to 5, specifying to which 8254 mode you want the specified counter to be configured.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Calling CTR_8254Mode() will halt the counter specified until it gets “loaded” by calling CTR_8254Load() or the like.

Neat Trick:
Configuring a counter for Mode 0 will set that counter's output LOW.
Configuring a counter for Mode 1 will set that counter's output HIGH.

This can be used to convert a counter into an additional, albeit slow, digital output bit. The output pin will remain as configured until/unless the counter is “loaded” with a count value.

CTR_8254Load()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Load a counter with a 16-bit count-down value.
Delphi function CTR_8254Load(DeviceIndex, BlockIndex, CounterIndex: LongWord; LoadValue: Word): LongWord; cdecl;
Visual C unsigned long CTR_8254Load(unsigned long DeviceIndex, unsigned long BlockIndex, unsigned long CounterIndex, unsigned short LoadValue);
C# UInt32 CTR_8254Load(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt16 LoadValue);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BlockIndex
Index of the 8254 chip you wish to control. See note at the beginning of this section.
CounterIndex
Index of the 8254 counter you wish to control. See note at the beginning of this section.
LoadValue
A number from 0 to 65535, specifying how many counts to load in the counter specified.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

A load value of “0” will behave like a (hypothetical) load value of 65536.

Some modes do not support “1” as a load value. Other modes support neither “1” nor “2” as load values.

CTR_8254ModeLoad()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Configure the mode of operation for a specified counter, and load that counter with a 16-bit count-down value.
Delphi function CTR_8254ModeLoad(DeviceIndex, BlockIndex, CounterIndex, Mode: LongWord; LoadValue: Word): LongWord; cdecl;
Visual C unsigned long CTR_8254ModeLoad(unsigned long DeviceIndex, unsigned long BlockIndex, unsigned long CounterIndex, unsigned long Mode, unsigned short LoadValue);
C# UInt32 CTR_8254ModeLoad(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt32 Mode, UInt16 LoadValue);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BlockIndex
Index of the 8254 chip you wish to control. See note at the beginning of this section.
CounterIndex
Index of the 8254 counter you wish to control. See note at the beginning of this section.
Mode
A number from 0 to 5, specifying to which 8254 mode you want the specified counter to be configured.
LoadValue
A number, from 0 to 65535, specifying how many counts to load in the counter specified.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

CTR_8254ModeLoad() is similar to CTR_8254Mode() followed by CTR_8254Load(), but takes a single USB transaction, making it at least 250µsec faster than issuing the two operations independently. See CTR_8254Mode() and CTR_8254Load() for more notes.

CTR_StartOutputFreq()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Output a frequency from a counter 2 of a block, assuming a standard configuration.
Delphi function CTR_StartOutputFreq(DeviceIndex, BlockIndex: LongWord; pHz: PDouble): LongWord; cdecl;
Visual C unsigned long CTR_StartOutputFreq(unsigned long DeviceIndex, unsigned long CounterIndex, double *pHz);
C# UInt32 CTR_StartOutputFreq(UInt32 DeviceIndex, UInt32 BlockIndex, ref double pHz);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BlockIndex
Index of the 8254 from which you wish to output a frequency. Most devices only contain one 8254, and therefore BlockIndex should be “0” for those units.
pHz
A pointer to a double-precision IEEE floating point number containing the desired output frequency. This value is set by the driver to the actual frequency that will be output, as limited by the device's capabilities.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

This function requires that the individual counters in the specified 8254 be wired up as follows: 10MHz → IN1, and OUT1 → IN2. If the 10MHz is replaced with other frequencies, the pHz calculation will scale predictably.

For most 8254s in our USB product line, this is the permanent wiring configuration. The exception is the USB-CTR-15, which has more flexibility; this wiring is provided by the USB-CTR-15's “Standard Configuration Adapter”.

The USB-CTR-15 can output as many as 15 frequencies, if you use CTR_8254ModeLoad() &emdash; but if you use CTR_StartOutputFreq(), you can only achieve 5, on CTR2 of each of the 5 blocks. (Counters 2, 5, 8, 11, and 14 under the secondary numbering convention. See note at the beginning of this section.)

CTR_8254Read()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Reads the current count value from the indicated counter.
Delphi function CTR_8254Read(DeviceIndex, BlockIndex, CounterIndex: LongWord; pReadValue: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254Read(unsigned long DeviceIndex, unsigned long BlockIndex, unsigned long CounterIndex, unsigned short *pReadValue);
C# UInt32 CTR_8254Read(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, out UInt16 pReadValue);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
BlockIndex
Index of the 8254 chip you wish to control. See note at the beginning of this section.
CounterIndex
Index of the 8254 counter you wish to control. See note at the beginning of this section.
pReadValue
A pointer to a WORD, which will be set to the value latched and read from the specified counter.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

The counts loaded cannot be read back. Only the “current count” is readable, and the current count does not initialize with the “(re-)load count value” until the first input clock occurs. Use CTR_8254ReadStatus() to distinguish between “the data read has never been loaded from the load count” (called a “null count” by the 8254 chip specification) and “the current count has been loaded, and decremented at least once”.

CTR_8254ReadAll()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15. Call if you need support for this function on a different device.
Purpose: Reads the current count values from all counters.
Delphi function CTR_8254ReadAll(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadAll(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadAll(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of WORDs, which will be set to the values latched and read from each counter, in order. Counter 0's value is stored in pData[0], etc.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

The counts loaded cannot be read back. Only the “current count” is readable, and the current count does not initialize with the “(re-)load count value” until the first input clock occurs. Let us know if you need CTR_8254ReadStatusAll() functionality in your application.

CTR_8254ReadStatus()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose: Reads both the current count value and the status from the indicated counter.
Delphi function CTR_8254ReadStatus(DeviceIndex, BlockIndex, CounterIndex: LongWord; pReadValue: PWord; pStatus: PByte): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadStatus(unsigned long DeviceIndex, unsigned long BlockIndex, unsigned long CounterIndex, unsigned short *pReadValue, unsigned char *pStatus);
C# UInt32 CTR_8254ReadStatus(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, out UInt16 pReadValue, out byte pStatus);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
BlockIndex
Index of the 8254 chip you wish to control. See note at the beginning of this section.
CounterIndex
Index of the 8254 counter you wish to control. See note at the beginning of this section.
pReadValue
A pointer to a WORD which will be set to the count value latched and read from the specified counter.
pStatus
A pointer to a BYTE which will be set to the status latched and read from the specified counter.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

The meaning of the individual bits in the status byte is best described in the 8254 chip spec, which is readily found by searching the internet. Most often useful is “null count”, bit 6; when it's high, the count value is not particularly useful.

CTR_8254ReadModeLoad()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
The read value is acquired before the mode and write happen.
Purpose: Read, then mode, then load, the specified counter.
Delphi function CTR_8254ReadModeLoad(DeviceIndex, BlockIndex, CounterIndex, Mode: LongWord; LoadValue: Word; pReadValue: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadModeLoad(unsigned long DeviceIndex, unsigned long BlockIndex, unsigned long CounterIndex, unsigned long Mode, unsigned short LoadValue, unsigned short *pReadValue);
C# UInt32 CTR_8254ReadModeLoad(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt32 Mode, UInt16 LoadValue, out UInt16 pReadValue);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BlockIndex
Index of the 8254 chip you wish to control. See note at the beginning of this section.
CounterIndex
Index of the 8254 counter you wish to control. See note at the beginning of this section.
Mode
A number from 0 to 5, specifying to which 8254 mode you want the specified counter to be configured.
LoadValue
A number, from 0 to 65535, specifying how many counts to load in the counter specified.
pReadValue
A pointer to a WORD which will be set to the count value latched and read from the specified counter.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

CTR_8254ReadModeLoad() is similar to CTR_8254Read() followed by CTR_8254Mode() followed by CTR_8254Load(), but takes a single USB transaction, making it at least 500µsec faster than issuing the two operations independently. See CTR_8254Read(), CTR_8254Mode(), and CTR_8254Load() for more notes.

The reading is taken before the mode and load occur.

Gate-Latch Functions

Some important notes about these CTR_8254 functions:

These functions only apply to the USB-CTR-15.

CTR_8254SelectGate() and CTR_8254ReadLatched() are used in measuring frequency. To measure frequency one must count pulses for a known duration. In simplest terms, the number of pulses that occur during 1 second is the frequency, in Hertz. In the USB-CTR-15 you can create a known duration by configuring one counter output to act as a “gating” signal for any collection of other counters. The other “measurement” counters will only decrement during the “high” side of the gate signal, which we can control.

So, to measure frequency:

  1. Create a gate signal of known duration by calling CTR_ModeLoad() on one or more concatenated counters. Use Mode 3, Square Wave Generation, for at minimum the last counter in the chain. (Mode 2 should be used for counters earlier in the chain. Due to how the counter interprets odd vs even load values in Mode 3, avoid loading odd numbers for the Mode 3 counter, or a +1 “factor” in the gate duration intrudes.)
  2. Connect this gating signal to the gate pins of the “measurement” counter(s).
  3. Connect the frequency(-ies) to be measured to the input pin(s) of the “measurement” counter(s).
  4. Configure each “measurement” counter with Mode 2 and a known load value (0 is best).
  5. Call CTR_8254SelectGate() to tell the board which counter is generating that gate.
  6. Call CTR_8254ReadLatched() once in a while to read the latched count values from all the “measurement” counters.

In practice, it may not be possible to generate a gating signal of sufficient duration from a single counter. Simply concatenate two or more counters into a series (daisy-chain them), and use the last counter's output as your gating signal. This last counter in the chain should be reported as the “gate source” using CTR_8254SelectGate().

Once a value has been read from a counter using the CTR_8254ReadLatched() call, it can be translated into actual Hz by dividing the count value returned by the high-side-duration of the gating signal, in seconds. For example, if your gate is configured for 10Hz, the high-side lasts .05 seconds; if you read a delta-counts of 1324 via the CTR_8254ReadLatched() call, the frequency would be “1324 / .05”, or 26.48kHz.

To be clear: the counters are count-down-only. Subtract the reading from the load value to determine the delta-counts for use in the calculation. E.g. if you use “0” as your load value, and read 56001 counts from the CTR_8254_ReadLatched() call, the delta-counts is 65536 - 56001 = 9535 counts. If your gate is configured for 10Hz, the input frequency would be “9535 / .05”, or 190.7kHz.

CTR_8254SelectGate()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: This function selects a counter for use as the gate in frequency measurement on other counters, and starts the frequency measurement process.
Delphi function CTR_8254SelectGate(DeviceIndex, GateIndex: LongWord): LongWord; cdecl;
Visual C unsigned long CTR_8254SelectGate(unsigned long DeviceIndex, unsigned long GateIndex);
C# UInt32 CTR_8254SelectGate(UInt32 DeviceIndex, UInt32 GateIndex);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
GateIndex
Index of the counter output being used as the gating signal, from 0 to 14.
Returns: Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

CTR_8254ReadLatched()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: Read the latest values latched by the board during frequency measurement.
Delphi function CTR_8254ReadLatched(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadLatched(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of 15 WORDs, followed by one BYTE, in which will be stored the most recent values latched and read from the counters by the board. After the array of WORDs is one additional BYTE. This byte contains useful information when optimizing polling rates. If the value of the byte is “0”, you're looking at old data, and are reading faster than your Gate signal is running.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note For Advanced Users: 

The value of the last byte returned is the number of Gate events that have occurred since you last read the data. “0” therefore means “old data, already seen, reading too often” and any number higher than “1” means “I could be getting data more often by reading faster by this factor”.

CTR_EndWaitGates()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: Read the latest values latched by the board during frequency measurement.
Delphi function CTR_8254ReadLatched(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadLatched(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of 15 WORDs, followed by one BYTE, in which will be stored the most recent values latched and read from the counters by the board. After the array of WORDs is one additional BYTE. This byte contains useful information when optimizing polling rates. If the value of the byte is “0”, you're looking at old data, and are reading faster than your Gate signal is running.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note For Advanced Users: 

The value of the last byte returned is the number of Gate events that have occurred since you last read the data. “0” therefore means “old data, already seen, reading too often” and any number higher than “1” means “I could be getting data more often by reading faster by this factor”.

CTR_GetPulseWidthMeasurement()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: Read the latest values latched by the board during frequency measurement.
Delphi function CTR_8254ReadLatched(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadLatched(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of 15 WORDs, followed by one BYTE, in which will be stored the most recent values latched and read from the counters by the board. After the array of WORDs is one additional BYTE. This byte contains useful information when optimizing polling rates. If the value of the byte is “0”, you're looking at old data, and are reading faster than your Gate signal is running.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note For Advanced Users: 

The value of the last byte returned is the number of Gate events that have occurred since you last read the data. “0” therefore means “old data, already seen, reading too often” and any number higher than “1” means “I could be getting data more often by reading faster by this factor”.

CTR_SetWaitGates()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: Read the latest values latched by the board during frequency measurement.
Delphi function CTR_8254ReadLatched(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadLatched(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of 15 WORDs, followed by one BYTE, in which will be stored the most recent values latched and read from the counters by the board. After the array of WORDs is one additional BYTE. This byte contains useful information when optimizing polling rates. If the value of the byte is “0”, you're looking at old data, and are reading faster than your Gate signal is running.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note For Advanced Users: 

The value of the last byte returned is the number of Gate events that have occurred since you last read the data. “0” therefore means “old data, already seen, reading too often” and any number higher than “1” means “I could be getting data more often by reading faster by this factor”.

CTR_StartMeasuringPulseWidth()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: Read the latest values latched by the board during frequency measurement.
Delphi function CTR_8254ReadLatched(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadLatched(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of 15 WORDs, followed by one BYTE, in which will be stored the most recent values latched and read from the counters by the board. After the array of WORDs is one additional BYTE. This byte contains useful information when optimizing polling rates. If the value of the byte is “0”, you're looking at old data, and are reading faster than your Gate signal is running.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note For Advanced Users: 

The value of the last byte returned is the number of Gate events that have occurred since you last read the data. “0” therefore means “old data, already seen, reading too often” and any number higher than “1” means “I could be getting data more often by reading faster by this factor”.

CTR_StopMeasuringPulseWidth()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: Read the latest values latched by the board during frequency measurement.
Delphi function CTR_8254ReadLatched(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadLatched(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of 15 WORDs, followed by one BYTE, in which will be stored the most recent values latched and read from the counters by the board. After the array of WORDs is one additional BYTE. This byte contains useful information when optimizing polling rates. If the value of the byte is “0”, you're looking at old data, and are reading faster than your Gate signal is running.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note For Advanced Users: 

The value of the last byte returned is the number of Gate events that have occurred since you last read the data. “0” therefore means “old data, already seen, reading too often” and any number higher than “1” means “I could be getting data more often by reading faster by this factor”.

CTR_WaitForGate()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Currently only supported by the USB-CTR-15.
Purpose: Read the latest values latched by the board during frequency measurement.
Delphi function CTR_8254ReadLatched(DeviceIndex: LongWord; pData: PWord): LongWord; cdecl;
Visual C unsigned long CTR_8254ReadLatched(unsigned long DeviceIndex, unsigned short *pData);
C# UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pData
A pointer to the first of an array of 15 WORDs, followed by one BYTE, in which will be stored the most recent values latched and read from the counters by the board. After the array of WORDs is one additional BYTE. This byte contains useful information when optimizing polling rates. If the value of the byte is “0”, you're looking at old data, and are reading faster than your Gate signal is running.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note For Advanced Users: 

The value of the last byte returned is the number of Gate events that have occurred since you last read the data. “0” therefore means “old data, already seen, reading too often” and any number higher than “1” means “I could be getting data more often by reading faster by this factor”.

Analog To Digital (ADC)

Overview

AIOUSB treats Analog Inputs as falling into two broad categories: “Waveform” Analog Inputs (provided by any buffered analog input board, such as the models in the USB-AIx and DPK- product Families “AIx”), and “DC-Level” Analog Inputs; those provided as easy-to-use “extra” features, but limited in functionality.

The “Waveform” analog input products are optimized for performing analog-to-digital conversions, with a wide variety of configurations and options available to tune the inputs to fit your exact needs, including resolution, samples per second, calibration and reference options, elaborate signal-conditioning, etc. They can use all of the API functions presented in this section.

The “DC-Level” analog inputs, however, are provided to monitor simple DC voltage levels with little or no flexibility in hardware or software. Analog input readings can only be acquired from these ADCs using ADC_GetScanV() (and all other ADC_Getxxx() functions). No other functions described in this chapter are useful for non-AIx analog inputs (at this time).

ADC_GetScanV()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This simple function takes one scan of A/D data and converts it to voltage. It also averages oversamples for each channel. On “DC-Level” boards with A/D that don't support ADC_SetConfig(), it scans all channels, without oversampling.

This function converts input counts to voltages based on the range previously configured with ADC_Init or ADC_SetConfig. It will take data at the configured number of oversamples or more, average the readings from the channels, and convert the counts to voltage.

This is the easiest way to read A/D data, but can't achieve more than hundreds of Hz, or even slower depending on options. It should readily achieve 0 to 100 Hz operation, on up to 128 channels.

The speed limit is because this function performs intro & outro housekeeping USB transactions each call, to make it simple to use. For a faster but less-convenient API that moves these housekeeping functions out of the acquisition loop, please refer to the section on ADC_GetFastScanV().

Delphi function ADC_GetScanV(DeviceIndex: LongWord; pBuf: PDouble): LongWord; cdecl;
Visual C unsigned long ADC_GetScanV(unsigned long DeviceIndex, double *pBuf);
C# UInt32 ADC_GetScanV(UInt32 DeviceIndex, [Out] double[] pBuf);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pBuf

Pointer to the first of an array of double-precision IEEE floating point numbers. Each element in the array will receive the value read from the corresponding A/D input channel. The array must be at least as large as the number of A/D input channels your product contains (16, 32, 64, 96, or 128) — but it is safe to always pass a pointer to an array of 128.

Only elements in the array corresponding to A/D channels actually acquired during the scan will be updated: start-channel through end-channel, inclusive. Other values will remain unchanged.

Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_GetChannelV()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
Note: slow.
Purpose:

Acquires the voltage level on one A/D input. Use this function when your language doesn't handle implicitly-lengthed arrays of doubles as used by ADC_GetScanV(), or to acquire readings from just a few channels, slowly — during debugging or calibration, for example

This function is provided only for ease of use, implemented as a convenience wrapper for ADC_GetScanV(); it acquires all configured channels using ADC_GetScanV(), but returns only the specified channel's data. Therefore, reading two channels using ADC_GetChannelV() is at least twice as slow as using ADC_GetScanV().

Delphi function ADC_GetChannelV(DeviceIndex, ChannelIndex: LongWord; pBuf: PDouble): LongWord; cdecl;
Visual C unsigned long ADC_GetChannelV(unsigned long DeviceIndex, unsigned long ChannelIndex, double *pBuf);
C# UInt32 ADC_GetChannelV(UInt32 DeviceIndex, UInt32 ChannelIndex, out double pBuf);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
ChannelIndex
Number of the channel to read voltage.
pBuf
A pointer to a double-precision IEEE floating point number which will receive the value read.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_GetTrigScanV()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Like ADC_GetScanV, except it waits for an A/D trigger. Remember to configure a trigger source(timer or external) with ADC_SetConfig.

Delphi function ADC_GetTrigScanV(DeviceIndex: LongWord; pBuf: PDouble; TimeoutMS: LongInt): LongWord; cdecl;
Visual C unsigned long ADC_GetTrigScanV(unsigned long DeviceIndex, double *pBuf, long TimeoutMS);
C# UInt32 ADC_GetTrigScanV(UInt32 DeviceIndex, [Out] double[] pBuf, Int32 TimeoutMS);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pBuf
Pointer to the first of an array of double-precision IEEE floating point numbers, just like ADC_GetScanV.
TimeoutMS
The number of milliseconds to wait for a trigger, minimum 1. If this expires with no trigger, take an immediate scan and return ERROR_TIMEOUT.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_GetScan()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Like ADC_GetScanV, except it doesn't convert to volts. It still averages oversamples for each channel.

All counts are offset-binary coded, and left-justified. For example, 12-bit boards read count values 0x0000 through 0xFFF0, with 0x0000 being “minimum input voltage” and 0xFFF0 being “maximum input voltage”.

The use of counts exposes the “digital” nature of the conversion. This function is also slow; see ADC_GetScanV() for details, see ADC_GetFastScanV() for a faster option that returns volts.

Delphi function ADC_GetScan(DeviceIndex: LongWord; pBuf: PWord): LongWord; cdecl;
Visual C unsigned long ADC_GetScan(unsigned long DeviceIndex, unsigned short *pBuf);
C# UInt32 ADC_GetScanV(UInt32 DeviceIndex, [Out] UInt16[] pBuf);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pBuf

Pointer to the first of an array of WORDs. Each element in the array will receive the value read from the corresponding A/D input channel. The array must be at least as large as the number of A/D input channels your product contains (16, 32, 64, 96, or 128) — but it is safe to always pass a pointer to an array of 128.

Only elements in the array corresponding to A/D channels actually acquired during the scan will be updated: start-channel through end-channel, inclusive. Other values will remain unchanged.

Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_GetTrigScan()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Like ADC_GetScan, except it waits for an A/D trigger. Remember to configure a trigger source(timer or external) with ADC_SetConfig.

Delphi function ADC_GetTrigScan(DeviceIndex: LongWord; pBuf: PWord; TimeoutMS: LongInt): LongWord; cdecl;
Visual C unsigned long ADC_GetTrigScan(unsigned long DeviceIndex, unsigned short *pBuf, long TimeoutMS);
C# UInt32 ADC_GetTrigScan(UInt32 DeviceIndex, [Out] UInt16[] pBuf, Int32 TimeoutMS);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pBuf
Pointer to the first of an array of WORDs, just like ADC_GetScan.
TimeoutMS
The number of milliseconds to wait for a trigger, minimum 1. If this expires with no trigger, take an immediate scan and return ERROR_TIMEOUT.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_SetScanLimits()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Provides an easier mechanism to modify the Scan Start Channel and Scan End Channel configuration.

Normally the Scan Start Channel are broken into two four-bit components each, and configured by masking the least-significant nybbles into the ADC_SetConfig() array elements [0x12] and [0x14]. This function performs this bit manipulation for you, and writes the resulting configuration to the card using ADC_SetConfig().

Delphi function ADC_SetScanLimits(DeviceIndex, StartChannel, EndChannel: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_SetScanLimits(unsigned long DeviceIndex, unsigned long StartChannel, unsigned long EndChannel);
C# UInt32 ADC_SetScanLimits(UInt32 DeviceIndex, UInt32 StartChannel, UInt32 EndChannel);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
StartChannel
The first channel to be acquired during each scan. Channels are Zero-based, and scans proceed from the StartChannel through the EndChannel, inclusive. The most common StartChannel value is "0", so scans begin with the first channel on the device.
EndChannel
The last channel to be acquired during each scan. This is usually the last channel number; for 16-channel boards, "15"; for 128 channel boards, "127", etc.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Please refer to ADC_SetConfig() for the parent function.

ADC_BulkAcquire()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Acquires a block of analog input data from the specified board into the provided buffer.

Call ADC_BulkPoll() to determine how much data has been collected, and thus if collection has completed.

Delphi function ADC_BulkAcquire(DeviceIndex: LongWord; BufSize: LongWord; pBuf: Pointer): LongWord; cdecl;
Visual C unsigned long ADC_BulkAcquire(unsigned long DeviceIndex, unsigned long BufSize, void *pBuf);
C# UInt32 ADC_BulkAcquire(UInt32 DeviceIndex, UInt32 BufSize, [In, Out] UInt16[] Buf);
Arguments:
DeviceIndex
The index of the device on which to start ADC Bulk Acquisition; generally either diOnly or a specific device's device index.
BufSize
The size, in bytes, of the buffer to receive the data
pBuf
A pointer to the buffer where data should be stored
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_BulkAbort()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Halt any ADC operations that are underway. This will terminate background ADC operations and cause ADC callbacks and blocking functions to execute with a user-abort status.

Delphi function ADC_BulkAbort(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_BulkAbort(unsigned long DeviceIndex);
C# UInt32 ADC_BulkAbort(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to halt Bulk ADC acquisition; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_BulkContinuousCallbackStart()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Acquires Analog Input data using a callback interface, as configured with ADC_SetConfig().

Internally, the continuous process generates a pool of buffers, which function as a FIFO. In general, at any particular time, one buffer is being filled, and another buffer is being given to the callback.

Delphi function ADC_BulkContinuousCallbackStart(DeviceIndex: LongWord; BufSize: LongWord; BaseBufCount: LongWord; Context: LongWord; pCallback: Pointer): LongWord; cdecl;
Visual C unsigned long ADC_BulkContinuousCallbackStart(unsigned long DeviceIndex, unsigned long BufSize, unsigned long BaseBufCount, unsigned long Context, void *pCallback);
C# UInt32 ADC_BulkContinuousCallbackStart(UInt32 DeviceIndex, UInt32 BufSize, UInt32 BaseBufCount, UInt32 Context, TADContCallback pCallback);
Arguments:
DeviceIndex
The index of the device to start Callback-based ADC Acquisition; generally either diOnly or a specific device's device index.
BufSize
The size of each buffer in the pool, in bytes. This must be a multiple of 512, and of course zero is invalid. In general, you'll want this to also be a multiple of the size of each scan; for example, when acquiring three channels, it's convenient for BufSize to be a multiple of 1,536. When going at high speed, larger buffers are needed; usually, a buffer size close to the data generated in 1/10 of a second is appropriate.
BaseBufCount
The number of buffers in the pool. This must be at least 2. 64 is large enough for the max rate of the USB-AI16-16A on any computer that can reasonably run Windows. During development, you can set BaseBufCount to 2, note the number of times Flags bit 4 is received by the callback, and increase this final buffer count by 50% to accomodate weaker computers.
Context
A number to be passed on to the callback; the meaning is between the callback and the caller of this function, but it may be an index into an array. Unless the callback pays attention to it, this value is ignored.
pCallback
A pointer to an ADContCallback() function(see below) to receive buffers of data.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADContCallback()

Purpose:

This represents the callback to be provided in your own code. Pass a pointer to this callback for the pCallback parameter to ADC_BulkContinuousCallback or similar functions.

Delphi procedure ADContCallback(pBuf: PWord; BufSize, Flags, Context: LongWord); cdecl;
Visual C void ADContCallback(unsigned short *pBuf, unsigned long BufSize, unsigned long Flags, unsigned long Context);
C# [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void TADContCallback(IntPtr pBuf, UInt32 BufSize, UInt32 Flags, UInt32 Context);
Arguments:
pBuf
A pointer to the first of an array of words. Each word is a sample of A/D data. Note that the buffer doesn't necessarily begin or end on scan boundaries, or even channel boundaries; the callback may need to buffer this data, to deal with it once it also has the next buffer.
BufSize
The size, in bytes, of the buffer pointed to by pBuf.
Flags
A bitmask with only two bits defined; the rest are reserved for future expansion. You should mask out reserved bits when checking bits in Flags. Meanings(and masks) are given below.
Context
The same value passed as a context to ADC_BulkContinuousCallback or a similar function.
Flags Bits
BitMaskMeaning
1Flags & 2End of stream; this is the last buffer. Typically one last zero-size buffer will be passed, in order to set this flag.
2Flags & 4The BaseBufCount was too small; this buffer was added to the pool, which may interrupt the data stream afterwards. At sampling rates of a hundred Hz, a BaseBufCount of 2 is plenty. On a fast computer, a BaseBufCount of 64 can handle up to 500kHz sampling rate. High sampling rates on a slow computer may require higher BaseBufCount values.

ADC_BulkContinuousCallbackStartClocked()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Deprecated: use ADC_BulkContinuousCallbackStart instead. This function was created to avoid a race condition that has since been resolved.

Delphi function ADC_BulkContinuousCallbackStartClocked(DeviceIndex: LongWord; BufSize: LongWord; BaseBufCount: LongWord; Context: LongWord; pCallback: Pointer; var Hz: Double): LongWord; cdecl;
Visual C unsigned long ADC_BulkContinuousCallbackStartClocked(unsigned long DeviceIndex, unsigned long BufSize, unsigned long BaseBufCount, unsigned long Context, void *pCallback, double *Hz);
C# UInt32 ADC_BulkContinuousCallbackStartClocked(UInt32 DeviceIndex, UInt32 BufSize, UInt32 BaseBufCount, UInt32 Context, TADContCallback pCallback, ref double Hz);
Arguments:
DeviceIndex
The index of the device to start Callback-based ADC Acquisition; generally either diOnly or a specific device's device index.
BufSize
The same as for ADC_BulkContinuousCallbackStart.
BaseBufCount
The same as for ADC_BulkContinuousCallbackStart.
Context
The same as for ADC_BulkContinuousCallbackStart.
pCallback
The same as for ADC_BulkContinuousCallbackStart.
Hz
As used by CTR_StartOutputFreq, this will be the "start ADC rate".
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_BulkContinuousDebug()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This function provides diagnostic information, generally for factory-use only. This debug information describes the buffer pool for an ongoing ADC bulk continuous mode acquisition.

Contact us if you'd like more information about this diagnostic function.

Delphi function ADC_BulkContinuousDebug(DeviceIndex: LongWord; var Blanks, Accessings, GotDatas: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_BulkContinuousDebug(unsigned long DeviceIndex, unsigned long *Blanks, unsigned long *Accessings, unsigned long *GotDatas);
C# UInt32 ADC_BulkContinuousDebug(UInt32 DeviceIndex, out UInt32 Blanks, out UInt32 Accessings, out UInt32 GotDatas);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
Blanks
Receives the number of blank buffers in the pool.
Accessings
Receives the number of buffers held for read or write.
GotDatas
Receives the number of buffers waiting with data.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_BulkContinuousEnd()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This function serves to gracefully cease background acquisition of ADC readings. Calling ADC_BulkContinuousEnd() is how a well-behaved application should close ADC operations started using ADC_BulkContinuousCallbackStart(), ADC_BulkContinuousCallbackStartClocked(), or ADC_BulkContinuousRingStart(),

Delphi function ADC_BulkContinuousEnd(DeviceIndex: LongWord; pIOStatus: PLongWord): LongWord; cdecl;
Visual C unsigned long ADC_BulkContinuousEnd(unsigned long DeviceIndex, unsigned long *pIOStatus);
C# UInt32 ADC_BulkContinuousEnd(UInt32 DeviceIndex, [Out] UInt32 pIOStatus);
Arguments:
DeviceIndex
The index of the device to stop background ADC Continuous Acquisition; generally either diOnly or a specific device's device index.
pIOStatus
Passed as the status to any related callbacks.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_BulkContinuousRingStart()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Starts acquiring ADC readings using a background/async process optimized for use from environments that cannot support callbacks. This function simplifies data collection from applications like Excel or LabVIEW.

Call ADC_ReadData() to grab Analog Input data that has been acquired asynchronously by this acquisition mode.

Delphi function ADC_BulkContinuousRingStart(DeviceIndex: LongWord; RingBufferSize: LongWord; PacketsPerBlock: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_BulkContinuousRingStart(unsigned long DeviceIndex, unsigned long RingBufferSize, unsigned long PacketsPerBlock);
C# UInt32 ADC_BulkContinuousRingStart(UInt32 DeviceIndex, UInt32 RingBufferSize, UInt32 PacketsPerBlock);
Arguments:
DeviceIndex
The index of the device to begin background ADC Ring-mode acquisition; generally either diOnly or a specific device's device index.
RingBufferSize
The size, in bytes, of the entire ring buffer. The absolute minimum is equal to 512×PacketsPerBlock, and in general you'll want about a dozen times that.
PacketsPerBlock
The number of 512-byte packets in each transfer block. This is analogous to the "streaming block size", or to the BufSize parameter to ADC_BulkContinuousCallbackStart.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_BulkMode()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Explicitly set the I/O mode of ADC bulk functions. This function is no longer supported; bulk mode is now set implicitly and automatically.

Delphi function ADC_BulkMode(DeviceIndex, BulkMode: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_BulkMode(unsigned long DeviceIndex, unsigned long BulkMode);
C# UInt32 ADC_BulkMode(UInt32 DeviceIndex, UInt32 BulkMode);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BulkMode
The ADC bulk mode to set.
Returns:

ERROR_NOT_SUPPORTED (50).

ADC_BulkPoll()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

After background/async analog input data acquisition has been started by a call to ADC_BulkAcquire(), call ADC_BulkPoll() to check how much ADC data remains to be taken, and thus how much in the buffer is available for use.

Delphi function ADC_BulkPoll(DeviceIndex: LongWord; var BytesLeft: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_BulkPoll(unsigned long DeviceIndex, unsigned long *BytesLeft);
C# UInt32 ADC_BulkPoll(UInt32 DeviceIndex, out UInt32 BytesLeft);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
BytesLeft
A pointer to a variable that receives the number of bytes left in the bulk block acquisition. Bytes that are no longer "left" have been acquired and are available; for example, if you call ADC_BulkAcquire with a 2MB buffer, and ADC_BulkPoll shows 1½MB left, then ½MB has been acquired and can be read out of the buffer.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_FullStartRing()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Provides a single function to configure and start acquiring ADC readings using a background/async process.

Delphi function ADC_FullStartRing(DeviceIndex: LongWord; pConfigBuf: Pointer; var ConfigBufSize: LongWord; CalFileName: PAnsiChar; pCounterHz: PDouble; RingBufferSize: LongWord; PacketsPerBlock: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_FullStartRing(unsigned long DeviceIndex, void *pConfigBuf, unsigned long *ConfigBufSize, char *CalFileName, double *pCounterHz, unsigned long RingBufferSize, unsigned long PacketsPerBlock);
C# UInt32 ADC_FullStartRing(UInt32 DeviceIndex, [Out] byte[] pConfigBuf, ref UInt32 ConfigBufSize, [ Out] Char[] CalFileName, ref double pCounterHz, UInt32 RingBufferSize, UInt32 PacketsPerBlock);
Arguments:
DeviceIndex
The index of the device to control ; generally either diOnly or a specific device's device index.
pConfigBuf
a pointer to the first of an array of bytes for configuration data. Refer to ADC_SetConfig() for more information.
ConfigBufSize
a pointer to a variable holding the number of configuration bytes to write (21 bytes, typically).
CalFileName
either the file name of a calibration file, or one of several reserved command strings. Refer to ADC_SetCal() for more information.
pCounterHz
A pointer to a double-precision IEEE floating point number containing the desired output frequency. This value is set by the driver to the actual frequency that will be output, as limited by the device's capabilities. Refer to CTR_StartOutputFreq() for more information.
RingBufferSize
The size, in bytes, of the entire ring buffer. The absolute minimum is equal to 512×PacketsPerBlock, and in general you'll want about a dozen times that.
PacketsPerBlock
The number of 512-byte packets in each transfer block. This is analogous to the "streaming block size", or to the BufSize parameter to ADC_BulkContinuousCallbackStart.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_GetCalRefV()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Read the current calibration reference value specified; useful for determining how much the device calibration has changed over time.

Delphi function ADC_GetCalRefV(DeviceIndex, CalRefIndex: LongWord; var pRef: Double): LongWord; cdecl;
Visual C unsigned long ADC_GetCalRefV(unsigned long DeviceIndex, unsigned long CalRefIndex, double *pRef);
C# UInt32 ADC_GetCalRefV(UInt32 DeviceIndex, UInt32 CalRefIndex, out double pRef);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
CalRefIndex
Pass 0 to read the "ground" reference value. Pass "1" to read the "+" reference value. The unipolar references will be used if channel 0 is set(see ADC_SetConfig) to unipolar, or likewise the bipolar references if channel 0 is set to bipolar.
pRef
a pointer to a variable where the reading will be stored, in volts.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_GetConfig()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Reads the ADC configuration last configured with ADC_SetConfig() and functions that call it.

Delphi function ADC_GetConfig(DeviceIndex: LongWord; pConfigBuf: Pointer; var ConfigBufSize: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_GetConfig(unsigned long DeviceIndex, void *pConfigBuf, unsigned long *ConfigBufSize);
C# UInt32 ADC_GetConfig(UInt32 DeviceIndex, [In, Out] byte[] pConfigBuf, ref UInt32 ConfigBufSize);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pConfigBuf
A pointer to a buffer to receive the ADC configuration.
ConfigBufSize
A pointer to a variable that holds the size of the buffer pointed to by pConfigBuf. The variable will be changed to the full size of the buffer on this device. Thus, it's safe to call ADC_GetConfig with ConfigBufSize pointing to a zero, to get the size of the actual buffer, then allocate that much and call ADC_GetConfig again.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_GetImmediate()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Performs a "software start" ADC trigger. This trigger obeys the ADC configuration normally, notably for purposes of which channels are acquired, and returns the ADC data normally, for example via ADC_BulkContinuousCallback.

Delphi function ADC_GetImmediate(DeviceIndex, Channel: LongWord; pBuf: PWord): LongWord; cdecl;
Visual C unsigned long ADC_GetImmediate(unsigned long DeviceIndex, unsigned long Channel, unsigned short *pBuf);
C# UInt32 ADC_GetImmediate(UInt32 DeviceIndex, UInt32 Channel, out UInt16 pBuf);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Channel
Reserved. This is conceptually the index of an ADC channel, but it no longer functions as such.
pBuf
Reserved. Still must point to a 16-bit word variable. This is conceptually to receive the ADC data, but it no longer functions as such.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_Initialize()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

A convenient function to use during initial configuration at the start of your application, ADC_Initialize() calls ADC_SetConfig() and ADC_SetCal() for you.

Delphi function ADC_Initialize(DeviceIndex: LongWord; pConfigBuf: Pointer; var ConfigBufSize: LongWord; CalFileName: PAnsiChar): LongWord; cdecl;
Visual C unsigned long ADC_Initialize(unsigned long DeviceIndex, void *pConfigBuf, unsigned long *ConfigBufSize, char *CalFileName);
C# UInt32 ADC_Initialize(UInt32 DeviceIndex, [In, Out] byte pConfigBuf, ref UInt32 pConfigBufSize, [In, Out] Char[] CalFileName);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pConfigBuf
a pointer to the first of an array of bytes for configuration data. Refer to ADC_SetConfig() for more information.
ConfigBufSize
a pointer to a variable holding the number of configuration bytes to write (21 bytes, typically).
CalFileName
either the file name of a calibration file, or one of several reserved command strings. Refer to ADC_SetCal() for more information.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_QueryCal()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Returns ERROR_SUCCESS if the specified DeviceIndex supports ADC_GetCalRefV(), and therefore ADC_SetCal(":AUTO:") and related functions.

You can skip calling ADC_QueryCal() by calling ADC_SetCal() regardless and simply ignoring any returned errors.

Delphi function ADC_QueryCal(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_QueryCal(unsigned long DeviceIndex);
C# UInt32 ADC_QueryCal(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_RangeAll()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Configure the Range Code for all ADC channels.

Normally configuring Range Codes requires bit manipulation to combine the Unipolar/Bipolar bit, the Differential/Single-Ended bit, and the Gain Bits into a single byte value per Range Group. This function performs this operation for you and updates the new configuration to the device using ADC_SetConfig()

This function is currently implemented as a convenience-wrapper via a read-modify-write algorithm: It calls ADC_GetConfig(), modifies the returned config array as requested, then writes the new config via ADC_SetConfig(). Although USB serializes operations across the cable this function performs several sequential transactions and is therefore not process-safe.

Delphi function ADC_RangeAll(DeviceIndex: LongWord; pGainCodes: PByte; bDifferential: LongBool): LongWord; cdecl;
Visual C unsigned long ADC_RangeAll(unsigned long DeviceIndex, unsigned char *pGainCodes, unsigned long bDifferential);
C# UInt32 ADC_RangeAll(UInt32 DeviceIndex, ref byte GainCodes, UInt32 bDifferential);
Arguments:
DeviceIndex
The index of the device to configure; generally either diOnly or a specific device's device index.
pGainCodes
a pointer to the first of an array of one Range Code per Range Group (generally 8 or 16 bytes (Differential or Singled-Ended, respectively))
bDifferential
pass zero to indicate Single-Ended mode, pass non-zero to indicate Differential mode.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Please refer to ADC_SetConfig() for gain code information.

ADC_Range1()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Configure the Range Code for a single “Range Group” of channels, which is a single channel on 16-channel boards.

Normally the Range Code for each Range Group is configured using the ADC_SetConfig() array byte at [Range Group #]. This function updates the config array for you, and writes the resulting configuration to the card using ADC_SetConfig().

This function is currently implemented as a convenience-wrapper via a read-modify-write algorithm: it calls ADC_QueryConfig(), modifies the returned config array as requested, then writes the new config via ADC_SetConfig(). Although USB serializes operations across the cable this function performs several sequential transactions and is therefore not process-safe.

Delphi function ADC_Range1(DeviceIndex, ADChannel: LongWord; GainCode: Byte; bDifferential: LongBool): LongWord; cdecl;
Visual C unsigned long ADC_Range1(unsigned long DeviceIndex, unsigned long ADChannel, unsigned char GainCode, unsigned long bDifferential);
C# UInt32 ADC_Range1(UInt32 DeviceIndex, UInt32 ADChannel, byte GainCode, UInt32 bDifferential);
Arguments:
DeviceIndex
The index of the device to configure; generally either diOnly or a specific device's device index.
ADChannel
The Range Group # you wish to configure.
GainCode
The gain code to set for this Range Group.
bDifferential
pass zero to indicate Single-Ended mode, pass non-zero to indicate Differential mode.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Please refer to ADC_SetConfig() for gain code information.

ADC_ReadData()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Retrieves analog input data acquired into a ring buffer via ADC_BulkContinuousRingStart or ADC_FullStartRing. Oversamples, if any, are averaged, and the data is converted to volts.

Delphi function ADC_ReadData(DeviceIndex: LongWord; pConfigBuf: Pointer; var ScansToRead: LongWord; pData: PDouble; Timeout: Double): LongWord; cdecl;
Visual C unsigned long ADC_ReadData(unsigned long DeviceIndex, void *pConfigBuf, unsigned long *ScansToRead, double *pData, double Timeout);
C# UInt32 ADC_ReadData(UInt32 DeviceIndex, [Out] byte[] pConfigBuf, ref UInt32 ScansToRead, ref double[] pData, ref double Timeout);
Arguments:
DeviceIndex
The index of the device to request data from; generally either diOnly or a specific device's device index.
pConfigBuf
A pointer to the ADC configuration used to acquire the data. ADC_ReadData uses this to determine the layout of the data, and to convert to volts.
ScansToRead
A pointer to a variable holding the number of "scans" to read. If the board is not in scan mode, then "scan" still refers to acquiring all selected channels in turn. On return, this will be changed to the number of "scans" read.
pData
A pointer to the first of a buffer of double precision IEEE floating point numbers, to receive the ADC data.
Timeout
A double precision IEEE floating point number indicating the timeout in seconds and timeout behavior. Note that, regardless of Timeout, if ADC_ReadData can immediately return all the requested data, then it will do so and return immediately.
Timeout ValueResulting Behavior
0Data already acquired is returned. ADC_ReadData doesn't wait for more, regardless of the amount.
InfinityThe specified number of scans(or an error) is returned. So long as the ADC operation is functioning, ADC_ReadData will continue to wait until this request is fulfilled.
PositiveADC_ReadData will wait up to Timeout seconds in order to return all the requested data. At that time, if a lesser amount of data is available, then ADC_ReadData will return what's available.
Negative"All or nothing". ADC_ReadData will wait up to abs(Timeout) seconds in order to return all the requested data. If there still isn't that much data available at that time, then ADC_ReadData will time out.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_SetCal()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Configure the analog input calibration of a USB-AIx board.

Some revisions of the driver will return errors under all conditions if you attempt to ADC_SetCal() unsupported hardware; other driver revisions will return ERROR_SUCCESS if you explicitly request “:NONE:” (or “:1TO1:”) on a board that does not support calibration, as the request, although skipped, was technically successful - the calibration table of unsupported hardware is always :NONE:

Call ADC_SetCalAndSave() to also receive the calibration table data for use by your application.

Delphi function ADC_SetCal(DeviceIndex: LongWord; CalFileName: PChar): LongWord; cdecl;
Visual C unsigned long ADC_SetCal(unsigned long DeviceIndex, char *CalFileName);
C# UInt32 ADC_SetCal(UInt32 DeviceIndex, [In, Out] Char[] CalFileName);
Arguments:
DeviceIndex
The index of the device to configure; generally either diOnly or a specific device's device index.
CalFileName
A file name can include the full path, or be relative to the current directory. The calibration file format consists of two 64k arrays of unsigned 16-bit count values. The first array is the Unipolar calibration table; the second, bipolar.
A command string of either ":NONE:" or ":1TO1:" turns off calibration.
":NORM:" applies only factory Vref calibration.
":AUTO:" commands AIOUSB to perform a self-calibration sequence, measuring the onboard + and - references using ADC_GetCalRefV(), generating an in-memory calibration file, and writing the calibration to the device.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_SetCalAndSave()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Configures the calibration for the specified Analog Input device, and returns the calibration table for use by your application.

This is mostly useful if you're curious what ADC_SetCal() did when you asked it to ":AUTO:" calibrate, as this function will return the generated calibration table.

Delphi function ADC_SetCalAndSave(DeviceIndex: LongWord; CalFileName, SaveCalFileName: PAnsiChar): LongWord; cdecl;
Visual C unsigned long ADC_SetCalAndSave(unsigned long DeviceIndex, char *CalFileName, char *SaveCalFileName);
C# UInt32 ADC_SetCalAndSave(UInt32 DeviceIndex, [In] Char[] CalFileName, [In] Char[] SaveCalFileName);
Arguments:
DeviceIndex
The index of the device to calibrate; generally either diOnly or a specific device's device index.
CalFileName
A file name can include the full path, or be relative to the current directory. The calibration file format consists of two 64k arrays of unsigned 16-bit count values. The first array is the Unipolar calibration table; the second, bipolar.
A command string of either ":NONE:" or ":1TO1:" turns off calibration.
":NORM:" applies only factory Vref calibration.
":AUTO:" commands AIOUSB to perform a self-calibration sequence, measuring the onboard + and - references using ADC_GetCalRefV(), generating an in-memory calibration file, and writing the calibration to the device.
SaveCalFileName
Path and filename to which the calibration table should be saved.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_SetOversample()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This utility function provides read-modify-write access to the “Oversample” configuration byte in the ADC_SetConfig array.

Delphi function ADC_SetOversample(DeviceIndex: LongWord; Oversample: Byte): LongWord; cdecl;
Visual C unsigned long ADC_SetOversample(unsigned long DeviceIndex, unsigned char Oversample);
C# UInt32 ADC_SetOversample(UInt32 DeviceIndex, byte Oversample);
Arguments:
DeviceIndex
The index of the device to configure Oversamples; generally either diOnly or a specific device's device index.
Oversample
Any compatible ADC acquisition operation will acquire one (1) reading from any given Analog Input Channel followed immediately by one additional reading per Oversample configured. These "Oversamples" are designed to be used in your digital filtering to improve the number of effective bits from the ADC acquisition
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Note: 

Please refer to ADC_SetConfig() for the parent function.

ADC_SetConfig()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Perform extensive configuration of analog inputs, typically useful only for the "USB-AIx" and "DPK-" product Families.

Read-Modify-Write convenience wrappers are available to simplify modifying individual components of the ADC Configuration structure. See ADC_RangeAll(), ADC_Range1(), ADC_SetOversamples(), and ADC_SetScanLimits() for more information on these convenient setters.

Delphi function ADC_SetConfig(DeviceIndex: LongWord; pConfigBuf: Pointer; var ConfigBufSize: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_SetConfig(unsigned long DeviceIndex, void *pConfigBuf, unsigned long *ConfigBufSize);
C# UInt32 ADC_SetConfig(UInt32 DeviceIndex, [In, Out] byte[] pConfigBuf, ref UInt32 ConfigBufSize);
Arguments:
DeviceIndex
The index of the device to configure; generally either diOnly or a specific device's device index.
pConfigBuf
a pointer to the first byte of an array of bytes for configuration data. The array of bytes can also be interpreted as a structure, described below.
ConfigBufSize
a pointer to a variable holding the number of configuration bytes to write (21 bytes, typically).
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Configuration bytes for analog input boards(the USB-AIx family) are as follows:

IndexContent
[00h]Range Code 0
[0Fh]Range Code 15
[10h]Calibration Code
[11h]Trigger & Counter
[12h]Start & End Channel (Low)
[13h]Oversample
[14h]Start & End Channel (High)
struct ADCConfig
{
	byte RangeCodePerRangeGroup[16]; // configures Diff/S.E. Uni/Bip and Gain
	byte CalCode;                    // selects Reference or Input ADC data
	byte TriggerMode;                // selects Timer or External ADC Starts
	byte ScanLimitsLSN;              // least-significant nybbles of start and end channel
	byte OversampleCount;            // configures how many extra conversions per reading
	byte ScanLimitsMSN;              // most-significant nybbles of start and end channel
}

A configuration of all zero is close to an "ordinary" use; you'll likely want to set timer or external trigger, and start and end channels.

Config Bytes 00-0Fh: Range Codes

Valid range codes are:

Range Code01234567
ADC Input RangeUnipolar 0-10VBipolar ±10VUnipolar 0-5VBipolar ±5VUnipolar 0-2VBipolar ±2VUnipolar 0-1VBipolar ±1V

When using 16-channel USB-AIx family boards, you can acquire differential data by adding 8 to some or all range codes for channels 0-7. Any channel (0-7) configured for differential causes the corresponding "+8" channel's range code to be ignored.

DAQ-PACK devices, and USB-AIx family devices with 32+ channels, include sub-multiplexer boards. This increases the number of channels, and can provide elaborate and flexible signal-conditioning options.

For example, a DAQ-PACK may have ×100 gain on most channels. If those channels are acquired using range code 7, then the effective range is ±.01V i.e. ±10mV. This is suitable for acquiring thermocouples within a few hundred degrees of the CJC temperature.

Regardless of the number of channels, there are 16 range code entries (bytes 00h-0Fh in the array). Each controls the input range/gain on one or more channels, as follows:

16-Channel Boards
Config Byte00h01h07h08h0Eh0Fh
Sets Range On Channels01781415
"64M" Boards (64-channel)
Config Byte00h01h07h08h0Eh0Fh
Sets Range On Channels0-34-728-3132-3556-5960-63
Other Boards (32-, 64-, 96-, or 128-channel)
Config Byte00h01h07h08h0Eh0Fh
Sets Range On Channels0-78-1556-6364-71112-119120-127
Config Byte 10h: Calibration Code

This byte is simply zero for normal use. Nonzero values replace the normal input with an onboard calibration constant, for boards that have them.

Calibration CodeBehaviorExpected
00hThe ADC will acquire data from the external pins, as normally expected.user input
01hThe ADC will acquire the onboard Unipolar Ground reference.0V
03hThe ADC will acquire the onboard Unipolar Full-Scale voltage reference..90909V @ 0-10V unipolar range
05hThe ADC will acquire the onboard Bipolar Zero reference.0V
07hThe ADC will acquire the onboard Bipolar Full-Scale voltage reference..90909V @ ±10V bipolar range
Config Byte 11h: Trigger & Counter
BitD7D6D5D4D3D2D1D0
ValueReserved, use 0CTR0 EXTFalling EdgeScanExternal TriggerTimer Trigger
  • If CTR0 EXT is set, counter 0 is externally-clocked; otherwise, counter 0 is clocked by the onboard 10MHz clock.
  • If Falling Edge is set, A/D acquisition is triggered by the falling edge of its trigger source; otherwise, A/D acquisition is triggered by the rising edge of its trigger source.
  • If Scan is set, a single A/D trigger will acquire all channels from start channel to end channel, with oversampling (if so configured), at maximum speed. Otherwise, a single A/D trigger will cause a single conversion, iterating through oversamples and channels.
  • If External Trigger is set, the external A/D trigger pin is an A/D trigger source. Otherwise, this pin is ignored. Please note: the trigger pin can trigger a Scan, or a single Conversion. It is not used to start a sequence of Scans or Conversions.
  • If Timer Trigger is set an onboard pacing clock circuit is used as an A/D trigger source. Otherwise, the output of the pacing clock circuit is ignored.
Config Bytes 12h & 14h: Start & End Channel
Bits4-70-3
Config Byte 12hEnd Channel bits 0-3Start Channel bits 0-3
Config Byte 14hEnd Channel bits 4-7Start Channel bits 4-7

For example, to start at 0 and end at 63 (3Fh), set config byte 12h to F0h and config byte 14h to 30h. To start at 7 and end at 107 (6Bh), set config byte 12h to B7h and config byte 14h to 60h. In any case, if the end channel is less than the start channel, then the board's behavior is unspecified.

Note that it may be more convenient to set these bytes by calling ADC_SetScanLimits.

Config Byte 13h: Oversample

Oversample is the number of extra samples to be acquired from each channel before moving on to the next. In a noisy environment, the samples can be averaged together by software to effectively reduce noise. The number set here is in addition to the single acquisition of every channel that happens normally. Therefore, an oversample of 0 results in one conversion per channel, an oversample of 1 results in two conversions per channel, and an oversample of 255 results in a total of 256 conversions per channel being taken.

ADC_GetFastScanV()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Takes a scan, similar to ADC_GetScanV, but without the intro and outro code. It's thus faster, but it requires the caller to call the intro and (optionally) outro.

Call ADC_InitFastScanV first. You can then call this function repeatedly. Optionally, call ADC_ResetFastScanV when you're done using this function.

Delphi function ADC_GetFastScanV(DeviceIndex: LongWord; pBuf: PDouble): LongWord; cdecl;
Visual C unsigned long ADC_GetFastScanV(unsigned long DeviceIndex, double *pBuf);
C# UInt32 ADC_GetFastScanV(UInt32 DeviceIndex, [Out] Double[] pBuf);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pBuf

Pointer to the first of an array of double-precision IEEE floating point numbers. Each element in the array will receive the value read from the corresponding A/D input channel. The array must be at least as large as the number of A/D input channels your product contains (16, 32, 64, 96, or 128) — but it is safe to always pass a pointer to an array of 128.

Only elements in the array corresponding to A/D channels actually acquired during the scan will be updated: start-channel through end-channel, inclusive. Other values will remain unchanged.

Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_ResetFastScanV()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Puts the ADC configuration back after ADC_GetFastScanV calls. This function is optional, because the configuration for ADC_GetFastScanV is still valid.

If you do call this function, then you'll need to call ADC_InitFastScanV again before you can resume calling ADC_GetFastScanV.

Delphi function ADC_ResetFastScanV(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_ResetFastScanV(unsigned long DeviceIndex);
C# UInt32 ADC_ResetFastScanV(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

ADC_InitFastScanV()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Prepares the ADC configuration for repeated ADC_GetFastScanV calls.

Delphi function ADC_InitFastScanV(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long ADC_InitFastScanV(unsigned long DeviceIndex);
C# UInt32 ADC_InitFastScanV(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Digital To Analog (DAC)

Overview

Similar to Digital Input/Output, the AIOUSB driver suite supports two broad classes of Analog Output functionality: "Fast", "Buffered", "ARB", or "Waveform" DAC output, and "Slow", "Normal", "Transactional", or "DC-Level" DAC updates.

“DC-Level” DACs on the USB bus are capable of not-more-than 4000 transactions per second. "Waveform" DAC operation is described in the “DAC Waveform” section, and refers to analog outputs capable of periodically-timed buffered operations at relatively fast rates, depending on the model. All "Waveform DAC" channels are equally capable of being used in a "DC-Level" fashion, so you may need to refer to both sections.

DAC Init Functions

The following function must be called one time before the DAC outputs can output commanded values. This is to ensure no DAC outputs a potentially dangerous level before the application has configured a known state.

DACSetBoardRange()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Enable DAC outputs to generate values other than “near ground”, and select the correct calibration table (on applicable models).

Delphi function DACSetBoardRange(DeviceIndex: LongWord; RangeCode: LongWord): LongWord; cdecl;
Visual C unsigned long DACSetBoardRange(unsigned long DeviceIndex, unsigned long RangeCode);
C# UInt32 DACSetBoardRange(UInt32 DeviceIndex, UInt32 RangeCode);
Arguments:
DeviceIndex
The index of the device to initialize; generally either diOnly or a specific device's device index.
RangeCode
Passing 0 selects "Unipolar" while passing "1" selects "Bipolar". If you pass an incorrect value you may see invalid data from your DACs.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACSetChannelCal()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Modify the calibration table for a given USB-AOxx-xxx Family DAC board channel

Delphi function DACSetChannelCal(DeviceIndex: LongWord; Channel: LongWord; CalFileName: PAnsiChar): LongWord; cdecl;
Visual C unsigned long DACSetChannelCal(unsigned long DeviceIndex, unsigned long Channel, char *CalFileName);
C# UInt32 DACSetChannelCal(UInt32 DeviceIndex, UInt32 Channel, [In] Char[] CalFileName);
Arguments:
DeviceIndex
The index of the device to calibrate; generally either diOnly or a specific device's device index.
Channel
The channel you are uploading a new calibration table for.
CalFileName
The path/filename to the new calibration table's data.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Analog "DC-Level" Output Functions

DACDirect()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Output a value on a single DAC

Delphi function DACDirect(DeviceIndex: LongWord; Channel: Word; Value: Word): LongWord; cdecl;
Visual C unsigned long DACDirect(unsigned long DeviceIndex, unsigned long Channel, unsigned short Counts);
C# UInt32 DACDirect(UInt32 DeviceIndex, UInt16 Channel, UInt16 Counts);
Arguments:
DeviceIndex
The index of the device to update the DAC; generally either diOnly or a specific device's device index.
Channel
DAC Channel to write
Value
Count value to write to specified DAC Channel
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACMultiDirect()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Simultaneously output values on multiple DACs.

This function is easy to use, but can't achieve kilohertz rates. You will typically achieve over 200 updates per second on all 16 channels of the USB-AO16-16A Family using this function.

Delphi function DACMultiDirect(DeviceIndex: LongWord; pDACData: PWord; DACDataCount: LongWord): LongWord; cdecl;
Visual C unsigned long DACMultiDirect(unsigned long DeviceIndex, void *pDACData, unsigned long DACDataCount);
C# UInt32 DACMultiDirect(UInt32 DeviceIndex, [In, Out] UInt16[] pDACData, UInt32 DACDataCount);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pDACData
Pointer to the first element of an array of pairs of channel / count words. Each pair's first word value is the Analog Output channel to which the corresponding count value should be written.
DACDataCount
The number of DACs to update; the number of pairs passed in pDACData, or the number of bytes ÷4.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Analog "Waveform" Output Functions

DACOutputProcess()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

The simplest way to output one or more simultaneous analog output waveforms (buffers of periodically-timed DAC values).

All DACs in a single “point” will be updated simultaneously (on the same clock tick). The next point will be output on the subsequent clock tick.

Delphi function DACOutputProcess(DeviceIndex: LongWord; var ClockHz: Double; NumSamples: LongWord; pSampleData: PWord): LongWord; cdecl;
Visual C unsigned long DACOutputProcess(unsigned long DeviceIndex, double *ClockHz, unsigned long NumSamples, unsigned short *SampleData);
C# UInt32 DACOutputProcess(UInt32 DeviceIndex, ref double ClockHz, UInt32 NumSamples, [In, Out] UInt16 SampleData);
Arguments:
DeviceIndex
The index of the device to generate waveforms on; generally either diOnly or a specific device's device index.
ClockHz
The rate each Sample should be written to the DAC(s).
NumSamples
The total number of samples to output. Notably, this is not a number of "points", but rather sizeof(SampleData)÷2.
pSampleData
A pointer to an array of WORDs; each DAC value is stored in a WORD, so it should contain (samples to output) WORDs. The features are controlled by the upper bits in the data array; for details on this format, refer to DACOutputFrameRaw().
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputClose()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
USB-DA12-8A only. Deprecated: DACOutputCloseNoEnd is preferred for new code.
Purpose:

This function causes the USB-DA12-8A to cease streaming data.

This function is deprecated because it will insert an EOM bit on the last data point under certain circumstances.

Delphi function DACOutputClose(DeviceIndex: LongWord; bWait: LongBool): LongWord; cdecl;
Visual C unsigned long DACOutputClose(unsigned long DeviceIndex, unsigned long bWait);
C# UInt32 DACOutputClose(UInt32 DeviceIndex, UInt32 bWait);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
bWait
Reserved for future expansion; currently, this function always waits for the streaming process to complete before returning to the caller.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputCloseNoEnd()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This function closes a DAC streaming process without ending it. This is most useful when you've set LOOP or EOM via DACOutputFrameRaw().

Delphi function DACOutputCloseNoEnd(DeviceIndex: LongWord; bWait: LongBool): LongWord; cdecl;
Visual C unsigned long DACOutputCloseNoEnd(unsigned long DeviceIndex, unsigned long bWait);
C# UInt32 DACOutputCloseNoEnd(UInt32 DeviceIndex, UInt32 bWait);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
bWait
Reserved for future expansion; currently, this function always waits for the streaming process to complete before returning to the caller.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputStatus()

Purpose:

Not implemented, returns ERROR_NOT_SUPPORTED.

DACOutputFrame()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This function writes a collection of points (called “a frame”) into the DAC stream, and configures their control bits. All DACs in a single “point” will be updated simultaneously (on the same clock tick). The next point will be output on the subsequent clock tick.

Delphi function DACOutputFrame(DeviceIndex, FramePoints: LongWord; FrameData: PWord): LongWord; cdecl;
Visual C unsigned long DACOutputFrame(unsigned long DeviceIndex, unsigned long FramePoints, unsigned short *FrameData);
C# UInt32 DACOutputFrame(UInt32 DeviceIndex, UInt32 FramePoints, [In, Out] UInt16 pFrameData);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
FramePoints
the number of points in the frame - NOT BYTES.
FrameData
a pointer to an array of WORDs; each DAC value is stored in a WORD, so it should contain (DAC Channel count) × (points in the frame) WORDs
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputFrameRaw()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This function writes a group of “points” (a group of points is referred to as a “frame”) into the DAC stream. All DACs in a single “point” will be updated simultaneously (on the same clock tick). The next point will be output on the subsequent clock tick.

Delphi function DACOutputFrameRaw(DeviceIndex, FramePoints: LongWord; FrameData: PWord): LongWord; cdecl;
Visual C unsigned long DACOutputFrameRaw(unsigned long DeviceIndex, unsigned long FramePoints, unsigned short *FrameData);
C# UInt32 DACOutputFrameRaw(UInt32 DeviceIndex, UInt32 FramePoints, [In, Out] UInt16 FrameData);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
FramePoints
the number of points in the frame - NOT BYTES. If you're using a variable "point" size, then it may be easiest to use DACOutputSetCount to set the DAC count to 1, in which case FramePoints is effectively the number of samples.
FrameData
a pointer to an array of WORDs; each DAC value is stored in a WORD, so it should contain (DAC Channel count) × (points in the frame) WORDs
Also note: all WORDs, in each point, contain a 12-bit count value AND four control 45 bits (in the highest nybble). See the discussion, below.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputOpen()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This function begins a DAC streaming process. The stream is divided into “points”; each point contains data for one or more DACs, and during the streaming process the onboard counter/timer clocks out points at a steady rate.

Delphi function DACOutputOpen(DeviceIndex: LongWord; var ClockHz: Double): LongWord; cdecl;
Visual C unsigned long DACOutputOpen(unsigned long DeviceIndex, double *ClockHz);
C# UInt32 DACOutputOpen(UInt32 DeviceIndex, ref double ClockHZ);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pClockHz
a pointer to a double precision IEEE floating point number containing the desired output clock frequency. This value is set by the driver to the actual frequency at which DAC data will be clocked out, as limited by the device's capabilities.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputSetCount()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

This function sets the number of DACs involved in each DAC streaming point henceforth.

Delphi function DACOutputSetCount(DeviceIndex, NewCount: LongWord): LongWord; cdecl;
Visual C unsigned long DACOutputSetCount(unsigned long DeviceIndex, unsigned long NewCount);
C# UInt32 DACOutputClose(UInt32 DeviceIndex, UInt32 bWait);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
NewCount
number from 1-8 indicating the number of DACs in future points, as used by various DAC "Frame" functions
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputSetClock()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Sets the output point rate of DAC streaming.

Delphi function DACOutputSetClock(DeviceIndex: LongWord; var ClockHz: Double): LongWord; cdecl;
Visual C unsigned long DACOutputSetClock(unsigned long DeviceIndex, double *ClockHz);
C# UInt32 DACOutputSetCount(UInt32 DeviceIndex, ref Double ClockHz);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
ClockHz
Pointer to a double-precision IEEE floating-point target frequency, in Hz. On a success, it will be set to the actual frequency, in Hz.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputSetInterlock()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Enables or disables the interlock feature. The device powers up with the interlock feature disabled. While interlock is enabled, DAC streaming is paused unless the interlock pin is grounded, usually through the cable. The interlock pin is pin 12 of the DB25 M connector (or, on the OEM version, pin 7 of the connector named J4).

Delphi function DACOutputSetInterlock(DeviceIndex: LongWord; bInterlock: LongBool): LongWord; cdecl;
Visual C unsigned long DACOutputSetInterlock(unsigned long DeviceIndex, unsigned long bInterlock);
C# UInt32 DACOutputSetInterlock(UInt32 DeviceIndex, UInt32 bInterlock);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
bInterlock
TRUE to enable interlock, FALSE to disable interlock.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACOutputStart()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Manually starts DAC streaming, when using DACOutputFrame/DACOutputFrameRaw. DAC streaming is intended to be continuous, and will be automatically started once 163,840 bytes(= 1¼ 128kB SRAMs) have been sent to the device. For a short DAC output, you can use DACOutputProcess instead, which automatically handles the start regardless.

Delphi function DACOutputStart(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long DACOutputStart(unsigned long DeviceIndex);
C# UInt32 DACOutputStart(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

DACDIO_WriteAll()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Simultaneously write to all the DACs and all the DIO on a USB-AIO* device.

Delphi function DACDIO_WriteAll(DeviceIndex: LongWord; pDACCounts: PWord; pDIOData: PByte): LongWord; cdecl;
Visual C unsigned long DACDIO_WriteAll(unsigned long DeviceIndex, unsigned short *pDACCounts, unsigned char *pDIOData);
C# UInt32 DACDIO_WriteAll(UInt32 DeviceIndex, ref UInt16 pDACCounts, ref UInt8 pDIOData);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pDACCounts
A pointer to the first of an array of words, one for each DAC, with the counts(0000..FFFFh) to output on each DAC.
pDIOData
A pointer to the first of an array of bytes, one for each DIO byte, with the data to output. Bytes written to ports configured as inputs are ignored. The number of bytes in the pData array needs to be the same as described for “pData” under DIO_Configure.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Functions For Multiple I/O Types

These functions are specific to a few I/O types, less-used, or otherwise less prominent than the functions for all I/O types.

AIOUSB_ClearFIFO()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Clears the buffered streaming FIFO on a device that has buffered streaming, whether ADC or DIO.

Delphi function AIOUSB_ClearFIFO(DeviceIndex: LongWord; TimeMethod: LongWord): LongWord; cdecl;
Visual C unsigned long AIOUSB_ClearFIFO(unsigned long DeviceIndex, unsigned long TimeMethod);
C# UInt32 AIOUSB_ClearFIFO(UInt32 DeviceIndex, UInt32 TimeMethod);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
TimeMethod
0 to simply clear the FIFO right away, or another per the table below.
CodeEffect
0Clear FIFO as soon as command received (and disable auto-clear).
1Enable auto-clear FIFO every falling edge of DIO port D bit 1, on digital boards. Analog boards treat this method as identical to "method 0".
5As 0, but also abort any streaming data flow currently in progress.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_SetStreamingBlockSize()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Sets the block size used by bulk block ADC streaming. This is analogous to the "buffer size" of bulk continuous ADC streaming. The streaming block size is also used by DIO streaming, but is rarely useful for DIO streaming to change.

Both DIO streaming and bulk block ADC streaming use fairly-large buffers, which are broken up into blocks at the level of the driver interface. Only one block is locked at a time, limiting the use of locked memory. For bulk block ADC streams, this is noticeable when using the ADC_BulkPoll() function; its "bytes left" tends to move in blocks, based on this streaming block size. A large size (like the default 31k) is necessary at high speeds, but a small size is more responsive at low speeds.

Delphi function AIOUSB_SetStreamingBlockSize(DeviceIndex, BlockSize: LongWord): LongWord; cdecl;
Visual C unsigned long AIOUSB_SetStreamingBlockSize(unsigned long DeviceIndex, unsigned long BlockSize);
C# UInt32 AIOUSB_SetStreamingBlockSize(UInt32 DeviceIndex, UInt32 BlockSize);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
BlockSize
The new block size. For DIO streaming, this block size is in words, and must be a multiple of 256 (decimal). For ADC streaming, this block size is in bytes, and must be a multiple of 512 (decimal). This difference exists for historical reasons; two older drivers were merged into AIOUSB, and each retains its own block size meaning.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_ResetChip()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Resets the device's on-board microcontroller chip.

Delphi function AIOUSB_ResetChip(DeviceIndex: LongWord): LongWord; cdecl;
Visual C unsigned long AIOUSB_ResetChip(unsigned long DeviceIndex);
C# UInt32 AIOUSB_ResetChip(UInt32 DeviceIndex);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_ReloadDeviceLinks()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Closes handles to all devices, then redetects and reopens them.

Certain applications and environments that do not properly unload AIOUSB.dll between runs may fail to detect boards on executions after the first.

For example, debugging an application in the IDE of Visual Basic 6 and running VIs inside LabVIEW both exhibit this symptom(while running the executable versions of VB6 programs and VIs does not).

You can resolve this issue by calling this function one time, first, during the init phase of your application.

Delphi function AIOUSB_ReloadDeviceLinks: LongWord; cdecl;
Visual C unsigned long AIOUSB_ReloadDeviceLinks;
C# UInt32 AIOUSB_ReloadDeviceLinks;
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_SetGlobalTickRate()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Sets the global tick rate, which then gets divided down for various FWE2.0 features (automap, PWM, etc).

Delphi function AIOUSB_SetGlobalTickRate(DeviceIndex: LongWord; pHz: PDouble): LongWord; cdecl;
Visual C unsigned long AIOUSB_SetGlobalTickRate(unsigned long DeviceIndex, double *pHz);
C# UInt32 AIOUSB_SetGlobalTickRate(UInt32 DeviceIndex, [In, Out] double pHz);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
pHz
Pointer to a double-precision IEEE floating-point target frequency, in Hz. On a success, it will be set to the actual frequency, in Hz.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_QuerySimplePNPData()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Reads the FWE 2.0 PNP record, which is used to tell the driver the capabilities of the device.

Contact ACCES if you'd like more information on the FWE 2.0 PNP record. In general, customers only buy devices of one model or a few models, and know their capabilities. This record exists because the driver needs to be able to handle devices of a wide variety of present and future models.

Delphi function AIOUSB_QuerySimplePNPData(DeviceIndex: LongWord; pPNPData: Pointer; pPNPDataBytes: PLongWord): LongWord; cdecl;
Visual C unsigned long AIOUSB_QuerySimplePNPData(unsigned long DeviceIndex, void *pPNPData, unsigned long *pPNPDataBytes);
C# UInt32 AIOUSB_QuerySimplePNPData(UInt32 DeviceIndex, [Out] Byte pPNPData[], ref UInt32 pPNPDataBytes);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
pPNPData
Pointer to a buffer to receive the device's FWE2.0 PNP record.
pPNPDataBytes
Pointer to a 32-bit unsigned int length of the buffer pointed to by pPNPData.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_FlashRead()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Reads back the onboard flash, which is used for DAC calibration in the USB-AOx family. Note that this isn't normally useful.

Delphi function AIOUSB_FlashRead(DeviceIndex: LongWord; StartAddress: LongWord; var DataSize: LongWord; Data: Pointer): LongWord; cdecl;
Visual C unsigned long AIOUSB_FlashRead(unsigned long DeviceIndex, unsigned long StartAddress, unsigned long *DataSize, void *Data);
C# UInt32 AIOUSB_FlashRead(UInt32 DeviceIndex, UInt32 StartAddress, [In, Out] UInt32 DataSize, [Out] byte[] Data);
Arguments:
DeviceIndex
The index of the device to query; generally either diOnly or a specific device's device index.
StartAddress
The first address to write to. The DAC calibration flash in the USB-AOx family has addresses from 0 to 1FFFFF hex overall, with each channel using 20000 hex bytes.
DataSize
A pointer to a variable holding the number of bytes to read. It will be changed to how many bytes were read.
Data
A pointer to a buffer to read the flash into.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_FlashEraseSector()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Erases a sector of the onboard flash, to prepare it for writing. Note that this isn't normally useful in the field.

Delphi function AIOUSB_FlashEraseSector(DeviceIndex: LongWord; Sector: Integer): LongWord; cdecl;
Visual C unsigned long AIOUSB_FlashEraseSector(unsigned long DeviceIndex, signed long Sector);
C# UInt32 AIOUSB_FlashEraseSector(UInt32 DeviceIndex, UInt32 Sector);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Sector
The index of the flash sector to erase. The USB-AOx family uses 2 sectors per channel.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AIOUSB_FlashWrite()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Write into (erased sectors of) the onboard flash, which is used for DAC calibration in the USB-AOx family. Note that this isn't normally useful in the field.

Delphi function AIOUSB_FlashWrite(DeviceIndex: LongWord; StartAddress: LongWord; DataSize: LongWord; Data: Pointer): LongWord; cdecl;
Visual C unsigned long AIOUSB_FlashWrite(unsigned long DeviceIndex, unsigned long StartAddress, unsigned long DataSize, void *Data);
C# UInt32 AIOUSB_FlashWrite(UInt32 DeviceIndex, UInt32 StartAddress, UInt32 DataSize, [In] byte[] Data);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
StartAddress
The first address to write to. The DAC calibration flash in the USB-AOx family has addresses from 0 to 1FFFFF hex overall, with each channel using 20000 hex bytes.
DataSize
A pointer to a variable holding the number of bytes to read. It will be changed to how many bytes were read.
Data
A pointer to a buffer to read the flash into.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

Raw / Lowest-level functions

Overview

GenericVendorRead()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Performs a low-level “control read” transaction. Other functions in this API result in control read, control write, bulk read, and/or bulk write transactions. The lowest-level functions (GenericVendorRead, GenericVendorWrite, AWU_GenericBulkIn, and AWU_GenericBulkOut) exist to bypass the API's logic and algorithms, generating those transactions directly as your application directs.

Delphi function GenericVendorRead(DeviceIndex: LongWord; Request: Byte; Value, Index: Word; var DataSize: LongWord; pData: Pointer): LongWord; cdecl;
Visual C unsigned long GenericVendorRead(unsigned long DeviceIndex, unsigned char Request, unsigned short Value, unsigned short Index, unsigned long *pDataSize, void *pData);
C# UInt32 GenericVendorRead(UInt32 DeviceIndex, Byte Request, UInt16 Value, UInt16 Index, ref UInt32 pDataSize, byte[] pData);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Request
The USB request number associated with the desired transaction. Note that the request type will be "vendor read".
Value
The Value word in the USB setup data packet.
Index
The Index word in the USB setup data packet.
pDataSize
A pointer to the size, in bytes, of the buffer pointed to by pData. Upon exit, this value will be changed to the size, in bytes, of the data read from the device.
pData
A pointer to the first of an array of bytes. USB data packet(s) will be read into the array. If DataSize is zero, then pData can be “null”.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

GenericVendorWrite()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Performs a low-level control write transaction. Other functions in this API result in control read, control write, bulk read, and/or bulk write transactions; GenericVendorRead, GenericVendorWrite, AWU_GenericBulkIn, and AWU_GenericBulkOut exist to bypass the API, generating those transactions directly.

Delphi function GenericVendorWrite(DeviceIndex: LongWord; Request: Byte; Value, Index: Word; DataSize: LongWord; Data: Pointer): LongWord; cdecl;
Visual C unsigned long GenericVendorWrite(unsigned long DeviceIndex, unsigned char Request, unsigned short Value, unsigned short Index, unsigned long DataSize, void *pData);
C# UInt32 GenericVendorWrite(UInt32 DeviceIndex, Byte Request, UInt16 Value, UInt16 Index, UInt32 DataSize, ref byte[] pData);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
Request
The USB request number associated with the desired transaction. Note that the request type will be "vendor write".
Value
The Value word in the USB setup data packet.
Index
The Index word in the USB setup data packet.
DataSize
The size, in bytes, of the buffer pointed to by pData.
pData
A pointer to the first of an array of bytes. Data in the array will be written in USB data packet(s). If DataSize is zero, then pData can be “null”.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AWU_GenericBulkIn()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Performs a low-level bulk read transaction. Other functions in this API result in control read, control write, bulk read, and/or bulk write transactions; GenericVendorRead, GenericVendorWrite, AWU_GenericBulkIn, and AWU_GenericBulkOut exist to bypass the API, generating those transactions directly.

This is not for the faint-hearted. Calling these low-level interfaces can interfere with the normal operation of the higher-level API functions. Caution: Some low-level interfaces could render your device inoperable. Warning: Recovery could involve returning your device to the factory.

Delphi function AWU_GenericBulkIn(DeviceIndex: LongWord; PipeID: LongWord; pData: Pointer; DataSize: LongWord; var BytesRead: LongWord): LongWord; cdecl;
Visual C unsigned long AWU_GenericBulkIn(unsigned long DeviceIndex, unsigned long PipeID, void *pData, unsigned long DataSize, unsigned long *pBytesRead);
C# UInt32 AWU_GenericBulkIn(UInt32 DeviceIndex, UInt32 PipeID, ref byte[] pData, UInt32 DataSize, ref UInt32 pBytesRead);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
PipeID
The USB endpoint number, ORed with 80 hex. For example, to bulk read from endpoint 6, PipeID is 86 hex.
pData
A pointer to the first of an array of bytes. Bulk data will be read into the array.
DataSize
The size, in bytes, of the buffer pointed to by pData. To a first approximation, digital bulk and continuous analog bulk must be done in multiples of 512 bytes, while block analog bulk must be consistent with the block size; however, the specifics are complex, and can depend on the timing of external hardware.
BytesRead
Upon exit, this value will be changed to the size, in bytes, of the data read from the device.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.

AWU_GenericBulkOut()

APPLIES TO
Digital
Inputs
Digital
Outputs
Analog
Inputs
Analog
Outputs
Buffered
DI, DO, DIO
Counter
Timers
 
Purpose:

Performs a low-level bulk write transaction. While the majority of functions in this API that you will use during normal operation result in control transfers or bulk read / write transactions; GenericVendorRead, GenericVendorWrite, AWU_GenericBulkIn, and AWU_GenericBulkOut exist to bypass the API, generating those transactions directly, under your application's complete control.

This is not for the faint-hearted. Calling these low-level interfaces can interfere with the normal operation of the higher-level API functions. Caution: Some low-level interfaces could render your device inoperable. Warning: Recovery could involve returning your device to the factory.

Delphi function AWU_GenericBulkOut(DeviceIndex: LongWord; PipeID: LongWord; pData: Pointer; DataSize: LongWord; var BytesWritten: LongWord): LongWord; cdecl;
Visual C unsigned long AWU_GenericBulkOut(unsigned long DeviceIndex, unsigned long PipeID, void *pData, unsigned long DataSize, unsigned long *pBytesWritten);
C# UInt32 AWU_GenericBulkOut(UInt32 DeviceIndex, UInt32 PipeID, ref byte[] pData, UInt32 DataSize, ref UInt32 pBytesWritten);
Arguments:
DeviceIndex
The index of the device to control; generally either diOnly or a specific device's device index.
PipeID
Equal to the USB endpoint number.
pData
A pointer to the first of an array of bytes. Data in the array will be written as bulk data.
DataSize
The size, in bytes, of the buffer pointed to by pData.
BytesWritten
Upon exit, this value will be changed to the size, in bytes, of the data written to the device.
Returns:

Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “Success”.