Section 6: Instrument programming
Model 2651A High Power System SourceMeter® Instrument Reference Manual
6-62
2651A-901-01 Rev. A / March 2011
4. Retrieve responses from the remote device using
tspnet.read
. The Model 2651A suspends
operation until data is available or a timeout error is generated. You can check if data is available
from the remote device using
tspnet.readavailable()
.
5. Disconnect from the remote device using
tspnet.disconnect()
. Terminate all remote
connections using
tspnet.reset()
.
Example script
The following example demonstrates how to connect to a remote non-TSP
®
enabled device, and send
and receive data from this device:
-- Disconnect all existing TSP-Net connections.
tspnet.reset()
-- Set tspnet timeout to 5 seconds.
tspnet.timeout = 5
-- Establish connection to another device with IP address 192.168.1.51
-- at port 1394.
id_instr = tspnet.connect("192.168.1.51", 1394, "*rst\r\n")
-- Print the device ID from connect string.
print("ID is: ", id_instr)
-- Set termination character to CRLF. You must do this on a per
-- connection basis after connection has been made.
tspnet.termination(id_instr, tspnet.TERM_CRLF)
-- Send the command string to the connected device.
tspnet.write(id_instr, "*idn?" .. "\r\n")
-- Read the data available, then print it.
print("instrument write/read returns: ", tspnet.read(id_instr))
-- Disconnect all existing TSP-Net sessions.
tspnet.reset()
TSP-Net versus TSP-Link to communicate with TSP-enabled devices
The TSP-Link
®
network interface is the preferred communication method when communicating
between the Model 2651A and another TSP-enabled instrument. The advantages of using the
TSP-Link network interface over using TSP-Net
®
commands include:
•
Error checking
: When connected to a TSP-enabled device, all errors that occur on the remote
device are transferred to the error queue of the Model 2651A. The Model 2651A indicates errors
from the remote device by prefacing these errors with “Remote Error”.
For example, if the remote device generates error number 4909, the Model 2651A generates the
error string “Remote Error: (4909) Reading buffer not found within device.”
•
Digital I/O triggering
: TSP-Link connections have three synchronization lines that are available
to each device on the TSP-Link network. You can use any one of the synchronization lines to
perform hardware triggering between devices on the TSP-Link network. Refer to Hardware trigger
modes for more details.