How to Automate Your Measurements
Article originally written by Richard Oed
Oscilloscopes are the tool of choice for every engineer when it comes to measurements. If the instrument can also work as a waveform generator and can do some mathematical calculations on the signals acquired, or allows automated tests, even better.
For many measurement tasks that designers face in their daily work, oscilloscopes are an excellent choice as they offer many ways to achieve good results. But occasionally, it is necessary to document the obtained data or to process the signals further. Just as a simple example: You want to quantify the power of a certain block in your circuitry, and you are also interested in the waveform originating from these calculations, not only in the absolute values.
But most oscilloscopes only measure voltages, the current, and therefore the power cannot be measured directly. So, a shunt resistor must be used to obtain the current passing through the circuit, allowing for the computation of the power consumed (Figure 1). You also have into account that the channels of most oscilloscopes are single ended, and all measurements therefore must be referred to ground. It is not possible to read the voltage drop over the load directly. A second measurement taking the voltage drop over the shunt resistor is necessary. In the end, this means that some computations have to be done to get the power reading.
Here oscilloscopes capable of doing the calculations right on the device, like the Analog Discovery Pro (ADP3450) from Digilent, enter the game. This four-channel oscilloscope (a two-channel version is available as well) with 14 bits of resolution at a sampling rate of up to 0.5 GSamples/s is a true mixed-signal measurement device that the meets the needs for professional-level electronic test-benches at the office or at home. Besides the analog inputs, it also provides engineers with 16 digital I/O-channels, two external trigger inputs, and a two-channel arbitrary waveform generator (Figure 2).
The Analog Discovery Pro ADP3450 is smaller and lighter than a laptop and has no built-in user-interface. It connects to a host computer through one of its four high-speed USB 2.0 ports or through its Ethernet interface, and it is controlled by the free WaveForms software from Digilent running on the host. This software, refined by over 10 years of customer feedback, provides a user experience with the look-and-feel of traditional benchtop applications and is compatible to the macOS, Windows, and Linux operating systems.
One Software for All Instruments
WaveForms comes with twelve built-in software instruments, like an oscilloscope, a pattern- and a waveform-generator (which, for example, could create the test signal for our power measurement), a controllable power supply, I/Os, logic-, spectrum-, network-, impedance- and protocol-analyzers, as well as a voltmeter and a data logger. This way users can capture, record, analyze, document, and generate mixed-signals and mixed-domain signals. Additionally, the WaveForms application includes a script editor tool, which allows custom programming of the instruments in JavaScript.
Sometimes, however, like in the case of the power-measurement example, it is not even necessary to create a script. The software’s oscilloscope instrument contains so-called Math channels, which perform the calculations and plot the result alongside the measurements. So, to display the total power of the circuit, simply writing “(C2 – C1) * C1 / RS“ in the “Script” field of a dialog is sufficient, with RS being the value of the shunt resistor.
This equation computes the current by dividing the voltage VS across the sensing resistor (Channel 1) by its resistance value and then multiplies the result with the voltage across the combined load (capacitance and resistance) derived by subtracting the voltage VS (Channel 1) from the voltage VG across the load (Channel 2). In the same window, also the unit of the signal and the range of the channel in units per division can be set. It is also possible to rename the measurement channels and the math channels for more clarity (Figure 3). Additional calculations, like the power consumption of the resistor RL, can be performed as well by simply adding more math channels. Besides arithmetic operations, the module also supports trigonometric operations, and others.
Script Instrument Eases Measurement Automation
Each of the Waveforms’ instruments can be run by scripts. By writing JavaScript code and executing it in the “Script” instrument, engineers can control any other instrument through extensive Application Programming Interfaces (APIs). This way, it is also possible to configure and run several instruments simultaneously in an easily repeatable way.
The script instrument not only allows to control the instruments and to acquire data. It also includes a plot pane, where users can integrate the data from many different instruments and display them in a highly customizable way. Moreover, GUI actions can be automated, as well as custom data analysis and manipulations.
This way, engineers can monitor signals and document the measurement results. With the WaveForms Software Development Kit (SDK), even more customization is possible, as the SDK can be used to create custom applications and scripts in Python, C, C++, C#, and Visual Basic. For LabVIEW and MATLAB, third-party toolkits are available.
Full Automation in Linux Mode
Beside the standard mode, where the device is connected to a host PC running WaveForms using a USB port or the Ethernet interface, the Analog Discovery Pro also operates in a Linux mode. In this mode, the ADP boots into a terminal-based Linux distribution from Debian installed on the device. This allows to run automated test scripts written in Python, C, C++, C#, or Visual Basic through the APIs of the WaveForms SDK without a host computer. The Analog Discovery Pro acts then as an embedded device and adds additional flexibility and connectivity. Figure 6 shows an excerpt from a Python script demonstrating an automated test of the analog-to-digital converter on a Pmod AD5 as an example.
When running automated tests, user-defined functions are exercised for repeating tasks like resetting or closing the used instruments, displaying error messages, and reading data from the SPI. Programmers will also have to define certain keywords and interrupt handlers before using them.
The ADP3450 has four USB ports on the back of the panel that are enabled in Linux Mode. This makes it possible to connect peripherals such as a compatible Wi-Fi dongle or a FAT/FAT32 formatted Flash drive. When scripts are run on the device, data can be stored locally, or streamed over a USB or a wireless interface, for example, to a cloud-based service like ThingSpeak, for storage, display, and manipulation. When running in Linux Mode, the device is accessible through a serial terminal program like PuTTY or TeraTerm. Communication between the device and the host computer is supported through USB, Ethernet, and Wi-Fi. Internet access for remote access or the Internet of Things (IoT) is also possible. Through WaveForms and a connected Flash drive, users can update the on-board Linux, keeping the operating system current. Updated OS-images are provided by Digilent.
With the different methods of automating tasks – math channels, scripts, and Linux mode – the Analog Discovery Pro supports engineers to research, validate, and test the increasingly complex systems and it helps to reduce the design cycle time.