lightlab.equipment.visa_bases.prologix_gpib module

Summary

Classes:

PrologixGPIBObject
param tempSess:If True, the session is opened and closed every time there is a command
PrologixResourceManager Controls a Prologix GPIB-ETHERNET Controller v1.2 manual: http://prologix.biz/downloads/PrologixGpibEthernetManual.pdf

Reference

class PrologixResourceManager(ip_address, timeout=2)[source]

Bases: lightlab.equipment.visa_bases.driver_base.TCPSocketConnection

Controls a Prologix GPIB-ETHERNET Controller v1.2 manual: http://prologix.biz/downloads/PrologixGpibEthernetManual.pdf

Basic usage:

p = PrologixResourceManager('prologix.school.edu')

p.connect()  # connects to socket and leaves it open
p.startup()  # configures prologix to communicate via gpib
p.send('++addr 23')  # talks to address 23
p.send('command value')  # sends the command and does not expect to read anything
p.query('command')  # sends a command but reads stuff back, this might hang if buffer is empty
p.disconnect()

The problem with the above is that if there is any error with startup, send or query, the disconnect method will not be called. So we coded a decorator called connected, to be used as such:

p = PrologixResourceManager('prologix.school.edu')

with p.connected():
    p.startup()
    p.send('++addr 23')  # talks to address 23
    p.send('command value')  # sends the command and does not expect to read anything
    p.query('command')  # sends a command but reads stuff back

If we try to send a message without the decorator, then we should connect and disconnect right before.

p = PrologixResourceManager('prologix.school.edu')

p.send('++addr 23')  # opens and close socket automatically

Warning

If a second socket is opened from the same computer while the first was online, the first socket will stop responding and Prologix will send data to the just-opened socket.

Todo

Make this class a singleton to mitigate the issue above.

Parameters:
  • ip_address (str) – hostname or ip address of the Prologix controller
  • timeout (float) – timeout in seconds for establishing socket connection to socket server, default 2.
port = 1234

port that the Prologix GPIB-Ethernet controller listens to.

startup()[source]

Sends the startup configuration to the controller. Just in case it was misconfigured.

query(query_msg, msg_length=2048)[source]

Sends a query and receives a string from the controller. Auto-connects if necessary.

Args:

query_msg (str): query message. msg_length (int): maximum message length. If the received

message does not contain a ‘
‘, it triggers another
socket recv command with the same message length.
class PrologixGPIBObject(address=None, tempSess=False)[source]

Bases: lightlab.equipment.visa_bases.driver_base.InstrumentSessionBase

Parameters:
  • tempSess (bool) – If True, the session is opened and closed every time there is a command
  • address (str) – The full visa address in the form: prologix://prologix_ip_address/gpib_primary_address:gpib_secondary_address
spoll()[source]

Return status byte of the instrument.

LLO()[source]

This command disables front panel operation of the currently addressed instrument.

LOC()[source]

This command enables front panel operation of the currently addressed instrument.

termination

Termination GPIB character. Valid options – ‘\r\n’, ‘\r’, ‘\n’, ‘’.

open()[source]

Open connection with instrument. If tempSess is set to False, please remember to close after use.

close()[source]

Closes the connection with the instrument. Side effect: disconnects prologix socket controller

write(writeStr)[source]
query(queryStr, withTimeout=None)[source]

Read the unmodified string sent from the instrument to the computer.

wait(bigMsTimeout=10000)[source]
clear()[source]

This command sends the Selected Device Clear (SDC) message to the currently specified GPIB address.

query_raw_binary(queryStr, withTimeout=None)[source]

Read the unmodified string sent from the instrument to the computer. In contrast to query(), no termination characters are stripped. Also no decoding.

timeout

This timeout is between the user and the instrument. For example, if we did a sweep that should take ~10 seconds but ends up taking longer, you can set the timeout to 20 seconds.