Measurement-computing DAQFlex User Guide Manual do Utilizador Página 12

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 125
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 11
DAQFlex Software User's Guide Using DAQFlex Software
12
Reading an analog input channel
C#
// Read the value of analog input channel 0
String[] Devices;
DaqDevice MyDevice;
DaqResponse Response;
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 using the DaqDevice object
MyDevice.SendMessage("AI{0}:RANGE=BIP10V");
MyDevice.SendMessage("AI:CAL=ENABLE");
MyDevice.SendMessage("AI:SCALE=ENABLE");
// Read and display the daq response
Response = MyDevice.SendMessage("?AI{0}:VALUE");
label1.Text = Response.ToString();
}
catch (Exception ex)
{
// handle error
label1.Text = ex.Message;
}
VB
' Read the value of analog input channel 0
Dim Devices As String ()
Dim MyDevice As DaqDevice
Dim Response As DaqResponse
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 using the DaqDevice object
MyDevice.SendMessage("AI{0}:RANGE=BIP10V")
MyDevice.SendMessage("AI:CAL=ENABLE")
MyDevice.SendMessage("AI:SCALE=ENABLE")
' Read and display the daq response
Response = MyDevice.SendMessage("?AI{0}:VALUE")
Label1.Text = Response.ToString()
Catch Ex As Exception
' handle error
Label1.Text = Ex.Message()
End Try
Vista de página 11
1 2 ... 7 8 9 10 11 12 13 14 15 16 17 ... 124 125

Comentários a estes Manuais

Sem comentários