Top ↑
AIOeNET.dll Software Reference Manual
V1.02

Introduction

This manual acts as a reference for the eNET-AIO Family's interface, “AIOeNET.dll”, which provides convenient, high-level functions for using the analog inputs and outputs of these devices from any programming language or environment.

Five primary types of functions are provided:

How To Use This Reference

First, read the entirety of this introduction.

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

API Overview

The AIOeNET API (Application Programming Interface) is designed to be convenient to use. We've also provided various "overloaded" versions for many functions, allowing you to switch between 16-bit count values and voltage values, for example, just by changing your variable types from integers to floating-point. Or control multiple DACs simultaneously by passing an array of values instead of a single variable — in either counts or volts.

Important Terms

Client Reference

It's possible to connect to multiple devices. To keep track of which device is being addressed by each function call, there's a client reference parameter, returned by Connect() and used by most functions. This refers to a specific connection to a specific device.

Range Code

Each of the ADC channels can be acquired at a variety of bipolar and unipolar ranges, and each DAC channel can be factory-configured for one of a variety of ranges. AIOeNET uses the TRangeCode to represent the available ranges, both as "FourCC" values, like "B±10" (0x3031E142) for the bipolar 10V range (-10 to +10V), and by register-level code specific to the chips involved.

We highly recommend using the mnemonic, hardware-independent, "FourCC" values for all development. To support this we provide constants like rcBipolar10 for your use.

However, because TRangeCode supports both ADC and DAC ranges, and is consistent with other hardware's APIs, you will find more FourCC constants in our API than your ADC or DAC can use. Refer to the ADC_SetRange() and DAC_GetRange() functions for the constant available to each function.

Channel Index

Channel Index means "channel number" or just "channel", starting from zero (0) and incrementing consecutively. The ADC channels are zero (0) through fifteen (15), or more — up to one hundred twenty-eight (0-127) — on a device with a submultiplexer. The DACs are channels zero (0) through three (3).

Analog Inputs (ADC)

Using the Analog Inputs can be as simple as calling an ADC_ImmediateGet() function in a loop. You should be able to achieve tens or even hundreds of kilohertz sampling rate using this technique.

On the other hand, the card is quite powerful, capable of running an acquisition stream up to 1MHz. Handling this much data could be complex, but AIOeNET provides two acqusition methods to satisfy the range of application types:

ADC Immediate Mode

As mentioned, this is a very simple way to take data, but not capable of the fastest speeds.

ADC Streaming Mode

ADC streaming requires your application to occasionally call an ADC_AcquireGetData() function to collect the samples that have accumulated in the FIFO. Top speed is limited by your application's worst-case polling interval.

Analog Outputs (DAC)

The(optional) onboard DAC provides four voltage output channels. You can output data as either a double-precision proportion (from 0 to 1) or 16-bit counts (offset binary in bipolar ranges; simple binary in unipolar ranges).

To output data to a single DAC channel call a DAC_Output() function.

To output data to multiple DAC channels simultaneously use a DAC_OutputN() function, or use the ciAll constant with a non-N function to write the same value to all DACs.

Digital Inputs & Outputs (DIO)

The onboard DIO provides 16 bits, each individually configurable as input or output.

To read digital inputs, call the DIO_ReadAll() function. This will also read back any digital outputs.

The device powers up with all DIO configured as inputs. To reconfigure some or all as outputs, call the DIO_Configure() function.

To write digital outputs, call the DIO_WriteAll() function.

Error/Status Return Values

In languages other than Python, unless otherwise documented all return values are Microsoft defined “Win32” error codes. (See the Connect() function for the exception to this rule.)

In Python, Unless otherwise documented all functions return a tuple containing an error/status value in the first position. This status is a Microsoft defined “Win32” error code. (See the Connect() function for the exception to this rule.) Refer to each function description for an explanation of the other values returned in the tuple.

The set of error codes AIOeNET.dll can produce is the combined set called out in our AIOeNET.dll source code (provided) plus anything the OS's lower-level code decides to throw our way. A return of “ERROR_SUCCESS” (equal to 0) means no error occurred.

Overloads In Typed Languages

For some functions — generally those that handle strings or arrays — what's listed as a single function exists in multiple versions. Overloads are provided in typed languages so the version can be selected by the compiler.

With strings — for example, the ScanForDevices() "function" — the function exists in three different charset versions: 8-bit ANSI codepage ("A"), 16-bit UTF-16 ("W"), and 32-bit true Unicode ("U") characters. The charset can be directly selected by calling ScanForDevicesA(), ScanForDevicesW(), or ScanForDevicesU(). However, simply calling ScanForDevices() with the appropriate type is sufficient to call the overloaded imports. Only two charsets are available in C#, and the overloaded imports are differenced with marshalling attributes, which is why their signatures look the same.

