Writing hardware-paced i/o – Measurement Computing DAQFlex User Guide User Manual
Page 22

DAQFlex Software User's Guide
Using DAQFlex Software
22
VB
Try
Dim ScanData As Double(,)
Dim Names As String()
Dim Device As DaqDevice
Names = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno)
Device = DaqDeviceManager.CreateDevice(Names(0))
Device.EnableCallback(AddressOf OnReadScanData, CallbackType.OnDataAvailable,
1000)
Device.EnableCallback(AddressOf OnReadScanData, CallbackType.OnScanComplete,
Nothing)
Device.SendMessage("AISCAN:LOWCHAN=0")
Device.SendMessage("AISCAN:HIGHCHAN=0")
Device.SendMessage("AISCAN:RATE=1000")
Device.SendMessage("AISCAN:SAMPLES=5000")
Device.SendMessage("AISCAN:START")
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Protected Sub ReadScanData(ByVal errorCode As ErrorCodes, ByVal callbackType As
CallbackType, _ ByVal callbackData As Object)
Try
Dim AvailableSamples As Integer
Dim ScanData As Double(,)
AvailableSamples = DirectCast(callbackData, Integer)
ScanData = Device.ReadScanData(AvailableSamples, 0)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Writing hardware-paced I/O
The basic approach to programming analog output scans is to set the device's output scan properties,
call the
WriteScanData()
method, and send the
START
command. The following examples show how to
program a basic output scan.
C#
try
{
double[,] scanData = new double[1, 5000];
string[] names = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno);
DaqDevice device = DaqDeviceManager.CreateDevice(names[0]);
// fill scanData with data
device.SendMessage("AOSCAN:LOWCHAN=0");
device.SendMessage("AOSCAN:HIGHCHAN=0");
device.SendMessage("AOSCAN:RATE=1000");
device.SendMessage("AOSCAN:SAMPLES=5000");
device.SendMessage("AOSCAN:BUFSIZE=5000");
int timeOut = 0;
device.WriteScanData(scanData, 5000, timeOut);
device.SendMessage("AOSCAN:START");
}