sssbbbaaa
sssbbbaaa

Reputation: 244

GPIB communication with Python (PyVisa)

I am trying to communicate with a very old instrument (CCD camera) by Python. The GPIB programming manual from the instrument manufacturer published in 1999 only provides a basic command listing. It also describes some standard procedures for GPIB communication.

I have coded some Python programs (with PyVisa) successfully before to control and acquire data from instruments connected with computers via ethernet or USB. However, GPIB is new to me and it seems quite different from them in terms of ATN, SRQ, a talker, or a listener.

I found GPIBInterface and GPIBInstrument classes from the PyVisa API documentation but couldn't find any information on talker or listener setting.

Here are my questions,

a. Is my presumption below for data acquisition process correct?

  1. Set the controller (PC) as a talker and the instrument as a listener.
  2. The controller asserts ATN.
  3. The controller commands data acquisition to the instrument.
  4. Wait for SRQ from the instrument.
  5. Set the instrument as a talker and the controller as a listener.
  6. The controller deasserts ATN.
  7. The instruments sends data message to the controller.
  8. Single acquisition done.

b. What is differences between a control message from the controller and direct 'write' function in a GPIBInstrument class?

Below code still works though it omits setting ATN, a talker, or a listener. Why's that?

import pyvisa

RM = pyvisa.ResourceMananger()
INSTRUMENT = RM.open_resource('instrument address')
print(INSTRUMENT.query('*IDN?'))

c. Is their any example or tutorial for GPIB programming via PyVisa?

I can't find appropriate one..

Any comments will be helpful. Thanks in advance.

Upvotes: 3

Views: 7731

Answers (1)

The Photon
The Photon

Reputation: 1367

a. Is my presumption below for data acquisition process correct?

  1. Set the controller (PC) as a talker and the instrument as a listener.
  2. The controller asserts ATN.
  3. The controller commands data acquisition to the instrument.
  4. Wait for SRQ from the instrument.
  5. Set the instrument as a talker and the controller as a listener.
  6. The controller deasserts ATN.
  7. The instruments sends data message to the controller.
  8. Single acquisition done.

I have been writing VISA-based instrument control code for over 20 years and I don't know the answer to this, and there is almost certainly no need for you to know it either.

Only if you're actually implementing the VISA API yourself, or debugging the GPIB interface on an instrument you designed, should you need to worry about the manipulation of the ATN or SRQ signals, or about assigning talkers and listeners.

Below code still works though it omits setting ATN, a talker, or a listener. Why's that?

Simply put, because the Visa viWrite() (or viQuery()) functions, which are called by the pyVisa write() or query() methods, take care of it all for you.

Similarly the viRead() function, called by the pyVisa read() method, will take care of all the low level signal manipulation needed to read a message from the slave device.

You might, someday, if you are unlucky, find you need to perform low-level functions like GTL (go to local, to tell an instrument to return to front-panel control), GET (group execute trigger, to trigger several instruments simultaneously), or respond to a SRQ. But even these the VISA library provides an abstract interface to, so that you won't have to manipulate the individual bus lines directly.

c. Is their any example or tutorial for GPIB programming via PyVisa?

The pyVisa docs provide several examples, for example under the headings

Communicating with your instrument

A more complex example

and

Reading and Writing values

Upvotes: 2

Related Questions