Connecting to SCPI Instrument by Generic SCPI in Python
Instrument Card
All SCPI Instrument
Device Specification: here
Connect to the SCPI Instrument in Python
Read our guide for turning Python scripts into Flojoy nodes.
PROTOCOLS > SCPI
Here is an example Python script that uses Instrumentkit to connect to a SCPI Instrument Miscellaneous:
import instrumentkit as ik
# Connect to the SCPI instrumentinst = ik.generic_scpi.SCPIInstrument.open_tcpip('192.168.0.2', 8888)
# Get the name of the connected instrumentname = inst.nameprint(name)
# Get the SCPI version supported by the instrumentscpi_version = inst.scpi_versionprint(scpi_version)
# Check if all operations sent to the instrument have been completedop_complete = inst.op_completeprint(op_complete)
# Get the power on status of the instrumentpower_on_status = inst.power_on_statusprint(power_on_status)
# Set the power on status of the instrumentinst.power_on_status = True
# Get the results of the instrument's self testself_test_ok = inst.self_test_okprint(self_test_ok)
# Reset the instrumentinst.reset()
# Clear the instrumentinst.clear()
# Send a software trigger event to the instrumentinst.trigger()
# Instruct the instrument to wait until it has completed all received commands before continuinginst.wait_to_continue()
# Get the power line frequency setting for the instrumentline_frequency = inst.line_frequencyprint(line_frequency)
# Set the power line frequency setting for the instrumentinst.line_frequency = 50
# Check and clear the error queue for the instrumenterror_queue = inst.check_error_queue()print(error_queue)
# Get the brightness of the display on the instrumentdisplay_brightness = inst.display_brightnessprint(display_brightness)
# Set the brightness of the display on the instrumentinst.display_brightness = 0.5
# Get the contrast of the display on the instrumentdisplay_contrast = inst.display_contrastprint(display_contrast)
# Set the contrast of the display on the instrumentinst.display_contrast = 0.8
# Close the connection to the instrumentinst.close()
This script demonstrates how to connect to a SCPI instrument using Instrumentkit and perform various operations such as getting the instrument name, checking the power on status, setting the power on status, resetting the instrument, getting and setting the display brightness and contrast, and more.