Today we are releasing the first version of our SCPI command application. This is the first of several releases that delivers a Python based, multi-instrument, "hardened" software application that can be used for simple bench testing as well as more sophisticated design validation. There are many examples of Python scripts that are freely available for specific instrument use cases, but when building solutions for our customers we haven't come across many general purpose frameworks that allow for resiliency, failure recovery, logging, and multi-instrument control. We've designed this from the ground up with many of those capabilities included.
Read below for more on how it works.
First, you'll need to make sure you have the below software packages installed:
The scpi_runner.py reads a scpi_script file to open a connection with an instrument and send commands. The commands and their responses are logged to a log file. A sample script is provided in scpi_script.sample for you to modify as needed.
We've added features in the program to make it more "hardened". These include resiliency features for exception handling and other errors that can be caught without crashing the application.
The scpi_runner will time out commands and scripts that take too long to run. The command timeouts will raise an exception and run the next command. If the whole script times out then an exception is raised and the remaining commands are not run. These timeouts can be modified by editing the values set in settings.py
GradientOne Script Logic
The scpi_runner.py supports basic loops and sleeps (delays). The syntax for the GradienOne ScriptLogic objects is not case-sensitive, so G1:StartLoop and g1:startloop are equivalent.
To start a block of commands to loop, a StartLoop command is needed.
The Max is required, otherwise the block of commands will only run once. The BreakOn is optional. The string G1:StartLoop:Max=3 will start a loop that runs 3 times. You then enter as many commands as needed in the next lines and end the block of code to loop with a line with G1:EndLoop
Will run the *IDN? command 3 times.
To add a delay to your script in between commands, use a G1:Sleep.
For example, to sleep 2 seconds:
This calls python's time.sleep() function to delay running the next line. This can also be used within a loop.
Example SCPI Script
1. Establish a connection to the instrument: The above script opens a connection to the instrument using the IP address of 192.168.1.238, which can be found on most instruments network/LAN settings.
2. The next several lines include the SCPI commands *IDN?, *RST, and :SAVE:IMAGE D:\screenshot.png. These commands will obtain basic instrument information, reset the devoce, and download the screenshot to onboard instrument storage.
3. The next two commands are GradientOne specific commands for inserting a sleep and a loop. These are followed by a SYST:ERR? which checks to see if there is an error.
4. The last line is another GradientOne specific command signifying the end of the loop.
See below for the example in action:
Below is an example of the logging:
Stay tuned...more advanced features to come.