Monday, October 22, 2012

Taking Advantage of Double and Triple Modulation in a Two Channel Waveform Generator

In this post we will look at two modulation capabilities found in some two channel waveform generators that we shall refer to as "Double Modulation" (DM) and "Triple Modulation" (TM). DM and TM give you the ability to create some complex waveforms that are not possible with a single channel generator or, in some cases, with an arbitrary waveform created in external software.

DM is the ability to modulate one of the waveform generator's channels with either the internal modulation engine or an external source and then modulate the other channel with the first modulated channel. That explanation is a little confusing so lets use a diagram to clarify. The below figure shows a high level diagram of how the two channel waveform generators from Agilent's 33500B series performs DM (33510B, 33520B, 33522B, and the 33522A).

High level overview of how DM is done in two channel waveform generators from the 33500B series
The above figure shows how two channel waveform generators from the 33500B series perform DM in their main FPGA. Notice that there are four independent waveform generation engines in the FPGA. Two waveform engines are used for channel 1 and 2. The other two less capable engines serve as an internal modulation sources for channel 1 and 2. In the figure channel 2 can be modulated by an external source or the channel 2 modulation waveform engine. From there channel 1 would be modulated using channel 2 as the modulation source, the resulting double modulated waveform will be outputted from channel 1.

Let's look at two examples that takes advantage of using double modulation. In the first example we want to simulate a non-ideal 10 MHz clock signal by adding both random jitter and deterministic jitter in the form of duty-cycle dependent jitter. For the random jitter we want 75 ps of RMS jitter. For the duty-cycle dependent jitter we want a 10 KHz square wave. To build this non-ideal clock signal with double modulation using a 33522B waveform generator we first set the waveform on channel 2 for a 10 KHz squarewave, this is the deterministic jitter. We then modulate the channel 2 waveform with random noise using sum modulation (mathematically add the noise signal to the squarewave). We then set channel 1 to our 10 MHz clock signal and phase modulate it with channel 2 to add the jitter. To obtain the desired jitter magnitudes it is balance between adjusting the sum modulation magnitude on channel 2 and the phase magnitude adjust on channel 1. The example non-ideal clock signal was generated and the resulting random and deterministic jitter can be seen in the scope capture below. The figure shows a zoomed-in view of the clock signal's rising edge. The histogram's standard deviation represents the random jitter's RMS value which is 75.07 ps (click on figure to enlarge). The outlying edges that are about 1.5 ns from the ideal edge is the deterministic jitter from the 10 KHz squarewave.

10 MHz clock signal with random and deterministic jitter
Note that if we refer back to the first figure of the FPGA, the example non-ideal clock signal is using three of the four waveform generators engines: main engine channel 1, main engine channel 2, and modulation engine channel 2.

Let's look at another example where we create a four tone signal and use all four waveform engines to achieve TM. Our four tone signal will consist of tone frequencies 15 MHz, 20 MHz, 25 MHz, and 30 MHz. To build the four tone signal we set channel 1 to a 20 MHz sinewave and sum modulate it with a 15 MHz sinewave. For channel 2 the same steps were repeated except 30 MHz and 25 MHz frequencies were used. The Channel Combine feature on the 33522B was used to mathematically add channel 2 to channel 1. The resulting four tone signal can be seen in the figure below.

Note that the TM abilities in a 2 channel waveform generator are not as capable as the DM capabilities since the channels can only be combined or summed together. This can be used for creating a four tone signal like we just saw or for summing an I and Q signal together.

In this blog post we looked at how a two channel waveform can be used to do double modulation and even triple modulation. If you have any personal insights to add to this post use the comments section below. If you have any questions from the post feel free to email me.

Click here for more info on the 33500B family of waveform generators

Monday, October 15, 2012

Creating an Arbitrary Waveform Remotely on a 33500 Series Waveform Generator

In this post we will look at how to send an arbitrary waveform to a 33500A/B series waveform generator using a remote connection. We will use Standard Commands for Programmable Instruments (SCPI) to communicate and send the waveform data to the waveform generator. We will look at two different ways to send the waveform data first the easier but less efficient method of just using ASCII or string characters for the waveform points. The second method, which is more complex but more efficient, is using binary blocks of the waveform data. Finally we will present information on where you can download a MATLAB function that connects and sends arbitrary waveform data to a 33500A/B series waveform generator using a LAN connection.

The following SCPI command examples will work on the following waveform generators: 33521A, 33522A, 33521B, 33522B, 33511B, 33512B. The SCPI commands are in green and the comments describing them are in blue.

SCPI Commands to Configure and Send Waveform to 33500
//Reset the 33500 to power up state
//Clear volatile memory (not needed, just used for completeness)
//Nine waveform points sent to waveform memory, normalized between 1 and -1 (binary block example //discussed later
DATA:ARB myArb, .75, 1, .50, .25, 0, -.25, -.50,-1, -.75
//Wait for command to finish (optional, do not need on waveforms that do not have a lot of points)
//Select the waveform (chan 1) we just sent to volatile memory
//Select Arb waveform mode on the generator
//Store waveform in non-volatile memory if you want to use it again otherwise it will be erased when //generator is turned off
MMEM:STOR:DATA1 "INT:\myArb.arb"
//Set the sample rate of the waveform generator
//Set the amplitude
//Set the amplitude offset
//Turn off filter for step / staircase response. Other filter settings include "Normal" and "Step" (default)
//Set output Z to 50 Ohms
//Turn on the output

Note that depending on the programming language and drivers being used you may have to add a newline character "\n" at the end of each command. The above SCPI commands resulted in the below waveform:

In the above example the waveform data was sent using data points in ASCII or string form. This method works fine for small to medium sized waveforms, but not large waveforms made up of hundred of thousands or millions of points. The two main reasons are long strings take up large amounts of memory and could cause a program to run out of RAM space and the long string causes to large latencies over the remote IO that often lead to connection timeouts. The answer is to send the data in binary blocks. The command for sending a waveform as a binary block of data is: DATA:ARB myArb, #236[36 bytes of your_binary_data];[PMT]. Notice the first part of the command is the same "DATA:ARB arbname," The number immediately after the pound sign tells the generator how long the byte length number is so in the example '2' means that the byte length number is two digits XX. The next numbers (2 digits) is 36, which tells the generator that there are 36 bytes of waveform data. The "PMT" portion of the example is the endline character.

What makes sending binary block waveform data a little more complex compared to the string example is the waveform data has to be converted into binary data. The details for converting double or float values to binary data differs from programming language to programming language. The following example is done in MATLAB. In this example only the command for sending the waveform data will be shown, the same setup and configuration commands used in the first example would be used here as well.