Code Definitions

The whole point of these names is so a section like this isn't needed, and especially not in a "read the entirety" section.

Device-Level Functions

Functions You Call At Initialization

These functions provide plug-and-play compatibility, allowing your application to detect devices on the network at runtime.

ScanForDevices()

Purpose

Finds devices on the network, retrieving host names to use for them. Pass a name to the Connect() function to connect to that device.

Delphi Signature
function ScanForDevices(NameListChAvailable: TUInt32; pNameList: TPAnsiChar; out NameListCh: TUInt32): TWinErrCode; overload; name 'ScanForDevicesA';
function ScanForDevices(NameListChAvailable: TUInt32; pNameList: TPWideChar; out NameListCh: TUInt32): TWinErrCode; overload; name 'ScanForDevicesW';
function ScanForDevices(NameListChAvailable: TUInt32; pNameList: TPUCS4Char; out NameListCh: TUInt32): TWinErrCode; overload; name 'ScanForDevicesU';
function ScanForDevicesA(NameListChAvailable: TUInt32; pNameList: TPAnsiChar; out NameListCh: TUInt32): TWinErrCode;
function ScanForDevicesW(NameListChAvailable: TUInt32; pNameList: TPWideChar; out NameListCh: TUInt32): TWinErrCode;
function ScanForDevicesU(NameListChAvailable: TUInt32; pNameList: TPUCS4Char; out NameListCh: TUInt32): TWinErrCode;
C# Signature
internal static extern TWinErrCode ScanForDevices(TUInt32 NameListChAvailable, [Out] Char[] pNameList, out TUInt32 NameListCh);
internal static extern TWinErrCode ScanForDevices(TUInt32 NameListChAvailable, [Out] Char[] pNameList, out TUInt32 NameListCh);
internal static extern TWinErrCode ScanForDevicesA(TUInt32 NameListChAvailable, [Out] Char[] pNameList, out TUInt32 NameListCh);
internal static extern TWinErrCode ScanForDevicesW(TUInt32 NameListChAvailable, [Out] Char[] pNameList, out TUInt32 NameListCh);
Arguments
NameListChAvailable
The number of characters available in the pNameList string. If this is smaller than the length of the name list to be put into the string, then the end of the name list is lost.
pNameList
A string or array of characters to receive the name list. In the name list, multiple names will have Windows "CR LF" returns in between. There's also a null on the end, for use as a low-level C string.
NameListCh
Receives the number of characters in the name list, not including the null. This can be greater than NameListChAvailable, in which case [NameListCh - NameListChAvailable] characters were lost, in addition to the null. If equal to NameListChAvailable, then only the null was lost.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Connect()

Purpose

Connects to the specified device. The returned client reference is used in subsequent calls to communicate through this connection.

Delphi Signature
function Connect(Host: TPAnsiChar; Index: TSInt32 = 0): TClientRef; overload; name 'ConnectA';
function Connect(Host: TPWideChar; Index: TSInt32 = 0): TClientRef; overload; name 'ConnectW';
function Connect(Host: TPUCS4Char; Index: TSInt32 = 0): TClientRef; overload; name 'ConnectU';
function ConnectA(Host: TPAnsiChar; Index: TSInt32 = 0): TClientRef;
function ConnectW(Host: TPWideChar; Index: TSInt32 = 0): TClientRef;
function ConnectU(Host: TPUCS4Char; Index: TSInt32 = 0): TClientRef;
C# Signature
internal static extern TClientRef Connect(Char[] Host, TSInt32 Index);
internal static extern TClientRef Connect(Char[] Host, TSInt32 Index);
Arguments
Host
A string with the IP address or host name of the device to connect to. IPv4 and IPv6 addresses are both supported. When connecting via host name, IPv6 is generally preferred, but it depends on system settings.
Index
Use the default zero. For future expansion, this argument supports indexing multiple interfaces on a single device.
Returns
A client reference to the device, or a null client reference on failure. If a null reference is returned, then GetLastError or Marshal.GetLastWin32Error can be used to get a Windows standard “Win32” error code associated with the failure.

Disconnect()

Purpose

Disconnects from the device. On success, the client reference is no longer valid.

Delphi Signature
function Disconnect(uClientRef: TClientRef): LongWord;
C# Signature
internal static extern TWinErrCode Disconnect(TClientRef uClientRef);
Arguments
uClientRef
The client reference for the device.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ChangeDeviceHostname()

Purpose

Changes the device's name, which is used to connect by host name. The reference remains valid and connected through this change, whether it was connected by host name or by IP address.

