Measurement-computing DAQFlex User Guide Manuel d'utilisateur Page 18

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 125
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 17
DAQFlex Software User's Guide Using DAQFlex Software
18
Reading a counter input channel
C#
// Read counter 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));
// Start the counter
MyDevice.SendMessage("CTR{0}:VALUE=0");
MyDevice.SendMessage("CTR{0}:START");
// Read and display the daq response
for(int i = 1;i<=10;i++)
{
System.Threading.Thread.Sleep(750);
Response = MyDevice.SendMessage("?CTR{0}:VALUE");
label1.Text = Response.ToString();
Application.DoEvents();
}
// Stop the counter
MyDevice.SendMessage("CTR{0}:STOP");
}
catch (Exception ex)
{
// handle error
label1.Text = ex.Message;
}
VB
' Read counter channel 0
Dim MyDevice As DaqDevice
Dim Response As DaqResponse
Dim Devices As String ()
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))
Dim I As Integer
' Start the counter
MyDevice.SendMessage("CTR{0}:VALUE=0")
MyDevice.SendMessage("CTR{0}:START")
' Read and display the daq response
For I = 1 To 10
System.Threading.Thread.Sleep(750)
Response = MyDevice.SendMessage("?CTR{0}:VALUE")
Label1.Text = Response.ToString()
Application.DoEvents()
Next
Vue de la page 17
1 2 ... 13 14 15 16 17 18 19 20 21 22 23 ... 124 125

Commentaires sur ces manuels

Pas de commentaire