⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpiomeas.frm

📁 HP GPIB的VB和C语言库文件,参考范例.
💻 FRM
字号:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'  This program does the following:
'  - Creates a GPIO session with timeout and error checking
'  - Signals the device with a CTL0 pulse
'  - Reads the device's response using formatted I/O
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub cmdMeas_Click ()
   Dim id As Integer                ' device session id
   Dim retval As Integer            ' function return value
   Dim buf As String                ' buffer for displaying
   Dim real_data As Double          ' data from device

'  Set up an error handler within this subroutine that will
'  be called if a SICL error occurs.
   On Error GoTo ErrorHandler

'  Disable the button used to initiate I/O while I/O is
'  being performed.
   cmdMeas.Enabled = False

'  Open an interface session using a known symbolic name
   id = iopen("gpio12")

'  Set the I/O timeout value for this session to 3 seconds
   Call itimeout(id, 3000)

'  Setup formatted I/O configuration
   Call igpiosetwidth(id, 8)
   Call igpioctrl(id, I_GPIO_READ_EOI, 10)
   
'  Signal the device to take a measurement
   Call itrigger(id)

'  Get the data
   retval = ivscanf(id, "%lf%*t", real_data)

'  Display the response as string in a Message Box
   buf = Str$(real_data)
   retval = MsgBox(buf, MB_OK, "GPIO Data")

'  Close the device session.
   Call iclose(id)

'  Enable the button used to initiate I/O
   cmdMeas.Enabled = True
   
   Exit Sub

ErrorHandler:

'  Display the error message string in a Message Box
   retval = MsgBox(Error$, MB_ICONEXCLAMATION, "SICL Error")

'  Close the device session if iopen was successful.
   If id <> 0 Then
      iclose (id)
   End If
   
'  Enable the button used to initiate I/O
   cmdMeas.Enabled = True
 
   Exit Sub

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'  The following routine is called when the application's
'  Start Up form is unloaded.  It calls siclcleanup to
'  release resources allocated by SICL for this
'  application.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Form_Unload (Cancel As Integer)
   Call siclcleanup    ' Tell SICL to clean up for this task
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -