VISA¶
VISA Interface module for Labtronyx
| codeauthor: | Kevin Kennedy |
|---|
-
class
labtronyx.interfaces.i_VISA.i_VISA(manager, **kwargs)[source]¶ VISA Controller
Wraps PyVISA. Requires a VISA driver to be installed on the system.
-
enumerate()[source]¶ Identify all devices known to the VISA driver and create resource objects for valid resources
-
open()[source]¶ Initialize the VISA Interface. Instantiates a VISA Resource Manager.
Returns: True if successful, False if an error occurred
-
-
class
labtronyx.interfaces.i_VISA.r_VISA(manager, resID, **kwargs)[source]¶ VISA Resource Base class.
Wraps PyVISA Resource Class
All VISA compliant devices will adhere to the IEEE 488.2 standard for responses to the *IDN? query. The expected format is: <Manufacturer>,<Model>,<Serial>,<Firmware>
BK Precision has a non-standard format for some of their instruments: <Model>,<Firmware>,<Serial>
Drivers derived from a VISA resource do not need to provide values for the following property attributes as they are derived from the identification string:
- deviceVendor
- deviceModel
- deviceSerial
- deviceFirmware
-
close()[source]¶ Close the resource. If a driver is loaded, that driver is also closed
Returns: True if successful, False otherwise
-
configure(**kwargs)[source]¶ Configure resource parameters to alter transmission characteristics or data interpretation
All VISA Resources
Parameters: Serial Resources
Parameters: - baud_rate (int) – Serial Baudrate. Default 9600
- data_bits (int) – Number of bits per frame. Default 8.
- parity (str) – Data frame parity (None, Even, Odd, Mark or Space)
- stop_bits (int) – Number of stop bits. Default 1
- break_length (int) – Duration of the break signal in milliseconds
- discard_null (bool) – Discard NUL characters
- send_end (bool) – Assert END during the transfer of the last byte of data in the buffer
Resource type dependent
Parameters:
-
getIdentity(section=None)[source]¶ Get the comma-delimited identity string returned from *IDN? command on resource enumeration
Parameters: section (int) – Section of comma-split identity Return type: str
-
getProperties()[source]¶ Get the property dictionary for the VISA resource.
Return type: dict[str:object]
-
getStatusByte()[source]¶ Read the Status Byte Register (STB). Interpretation of the status byte varies by instrument
Returns:
-
identify()[source]¶ Query the resource to find out what instrument it is. Uses the standard SCPI query string *IDN?. Will attempt to load a driver using the information returned.
-
inWaiting()[source]¶ Return the number of bytes in the receive buffer for a Serial VISA Instrument. All other VISA instrument types will return 0.
Returns: int
-
lineBreak(length)[source]¶ Suspends character transmission and places the transmission line in a break state
Parameters: length (int) – Length of time to break
-
loadDriver(driverName=None, force=False)[source]¶ Load a Driver.
VISA supports enumeration and will thus search for a compatible driver. A driverName can be specified to load a specific driver, even if it may not be compatible with this resource. If more than one compatible driver is found, no driver will be loaded.
On startup, the resource will attempt to load a valid driver automatically. This function only needs to be called to override the default driver.
unloadDriver()must be called before loading a new driver for a resource.Parameters: driverName (str) – Driver name to load Returns: True if successful, False otherwise
-
open()[source]¶ Open the resource and prepare to receive commands. If a driver is loaded, the driver will also be opened
Returns: True if successful, False otherwise Raises: labtronyx.ResourceUnavailable
-
query(data, delay=None)[source]¶ Retrieve ASCII-encoded data from the device given a prompt.
A combination of write(data) and read()
Parameters: Returns: str
Raises: labtronyx.ResourceNotOpen
Raises: labtronyx.InterfaceTimeout
Raises: labtronyx.InterfaceError
-
read(termination=None, encoding=None)[source]¶ Read ASCII-formatted data from the instrument.
Reading stops when the device stops sending, or the termination characters sequence was detected. All line-ending characters are stripped from the end of the string.
Parameters: Returns: str
Raises: labtronyx.ResourceNotOpen
Raises: labtronyx.InterfaceTimeout
Raises: labtronyx.InterfaceError
-
read_raw(size=None)[source]¶ Read Binary-encoded data directly from the instrument.
Parameters: size (int) – Number of bytes to read Raises: labtronyx.ResourceNotOpen Raises: labtronyx.InterfaceTimeout Raises: labtronyx.InterfaceError
-
reset()[source]¶ Reset the instrument. Behavior varies by instrument, typically this will reset the instrument to factory default settings.
-
trigger()[source]¶ Trigger the instrument using the common trigger command *TRG. Behavior varies by instrument