Introducing Message-Based DAQ
Introducing Message-Based DAQ
Introducing Message-Based DAQ
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Analog input scan operation<br />
C# Visual Basic<br />
// Read data from a scan operation<br />
DaqDevice MyDevice;<br />
String[] Devices;<br />
int Sample;<br />
int Channel;<br />
try<br />
{<br />
// Get a list of message-based <strong>DAQ</strong> devices<br />
Devices = DaqDeviceManager.GetDeviceNames<br />
(DeviceNameFormat.NameAndSerno);<br />
// Get a DaqDevice object for device 0<br />
MyDevice = DaqDeviceManager.CreateDevice<br />
(Devices(0));<br />
double[,] ScanData;<br />
String DataDisplay;<br />
// Configure the scan<br />
MyDevice.Send<strong>Message</strong><br />
("AISCAN:XFRMODE=BLOCKIO");<br />
MyDevice.Send<strong>Message</strong><br />
("AISCAN:RANGE=BIP10V");<br />
MyDevice.Send<strong>Message</strong>("AISCAN:LOWCHAN=0");<br />
MyDevice.Send<strong>Message</strong>("AISCAN:HIGHCHAN=3");<br />
MyDevice.Send<strong>Message</strong>("AISCAN:CAL=ENABLE");<br />
MyDevice.Send<strong>Message</strong><br />
("AISCAN:SCALE=ENABLE");<br />
MyDevice.Send<strong>Message</strong>("AISCAN:RATE=500");<br />
MyDevice.Send<strong>Message</strong><br />
("AISCAN:SAMPLES=256");<br />
// Start the scan<br />
MyDevice.Send<strong>Message</strong>("AISCAN:START");<br />
// Read and display the scan data<br />
ScanData = MyDevice.ReadScanData(256);<br />
DataDisplay = String.Empty;<br />
For (Sample = 0; Sample < 256; Sample ++)<br />
{<br />
}<br />
for (int j = 0; j < 4; j++)<br />
{<br />
DataDisplay += ScanData[Channel,<br />
Sample].ToString("F04") + " ";<br />
}<br />
DataDisplay += Environment.NewLine;<br />
textBox1.Text = DataDisplay;<br />
}<br />
catch (Exception ex)<br />
{<br />
}<br />
// handle error<br />
textBox1.Text = ex.<strong>Message</strong>;<br />
' Read data from a scan operation<br />
Dim MyDevice As DaqDevice<br />
Dim Devices As String()<br />
Dim Sample As Integer<br />
Dim Channel As Integer<br />
Try<br />
' Get a list of message-based <strong>DAQ</strong> devices<br />
Devices = DaqDeviceManager.GetDeviceNames_<br />
(DeviceNameFormat.NameAndSerno)<br />
' Get a DaqDevice object for device 0<br />
MyDevice = DaqDeviceManager.CreateDevice<br />
(Devices(0))<br />
Dim ScanData As Double(,)<br />
Dim DataDisplay As String<br />
' Configure the scan<br />
MyDevice.Send<strong>Message</strong>("AISCAN:XFRMODE=BLOCKIO")<br />
MyDevice.Send<strong>Message</strong>("AISCAN:RANGE=BIP10V")<br />
MyDevice.Send<strong>Message</strong>("AISCAN:LOWCHAN=0")<br />
MyDevice.Send<strong>Message</strong>("AISCAN:HIGHCHAN=3")<br />
MyDevice.Send<strong>Message</strong>("AISCAN:CAL=ENABLE")<br />
MyDevice.Send<strong>Message</strong>("AISCAN:SCALE=ENABLE")<br />
MyDevice.Send<strong>Message</strong>("AISCAN:RATE=500")<br />
MyDevice.Send<strong>Message</strong>("AISCAN:SAMPLES=256")<br />
' Start the scan<br />
MyDevice.Send<strong>Message</strong>("AISCAN:START")<br />
' Read and display the scan data<br />
ScanData = MyDevice.ReadScanData(256)<br />
DataDisplay = String.Empty<br />
For Sample = 0 To 255<br />
For Channel = 0 To 3<br />
DataDisplay = String.Concat(DataDisplay,<br />
ScanData(Channel, _ Sample).ToString<br />
("F04") & " ")<br />
Next<br />
DataDisplay = String.Concat(DataDisplay,<br />
Environment.NewLine)<br />
Next<br />
TextBox1.Text = DataDisplay<br />
catch ex as Exception<br />
' handle error<br />
TextBox1.Text = Ex.<strong>Message</strong><br />
End try<br />
Page 11 of 43
API message reference<br />
The API messages that you send to an MBD device are text-based commands. Each message pertains to a specific <strong>DAQ</strong> Component.<br />
A <strong>DAQ</strong> Component is a device element that encapsulates a <strong>DAQ</strong> subsystem which has multiple properties or commands associated<br />
with it.<br />
The <strong>DAQ</strong>Flex API defines the following <strong>DAQ</strong> components. Click on a component name below for the string messages, device<br />
responses, and property values supported by the component.<br />
Component<br />
DEV<br />
AI<br />
AISCAN<br />
AITRIG<br />
AO<br />
DIO<br />
CTR<br />
Description<br />
Encapsulates device-level operations.<br />
Encapsulates single-point analog input operations.<br />
Encapsulates analog input scanning operations.<br />
Encapsulates analog input triggering operations.<br />
Encapsulates single-point analog output operations.<br />
Encapsulates digital I/O operations.<br />
Encapsulates counter input operations.<br />
Page 12 of 43
DEV<br />
Sets and gets device property values.<br />
Properties<br />
MFGSER, FWV, FLASHLED, ID, MFGCAL, RESET, DATATYPE<br />
The tables below list the messages used to get and set device parameters, the device response to each message, a description of the<br />
message, and the variable(s) the message may contain.<br />
Note: Refer to the device-specific information in the Hardware Reference section for the component properties and commands<br />
supported by each <strong>DAQ</strong> device.<br />
MFGSER<br />
<strong>Message</strong> Device response Description<br />
"?DEV:MFGSER" "DEV:MFGSER=value" Returns the manufacturer's device serial<br />
number.<br />
value = Serial number of the device<br />
Example: "DEV:MFGSER=00000001"<br />
FWV<br />
<strong>Message</strong> Device response Description<br />
"?DEV:FWV" "DEV:FWV=value" Returns the firmware version<br />
value = Firmware version<br />
Example: "DEV:FWV=01.02" or<br />
"DEV:FWV=01.01.00f00"<br />
FLASHLED<br />
<strong>Message</strong> Device response Description<br />
"DEV:FLASHLED/{n}" "DEV:FLASHLED" Flashes the device LED.<br />
n = a number indicating how many times to<br />
flash the device LED.<br />
Example: "DEV:FLASHLED/5"<br />
ID<br />
<strong>Message</strong> Device response Description<br />
"DEV:ID=value" "DEV:ID" Sets the device ID. Enter up to 57 characters.<br />
value = device ID; value is set to MYDEVICE<br />
by default.<br />
Example: "DEV:ID=MYDEVICE"<br />
"?DEV:ID" "DEV:ID=value" Returns the ID set for the device.<br />
value = ID set for the device<br />
Page 13 of 43
MFGCAL<br />
<strong>Message</strong> Device response Description<br />
"?DEV:MFGCAL" "DEV:MFGCAL=value" Returns the date and time in which the device<br />
was last calibrated.<br />
value = calibration date and time.<br />
Example: "DEV:MFGCAL=2009-03-14<br />
13:56:27"<br />
"?DEV:MFGCAL{YEAR}" "DEV:MFGCAL{YEAR}=value" Returns the year in which the device was last<br />
calibrated.<br />
YEAR = calibration year.<br />
Example: "DEV:MFGCAL{YEAR}=2009"<br />
"?DEV:MFGCAL{MONTH}" "DEV:MFGCAL{MONTH}=value" Returns the month in which the device was last<br />
calibrated.<br />
MONTH = calibration month<br />
Example: "DEV:MFGCAL{MONTH}=03"<br />
"?DEV:MFGCAL{DAY}" "DEV:MFGCAL{DAY}=value" Returns the day in which the device was last<br />
calibrated.<br />
DAY = calibration day<br />
Example: "DEV:MFGCAL{DAY}=14"<br />
"?DEV:MFGCAL{HOUR}" "DEV:MFGCAL{HOUR}=value" Returns the hour in which the device was last<br />
calibrated.<br />
HOUR = calibration hour<br />
Example: "DEV:MFGCAL{HOUR}=13"<br />
"?DEV:MFGCAL{MINUTE}" "DEV:MFGCAL{MINUTE}=value" Returns the minute in which the device was last<br />
calibrated.<br />
MINUTE = calibration minute<br />
Example: "DEV:MFGCAL{MINUTE}=56"<br />
"?DEV:MFGCAL{SECOND}" "DEV:MFGCAL{SECOND}=value" Returns the second in which the device was last<br />
calibrated.<br />
SECOND = calibration second<br />
Example: "DEV:MFGCAL{SECOND}=27"<br />
Page 14 of 43
RESET<br />
<strong>Message</strong> Device response Description<br />
"DEV:RESET/value"<br />
"NO COMPONENT SET" when value<br />
is set to SYSTEM.<br />
"DEV:RESET" when value is set to<br />
DEFAULT.<br />
Resets the device or the default parameters.<br />
value = SYSTEM or DEFAULT<br />
SYSTEM resets the USB interface to the device<br />
(not recommended for use through the API).<br />
DEFAULT resets all device parameters to the<br />
default value.<br />
Example: "DEV:RESET/DEFAULT"<br />
DATATYPE<br />
<strong>Message</strong> Device response Description<br />
"DEV:DATATYPE=value" "DEV:DATATYPE" Sets whether the datatype is included in raw<br />
data returns.<br />
value = ENABLE or DISABLE<br />
Example: "DEV:DATATYPE=ENABLE"<br />
• Refer to the RawData discussion in the Firmware specification for more information about DATATYPE.<br />
Page 15 of 43
CJC<br />
<strong>Message</strong> Device response Description<br />
"?AI{ch}:CJC/format" "AI{ch}:CJC/format=value" Returns the CJC value in the specified format.<br />
format = DEGC, DEGF, KELVIN<br />
value = measured temperature<br />
Example: "?AI{0}:CJC/DEGC"<br />
STATUS<br />
<strong>Message</strong> Device response Description<br />
"?AI:STATUS" "AI:STATUS=value" Returns the current ADC status of the AI<br />
operation.<br />
value = BUSY, ERROR, or READY<br />
SLOPE<br />
<strong>Message</strong> Device response Description<br />
"?AI{ch}:SLOPE" "AI{ch}:SLOPE=value" Returns the calibration slope coefficient for the<br />
specified channel.<br />
ch = channel number<br />
value = calibration slope<br />
Example: "?AI{0}:SLOPE"<br />
OFFSET<br />
<strong>Message</strong> Device response Description<br />
"?AI{ch}:OFFSET" "AI{ch}:OFFSET=value" Returns the calibration offset coefficient for the<br />
specified channel.<br />
ch = channel number<br />
value = calibration offset<br />
Example: "?AI{0}:OFFSET"<br />
CAL 1<br />
<strong>Message</strong> Device response Description<br />
"AI:CAL=value" "AI:CAL" Enables or disables calibration of all A/D<br />
channels.<br />
value = ENABLE or DISABLE<br />
Example: "AI:CAL=ENABLE"<br />
"?AI:CAL" "AI:CAL=value" Returns a value indicating whether the<br />
calibration coefficients will be applied to the raw<br />
A/D data.<br />
value = ENABLE or DISABLE<br />
Example: "?AI:CAL"<br />
1 These messages are processed by the <strong>DAQ</strong>Flex Software library, and are not sent to the device.<br />
Page 18 of 43
SCALE 1<br />
<strong>Message</strong> Device response Description<br />
"AI:SCALE=value" "AI:SCALE" Enables or disables scaling of A/D channels.<br />
value = ENABLE or DISABLE<br />
Example: "AI:SCALE=ENABLE"<br />
"?AI:SCALE" "AI:SCALE=value" Returns a value indicating whether scaling will<br />
be applied to the A/D channels.<br />
value = ENABLE or DISABLE<br />
1 These messages are processed by the <strong>DAQ</strong>Flex Software library, and are not sent to the device.<br />
Working with the CAL and SCALE properties<br />
The ENABLE/DISABLE setting of the CAL and SCALE properties affect the kind of data that is returned:<br />
• CAL=DISABLE, SCALE=DISABLE<br />
If CAL and SCALE are both disabled, the data returned will be raw A/D integer values within the range of 0 to 2 res olution -1 of<br />
the device. If the calibration factors are stored on the device and applied to the data by the application software, the data<br />
range may be limited to well within these values.<br />
• CAL=ENABLE, SCALE=DISABLE<br />
When CAL is enabled and SCALE is disabled, the format of the analog data returned will depend on the type of calibration<br />
implemented. If the calibration factors are stored on the device and applied to the data by the application software, the data<br />
will be floating point values, not integer values, and may exceed the theoretical limits and include negative values and values<br />
above 2 res olution -1.<br />
• SCALE=ENABLE<br />
When SCALE is enabled, scaled floating point values are returned. The limits of the data will depend on the implementation of<br />
calibration, as described above. Data range limits may be a small percentage less than or greater than the full scale range<br />
selected for devices for which the calibration factors are stored on the device and applied to the data by the application<br />
software.<br />
Page 19 of 43
AISCAN<br />
Sets and gets property values when scanning analog input channels.<br />
Properties<br />
XFRMODE, RATE, SAMPLES, BUFSIZE, EXTPACER, HIGHCHAN, LOWCHAN, TRIG, RANGE, QUEUE, START, STOP, STATUS, COUNT,<br />
CAL, SCALE<br />
The tables below list the messages used to get and set device parameters, the device response to each message, a description of the<br />
message, and the variable(s) the message may contain.<br />
Note: Refer to the device-specific information in the Hardware Reference section for the component properties and commands<br />
supported by each <strong>DAQ</strong> device.<br />
XFRMODE<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:XFRMODE=value" "AISCAN:XFRMODE" Sets the transfer mode for analog input scan<br />
data.<br />
value = SINGLEIO or BLOCKIO<br />
Example: "AISCAN:XFRMODE=BLOCKIO"<br />
"?AISCAN:XFRMODE" "AISCAN:XFRMODE=value" Returns the transfer mode that is set for the<br />
scan.<br />
value = SINGLEIO or BLOCKIO<br />
RATE<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:RATE=value" "AISCAN:RATE" Sets the A/D sampling rate in Hz for each<br />
channel.<br />
value = 0 to N<br />
Example: "AISCAN:RATE=1000"<br />
• If value is less than the device's minimum sampling rate, then the minimum rate is used. If value is greater than the<br />
device's maximum sampling rate, then the device's maximum sampling rate is used.<br />
• It is recommended to check the actual scan rate set using the "?AISCAN:RATE" query after setting the RATE.<br />
"?AISCAN:RATE" "AISCAN:RATE=value" Returns the A/D sampling rate in Hz for each<br />
channel.<br />
value = a value between the minimum and<br />
maximum rate that the device is capable of.<br />
• The value returned may not match the value requested using the "AISCAN:RATE=value" message due to device<br />
limitations.<br />
• If the value returned is at or near the device's maximum sampling rate, then sending other messages to the device<br />
should be kept to a minimum. Otherwise, there is a potential for a data overrun to occur. A data overrun occurs when<br />
the device fills its buffer with data faster than it is read back.<br />
Page 20 of 43
SAMPLES<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:SAMPLES=value" "AISCAN:SAMPLES" Sets the number of samples/channel to acquire<br />
in the scan.<br />
• A value of 0 results in a continuous scan.<br />
value = 0 to N<br />
Example: "AISCAN:SAMPLES=1000"<br />
"?AISCAN:SAMPLES" "AISCAN:SAMPLES=value" Returns the number of samples/channel to<br />
acquire in the scan.<br />
• A value of 0 results in a continuous scan.<br />
value = 0 to N<br />
BUFSIZE<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:BUFSIZE=value" "AISCAN:BUFSIZE" Sets the size in bytes of the buffer to be used<br />
for AISCAN.<br />
value = the size in bytes of the buffer.<br />
Example: "AISCAN:BUFSIZE=131072"<br />
• The default buffer size 1024000 bytes. This should be sufficient for most applications. The actual buffer size will always<br />
be an integer multiple of the device's maximum packet size.<br />
If this value is set, it should be at least the (number of bytes per sample) x (number of channels) x (sample count) for<br />
finite mode, and twice this value for continuous mode.<br />
"?AISCAN:BUFSIZE" "AISCAN:BUFSIZE=value" Returns the size of the buffer used for AISCAN.<br />
value = the size in bytes of the buffer.<br />
Page 21 of 43
EXTPACER<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:EXTPACER=value" "AISCAN:EXTPACER" Sets the configuration of the device's external<br />
pacer pin.<br />
value = ENABLE for most devices.<br />
Example: "AISCAN:EXTPACER=ENABLE"<br />
• Some devices support ENABLE/MASTER, ENABLE/SLAVE, ENABLE/GSLAVE, DISABLE/MASTER, or DISABLE/SLAVE.<br />
For devices which do not support a master and slave configuration, the /MASTER and /SLAVE designation is ignored.<br />
For devices which do not support disabling of the pacer or SYNC input (for example, the terminal is always enabled as<br />
either input or output), the DISABLE designation is invalid.<br />
When the optional portion of the message is omitted, the default is SLAVE.<br />
• Set to ENABLE if the device is paced using a continuous clock source, such as a generator. In this mode, the first clock<br />
pulse after setting up the scan is ignored in order to ensure adequate setup time for the first conversion.<br />
Set to ENABLE/GSLAVE if the device is paced from a <strong>DAQ</strong>Flex Series device. In this mode, the first clock pulse after<br />
setting up the scan is held off to ensure adequate setup time for the first conversion. No pulses are ignored.<br />
• When the external pacer is enabled, the AISCAN:RATE property should be set to approximately what the external<br />
pacer rate will be, because internal transfer sizes are calculated using the rate and channel count.<br />
"?AISCAN:EXTPACER" "AISCAN:EXTPACER=value" Returns the configuration of the device's<br />
external pacer pin.<br />
value = ENABLE for most devices.<br />
• Some devices support ENABLE/MASTER, ENABLE/SLAVE, ENABLE/GSLAVE, DISABLE/MASTER, or DISABLE/SLAVE.<br />
HIGHCHAN<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:HIGHCHAN=value" "AISCAN:HIGHCHAN" Sets the last channel to include in the<br />
hardware-paced scan operation.<br />
value = channel number<br />
Example: "AISCAN:HIGHCHAN=3"<br />
"?AISCAN:HIGHCHAN" "AISCAN:HIGHCHAN=value" Returns the last channel to include in the<br />
hardware-paced scan operation.<br />
value = channel number<br />
Page 22 of 43
LOWCHAN<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:LOWCHAN=value" "AISCAN:LOWCHAN" Sets the first channel to include in the<br />
hardware-paced scan operation.<br />
value = channel number<br />
Example: "AISCAN:LOWCHAN=0"<br />
"?AISCAN:LOWCHAN" "AISCAN:LOWCHAN=value" Returns the first channel to include in the<br />
hardware-paced scan operation.<br />
value = channel number<br />
DEBUG<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:DEBUG=value" "AISCAN:DEBUG" Enables or disables the debug feature.<br />
value = ENABLE or DISABLE<br />
Example: "AISCAN:DEBUG=ENABLE"<br />
• When the debug feature is enabled, the data returned by ReadScanData will be an incrementing count from 0 to the<br />
maximum value of the device's A/D. For 16-bit A/Ds this value is 65535. When this value is reached the count is reset<br />
to 0.<br />
"?AISCAN:DEBUG" "AISCAN:DEBUG=value" Returns the debug status.<br />
value = ENABLE or DISABLE<br />
TRIG<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:TRIG=value" "AISCAN:TRIG" Enables or disables the trigger.<br />
value = ENABLE or DISABLE<br />
Example: "AISCAN:TRIG=ENABLE"<br />
• If not set, TRIG is set to DISABLE by default.<br />
"?AISCAN:TRIG" "AISCAN:TRIG=value" Returns the trigger status.<br />
value = ENABLE or DISABLE<br />
Page 23 of 43
eturned.<br />
value = range value (see values listed above)<br />
ch - channel number<br />
element - the element's position in the gain<br />
queue<br />
QUEUE<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:QUEUE=value" "AISCAN:QUEUE" Enables or disables the gain queue.<br />
value = ENABLE, DISABLE, or RESET<br />
RESET resets the queue count to 0, and<br />
disables the gain queue.<br />
Example: "AISCAN:QUEUE=ENABLE"<br />
"?AISCAN:QUEUE" "AISCAN:QUEUE=value" Reads whether the gain queue is used in the<br />
scanning operation.<br />
value = ENABLE or DISABLE<br />
START<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:START" "AISCAN:STATUS=RUNNING" Starts an analog input scan.<br />
Example: "?AISCAN:START"<br />
STOP<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:STOP" "AISCAN:STATUS=IDLE" Stops an analog input scan.<br />
STATUS<br />
<strong>Message</strong> Device response Description<br />
"?AISCAN:STATUS" "AISCAN:STATUS=value" Returns the status of the AISCAN operation.<br />
value = IDLE, RUNNING, or OVERRUN<br />
COUNT 1<br />
<strong>Message</strong> Device response Description<br />
"?AISCAN:COUNT" "AISCAN:COUNT=value" Returns the number of samples per channel<br />
that have been acquired by the AISCAN<br />
operation.<br />
value = the number of samples per channel<br />
acquired.<br />
Example: "AISCAN:COUNT=64"<br />
1 This message is processed by the <strong>DAQ</strong>Flex Software library, and is not sent to the device.<br />
Page 25 of 43
CAL 1<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:CAL=value" "AISCAN:CAL" Enables or disables calibration of the A/D data.<br />
value = ENABLE or DISABLE<br />
Example: "AISCAN:CAL=ENABLE"<br />
"?AISCAN:CAL" "AISCAN:CAL=value" Returns a value indicating whether calibration<br />
coefficients will be applied to the raw A/D data.<br />
value = ENABLE or DISABLE<br />
Example: "?AISCAN:CAL"<br />
1 These messages are processed by the <strong>DAQ</strong>Flex Software library, and are not sent to the device.<br />
SCALE 1<br />
<strong>Message</strong> Device response Description<br />
"AISCAN:SCALE=value" "AISCAN:SCALE" Enables or disables scaling of the A/D data.<br />
value = ENABLE or DISABLE<br />
Example: "AISCAN:SCALE=ENABLE"<br />
"?AISCAN:SCALE" "AISCAN:SCALE=value" Returns a value indicating whether scaling will<br />
be applied to the A/D data.<br />
value = ENABLE or DISABLE<br />
1 These messages are processed by the <strong>DAQ</strong>Flex Software library, and are not sent to the device.<br />
Working with the CAL and SCALE properties<br />
The ENABLE/DISABLE setting of the CAL and SCALE properties affect the kind of data that is returned:<br />
• CAL=DISABLE, SCALE=DISABLE<br />
If CAL and SCALE are both disabled, the data returned will be raw A/D integer values within the range of 0 to 2 res olution -1 of<br />
the device. If the calibration factors are stored on the device and applied to the data by the application software, the data<br />
range may be limited to well within these values.<br />
• CAL=ENABLE, SCALE=DISABLE<br />
When CAL is enabled and SCALE is disabled, the format of the analog data returned will depend on the type of calibration<br />
implemented. If the calibration factors are stored on the device and applied to the data by the application software, the data<br />
will be floating point values, not integer values, and may exceed the theoretical limits and include negative values and values<br />
above 2 res olution -1.<br />
• SCALE=ENABLE<br />
When SCALE is enabled, scaled floating point values are returned. The limits of the data will depend on the implementation of<br />
calibration, as described above. Data range limits may be a small percentage less than or greater than the full scale range<br />
selected for devices for which the calibration factors are stored on the device and applied to the data by the application<br />
software.<br />
Page 26 of 43
AITRIG<br />
Sets and gets analog input trigger property values.<br />
Properties<br />
TYPE, REARM<br />
The tables below list the messages used to get and set device parameters, the device response to each message, a description of the<br />
message, and the variable(s) the message may contain.<br />
Note: Refer to the device-specific information in the Hardware Reference section for the component properties and commands<br />
supported by each <strong>DAQ</strong> device.<br />
TYPE<br />
<strong>Message</strong> Device response Description<br />
"AITRIG:TYPE=value" "AITRIG:TYPE" Sets the edge trigger type.<br />
value = EDGE/RISING or EDGE/FALLING<br />
Example: "AITRIG:TYPE=EDGE/RISING"<br />
"?AITRIG:TYPE" "AITRIG:TYPE=value" Returns the edge trigger type.<br />
value = EDGE/RISING or EDGE/FALLING<br />
REARM<br />
<strong>Message</strong> Device response Description<br />
"AITRIG:REARM=value" "AITRIG:REARM" Sets the state of the retrigger mode.<br />
value = ENABLE or DISABLE<br />
Example: "AITRIG:REARM=ENABLE"<br />
"?AITRIG:REARM" "AITRIG:REARM=value" Returns the state of the retrigger mode.<br />
value = ENABLE or DISABLE<br />
Note<br />
• When running the <strong>DAQ</strong>Flex test application, AITRIG messages are listed on the AISCAN tab.<br />
Page 27 of 43
AO<br />
Sets and gets property values for analog output channels.<br />
Properties<br />
VALUE, SCALE<br />
The tables below list the messages used to get and set device parameters, the device response to each message, a description of the<br />
message, and the variable(s) the message may contain.<br />
Note: Refer to the device-specific information in the Hardware Reference section for the component properties and commands<br />
supported by each <strong>DAQ</strong> device.<br />
<strong>Message</strong> Device response Description<br />
"?AO" "AO=value" Returns the number of analog output channels<br />
on the device.<br />
value = number of D/A channels on the device<br />
VALUE<br />
<strong>Message</strong> Device response Description<br />
"AO{ch}:VALUE=value" "AO{ch}:VALUE" Sets the value of a D/A channel.<br />
ch = D/A channel number<br />
value = D/A value<br />
Example: "AO{0}:VALUE=4095"<br />
SCALE 1<br />
<strong>Message</strong> Device response Description<br />
"AO:SCALE=value" "AO:SCALE" Enables or disables scaling of all D/A channels.<br />
value = ENABLE or DISABLE<br />
Example: "AO:SCALE=ENABLE"<br />
"?AO:SCALE" "AO:SCALE=value" Returns a value indicating whether scaling will<br />
be applied to the D/A channels.<br />
value = ENABLE or DISABLE<br />
1 These messages are processed by the <strong>DAQ</strong>Flex Software library, and are not sent to the device.<br />
Page 28 of 43
CTR<br />
Sets and gets property values for counter channels.<br />
Properties<br />
VALUE, START, STOP<br />
The tables below list the messages used to get and set device parameters, the device response to each message, a description of the<br />
message, and the variable(s) the message may contain.<br />
Note: Refer to the device-specific information in the Hardware Reference section for the component properties and commands<br />
supported by each <strong>DAQ</strong> device.<br />
<strong>Message</strong> Device response Description<br />
"?CTR" "CTR=value" Returns the number of counter channels on the<br />
device.<br />
value = number of counter channels<br />
VALUE<br />
<strong>Message</strong> Device response Description<br />
"CTR{ch}:VALUE=value" "CTR{ch}:VALUE" Loads the specified counter with the specified<br />
value.<br />
ch = counter number<br />
value = counter value<br />
Example: "CTR{0}:VALUE=0"<br />
"?CTR{ch}:VALUE" "CTR{ch}:VALUE=value" Returns the value of the specified counter.<br />
ch = counter number<br />
value = counter value<br />
Example: "?CTR{0}:VALUE"<br />
START<br />
<strong>Message</strong> Device response Description<br />
"CTR{ch}:START" "CTR{ch}:START" Starts the specified counter channel.<br />
ch = counter number<br />
Example: "CTR{0}:START"<br />
STOP<br />
<strong>Message</strong> Device response Description<br />
"CTR{ch}:STOP" "CTR{ch}:STOP" Stops the specified counter channel.<br />
ch = counter number<br />
Example: "CTR{0}:STOP"<br />
Page 29 of 43
DIO<br />
Sets and gets property values for digital I/O channels.<br />
Properties<br />
DIR, VALUE<br />
The tables below list the messages used to get and set device parameters, the device response to each message, a description of the<br />
message, and the variable(s) the message may contain.<br />
Note: Refer to the device-specific information in the Hardware Reference section for the component properties and commands<br />
supported by each <strong>DAQ</strong> device.<br />
<strong>Message</strong> Device response Description<br />
"?DIO" "DIO=value" Returns the number of digital ports on the<br />
device.<br />
value = number of digital ports<br />
"?DIO{bit}" "DIO{bit}=value" Returns the number of bits in the port.<br />
value = number of bits in the port<br />
Example: "?DIO{0}"<br />
DIR<br />
<strong>Message</strong> Device response Description<br />
"DIO{port}:DIR=value" "DIO{port}:DIR" Sets the specified port for input or output.<br />
port = port number<br />
value = IN or OUT<br />
Example: "DIO{0}:DIR=IN"<br />
• If DIR is not specified, the devise's default power up value is used.<br />
"?DIO{port}:DIR" "DIO{port}:DIR=value" Returns the direction of the specified port.<br />
port = port number<br />
• If bits are not individually configurable, the value returned will be either "IN" or "OUT."<br />
value = "IN", "OUT", or a number between 0<br />
and 2 n -1, where n is the number of bits in the<br />
port.<br />
• If each bit is individually configurable, value is a bit mask, in which a 1 indicates that the bit is configured for input, and<br />
a 0 indicates that the bit is configured for output.<br />
"DIO{port/bit}:DIR=value" "DIO{port/bit}:DIR" Sets the specified bit for input or output.<br />
port = port number<br />
bit = bit number<br />
value = IN or OUT<br />
Example: "DIO{0/1}:DIR=IN"<br />
• If DIR is not specified, the device's default power up value is used.<br />
"?DIO{port/bit}:DIR" "DIO{port/bit}:DIR=value" Returns the direction of the specified bit.<br />
Page 30 of 43
port = port number<br />
bit = bit number<br />
value = IN or OUT<br />
Example: "?DIO{0/1}:DIR"<br />
VALUE<br />
<strong>Message</strong> Device response Description<br />
"DIO{port}:VALUE=value" "DIO{port}:VALUE" Sets the value of the specified port.<br />
port = port number<br />
value = value of the port<br />
Example: "DIO{0}:VALUE=128"<br />
"?DIO{port}:VALUE" "DIO{port}:VALUE=value" Returns the value of the specified port.<br />
port = port number<br />
value = value of the port<br />
Example: "?DIO{0}:VALUE"<br />
"DIO{port/bit}:VALUE=value" "DIO{port/bit}:VALUE" Sets the value of the specified bit.<br />
port = port number<br />
bit = bit number<br />
value = value of the bit (0 or 1)<br />
Example: "DIO{0/1}:VALUE=1"<br />
"?DIO{port/bit}:VALUE" "DIO{port/bit}:VALUE=value" Returns the value of the specified bit.<br />
port = port number<br />
bit = bit number<br />
value = value of the bit (0 or 1)<br />
Example: "?DIO{0/1}:VALUE"<br />
Page 31 of 43
Note: Click Send <strong>Message</strong> after changing the type of data to return.<br />
API message reference<br />
Click on a component link below to go the text messages, device responses, and property values supported by each <strong>DAQ</strong> component.<br />
AI<br />
AISCAN<br />
AITRIG<br />
DIO<br />
CTR<br />
DEV<br />
AO<br />
Page 34 of 43
<strong>DAQ</strong>Flex Firmware Architecture<br />
This document contains the specifications for the interface between the <strong>DAQ</strong>Flex Software API and the <strong>DAQ</strong>Flex firmware that is<br />
required to create <strong>Message</strong>-<strong>Based</strong> <strong>DAQ</strong> (MBD) applications.<br />
The <strong>DAQ</strong>Flex firmware uses a String <strong>Message</strong> <strong>Based</strong> Interface (SMBI) to communicate with <strong>DAQ</strong>Flex Series hardware. Refer to the<br />
API message reference for information about the <strong>DAQ</strong> components and string messages supported by the <strong>DAQ</strong>Flex API. Refer to the<br />
Hardware Reference section for information on the commands and property values that are supported by <strong>DAQ</strong>Flex Series devices.<br />
SMBI data types<br />
Special formatting characters are retuned with RAW data (except streaming data from bulk transfers) to indicate the following data<br />
types:<br />
• char[64]: String data in a character array<br />
• uint8: unsigned 8-bit value<br />
• uint16: unsigned 16-bit value<br />
• uint32: unsigned 32-bit value<br />
• float32: float 32-bit value<br />
Communication mechanism<br />
The device enumerates as a USB device using an MCC driver.<br />
Control transfers<br />
• Control transfers to endpoint 0 are used to communicate with the device.<br />
• The control transfer maximum buffer size is 64 bytes.<br />
• The control transfers are vendor transfers.<br />
• The command code is in the bRequest field.<br />
¡ SMBI uses the 0x80 data type for strings, and the 0x81 data type for RAW data, when supported.<br />
• Parameters passed for OUT control transfers are sent during the data stage.<br />
• The SMBI data stage will return RAW data, LSB first.<br />
The DEV component message "DEV:DATATYPE=ENABLED" specifies whether raw data is enabled or disabled for returned data.<br />
When using "DEV:DATATYPE=ENABLED" the first byte indicates the data type returned. Refer to the Notes below for more<br />
information.<br />
• The amount of data being transferred must be specified in the wLength field.<br />
SMBI control messages<br />
• Invalid OUT messages have a STALL response, and the IN response is "INVALID", RAW return is a 0 length data packet.<br />
• Default return for an IN request before an OUT results in a return message of "NO COMPONENT SET"<br />
• Valid messages have an ACK response.<br />
A valid response to an IN request is in the form of a string. RAW data is only returned for supported messages.<br />
• A RAW data return for an invalid message is a 0 length packet, unless "DEV:DATATYPE=ENABLE" where it will return a 1 byte<br />
packet with 0xFF as the value indicating an error/invalid.<br />
Miscellaneous<br />
• Bulk transfers from endpoint 1 IN are used for analog input scans.<br />
Data is in RAW format and "DEV:DATATYPE" has no impact on the data.<br />
Note:Refer to device-specific information to determine whether bulk transfer components are supported.<br />
• Multi-byte data, for example integers, are sent LSB first.<br />
Page 35 of 43
Programming and developing applications<br />
You can access <strong>DAQ</strong>Flex series hardware functions using either the <strong>DAQ</strong>Flex software API library or the <strong>DAQ</strong>Flex firmware<br />
architecture.<br />
• The <strong>DAQ</strong>Flex software API is an open source library that implements a simple message-based protocol consisting of textbased<br />
commands, or messages.<br />
The software API operates with standard drivers for Windows or Linux.<br />
Refer to the Software API topics in the <strong>DAQ</strong>Flex Help file for more information on using the <strong>DAQ</strong>Flex software API.<br />
• The <strong>DAQ</strong>Flex firmware architecture uses a String <strong>Message</strong> <strong>Based</strong> Interface (SMBI) to communicate with <strong>DAQ</strong>Flex series<br />
hardware using a minimal number of device transactions. Communication with the device is accomplished through the USB<br />
driver (winusb, libusb, or other custom driver). Only experienced USB programmers should attempt to write a driver for use<br />
with the <strong>DAQ</strong>Flex firmware.<br />
Refer to the Firmware Specification in the <strong>DAQ</strong>Flex Help file for more information on using the <strong>DAQ</strong>Flex firmware. The source<br />
code for the <strong>DAQ</strong>Flex software API may be used as a guide for developing a driver to interface directly with the hardware.<br />
Getting started with the <strong>DAQ</strong>Flex software API library<br />
Windows XP and Windows Vista:<br />
1. Run the <strong>DAQ</strong>Flex.msi Windows installer.<br />
When running Windows XP, a winusb driver is automatically installed. This driver is included on Windows Vista.<br />
2. Run the <strong>DAQ</strong>Flex test application (FlexTest.exe). This application is an interactive C# console program that demonstrates<br />
how to use the <strong>DAQ</strong>Flex software API.<br />
Additionally, you can build and run the C# or VB .NET example programs included in the installation using ExampleBuilder or<br />
Visual Studio (version 2005 or greater).<br />
3. Review the <strong>DAQ</strong>Flex Help file for the functions supported by <strong>DAQ</strong>Flex series hardware.<br />
Linux:<br />
1. Using your Software/Package manager, verify that the Mono framework (version 2.4 or later) and the libusb user-mode<br />
driver are installed on your Linux system.<br />
If these versions aren't listed, information on installing, updating, or adding software repositories to your Software/Package<br />
manager can be found at the following links. Click here to go to the Mono web site. Click here to go to the libusb web site.<br />
2. As a root user, create a symbolic link to the libusb-1.0 shared object file. For example:<br />
¡ $ ln -s /usr/lib/libusb-1.0.so.0/usr/lib/libusb-1.0.so<br />
(The actual file location may vary.)<br />
3. Extract the files from the <strong>DAQ</strong>Flex-1.3.tar.gz archive file from the <strong>DAQ</strong>Flex software CD using an archive manager.<br />
4. In a terminal window, set the current directory to <strong>DAQ</strong>Flex/Source/<strong>DAQ</strong>FlexAPI.<br />
5. As a root user, run the following commands:<br />
¡ $ make<br />
¡ $ make install<br />
6. Restart the system.<br />
7. In a terminal window, set the current directory to <strong>DAQ</strong>Flex/Source/<strong>DAQ</strong>FlexTest.<br />
8. As a root user, run the following commands:<br />
¡ $ make<br />
¡ $ make install<br />
9. From a terminal window, run the FlexTest application using the following command:<br />
¡ $ flextest<br />
This application is an interactive C# console program that demonstrates how to create an application using the <strong>DAQ</strong>Flex<br />
software API. Additionally, you can build and run the C# example programs included in the installation using MonoDevelop or<br />
the Mono command line interpreter.<br />
10. Review the <strong>DAQ</strong>Flex Help.pdf file for the functions supported by <strong>DAQ</strong>FLex series hardware.<br />
Page 42 of 43
Using the <strong>DAQ</strong>Flex firmware architecture<br />
• Communicate with <strong>DAQ</strong>Flex series hardware through the USB driver installed on your system (winusb, libusb, or other custom<br />
driver).<br />
Only experienced USB programmers should attempt to write a driver for use with the <strong>DAQ</strong>Flex firmware. Experience with<br />
CONTROL transfers for asynchronous communications, and BULK transfers for synchronous communications is recommended.<br />
• Refer to the Windows driver (winusb) or the Linux driver (libusb) for an example of how to communicate with <strong>DAQ</strong>Flex series<br />
hardware.<br />
• Refer to the Firmware Specification in the <strong>DAQ</strong>Flex Help file for more information on using the string-based messages, transfer<br />
methods, and commands that are supported by the <strong>DAQ</strong>Flex firmware.<br />
Page 43 of 43