Sending Waveform using Binary Block Data in MATLAB
%Store waveform in array called wPoints
wPoints = [ .75 1 .50 .25 0 -.25 -.50 -1 -.75];
%Since default is double convert wPoint to single precision and convert to column vector
wPoints = single(wPoints');
%Tells generator that least-significant byte (LSB) of each data point is first. Most computers use this
fprintf(fgen, 'FORM:BORD SWAP');  

%get the length of the waveform data in points in bytes (each points 4 bytes)
iBytes=num2str(length(I) * 4);
%create string header of SCPI command
header= ['SOUR1:DATA:ARB myArb, #' num2str(length(iBytes)) iBytes];
%Convert waveform datapoints to a block of binary data
binblockBytes = typecast(wPoints, 'uint8');  
%combine header and datapoints then send to waveform generator
fwrite(fgen, [header binblockBytes], 'uint8'); 

I created a MATLAB function that connects to a 33500A/B waveform generator via LAN and sends it a waveform from a vector variable. The function is free to download at MATLAB Central using the link provided below or just search on its name "33500 Arbitrary Waveform Function" to find it.

In this post we looked at how to create an arbitrary waveform on the 33500A/B series of waveform generators. We looked at how to send waveform data in string form and binary block form. If you have any questions from this posts please email me and if you have anything to add to this post use the comments section below.

Download MATLAB function to send waveform data to 33500

Click here to download the 33500 series user guide / programming reference

Click here for more information on the 33500B series of waveform generators

Monday, October 8, 2012

How to Calculate Power Supply Accuracy

If we go back a couple decades’ the output level of an instrumentation power supply typically had to be set by turning the supply's analog knob and watching the display of your voltmeter connected to the supply's output to achieve an accurate voltage level. Today that is still true with low end power supplies, but mid range and high performance supplies can deliver an accurate user set voltage level that you can trust. In this post we will take a look at power supply accuracy specs including how to determine a power supply’s voltage level accuracy as well as some other power supply accuracy calculations.

There are typically 5 specifications found on a power supply's data sheet that relate to its voltage level accuracy, they are:
  • Load Effect (Load Regulation): Voltage variations on the supply’s output level caused by changes to the load that the supply is connected to. The error here is caused by the supplies regulation circuitry not able to maintain the exact voltage level after a load change or change in current draw from the supply.
  • Source Effect (Line Regulation): Error on the supply’s set voltage level caused by non-ideal input AC line power. 
  • Programming resolution: When setting a supply’s level, that level is turned into a digital value that is used by a digital to analog converter (DAC). The output of the DAC is used by the supply internally as a reference to set the correct output voltage level. In the digital to analog conversion process there is always quantization error and that is what the programming resolution represents. The higher resolution the DAC (more bits) the less error.
  • Programming Accuracy: This is the key specification that encompasses includes the three just mentioned (load effect, source effect, and prog resolution) as well as parts tolerances such as amplifier drift.
  • Programming Temperature Coefficient: If the power supply is not being operated in its ideal temperature range a temperature coefficient error value is added for every degree out of that range.
As mentioned above, the only specs we need to calculate the supply's output accuracy are the programming accuracy spec, which includes load effect, source effect, and programming resolution, and the programming temperature coefficient spec, but only if we are not in the spec'd ideal temperature range. Of course just like every instrument, the supply's output accuracy cannot be computed until after the spec'd warm-up time which is typically no more than 30 min. Here is what our output accuracy calculation looks like:

Error Tolerance +/- = Prog Accuracy + Temp Coeff (if not in ideal temp range)

The specs will typically be in the form of a static value (such as 4 mV), a percentage of the voltage range, a percentage of the programmed voltage level, or a combination of two of them.

Let's walk through an example calculation using Agilent's N6761A Precision DC Power Module which is part of the N6700 family of modular power supplies. The N6761A is a high performance supply so it will have a high accuracy output level (low error tolerance). Below is a snapshot from the N6761A's data sheet showing the programming accuracy spec as well as other specs. 

For our example we will be operating the N6761A after a 30 min warm-up time at 5 V (low range) with a load pulling 4 A at an environmental temperature of 29 degrees C. Notice in the programming accuracy row that the ideal temperature range is 23 C +/- 5, since we are operating at 29 C we are 1 degree out of the temperature range so we will have to add temp coefficient error to our calculation. The voltage programming accuracy spec for the N6761A in the low range is 0.016% + 1.5 mV. The temperature coefficient spec is 40 ppm + 70 uV. Let's go through the terms of our accuracy calculation:
  • Programming accuracy is 0.016% of programmed value plus 1.5 mV, which is 5*.00016 + .0015 =  2.3 mV
  • Temperature coefficient is 1 degree so 1*(5*30e-6 + 40 uV) = 190 uV 
@ 5 V Err Tolerance is +/- = 2.3 mV + 0.19 mV = 2.49 mV

That is pretty good accuracy for a power supply that is just slightly out of its ideal temperature range! One thing to note from this calculation is that we are assuming that we are looking at the power supply level over some averaged time period lets say 10 power line cycles or 166.7 ms. If we are looking at some instantaneous point on the voltage level of the power supply we can see higher error due to noise. The noise on a supply level is covered in the Output Ripple and Noise or PARD spec on the supply's data sheet. In the above data sheet figure we can see the N6761A has a PARD spec of 4.5 mVpp and 0.35 mVRMS. If we had a high resolution scope we could see the noise on the supply level. If we take an average measurement of the supply level the noise cancels out. 

When working with a supply that has built in measurement capability (like most supplies on the market today) remember that the measurement accuracy is separate from the programming accuracy. Also the measurement accuracy error spec may be worse or larger than the programming accuracy spec. As an example, below is a figure from Agilent's N6741B power supply data sheet. The voltage programming accuracy spec is circled in green and the voltage measurement accuracy is circled in red.

As you can see the voltage measurement accuracy is worse than the voltage programming accuracy. In cases like this it is more accurate to use the programmed voltage level and not the measured voltage value.

In the accuracy calculation we did it was assumed that the supply was being used in constant voltage mode (CV), where the supply regulates the output voltage at a set level and allows the current to fluctuate as the load changes (most common way to use a power supply). What if you are operating the supply in constant current mode (CC), where the supply regulates at a certain current level and the voltage is allowed to fluctuate with the load? The calculation is the same except you use the current specs versus the voltage specs.

In this post we discussed what specs are used to make a power supply output level accuracy calculation. We then walked through an example calculation using Agilent's N6761A precision power module. We also compared measurement accuracy to programming accuracy. If you have any questions from this post feel free to email me and if you have anything to add use the comments section below.

Blog post on Power Supply Resolution versus Accuracy

Monday, October 1, 2012

Free MATLAB Program for Building IQ Baseband Signals

In this post we will take a look at a free MATLAB program called IQ Baseband Builder (IQBB) that is available for free download at MATLAB Central. IQBB program allows you to generate an ideal or non-ideal baseband IQ signal, analyze that signal using various plots, and then download the signal to either a CSV file or one of Agilent's new two channel waveform generators, the 33512B and 33522B.

Back in August Agilent introduced a new family of waveform generators, the 33500B series (click here to view my post on the intro). The 33500B features a new exclusive waveform generation technology called Trueform which delivers the performance specs of a high end waveform generator, but at a much lower price point. For more on Trueform waveform generation technology check my post on it by clicking here. From the 33500B series of waveform generators, the 33522B and 33512B provide excellent solutions for generating baseband IQ signals since they provide two channels that can easily be synchronized.

Let's take a look at an overview of the IQBB's features and capaiblities. Below you will find a screen shot of the IQBB GUI.

The IQBB program creates an IQ signal using digital data (binary ones and zeros), user defined modulation type, and a user defined samples per symbol count. The digital data can either be generated randomly by the program (default) or the user can upload existing digital data via a CSV file. For modulation type, IQBB allows the user to select between 4 to 256 QAM formats (Binary or Gray coding). Once the basis parameters of the IQ signals have been defined, IQBB provides the following features for shaping, distorting, and displaying the resulting IQ baseband signals:
  • Pulse shaping filters including raised cosine, root raised cosine, Gaussian, and rectangular. There are also settings for defining filter parameters such as beta and filter order.
  • The ability to add white noise to the I and Q signals.
  • Phase balance adjust of the signals
  • Amplitude balance adjust of the signals
  • DC offset adjust of the I and Q signal
  • Plots for analyzing the resulting signals including a constellation diagram, eye diagram, frequency domain plot, time domain plot, and filter response plot.
Once the I and Q signals have been generated and analyzed they can be exported to a waveform generator (33512B and 33522B) or a CSV file. The IQBB program uses a LAN connection to export signal data remotely to either the 33512B or 33522B.

Let's look at an example of the 33522B's signal quality using a IQ baseband signal created with the IQBB program. The signal was 64 QAM, 5 samples per symbol, and had a raised cosine impulse response. The resulting signal was captured with a wideband scope and analyzed with Agilent's 89600 Vector Signal Analysis software. A screen shot from the software is shown below.

With Trueform technology the 33522B was able to deliver a 64 QAM baseband signal with only 0.3 % error vector magnitude! Notice too that the phase error is in milli-degrees and the magnitude error is in mV.

In this post we look at a free MATLAB called IQ Baseband Builder that allows you to generate ideal or non-ideal IQ baseband signals. The program can connect remotely to an 33522B or 33512B waveform generators and export the software IQ signals so they can be generated in hardware. If you have any questions from this post send me an email and if you have anything to add use the comments section below.

For more info on the 33500B family of waveform generators click here