Software wrapper links Matlab to instruments
Martin Rowe, Senior Technical Editor -- Test & Measurement World, 12/1/2007
Matlab is a popular computing environment for electrical engineers. Many use it to analyze data, although they often save the data using another program, then import the data into Matlab. Mike Flaherty, an applications engineer at Agilent Technologies, wanted a direct programming interface from Matlab scripts to generate waveforms with an arbitrary waveform generator (AWG).
Flaherty needed Matlab scripts that generate numerous waveforms, including 7-bit Barker-coded radar pulses, and multitone signals. The software needed to work with two AWGs: one through Ethernet, the other through CompactPCI.
To provide an easy-to-understand programming interface, Agilent engineers developed several Matlab scripts to control the instruments. They used function names such as awg_open and awg_storewaveform.
![]() |
| A Matlab MEX file provides an interface between Matlab and LXI or CompactPCI instrument drivers. |
“The waveform generators are 100% code compatible with this application,” said Flaherty.
Flaherty also developed a user interface that lets users select from a menu of signals, then select specific parameters. Using Matlab and Agilent Vee, he built prototypes of the user interface. He wanted to develop a compiled, stand-alone executable, though. Because Vee is an interpreted language, Agilent engineers ported the GUI and the control code to Microsoft C#. The waveform engine is still Matlab but is compiled and linked to the application when built.
“The key to the application is the Matlab interface,” explained Flaherty. “It communicates through a MEX file to an instrument's IVI-C driver. It passes a resource string to a CompactPCI or Ethernet stack.”




















