6146/6156 DC Voltage/Current Generators Operation Manual
5.9.1 Common Sub Procedures for Interface Control
5-46
5.9.1 Common Sub Procedures for Interface Control
5.9.1.1 Common Sub Procedure to Program Examples Using GPIB
' GPIB data transmission sub procedure
Sub gpibwrt(intDes As Integer, strCmd As String)
Call ibwrt(intDes, strCmd & vbLf) ' Sends adding the LF character.
End Sub
' GPIB data transmission sub procedure
Sub gpibrd(intDes As Integer, strData As String)
Dim strRawStr As String * 30 ' Data receive buffer
Dim intSize As Integer ' Number of characters to be extracted
Call ibrd(intDes, strRawStr) ' Reception (buffer number only)
If InStr(strRawStr, vbCr) <> 0 Then ' Searches for the CR or CL character.
intSize = InStr(strRawStr, vbCr) - 1
ElseIf InStr(strRawStr, vbLf) <> 0 Then
intSize = InStr(strRawStr, vbLf) - 1
End If
If intSize = 0 Then ' Checks the search result.
strData = ""
Else
strData = Left$(strRawStr, intSize) ' Extracts except the CR/LF character.
End If
End Sub
5.9.1.2 Common Sub Procedure to Program Examples Using USB
' USB driver initialization sub procedure
Sub aUSBSta(lngTimeOut As Long)
Dim lngRet As Long ' USB driver return value
lngRet = ausb_start(lngTimeOut)
If lngRet = OK Then
blnUSBComErr = False ' If OK
Else
blnUSBComErr = True ' If not OK
MsgBox"USB initialization error", vbCritical, "error:" & lngRet
End If
Call mSecSleep(100) ' Waits for USB initialization (100 ms)
End Sub