Using Python With GradientOne's APIs
The adoption of Python as a programming language for hardware test development and instrument control has accelerated significantly over the past decade. Python’s ease-of-use, portability, and error reduction make it an ideal language for beginners as well as professionals. A recent study by IEEE ranked Python as the most popular programming language in the world.
In this blog post we’ll show how someone can leverage GradientOne’s Hybrid Cloud Test Lab features by combining Python and GradientOne’s instrument control APIs. This approach allows for normal lab operations and uploading data to the cloud. It supports semi-automated testing for use cases that involve hardware lab, manufacturing line, or field operations.
For this example of Hybrid Cloud Lab I have an Aardvark I2C/SPI Host Adapter, an I2C board, a Tektronix MSO5204B oscilloscope, a laptop, and a GradientOne Gateway. The Python program runs on the laptop.
The basic steps that occur when the Python program starts:
Initialize Cloud Defined Oscilloscope Setup
One of the capabilities that GradientOne provides is a cloud based, centralized test plan repository. This allows for fast and easy re-use of previously vetted, test routines, all of which are reviewable and editable via a web browser. Highlights of this configuration are shown below:
The Python script issues an HTTP POST specifying the name of the oscilloscope configuration to be used in the test.
URL - https://acme.gradientone.com/commands
Oscilloscope configuration = “I2C_Test”
When this occurs the GradientOne Gateway receives the configuration and loads it on the oscilloscope.
Below is an excerpt of the Python script that controls the initialization of the oscilloscope. (Note: not all aspects of the variable instantiation and authentication are shown for brevity.)
Generate I2C Signals
The Python script will generate I2C signals on the Aardvark, that are sent to the I2C activity board. I have slightly modified the script for this example (see the excerpt below), but the base script is provided by Total Phase and is available here. The Tektronix scope leads are connected to the I2C activity board.
The script used for generating the I2C signals takes the following arguments:
The signal is subsequently acquired by the oscilloscope and transmitted to the cloud via the GradientOne Gateway. The Gateway takes care of the data management and network optimization for a fast and simple upload to the cloud.
Putting It All Together
For the example I will initiate the script with the following arguments:
The test result is now available via the GradientOne platform. The test result includes the raw data (time series/voltages) and all available meta data (scope settings, DUT settings, user, date time stamp, etc).
We also store the image from the scope to provide the user with additional information and confirmation.
The benefit of storing all the raw data is it leverages the benefits of cloud computing and contemporary web browser technologies. I can zoom in (shown below), use markers, compute deltas, as well as take advantage of advanced analysis features such as anomaly detection, waveform matching, custom measurements, and more.
Many organizations we work with have significant investments in their existing test labs, but are looking for a way to capitalize on the benefits of cloud computing's analysis, storage, and data visualization capabilities. The Hybrid Cloud Test Lab approach is an easy way to get started.