Numerical Methods







- Establishing communication
Communicating with instruments


Establishing communication with PyVISA

The textbox below contains some Python code that imports the PyVISA package and then creates a resource manager object. The resource manager class contains a method that lists the devices it detects that are connected to the computer. The 'print' statement prints this list. If your computer is configured to open *.py files in a development environment, you can click on the link below the textbox to open the code and run it.

When the code above was run with a Keithley Model 3390 Arbitray Waveform Generator connected to the computer by USB and a Keithley Model 2636A Source Meter connected via LAN, the reponse was a list of four strings,

    ('USB0::0x05E6::0x3390::1421720::INSTR', 'TCPIP0::', 'ASRL1::INSTR', 'ASRL3::INSTR')

The first string corresponds to an instrument connected via USB. Knowing that the Arbitray Waveform Generator is the only device connected by USB, we create an instrument object called Keithley_3390 and then ask it to identify itself.

    Keithley_3390 = rm.open_resource('USB::0x05E6::0x3390::1421720::INSTR')

The response is,

    Keithley Instruments Inc.,3390,1421720,1.06-0C2-04-07-04

Similarly, creating an instrument object for the Source Meter and asking it to identify itself,

    SM_2636A = rm.open_resource('TCPIP0::')

results in,

    Keithley Instruments Inc., Model 2636A, 1239787, 2.1.3

The last two strings in this example 'ASRL1::INSTR' and 'ASRL3::INSTR' correspond to COM ports. Since nothing was connected to the COM ports trying to communicate with them resulted in a timeout error. The code below automates the process of identifying the instruments connected to the computer. Use it to check that all of the instruments that you think are connected are really communicating with the computer.