beautypg.com

Writing to an analog output channel – Measurement Computing DAQFlex User Guide User Manual

Page 13

background image

DAQFlex Software User's Guide

Using DAQFlex Software

13

Writing to an analog output channel

C#

// Write a value to analog output channel 0
String[] Devices;
DaqDevice MyDevice;

try
{

// Get a list of message-based DAQ devices
Devices = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno);

// Get a DaqDevice object for device 0
MyDevice = DaqDeviceManager.CreateDevice(Devices[0]);

// Send device messages
MyDevice.SendMessage("AO{0}:RANGE=BIP10V");
MyDevice.SendMessage("AO:CAL=ENABLE");
MyDevice.SendMessage("AO:SCALE=ENABLE");
MyDevice.SendMessage("AO{0}:VALUE=2.53");

}
catch (Exception ex)
{

// handle error
label1.Text = ex.Message;

}

VB

' Write a value to analog output channel 0
Dim Devices As String()
Dim MyDevice As DaqDevice

Try

' Get a list of message-based DAQ devices
Devices = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno)

' Get a DaqDevice object for device 0
MyDevice = DaqDeviceManager.CreateDevice(Devices(0))

' Send device messages
MyDevice.SendMessage("AO{0}:RANGE=BIP10V")
MyDevice.SendMessage("AO:CAL=ENABLE")
MyDevice.SendMessage("AO:SCALE=ENABLE")
MyDevice.SendMessage("AO{0}:VALUE=2.53")

Catch Ex As Exception

' handle error
Label1.Text = Ex.Message

End Try