Using GPIB Device Sessions
A device session allows you direct access to a device without knowing the type of interface to which it is connected. The specifics of the interface are hidden from the user.
Subtopics are:
SICL Functions for GPIB Device Sessions
This section shows how some SICL functions are implemented for GPIB device sessions. The data transfer functions work only when the GPIB interface is the Active Controller. Passing control to another GPIB device causes this device to lose active control.
Function |
Description |
iwrite |
Causes all devices to untalk and unlisten. It sends this controller’s talk address followed by unlisten and then the listen address of the corresponding device session. Then, it sends the data over the bus. |
iread |
Causes all devices to untalk and unlisten. It sends an unlisten, then sends this controller’s listen address followed by the talk address of the corresponding device session. Then, it reads the data from the bus. |
ireadstb |
Performs a GPIB serial poll (SPOLL). |
itrigger |
Performs an addressed GPIB group execute trigger (GET). |
iclear |
Performs a GPIB selected device clear (SDC) on the device corresponding to this session. |
Addressing GPIB Devices
To create a device session, specify the interface logical unit or symbolic name and a particular device logical address in the addr parameter of the iopen function. The interface logical unit and symbolic name are set by running Connection Expert.
Opening Connection Expert
There are two methods to launch Connection Expert (CE):
From the Application Finder:
-
Open the Application Finder on your Linux machine.
-
Use any of the following ways to launch Connection Expert:
-
Search for Connection Expert and click to launch the application.
-
Or, search for IO Control and launch it. In the IO Control application, click on the Connection Expert application to it.
-
-
Open your preferred web browser.
-
Enter the URL in the format: https://<IP Address of the machine where IO Libraries Suite is installed>:4211.
For example: https://10.17.68.235:4211.
Primary and Secondary Addresses
SICL supports both primary and secondary addressing on GPIB interfaces. The primary address must be between 0 and 30 and the secondary address must be between 0 and 30. The primary and secondary addresses correspond to the GPIB primary and secondary addresses. Some example GPIB addresses for device sessions are:
|
A device address corresponding to the device at primary address 7. |
|
A device address corresponding to the device at primary address 3, secondary address 2. |
VXI Mainframe Connections
Please note, VXI is only supported in the Windows product.
For connections to a VXI mainframe via an E1406 Command Module (or equivalent), the primary address passed to iopen corresponds to the address of the Command Module, and the secondary address must be specified to select a specific instrument in the card cage.
Secondary addresses of 0, 1, 2, ... 30 correspond to VXI instruments at logical addresses of 0, 8, 16, ... 240, respectively. See GPIB Device Session Code Samples for a sample program to communicate with a VXI mainframe via the GPIB interface.
Sample code to open a device session with a GPIB device at bus address 16 follows.
C sample:
INST dmm;
dmm = iopen (“gpib0,16”);
Visual Basic sample:
Dim dmm As Integer
dmm = iopen (“gpib0,16”)
GPIB Device Sessions and Service Requests
There are no device-specific interrupts for the GPIB interface, but GPIB device sessions do support Service Requests (SRQs). On the GPIB interface, when one device issues an SRQ, the library informs all GPIB device sessions that have SRQ handlers installed.
This is an artifact of how GPIB handles the SRQ line. The interface cannot distinguish which device requested service. Therefore, the library acts as if all devices require service. The SRQ handler can retrieve the device’s status byte by using the ireadstb function. See Writing GPIB Interrupt Handlers for more information.
GPIB Device Session Code Samples
This section provides C language and Visual Basic language sample programs for GPIB device sessions.
Sample: GPIB Device Session (C)
This sample opens two GPIB communications sessions with VXI devices (via a VXI Command Module). Then, a scan list is sent to a switch and measurements are taken by the multimeter every time a switch is closed.
/* gpibdev.c
This example program sends a scan list to a switch and, while looping, closes channels and takes measurements. */
#include <sicl.h>
#include <stdio.h>
main()
{
INST dvm;
INST sw;
double res;
int i;
/* Log message and terminate on error */
ionerror (I_ERROR_EXIT);
/* Open the multimeter and switch sessions*/
dvm = iopen (“gpib0,9,3”);
sw = iopen (“gpib0,9,14”);
itimeout (dvm, 10000);
itimeout (sw, 10000);
/*Set up trigger*/
iprintf (sw, “TRIG:SOUR BUS\n”);
/*Set up scan list*/
iprintf (sw,”SCAN (@100:103)\n”);
iprintf (sw,”INIT\n”);
for (i=1;i<=4;i++)
{
/* Take a measurement */
iprintf (dvm,”MEAS:VOLT:DC?\n”);
/* Read the results */
iscanf (dvm,”%lf”,&res);
/* Print the results */
printf (“Result is %lf\n”,res);
/* Trigger to close channel */
iprintf (sw, “TRIG\n”);
}
/* Close the multimeter and switch sessions */
iclose (dvm);
iclose (sw);
return 0;
}
Sample: GPIB Device Session (Visual Basic)
This sample opens two GPIB communications sessions with VXI devices (via a VXI Command Module). Then, a scan list is sent to a switch and measurements are taken by the multimeter every time a switch is closed.
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''‘ gpibdv.bas
' This example program sends a scan list to a
‘ switch and while looping closes channels and
‘ takes measurements.
'''''''''''''''''''''''''''''''''''''''''''''''
Sub Main()
Dim dvm As Integer
Dim sw As Integer
Dim res As Double
Dim i As Integer
Dim argcount As Integer
'Open the multimeter and switch sessions
'"gpib0" is the SICL Interface name as defined
'in Connection Expert
'Change this to the SICL name you have defined
dvm = iopen("gpib0,9,3")
sw = iopen("gpib0,9,14")
' set timeouts
Call itimeout(dvm, 10000)
Call itimeout(sw, 10000)
' Set up trigger
argcount = ivprintf(sw, "TRIG:SOUR BUS" +
Chr$(10))
' Set up scan list
argcount = ivprintf(sw, "SCAN (@100:103)" +
Chr$(10))
argcount = ivprintf(sw, "INIT" + Chr$(10))
'Display Form1 and print voltage measurements
'default form, (Name) "Form1", containing no
‘ controls)
Form1.Show
For i = 1 To 4
'Take a measurement
argcount = ivprintf(dvm, "MEAS:VOLT:DC?" +
Chr$(10))
' Read the results
argcount = ivscanf(dvm, "%lf", res)
' Print the results
Form1.Print "Result is " + Format(res)
' Trigger switch
argcount = ivprintf(sw, "TRIG" + Chr$(10))
Next i
' Close the sessions
Call iclose(dvm)
Call iclose(sw)
' Tell SICL to cleanup for this task
Call siclcleanup
End Sub