This article explains how to record a macro and how to use it within Python and MATLAB environments to automate certain evaluation tasks without having to develop any complex software controller code.
Evaluation boards (EVBs), along with their accompanying software, can easily evaluate the performance of Analog Devices products with their plug and play capability. Their graphical user interface (GUI) provides an intuitive means to manually configure and communicate with the device. However, in more complex products, sweeping across all the product’s bells and whistles while evaluating all the available features may become time consuming if these repetitive tasks are not automated.
This article explains how to record a macro and how to use it within Python and MATLAB environments to automate certain evaluation tasks without having to develop any complex software controller code. The AD7380 and AD7606C-16 examples used in this article automate all the user interaction such that they sweep through many different configurations and launch conversions, then export the results. These examples are used in the article to automate the evaluation of the performance benefits that an oversampling digital filter brings to an analog-to-digital converter (ADC). While this article focuses on the AD7380 and AD7606C-16, the information in this article can also apply to other ADI products and applications.
Introduction
Within the ACE platform, each product features a plug-in that eases the device configuration by accessing the device register map through clean, easily navigable GUI.
Following the ADC example, ACE normally displays the raw data in the form of a waveform or histogram and calculates AC performance metrics like SNR or THD through FFTs. This article shows how to automate all these procedures without the need for software development.
Figure 1. A block diagram of an evaluation board’s hardware and software interaction, including ACE to Python/MATLAB communication.
ACE Plug-Ins
Figure 2 shows the AD7380 plug-in chip view where several buttons are offered to easily configure the device:
click for full size image
Figure 2. The AD7380’s ACE plug-in chip view.
Figure 3 shows the AD7606C-16 plug-in chip view where several buttons, highlighted with darker blue color, can be used among others to:
click for full size image
Figure 3. The AD7606C-16’s ACE plug-in chip view.
While the previous examples use the AD7380 and AD7606C-16, the scope of this article is not just these products, but everything related to working with ACE and automating repetitive tasks. Every ACE plug-in will have its own GUI layout. However, as the products grow in complexity and more features are added (for example, diagnostics, calibrations, etc.), the more complex and tedious it becomes to test all these features manually. ACE remote control offers the ability to set or sweep parameters to, for example, sweep the oversampling ratio and measure how the noise performance improves.
Setting Up ACE Remote Control
Before starting to create code to control ACE remotely, the communication with ACE needs to be established by following these steps:
click for full size image
Figure 4. Setting up communication with ACE.
Recording a Macro and Generating Scripts
ACE has a Macro Tools menu to record configuration and device interaction steps by putting them into a macro file. Once a macro is generated, it can then be used to automatically repeat all the steps at once. The following steps explain how to generate a macro:
As an example, while recording the macro, the user configures the oversampling ratio and the resolution mode, just by using the buttons explained in Figure 2. The Command window will look like Figure 5.
click for full size image
Figure 5. Command window and macro tools.
In this window, all the steps recorded can be reviewed and even skip/break any unwanted autogenerated step, before exporting the whole program into a selectable language script, as highlighted in red in Figure 5.
Once a macro file has been recorded, it can then be saved and played again to repeat the previously performed steps. ACE has a built-in feature to generate scripts that perform the recorded actions in a supported language of choice. So, following the previous list, the next steps will be:
This code can then be imported into an IDE for execution. Using this code as the base, add additional features like instrument control to have an automated test bench for measurements.[2] Visual Studio Code or MATLAB is used on the examples displayed in the next sections, and the examples will just use the product evaluation board to perform noise analysis, without any extra piece of equipment. In order to find code examples for manipulating, storing, or plotting the data gathered, as shown in the next couple of sections, visit wiki.analog.com and search for the evaluation board of interest.
click for full size image
Figure 6. An ACE generated code editor using Python language.
Automate Evaluation Tasks with Python
The.py file generated in the previous section allows for easily launching and repeating a series of previously recorded actions. Furthermore, even greater benefits come by editing these scripts and automating certain tasks. Following the previous example where the oversampling ratio and resolution were set in the AD7380 ACE plug-in, the generated macro is edited to allow input parameters, as shown in Figure 7. Note that, by default, these macros are called execute_macro(), but this name can be changed to a more descriptive name.
click for full size image
Figure 7. Edit the Python function in order to use input parameters.
This macro can now be called inside for a loop, sweeping the oversampling ratio values and seeing how the noise performance improves as the oversampling ratio increases, as well as seeing the benefits of enabling two extra bits of resolution.
click for full size image
Figure 8. These instructions are for a loop that sweeps the oversampling ratio and turns on and off the two extra bits of resolution.
As a result, the Python example code accesses the exported data files, reads the SNR data measured by the ACE plug-in, and reports it through the serial monitor. As shown in Table 1, oversampling improves noise performance[3] but, at a certain point, two extra bits of resolution are needed in order to see the real benefit where AD7380 is shown as an 18-bit word instead of 16-bit.
Table 1. AD7380’s SNR vs. Oversampling Ratio
OSR |
Dynamic Range (Normal Resolution) |
Dynamic Range (Boost Resolution, 18-Bit) |
1 | 90.8 dB | 90.8 dB |
2 | 92.6 dB | 93.6 dB |
4 | 94.3 dB | 96.5 dB |
8 | 95.8 dB | 99.2 dB |
16 | 96.3 dB | 100.4 dB |
32 | 96.5 dB | 100.5 dB |
Automate Evaluation Tasks with MATLAB
Like the Python example, the autogenerated code can be exported also for MATLAB, generating an.m file in this case. Here, macros are defined as a function, but these can also be edited to allow input parameters. The following MATLAB examples use the AD7606C-16 board instead.
Again, the benefits of AD7606C-16’s oversampling can easily be evaluated through automating ACE. Figure 9 shows a MATLAB function, edited to accept parameters like the throughput, number of samples, interface type (serial or parallel), the reference source (internal or external), oversampling ratio, number of digital lines, or the analog input range.
click for full size image
Figure 9. Edit the MATLAB function in order to use input parameters.
This particular function could be used within the main code in order to quickly launch the data capture different configurations to easily perform several AD7606C-16 comparisons like:
And many more. Note that this is just the AD7606C-16 example; depending on the product under evaluation, many different performance evaluation needs may arise.
A good hand of AD7606C-16 can be found at wiki.analog.com,[4] with the source code available. This shows how to code the macros and also gives examples to postprocess the data. The OversamplingSweep.m example sweeps the oversampling ratio and plots a histogram of codes for each value. As shown in Figure 10, the larger the oversampling ratio, the narrower the histogram of codes. Table 2 also shows how the peak-to-peak distribution of codes reduces with oversampling.
Table 2. AD7606C-16’s Distribution of Codes vs. Oversampling Ratio
OSR | Peak-to-Peak (LSBs) |
1 | 16 |
2 | 13 |
4 | 12 |
8 | 10 |
16 | 7 |
32 | 6 |
64 | 4 |
128 | 4 |
256 | 2 |
click for full size image
Figure 10. Histograms of codes show how the noise performance improves with the oversampling ratio. A simple script allows to sweep across the many oversampling ratio options available (up to 256).
Conclusion
The newer ACE platform, the framework for the latest evaluation board’s software, is an advantageous tool for any hardware designer eager to speed up the ADI product’s evaluation work because of the capability of recording macros. These macros enable test automation, through industry known programming languages such as Python or MATLAB. Automating these tasks, in turn, enables faster product evaluation and selection phase, resulting on an improvement in time to market and shortening hardware design cycles. Further support can always be found, for this and other topics, in EngineerZone™, and more remote control examples can be found at wiki.analog.com.
References
[1] “Analysis | Control | Evaluation (ACE) Software.” Analog Devices, Inc.
[2] “AD5791 ACE Remote Control.” Analog Devices, Inc., February 2020.
[3] Jonathan Colao. “Fast Reacting Optical Encoder Feedback System for Miniature Motor Driven Applications.” Analog Dialogue, Vo. 54, No. 2, April 2020.
[4] “AD7606B/C ACE Remote Control.” Analog Devices, Inc., February 2021.
Note: Figures and charts are courtesy of Analog Devices.
This article was originally published on Embedded.
Lluis Beltran Gil received his B.S. degree in electronics engineering in 2009 and in industrial engineering in 2012, both from the Universitat Politècnica de València, UPV (Technical University of Valencia). After graduation, Lluis joined Analog Devices in 2013 as an applications engineer in the Precision Converter Group in Limerick. Currently, Lluis is working on the SAR ADC Applications Team within the Instrumentation BU, and he is based in Valencia, Spain, where he also received his M.Sc. degree in electronics engineering from Universitat de València, UV (University of Valencia).