Working with external equipment via VISA at Engee
Page in progress. |
VISA (Virtual Instrument Software Architecture) is a specification developed to unify interaction with measuring instruments.
VISA provides an abstraction for communicating with various types of hardware such as USB, Ethernet, GPIB and other interfaces. In the context of Engee, VISA is used to integrate third-party measuring devices and allows them to be controlled through Julia code without leaving Engee.
To start working with VISA in Engee, you need to connect the external hardware support package, run the client program and insert the URL for the server operation on the Engee side. For more information, see article. After that, perform:
Next, you need to create a VISA object that will be used to interact with measuring devices.:
|
Basic methods of working with VISA
The following methods are used to work with devices connected via the VISA specification:
-
`visa.close_instument' — releases the bus for the device connected via the VISA specification.
-
`visa.close_session' — closes the session with VISA.
-
`visa.create_instument' — creates an instance of the device connected on the specified port.
-
`visa.create_session' — creates a session for working with VISA.
-
visa.flush
— clears the I/O buffers of the device. -
visa.get_ports
— gets a list of available physical ports. -
`visa.read' — reads data from the device.
-
`visa.readbinblock' — reads binary data from the device.
-
visa.visatrigger
— sends interrupt commands to the device. -
`visa.write' — writes messages to the device.
-
`visa.writebinblock' — writes binary data to the device.
-
`visa.writeread' — writes the answer to the device and reads it.
For a detailed description of each method, see the article VISA Software Management.
Step-by-step example of working with VISA
Consider an example in which a session is created, a list of ports is obtained, a device is created, a command is written to the device and the response is read:
-
Create a session for working with VISA devices — create a session by specifying the hardware implementation (for example,
@py
):visa.create_session("@py")
Read more about the hardware implementation at link. -
Get a list of available physical ports — Get a list of available ports and select the last one:
ports = visa.get_ports().data port = last(ports)
-
Create an abstraction of the device on the specified port — create a device to work with the selected port:
visa.create_instrument(port)
If you need to work with more than one measuring device, repeat the command VISA.create_instument(visa, port)
with the port of another device. -
Write a reset message to the device — send a command to reset the device settings:
visa.write(port, "*RST;:SYSTEM:LOCK OFF", "")
-
Write data to the device and read the response with a delay — send a command and read the response with a delay of 1.2 seconds:
writeread_result = visa.writeread(port, ":CHAN1:BASE:WAV?", 1.2).data
-
Read the message from the device — Read the data from the device (make sure that the device is sending data):
read_result = visa.read(port, "").data
-
Write binary data to the device — write two bytes to the device:
visa.writebinblock(port, [0x01, 0x00])
-
Read binary data from the device — read 8 bytes of data from the device:
bytes = visa.readbinblock(port, 8).data
-
Initiating an interrupt in the device — Send an interrupt command (may not be available on some devices):
visa.visatrigger(port)
-
Clearing the recording I/O buffer in the device — Clear the recording buffer (may not be available on some devices):
visa.flush(port, "flush_write_buffer")
-
Releasing the bus for the device — Release the bus so that other devices can use the port:
visa.close_instrument(port)
-
Close the device session — close the VISA session:
visa.close_session()
Possible problems and their solutions
-
Problem with displaying ports — if the method is
visa.get_ports
does not return available ports, then make sure that the measuring equipment is available on the user’s side.:-
On Linux, to interact with the hardware, you may need to run an installed client program with sudo rights or add a user to the dialout group.
-
In Windows, check if all the necessary drivers are installed and, if necessary, run the client program as an administrator.
-
-
Problem with Ethernet devices - To work with an Ethernet connection, make sure that the interfaces are configured correctly. If the port is returned in the format
"TCPIP::INSTR"
, then use it to create the device using the functionvisa.create_instument
:visa.create_instrument("TCPIP::INSTR")
-
Transmission bus lockout — If the next call does not work after calling
visa.write
, then the transmission bus may be blocked. Free up resources using `visa.read'. -
Driver conflicts — If the device drivers and VISA implementations conflict, then check the device logs on the user’s side to identify missing drivers.