Delphi Signature
function ChangeDeviceHostname(uClientRef: TClientRef; NewHostname: TPAnsiChar): TWinErrCode; overload; name 'ChangeDeviceHostnameA';
function ChangeDeviceHostname(uClientRef: TClientRef; NewHostname: TPWideChar): TWinErrCode; overload; name 'ChangeDeviceHostnameW';
function ChangeDeviceHostname(uClientRef: TClientRef; NewHostname: TPUCS4Char): TWinErrCode; overload; name 'ChangeDeviceHostnameU';
function ChangeDeviceHostnameA(uClientRef: TClientRef; NewHostname: TPAnsiChar): TWinErrCode;
function ChangeDeviceHostnameW(uClientRef: TClientRef; NewHostname: TPWideChar): TWinErrCode;
function ChangeDeviceHostnameU(uClientRef: TClientRef; NewHostname: TPUCS4Char): TWinErrCode;
C# Signature
internal static extern TWinErrCode ChangeDeviceHostname(TClientRef uClientRef, [Out] Char[] NewHostname);
internal static extern TWinErrCode ChangeDeviceHostname(TClientRef uClientRef, [Out] Char[] NewHostname);
internal static extern TWinErrCode ChangeDeviceHostnameA(TClientRef uClientRef, [Out] Char[] NewHostname);
internal static extern TWinErrCode ChangeDeviceHostnameW(TClientRef uClientRef, [Out] Char[] NewHostname);
Arguments
uClientRef
The client reference for the device.
NewHostname
A null-terminated string with the new name for the device to change to.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

GetDeviceFeatures()

Purpose

Changes the device's name, which is used to connect by host name. The reference remains valid through this change.

Delphi Signature
function GetDeviceFeatures(uClientRef: TClientRef; FeatureBytes: TUInt32; pFeatures: TPUInt8): TWinErrCode;
C# Signature
internal static extern TWinErrCode GetDeviceFeatures(TClientRef uClientRef, TUInt32 FeatureBytes, [Out] TUInt8[] pFeatures);
Arguments
uClientRef
The client reference for the device.
FeatureBytes
`
pFeatures
`
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Reference-Level Functions

SetTimeout()

Purpose

Changes the timeout for the client reference. The default timeout is intended to handle LAN and WAN devices with high-speed connections. For a hard-wired LAN device, a shorter timeout like 10 milliseconds would be reasonable. With a slow connection, or a faulty connection requiring many retries, a longer timeout like 10,000 milliseconds would be reasonable.

An application that calls SetTimeout will generally do so right after Connect, since each client reference is created with the default timeout.

Delphi Signature
function SetTimeout(uClientRef: TClientRef; TimeoutMS: TSInt32): TWinErrCode;
C# Signature
internal static extern TWinErrCode SetTimeout(TClientRef uClientRef, TSInt32 TimeoutMS);
Arguments
uClientRef
The client reference to change.
TimeoutMS
The new timeout value, in milliseconds.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Analog To Digital(ADC)

Overview

The ADC on the card can acquire analog data from a single channel or a scan of channels. The API allows samples to be taken singly, or periodically as a continuous stream of data, flowing through the device into your application until stopped.

Each scan is contiguous from a start channel to an end channel, inclusive. The device also supports adjustable oversampling, so each channel consists of up to 256 samples.

A scan is acquired at 1µs per sample, but the rate of scans is configurable. The fastest the scan rate can be is 1MHz divided by the number of samples in the scan. Therefore, if you acquire data only from 1 channel, then that channel can be sampled as often as once per microsecond. If you acquire data from 8 channels, then the fastest scan rate would be 125kHz, where the device would sample any given channel once every 8µs. You can set any lower rate, and less data can be easier to process, so long as it still represents the signal being acquired.

Quick & Easy "Snapshot"

ADC_ImmediateGetData()

Purpose

Acquire an immediate "snapshot" of the analog inputs. This can be from the single channel specified, or from the configured scan of channels.

If oversampling is enabled (see ADC_SetOversample), then the first oversample will be discarded, and the rest averaged.

