Operating instructions

Basic Steps of IEC/IEEE-Bus Programming R&S ESCI
1166.6004.12 7.2 E-1
Generating a response buffer
Since the DLL returns zero-terminated strings in case of responses, a string of sufficient length
should be generated prior to calling the functions ibrd() and ilrd(), since Visual Basic prefixes
a length value to the strings which is not updated by the DLL.
The following two possibilities are available to generate a length value for a string:
- Dim Rd as String * 100
- Dim Rd as String
Rd = Space$(100)
Initialization and Default Status
Variables used by all subroutines should be stored at the beginning of every program.
Then the IEC/IEEE bus as well as the settings of the instrument are brought into a defined default status
at the beginning of every program. Subroutines "InitController" and "InitDevice" are used to
this effect.
Creating Global Variables
Global variables are placed in so-called "modules" (file extension: .BAS) in Visual Basic. Therefore, at
least one module (e.g. "GLOBALS.BAS) should be created which contains the variables used by all
subroutines, such as the device addresses used by the IEC/IEEE-bus driver.
The file should contain the following instructions for the programming examples below:
Global receiver As Integer
Global boardId As Integer
Initiate Controller
REM ------------ Initiate controller ---------------------------------------
Public SUB InitController()
iecaddress% = 20 'IEC/IEEE-bus address of the
'instrument
CALL IBFIND("GPIB0", boardId%) 'Open port to the controller
CALL IBFIND("DEV1", receiver%) 'Open port to the instrument
CALL IBPAD(receiver%, iecaddress%) 'Inform controller on instrument
'address
CALL IBTMO(receiver%, 11) 'Response time to 1 sec
END SUB
REM ************************************************************************