# Create high-performance stimulus test systems using MATLAB and arbitrary waveform generators

Chris Loberg
-April 05, 2013

One of the more challenging tasks facing test engineers is the creation of stimulus signals to exercise a PCB prototype or silicon turn, or to define complex high-frequency modulated signals for RF technologies. While a benchtop full of pulse, function, modulation and RF generators is one approach, direct synthesis signal generation using an arbitrary waveform generator (AWG) offers more flexibility, repeatability and measurement accuracy.

The flexibility results from the way waveforms are generated -- directly from the memory stored in the AWG – making them easily manipulated to meet an endless variety of application and test needs. The sampling-based architecture of an AWG essentially reverses what a digitizing oscilloscope does. Whereas the oscilloscope acquires sample points from analog waveforms, the arbitrary waveform generator reconstructs analog waveforms from stored sample points (ie, DACs vs ADCs). These samples can define essentially any waveform, from sine waves to serial digital pulses.

Many traditional signal-generation instruments produce one type of waveform – say, a sine wave – and rely on external modulators to process the signal further. In contrast, an AWG uses direct digital synthesis to produce a signal that incorporates required modulation characteristics or transmission path effects such as jitter, noise, intersymbol interference (ISI), and so forth. The signaling characteristics can be defined and constructed using a variety of software tools.

AWGs, like oscilloscopes, are keeping up with the rapid advances in speeds and complexity occurring across the electronics and RF landscape. The latest AWGs offer the high sample rate, long waveform memory, deep dynamic range and resolution necessary to support even the most demanding signal generation requirements in defense electronics, high-speed serial, optical networking and advanced research.

One of the most important banner specs in an AWG is sample rate. Just last year, sample rates topped out at around 24 gigasamples per second (GS/s). Now, however, AWGs are available with a 50 GS/s sample rate. This means that in RF applications an AWG can be used to create complex wideband signals up to 20 GHz. In high-speed serial applications, today’s 50 GS/s AWGs can be used to create serial streams up to 12.5 Gb/s. In optical applications, this same 50 GS/s AWG has the speed to generate high baud rate baseband signals, while also having the vertical resolution to handle complex modulations, such as OFDM and higher order QAM formats.

The growing popularity of AWGs as a stimulus source for a variety of test and measurement applications is due to a number of inherent advantages compared to alternatives, including:

• Stored signal information or digital samples can be modified in hundreds of ways: filtered, convolved, time-shifted, modulated and much more.

• The output frequency can be changed without altering the waveform content by changing the frequency of the sample clock.

• Aberrant characteristics (such as transients or dropouts) can be added anywhere in the output waveform stream. This is useful for providing “real-world” stresses like sinusoidal jitter during prototype validation, for example.

• Direct digital synthesis techniques can be used in conjunction with design (modeling) tools to simulate component, channel and/or system performance.

• Software-based editing tools simplify the process of developing and modifying waveforms.

With the need to design ever more complex signals, software-based tools have become the preferred means of creating waveforms. The more comprehensive software tools offer the ability to archive and re-use code, to compute almost any wave shape from math functions, and to model the resulting waveform. There are several kinds of waveform creation tools that range from simplest to advanced.

Below is an overview of some available options followed by a more detailed example based on MATLAB.

Most AWGs include a set of basic waveform files for recall into waveform memory. These waveforms are usually derived directly from simple math functions such as sine equations. Other basic waveforms include signal shapes like triangles, ramps, and square waves. The onboard functions are a convenient way to perform “signal present” checks on both the AWG and devices attached to it, and they may suffice for other simple tests.

Vendors often also offer a basic suite of waveform creation and editing tools designed to run on Windows computing platforms or within the instrument itself. Figure 1 shows an equation editor being used to create a sine wave.

The equation window (upper left) contains the actual equation and other details. Specifically, the equation is as follows:

#Here w = 2*pi*10^4*t

#The Freq of the equation F= 1/((points/cycle) * clock)

#In this equation Freq is 1/1000*100ns = 10KHz i.e. 10^4

#View the waveform with the settings Points: 1K,SR,10MS/s

Range(0us, 100us)

Note that most of the text consists of comments; the operative function is simply “sin(w).” Once the basic waveform is complete, drawing tools that make it possible to modify the simplistic sine shape with intentional distortion or aberrations.