Note
Given a connection (Connect()/Disconnect()), this is the only function call necessary to operate the analog inputs — if you don't need to acquire data faster than a few hundred readings per second, and don't need the data to be periodic.
For periodic and faster data, use "ADC_Acquire" functions.
Delphi Signature
function ADC_ImmediateGetData(uClientRef: TClientRef; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; name 'ADC_ImmediateGetScanV';
function ADC_ImmediateGetData(uClientRef: TClientRef; pDataRaw: TPUInt32): TWinErrCode; cdecl; overload; name 'ADC_ImmediateGetScanRaw';
function ADC_ImmediateGetData(uClientRef: TClientRef; Ch: TChannelIndex; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; name 'ADC_ImmediateGetSampleV';
function ADC_ImmediateGetData(uClientRef: TClientRef; Ch: TChannelIndex; pDataRaw: TPUInt32): TWinErrCode; cdecl; overload; name 'ADC_ImmediateGetSampleRaw';
function ADC_ImmediateGetScanV(uClientRef: TClientRef; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl;
function ADC_ImmediateGetScanRaw(uClientRef: TClientRef; pDataRaw: TPUInt32): TWinErrCode; cdecl;
function ADC_ImmediateGetSampleV(uClientRef: TClientRef; Ch: TChannelIndex; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl;
function ADC_ImmediateGetSampleRaw(uClientRef: TClientRef; Ch: TChannelIndex; pDataRaw: TPUInt32): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_ImmediateGetData(TClientRef uClientRef, [Out] TDouble[] pData, [Out] TUInt16[] pStatus, [Out] TUInt16[] pTimestamp);
internal static extern TWinErrCode ADC_ImmediateGetData(TClientRef uClientRef, [Out] TUInt32[] pDataRaw);
internal static extern TWinErrCode ADC_ImmediateGetData(TClientRef uClientRef, TChannelIndex Ch, [Out] TDouble[] pData, [Out] TUInt16[] pStatus, [Out] TUInt16[] pTimestamp);
internal static extern TWinErrCode ADC_ImmediateGetData(TClientRef uClientRef, TChannelIndex Ch, [Out] TUInt32[] pDataRaw);
internal static extern TWinErrCode ADC_ImmediateGetScanV(TClientRef uClientRef, [Out] TDouble[] pData, [Out] TUInt16[] pStatus, [Out] TUInt16[] pTimestamp);
internal static extern TWinErrCode ADC_ImmediateGetScanRaw(TClientRef uClientRef, [Out] TUInt32[] pDataRaw);
internal static extern TWinErrCode ADC_ImmediateGetSampleV(TClientRef uClientRef, TChannelIndex Ch, [Out] TDouble[] pData, [Out] TUInt16[] pStatus, [Out] TUInt16[] pTimestamp);
internal static extern TWinErrCode ADC_ImmediateGetSampleRaw(TClientRef uClientRef, TChannelIndex Ch, [Out] TUInt32[] pDataRaw);
Arguments
uClientRef
The client reference for the device.
pData
Output parameter to store the converted voltage. You can leave this parameter null to only receive status data. For scan functions, this is the first entry of a per-channel array.
pStatus
Output parameter to store the status word of the conversion. You can leave this pointer null to only receive voltage data. For scan functions, this is the first entry of a per-channel array.
pTimestamp
Output parameter reserved for future expansion. Leave this pointer null for ease of use. This parameter can be used, but as of this writing, timestamps are always zero. For scan functions, this is the first entry of a per-channel array.
pDataRaw
Output parameter to store the raw sample from the device, including the counts and status word. This is useful to collect and condition the data in raw form before converting to volts. For scan functions, this is the first entry of a per-channel array.
Ch
The channel to acquire, for single-sample functions. Scan functions will acquire the configured scan, which defaults to all channels.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Functions You Call At Initialization

In order to optimize throughput, and because each access of registers takes time (including round-trip Ring3-0-3 kernel transitions!), as many operations as possible should be moved out of the acquisition-loop into init-time code that only occurs once, regardless of how much data is being collected.

Thus, the following functions are suitable for calling at init, and usually only need to be issued once per program execution.

ADC_Reset()

Purpose

Resets the analog inputs to a known configuration. Use it before other initialization to clear any state left by past runs or other apps.

Delphi Signature
function ADC_Reset(uClientRef: TClientRef): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_Reset(TClientRef uClientRef);
Arguments
uClientRef
The client reference for the device.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_SetRange()

Purpose

Configures the analog input range for one channel or all channels.

Delphi Signature
function ADC_SetRange(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; RangeCode: TRangeCode): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_SetRange(TClientRef uClientRef, TChannelIndex Ch, TRangeCode RangeCode);
Arguments
uClientRef
The client reference for the device.
Ch
The channel(s) to configure. To configure all channels for the same range, use ciAll.
RangeCode
The range to configure on the specified channel(s). Defaults to ±10V (rcBipolar10).
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_SetDifferential()

Purpose

Configure differential vs single-ended for one channel or all channels. Most users will want single-ended, so that's the default at device reset, and this function is needed to use differential.

Single-ended acquisition acquires each channel relative to ground. With Ethernet-attached devices, the device acquiring the analog data can often be placed nearby the signal sources — like on the same power strip. Once the data is in digital form, it can then be transmitted over Ethernet, without further analog issues.

However, when the device isn't near the signal source(s), ground voltage can be different between the two places — and even between each signal. Differential acquisition compensates for this by acquiring each differential channel across what would otherwise be two single-ended channels. This differential pair can be simply the regular signal and the ground voltage where the signal was generated, but noise and distortion are reduced by using balanced pairs — the positive signal and the inverse of the signal. The downside of differential is offering half as many differential channels.

Delphi Signature
function ADC_SetDifferential(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; bDifferential: ByteBool): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_SetDifferential(TClientRef uClientRef, TChannelIndex Ch, byte bDifferential);
Arguments
uClientRef
The client reference for the device.
Ch
The channel(s) to configure. To configure all channels for the same range, use ciAll.
bDifferential
True to set the channel(s) to differential, False to return the channel(s) to single-ended.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_SetRate()

Purpose

Configures the sampling rate, in Hz, of the analog input stream.

Note
Not all possible frequencies can be achieved by the onboard timing, as it is based on the integer division of a high-frequency clock. Confirm your actual vs requested frequency using ADC_GetRate(). For example, requesting rates higher than 1MHz will result in an actual Hz of 1MHz.
Delphi Signature
function ADC_SetRate(uClientRef: TClientRef; Rate: TDouble): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_SetRate(TClientRef uClientRef, TDouble Rate);
Arguments
uClientRef
The client reference for the device.
Rate
The desired sample rate for the analog inputs.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_GetRate()

Purpose

Retrieves the analog input stream's configured sampling rate, in Hz.

Note
Not all possible frequencies can be achieved by the onboard timing, as it is based on the integer division of a high-frequency clock. Confirm your actual vs requested frequency using this function. For example, requesting rates higher than 1MHz will result in an actual rate of 1MHz.
Delphi Signature
function ADC_GetRate(uClientRef: TClientRef; out Rate: TDouble): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_GetRate(TClientRef uClientRef, ref TDouble Rate);
Arguments
uClientRef
The client reference for the device.
Rate
out parameter where the actual rate is returned, in Hz.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_SetChScan()

Purpose

Configure the channels in each scan.

Analog input functions that acquire "scans" acquire multiple data points, over a contiguous range of channels. This range is defined by its first channel and last channel. For example, setting the first channel to 3 and the last channel to 5 results in a single scan acquiring from [3, 4, 5], and a stream to acquire from [3, 4, 5, 3, 4, 5…]. You can configure scan functions to dwell on a single channel by setting first and last channels to be equal.

Delphi Signature
function ADC_SetChScan(uClientRef: TClientRef; FirstCh, LastCh: TChannelIndex): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_SetChScan(TClientRef uClientRef, TChannelIndex FirstCh, TChannelIndex LastCh);
Arguments
uClientRef
The client reference for the device.
FirstCh
The zero-based index of the first channel in each scan. Must be less than or equal to LastCh.
LastCh
The zero-based index of the last channel in each scan. Must be greater than or equal to FirstCh.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_SetOversample()

Purpose

Configure analog input oversampling, in which multiple oversamples are taken in place of each sample.

Delphi Signature
function ADC_SetOversample(uClientRef: TClientRef; Oversample: TUInt32): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_SetOversample(TClientRef uClientRef, TUInt32 Oversample);
Arguments
uClientRef
The client reference for the device.
Oversample
The number of extra oversamples to acquire. If set to 0, then oversampling is disabled — only regular samples are taken. If set to a greater value, up to 255, then that many extra oversamples will be taken. When these are averaged together by the driver, the first will be discarded for the sake of possible crosstalk, and the rest averaged together to make the sample.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_SetCalMode()

Purpose

Configure analog inputs to acquire calibration sources, or to acquire data normally.

Before acquiring calibration sources, we recommend resetting the calibration to scale = 1 and offset = 0, in order to perform absolute calibration. This driver doesn't directly support relative calibration, although relative calibration can be performed afterwards by saving the calibration constants in the calibration app.

Delphi Signature
function ADC_SetCalMode(uClientRef: TClientRef; CalMode: TCalMode = cmRealData): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_SetCalMode(TClientRef uClientRef, TCalMode CalMode = cmRealData);
Arguments
uClientRef
The client reference for the device.
CalMode
The calibration mode to configure. If this is cmRealData, then calibration sources are disabled, and real data is taken normally. Any other mode will cause all analog inputs to read that calibration source instead.
Use cmUnipolarGround and cmUnipolarReference to calibrate unipolar ranges. Use cmBipolarGround and cmBipolarReference to calibrate bipolar ranges. Acquiring unipolar calibration sources in a bipolar range, or vice versa, will give inaccurate results.
Regardless of range, the ground calibration source is 0V, and the reference calibration source is .9V. Two sources are enough for each range because the device needs only linear calibration, even as it ages.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_SetRangeCal()

Purpose

Permanently write calibration constants for a specified range.

Analog input data is automatically multiplied by the scale, then added to the offset, to perform MX+B linear calibration.

Delphi Signature
function ADC_SetRangeCal(uClientRef: TClientRef; RangeCode: TRangeCode; ScaleFactor: TDouble = 1; OffsetCounts: TDouble = 0): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_SetRangeCal(TClientRef uClientRef, TRangeCode RangeCode, TDouble ScaleFactor = 1, TDouble OffsetCounts = 0);
Arguments
uClientRef
The client reference for the device.
RangeCode
The range code for the range to write. Note that the same range can be referred to using two range codes. The global range code, like rcUnipolar10, refers to the 0-10V range regardless of device. The local range code, like rcRangeCode0, refers to the first range the device has, whichever that is. On a device with 0-10V as its first range, these two constants control the same range.
ScaleFactor
The scale constant for the range. This will generally be slightly greater than 1. For example, 1.01.
OffsetCounts
The offset constant for the range. This can vary on either side of 0, but is measured in counts, so even a value of +16 or so is rather small.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Analog Input Streaming

A "snapshot" of the analog inputs can be acquired with ADC_ImmediateGet functions.

To acquire data continuously and/or periodically, you must use a stream, via the functions described in this section.

ADC_AcquireBegin()

Purpose

Begins the analog input stream, sampling data continuously and periodically, until ADC_AcquireEnd() is called.

Delphi Signature
function ADC_AcquireBegin(uClientRef: TClientRef; TriggerMode: TUInt8 = $15): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_AcquireBegin(TClientRef uClientRef, byte TriggerMode = 0x15);
Arguments
uClientRef
The client reference for the device.
TriggerMode
Normally 15 hex (21 decimal). Other values are possible, but constitute an advanced topic beyond the scope of this manual. If you wish to adjust how samples/scans are triggered, then please contact the factory, and we'll be happy to teach you the ins and outs of this parameter.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_AcquireEnd()

Purpose

Gracefully ends the analog input stream begun by ADC_AcquireBegin(). Calling ADC_AcquireEnd() is how a well-behaved application should finish using an analog input stream.

Delphi Signature
function ADC_AcquireEnd(uClientRef: TClientRef): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_AcquireEnd(TClientRef uClientRef);
Arguments
uClientRef
The client reference for the device.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

ADC_AcquireGetData()

Purpose

Gathers data from the analog input stream.

Delphi Signature
function ADC_AcquireGetData(uClientRef: TClientRef; pDataSamples: TPUInt32; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; name 'ADC_AcquireGetDataV';
function ADC_AcquireGetData(uClientRef: TClientRef; pDataSamples: TPUInt32; pDataRaw: TPUInt32): TWinErrCode; cdecl; overload; name 'ADC_AcquireGetDataRaw';
function ADC_AcquireGetDataV(uClientRef: TClientRef; pDataSamples: TPUInt32; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl;
function ADC_AcquireGetDataRaw(uClientRef: TClientRef; pDataSamples: TPUInt32; pDataRaw: TPUInt32): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode ADC_AcquireGetData(TClientRef uClientRef, ref TUInt32 pDataSamples, [Out] TUInt32[] pDataRaw);
internal static extern TWinErrCode ADC_AcquireGetData(TClientRef uClientRef, ref TUInt32 pDataSamples, [Out] TDouble[] pData, [Out] TUInt16[] pStatus, [Out] TUInt16[] pTimestamp);
internal static extern TWinErrCode ADC_AcquireGetDataRaw(TClientRef uClientRef, ref TUInt32 pDataSamples, [Out] TUInt32[] pDataRaw);
internal static extern TWinErrCode ADC_AcquireGetDataV(TClientRef uClientRef, ref TUInt32 pDataSamples, [Out] TDouble[] pData, [Out] TUInt16[] pStatus, [Out] TUInt16[] pTimestamp);
Arguments
uClientRef
The client reference for the device.
pDataSamples
On entry, the number of samples there is room for in the array(s) for the subsequent parameter(s). On exit, the number of samples stored in the array(s).
pData
A pointer to the first entry of an array which receives volts for each sample. You can leave this parameter null to only receive status data — but note that voltage data will thus be discarded.
pStatus
A pointer to the first entry of an array which receives the status word for each sample. You can leave this parameter null to only receive voltage data.
pTimestamp
Output parameter reserved for future expansion. Leave this pointer null for ease of use. This parameter can take a pointer to the first entry of an array, but as of this writing, timestamps are always zero.
pDataRaw
A pointer to the first entry of an array which receives raw samples, including the counts and status word. This is useful to collect and condition the data in raw form before converting to volts.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Digital To Analog(DAC)

Functions You Call At Initialization

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

DAC_GetRange()

Purpose

Get the range wired on the specified DAC. This can be in either or both of two forms: The range code, which represents the range as a single value, or the bounds of the range, which together indicate the actual values that can be used.

This function is entirely optional. If you already know the DAC range wired on the devices you ordered, then you can simply output voltages and enable the DACs.

Delphi Signature
function DAC_GetRange(uClientRef: TClientRef; Ch: TChannelIndex; pRange: TPRangeCode = nil; pLowV: TPDouble = nil; pHighV: TPDouble = nil): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode DAC_GetRange(TClientRef uClientRef, TChannelIndex iDAC, out TRangeCode RangeCode, out TDouble MinV, out TDouble MaxV);
Arguments
uClientRef
The client reference for the device.
Ch
The DAC to get the range for.
pRange
Output parameter to receive the range code. Can be null if you don't need the code.
pLowV
Output parameter to receive the lower-bound voltage (or other value) the DAC can output. Can be null if you only need the code.
pHighV
Output parameter to receive the upper-bound voltage (or other value) the DAC can output. Can be null if you only need the code.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

DAC_Enable() & DAC_Disable()

Purpose

Enable/disable the DACs. The DACs power up disabled as a safety feature. Output a voltage that's safe for your application before enabling the DACs, and then you can proceed with outputting varied voltages. Optionally, disable the DACs when done.

Delphi Signature
function DAC_Enable(uClientRef: TClientRef): TWinErrCode; cdecl;
function DAC_Disable(uClientRef: TClientRef): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode DAC_Enable(TClientRef uClientRef);
internal static extern TWinErrCode DAC_Disable(TClientRef uClientRef);
Arguments
uClientRef
The client reference for the device.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Analog Output Functions

Each analog output has its own DAC. Analog output functions differ from each other in two ways:

  • The format of the value: voltage, counts, or fractional.
  • Whether a single value or "N" values are provided.

All six combinations are provided. The four voltage and count functions are also overloaded as "DAC_Output", in languages that support overloads.

DAC_Output()

Purpose

Output value(s) to one or more DAC outputs.

Delphi Signature
function DAC_Output(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; V: TDouble): TWinErrCode; cdecl; overload; name 'DAC_OutputV';
function DAC_Output(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; Counts: TUInt16): TWinErrCode; cdecl; overload; name 'DAC_OutputCounts';
function DAC_Output(uClientRef: TClientRef; Channels: TUInt32; pV: TPDouble): TWinErrCode; cdecl; overload; name 'DAC_OutputNV';
function DAC_Output(uClientRef: TClientRef; Channels: TUInt32; pCounts: TPUInt16): TWinErrCode; cdecl; overload; name 'DAC_OutputNCounts';
function DAC_OutputV(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; V: TDouble): TWinErrCode; cdecl;
function DAC_OutputCounts(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; Counts: TUInt16): TWinErrCode; cdecl;
function DAC_OutputFrac(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; Frac: TDouble): TWinErrCode; cdecl;
function DAC_OutputNV(uClientRef: TClientRef; Channels: TUInt32; pV: TPDouble): TWinErrCode; cdecl;
function DAC_OutputNCounts(uClientRef: TClientRef; Channels: TUInt32; pCounts: TPUInt16): TWinErrCode; cdecl;
function DAC_OutputNFrac(uClientRef: TClientRef; Channels: TUInt32; pFrac: TPDouble): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode DAC_Output(TClientRef uClientRef, TChannelIndex Ch, TDouble Volts);
internal static extern TWinErrCode DAC_Output(TClientRef uClientRef, TChannelIndex Ch, TUInt16 Counts);
internal static extern TWinErrCode DAC_Output(TClientRef uClientRef, TUInt32 Channels, [In] TDouble[] Volts);
internal static extern TWinErrCode DAC_Output(TClientRef uClientRef, TUInt32 Channels, [In] TUInt16[] Counts);
internal static extern TWinErrCode DAC_OutputV(TClientRef uClientRef, TChannelIndex Ch, TDouble Volts);
internal static extern TWinErrCode DAC_OutputCounts(TClientRef uClientRef, TChannelIndex Ch, TUInt16 Counts);
internal static extern TWinErrCode DAC_OutputFrac(TClientRef uClientRef, TChannelIndex Ch, TDouble Frac);
internal static extern TWinErrCode DAC_OutputNV(TClientRef uClientRef, TUInt32 Channels, [In] TDouble[] Volts);
internal static extern TWinErrCode DAC_OutputNCounts(TClientRef uClientRef, TUInt32 Channels, [In] TUInt16[] Counts);
internal static extern TWinErrCode DAC_OutputNFrac(TClientRef uClientRef, TUInt32 Channels, [In] TDouble[] Frac);
Arguments
uClientRef
The client reference for the device.
Ch
The DAC channel(s) to output on, or ciAll to write a single value to all DACs.
V
The single voltage value to output. DACs wired for different ranges will go to the same voltage, even though that's backed by different count/frac values.
Counts
The single count value to output. For 16-bit counts, this varies from 0 at the lower bound to 65535 at the upper bound. DACs wired for different ranges will go to different voltages, based on the same count value.
Frac
The single fractional value to output. This varies from 0 to 1 over the wired range. DACs wired for different ranges will go to different voltages, based on the same fractional value.
Channels
The number of DAC channel(s) to output varied values on, for "N" functions. The arrays below hold this many entries. The first entry is output to DAC 0, the next(if present) to DAC 1, etc.
pV
A pointer to the first entry of an array of voltage values. Each value is similar to the V parameter.
pCounts
A pointer to the first entry of an array of count values. Each value is similar to the Counts parameter.
pFrac
A pointer to the first entry of an array of fractional values. Each value is similar to the Frac parameter.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Digital Inputs & Outputs(DIO)

Overview

Each digital bit can be configured as an input or an output. Regardless of this configuration, each bit remains at the same place in the DIO data buffers. Both inputs and outputs can be read — an output reads back the written value. After a fashion, both inputs and outputs can be written to — inputs simply ignore any writes.

Functions You Call At Initialization

DIO_Configure()

Purpose

Configure every digital bit as an input or an output.

Delphi Signature
function DIO_Configure(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8; pDirection: TPUInt8): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode DIO_Configure(TClientRef uClientRef, ref TUInt32 pDataBytes, [In, Out] TUInt8[] pData, [In, Out] TUInt8[] pDirection);
Arguments
uClientRef
The client reference for the device.
pDataBytes
A pointer to the size (in bytes) of the buffers in the last two parameters. Should be 2 for this device.
pData
A pointer to the first of a two-byte array, which will be written to the outputs. The timing relative to the direction array is adjusted to prevent glitching, but this is otherwise similar to pData for DIO_WriteAll.
pDirection
A pointer to the first of a two-byte array, which determines the direction for each digital bit. For each bit, 0 means set that bit to output, 1 means set that bit to input.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

DIO_ReadDirection()

Purpose

Read back the directions(input vs output) of the digital bits.

Delphi Signature
function DIO_ReadDirection(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode DIO_ReadDirection(TClientRef uClientRef, ref TUInt32 pDataBytes, [Out] TUInt8[] pData);
Arguments
uClientRef
The client reference for the device.
pDataBytes
A pointer to the size (in bytes) of the buffer in the pData parameter. Should be 2 for this device.
pData
A pointer to the first of a two-byte array, which will receive the directions of the digital bits. For each bit, 0 means it's an output, 1 means it's an input. Assuming no other clients might try to do the same thing at the same time, you can call this function, change a bit or few in the array, and then pass the same array for pDirection in DIO_Configure.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

Input / Output Functions

DIO_ReadAll()

Purpose

Read the values of the digital bits.

Delphi Signature
function DIO_ReadAll(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode DIO_ReadAll(TClientRef uClientRef, ref TUInt32 pDataBytes, [Out] TUInt8[] pData);
Arguments
uClientRef
The client reference for the device.
pDataBytes
A pointer to the size (in bytes) of the buffer in the pData parameter. Should be 2 for this device.
pData
A pointer to the first of a two-byte array, which will receive the data read from the digital bits. For each bit, 0 means the bit is low, 1 means the bit is high. Inputs read their input state, outputs will read back their output state. Assuming no other clients might try to do the same thing at the same time, you can call this function, change an output bit or few in the array, and then pass the same array for pData in DIO_WriteAll or DIO_Configure.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.

DIO_WriteAll()

Purpose

Write values to the output digital bits.

Delphi Signature
function DIO_WriteAll(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8): TWinErrCode; cdecl;
C# Signature
internal static extern TWinErrCode DIO_WriteAll(TClientRef uClientRef, ref TUInt32 pDataBytes, [In] TUInt8[] pData);
Arguments
uClientRef
The client reference for the device.
pDataBytes
A pointer to the size (in bytes) of the buffer in the pData parameter. Should be 2 for this device.
pData
A pointer to the first of a two-byte array, which determines the states of the output bits. For each output bit, 0 means set the bit low, 1 means set the bit high. Inputs ignore the corresponding bits in the array.
Returns
Windows standard “Win32” error codes. ERROR_SUCCESS (0) means “success”.