Specialized software is also available for specific applications such as serial data. Such software enables high speed serial data designers to develop waveforms with specific amounts of Random, Periodic or Duty Cycle Dependent (DCD) jitter software components or to create channel properties such as pre-emphasis, ISI, noise and equalization. It also allows for creation of spread spectrum-enabled signals. With the combination of signal generation software and an AWG, designers can stress, characterize and perform compliance test on serial data receivers and related components.

MATLAB, the highly popular software toolset from Mathworks, gives engineers comprehensive math, analysis, and DSP functions. MATLAB is a high-level mathematics-based language and interactive environment designed to carry out compute-intensive tasks faster than general-purpose programming languages such as C, C++, and others. MATLAB includes tools that enable designers to calculate and preview complex waveforms that carry, for example, modulation, jitter or distortion.

MATLAB’s instrument control toolbox facilitates communication with instruments (including signal generators) directly from MATLAB. The toolbox supports GPIB, VISA, TCP/IP, and UDP communication protocols, among others. Once communication has been established, between MATLAB and the AWG, the tools are straightforward and easy to use, with a small, optimized instruction set.

The previous code example involved in generating a basic sine wave using a two-line “program” that simply stated the range and called the function. With MATLAB and other tools of its kind, complex waveforms can be designed. Waveforms “enhanced” with modulation, distortion, transients and jitter are at the core of stress testing. While programming such signals will likely require more than two lines of code, the process need not be intimidating, as the following example will illustrate. The “%” sign that precedes the comment lines is a MATLAB convention. Be sure to consult MATLAB documentation for specific commands and their qualifiers. The follow example is for use with a Tektronix AWG, but the process is similar for any AWG you are likely to encounter.

%This sample shows how to connect to an AWG to create a linear sweep waveform

%////////////////////////////////////////////////////////////////

%// Parameters you can change

%////////////////////////////////////////////////////////////////

clock = 10e+9; %// AWG clock

fc = 1.25e+9; %// Center frequency

pd = 4e-6; %// sweep period

fs = -4.5e6; %// starting frequency

fe = 4.5e+6; %// ending frequency

len = pd * clock; %Waveform length

t = (0:len-1)/clock; %Sample interval

The action items in this segment set the instrument clock frequency and the center frequency as well as the sweep frequencies. The desired waveform is an RF chirp that sweeps about a center frequency of 1.25 GHz. Values are expressed in conventional engineering notation, where “e+9,” for example, signifies a multiplier of 10

%Create a sample pulse waveform with I & Q

i = cos(2*pi*fs*t + 2*pi*(fe-fs)*(((t.^2)/2)/pd));

q = sin(2*pi*fs*t + 2*pi*(fe-fs)*(((t.^2)/2)/pd));

%Create IF waveform

Waveform = i .* cos(2*pi*fc*t) - q .* sin(2*pi*fc*t);

%Plot Waveform

plot(Waveform)

This is the math-intensive step. The terms set up in Step 1 are entered into equations that define the in-phase (I) component using a cosine equation and the quadrature (Q) component using a sine equation. Next, an array named “Waveform” is calculated based on the combination of IQ terms. And lastly, the array known as Waveform is plotted. This is the actual IF waveform.

%Initialize the driver and connect to the instrument using Visa calls

%Use this for LAN, with your IP address

%[sess,msg]=NewSession('TCPIP::xxx.xxx.xxx.xxx::INSTR','LAN');

%Use this for GPIB, with your GPIB address

[sess,msg]=NewSession('GPIB0::01::INSTR','GPIB');

%Reset the instrument.

Write(sess,'*RST');

In this step, you make the first contact with the instrument using either TCP/IP or GPIB protocols. This example segment opens a new communication session with an AWG at a particular GPIB address. Note that an equivalent line for an instrument on a LAN has been included, although disabled by a comment symbol. The “Write” command in the last line resets the instrument. Unlike segments 1 and 2 above, which are application-specific, this is a good general-purpose code segment suitable for almost every MATLAB session with the AWG.

>>Next Page (on tmworld.com)

The flexibility results from the way waveforms are generated -- directly from the memory stored in the AWG – making them easily manipulated to meet an endless variety of application and test needs. The sampling-based architecture of an AWG essentially reverses what a digitizing oscilloscope does. Whereas the oscilloscope acquires sample points from analog waveforms, the arbitrary waveform generator reconstructs analog waveforms from stored sample points (ie, DACs vs ADCs). These samples can define essentially any waveform, from sine waves to serial digital pulses.

Many traditional signal-generation instruments produce one type of waveform – say, a sine wave – and rely on external modulators to process the signal further. In contrast, an AWG uses direct digital synthesis to produce a signal that incorporates required modulation characteristics or transmission path effects such as jitter, noise, intersymbol interference (ISI), and so forth. The signaling characteristics can be defined and constructed using a variety of software tools.

AWGs, like oscilloscopes, are keeping up with the rapid advances in speeds and complexity occurring across the electronics and RF landscape. The latest AWGs offer the high sample rate, long waveform memory, deep dynamic range and resolution necessary to support even the most demanding signal generation requirements in defense electronics, high-speed serial, optical networking and advanced research.

One of the most important banner specs in an AWG is sample rate. Just last year, sample rates topped out at around 24 gigasamples per second (GS/s). Now, however, AWGs are available with a 50 GS/s sample rate. This means that in RF applications an AWG can be used to create complex wideband signals up to 20 GHz. In high-speed serial applications, today’s 50 GS/s AWGs can be used to create serial streams up to 12.5 Gb/s. In optical applications, this same 50 GS/s AWG has the speed to generate high baud rate baseband signals, while also having the vertical resolution to handle complex modulations, such as OFDM and higher order QAM formats.

The growing popularity of AWGs as a stimulus source for a variety of test and measurement applications is due to a number of inherent advantages compared to alternatives, including:

• Stored signal information or digital samples can be modified in hundreds of ways: filtered, convolved, time-shifted, modulated and much more.

• The output frequency can be changed without altering the waveform content by changing the frequency of the sample clock.

• Aberrant characteristics (such as transients or dropouts) can be added anywhere in the output waveform stream. This is useful for providing “real-world” stresses like sinusoidal jitter during prototype validation, for example.

• Direct digital synthesis techniques can be used in conjunction with design (modeling) tools to simulate component, channel and/or system performance.

• Software-based editing tools simplify the process of developing and modifying waveforms.

**Creating Waveforms**With the need to design ever more complex signals, software-based tools have become the preferred means of creating waveforms. The more comprehensive software tools offer the ability to archive and re-use code, to compute almost any wave shape from math functions, and to model the resulting waveform. There are several kinds of waveform creation tools that range from simplest to advanced.

Below is an overview of some available options followed by a more detailed example based on MATLAB.

Most AWGs include a set of basic waveform files for recall into waveform memory. These waveforms are usually derived directly from simple math functions such as sine equations. Other basic waveforms include signal shapes like triangles, ramps, and square waves. The onboard functions are a convenient way to perform “signal present” checks on both the AWG and devices attached to it, and they may suffice for other simple tests.

Vendors often also offer a basic suite of waveform creation and editing tools designed to run on Windows computing platforms or within the instrument itself. Figure 1 shows an equation editor being used to create a sine wave.

**Figure 1. A standard AWG waveform tool allows for fast creation of waveform, such as a sine wave shown here.**The equation window (upper left) contains the actual equation and other details. Specifically, the equation is as follows:

#Here w = 2*pi*10^4*t

#The Freq of the equation F= 1/((points/cycle) * clock)

#In this equation Freq is 1/1000*100ns = 10KHz i.e. 10^4

#View the waveform with the settings Points: 1K,SR,10MS/s

Range(0us, 100us)

Note that most of the text consists of comments; the operative function is simply “sin(w).” Once the basic waveform is complete, drawing tools that make it possible to modify the simplistic sine shape with intentional distortion or aberrations.

Specialized software is also available for specific applications such as serial data. Such software enables high speed serial data designers to develop waveforms with specific amounts of Random, Periodic or Duty Cycle Dependent (DCD) jitter software components or to create channel properties such as pre-emphasis, ISI, noise and equalization. It also allows for creation of spread spectrum-enabled signals. With the combination of signal generation software and an AWG, designers can stress, characterize and perform compliance test on serial data receivers and related components.

**Using MATLAB**MATLAB, the highly popular software toolset from Mathworks, gives engineers comprehensive math, analysis, and DSP functions. MATLAB is a high-level mathematics-based language and interactive environment designed to carry out compute-intensive tasks faster than general-purpose programming languages such as C, C++, and others. MATLAB includes tools that enable designers to calculate and preview complex waveforms that carry, for example, modulation, jitter or distortion.

MATLAB’s instrument control toolbox facilitates communication with instruments (including signal generators) directly from MATLAB. The toolbox supports GPIB, VISA, TCP/IP, and UDP communication protocols, among others. Once communication has been established, between MATLAB and the AWG, the tools are straightforward and easy to use, with a small, optimized instruction set.

Creating a Waveform with MATLABCreating a Waveform with MATLAB

The previous code example involved in generating a basic sine wave using a two-line “program” that simply stated the range and called the function. With MATLAB and other tools of its kind, complex waveforms can be designed. Waveforms “enhanced” with modulation, distortion, transients and jitter are at the core of stress testing. While programming such signals will likely require more than two lines of code, the process need not be intimidating, as the following example will illustrate. The “%” sign that precedes the comment lines is a MATLAB convention. Be sure to consult MATLAB documentation for specific commands and their qualifiers. The follow example is for use with a Tektronix AWG, but the process is similar for any AWG you are likely to encounter.

**1. Specify the waveform characteristics**%This sample shows how to connect to an AWG to create a linear sweep waveform

%////////////////////////////////////////////////////////////////

%// Parameters you can change

%////////////////////////////////////////////////////////////////

clock = 10e+9; %// AWG clock

fc = 1.25e+9; %// Center frequency

pd = 4e-6; %// sweep period

fs = -4.5e6; %// starting frequency

fe = 4.5e+6; %// ending frequency

len = pd * clock; %Waveform length

t = (0:len-1)/clock; %Sample interval

The action items in this segment set the instrument clock frequency and the center frequency as well as the sweep frequencies. The desired waveform is an RF chirp that sweeps about a center frequency of 1.25 GHz. Values are expressed in conventional engineering notation, where “e+9,” for example, signifies a multiplier of 10

^{9}. Thus the center frequency fc will be 1.25 x 10^{9}, or 1.25 GHz. The length of the sweep will be the product of the period (4e-6) and the clock (10e+9).**2. Generate the waveforms**%Create a sample pulse waveform with I & Q

i = cos(2*pi*fs*t + 2*pi*(fe-fs)*(((t.^2)/2)/pd));

q = sin(2*pi*fs*t + 2*pi*(fe-fs)*(((t.^2)/2)/pd));

%Create IF waveform

Waveform = i .* cos(2*pi*fc*t) - q .* sin(2*pi*fc*t);

%Plot Waveform

plot(Waveform)

This is the math-intensive step. The terms set up in Step 1 are entered into equations that define the in-phase (I) component using a cosine equation and the quadrature (Q) component using a sine equation. Next, an array named “Waveform” is calculated based on the combination of IQ terms. And lastly, the array known as Waveform is plotted. This is the actual IF waveform.

**3. Initialize and connect**%Initialize the driver and connect to the instrument using Visa calls

%Use this for LAN, with your IP address

%[sess,msg]=NewSession('TCPIP::xxx.xxx.xxx.xxx::INSTR','LAN');

%Use this for GPIB, with your GPIB address

[sess,msg]=NewSession('GPIB0::01::INSTR','GPIB');

%Reset the instrument.

Write(sess,'*RST');

In this step, you make the first contact with the instrument using either TCP/IP or GPIB protocols. This example segment opens a new communication session with an AWG at a particular GPIB address. Note that an equivalent line for an instrument on a LAN has been included, although disabled by a comment symbol. The “Write” command in the last line resets the instrument. Unlike segments 1 and 2 above, which are application-specific, this is a good general-purpose code segment suitable for almost every MATLAB session with the AWG.

>>Next Page (on tmworld.com)

EM simulation tools only go so far

Try an oscilloscope for under $200

Simple tester checks Christmas-tree lights

Sensor basics: Types, functions and applications

Thermocouples: Simple but misunderstood

Eye Diagram Basics: Reading and applying eye diagrams

Currently no items

FEATURED RESOURCES