Swept Frequency Magnitude and Phase Measurements with Tektronix MDO34 using MATLAB

Contents

Two manuals, the MDO34 Audio Analyzer User Manual, and Programmer Manual, were used in the preparation of this document and the Rear-Panel and Front-Panel Connector images were take from the User Manual. The preceding links are to local copies of the documents, you may want to check the Tektronix website for more recent versions.

Getting Set Up

Software

The software described here is available on github at: https://github.com/echeever/MDO34GUI

Connect MDO34 to Computer Before Starting MATLAB

This software requires that the MDO34 be connected to your computer via a USB cable before starting MATLAB. The USB connector is on the rear panel of the MDO34 (labeled "5" in the Rear-Panel Connector image at right). MATLAB only checks for devices when it starts, so the MDO34 must be connected beforehand.

Circuit Connections

This document describes how to make measurements of the magnitude and phase response of a circuit or system, hereafter called the device under test, or DUT. It is possible to do this at a single frequency, or at a series of frequencies. It is also possible to make a measurement of the output for a sine wave input.The circuit being measured is refered to as a Device Under Test (DUT) and looks something like the image shown. For this example we will use a resistor and capacitor, but you will likely use a different circuit. The important thing is that there is a single input voltage, and a single output voltage.

To generate the input voltage, we use the Arbitrary Function Generator, or AFG (labeled "1" in the rear panel image shown above). The connector for this is on the rear panel of the MDO34. We connect the AFG to "Vin" on the DUT. Now we have to measure Vin and Vout. To do this we connect Vin to Channel 1 of ths MDO34, and we connect Vout to Channel 3. This is shown schematically below.

The three symbols, ⊙, represent the three BNC connectors for the AFG, Channel 1, and Channel 3. The outer circle is ground, the inner dot is the signal connection. Note:

MATLAB Interface

Remember, the MDO34 must be turned on before you start MATLAB. Start the MATLAB App "MDO34 Signal Analyzer" available on github (see address above). If all works well you should see a screen like the one below.

Measurements 

Measurement in the time domain of a sinusoidal signal at a single frequency:

Make sure the switch on the left is set to the "Scope" position, and that the "Sine" option is chosen for input in the GUI.

The AFG generates a sine wave. It is measured on Vin (the yellow line), and Vout is also shown (the red line). By default the frequency is 100 Hz (it can be between 1 and 100,000 Hz). The app also measures and displays the ration of the magnitude of Vout divided by that of Vin (as a raw number, and in dB). It also measures the phase difference between the two. You can change the frequency to suit your needs, and Vin and Vout will be measured at the new frequency.

Note that if you change your circuit, you will have to hit the "Go" button to collect the new data.

You can save the data by hitting the "Save" button. The default file name is "myScopeData.mat," but you can change it to whatever you want.

To load the data into MATLAB and plot it, enter the following in the Command Window:

>> load myScopeData % the variables loaded are the vectors t, Vin, and Vout, and the frequency, f.
>> plot(t,Vin,t,Vout); 
>> xlabel('Time');
>> ylabel('Vin, Vout');
>> title(sprintf('Scope Data, f=%g Hz', f));
>> legend({'Vin' 'Vout'});
		

This yields the following plot (using the circuit shown as DUT, above, with R1=1000Ω, C1=0.05μF)

Measurement in the time domain of a square wave signal:

To make the input a square wave select the radio button for the "Input" to be "Square." Everything works as before, except magnitude and phase are not displayed. (The circuit used was the DUT, above, with R1=1000Ω, C1=0.05μF)

To make a measurement with a square wave input, choose "Time" as the Analysis type, the frequency of the input signal, the length of the acquisition, and make sure "Square Wave" is selected. Hit "Get Data".

Bode Plot (swept frequency)Measurement:

Put the toggle button to "Sweep."

Enter the start and stop frequencies and the number of points per decand and hit the "Go" button. The measurement can take some time (over a minute). If low frequencies are involved it takes even longer because it is necessary to let the system reach equilibrium (tens of cycles) before making a measurement. The final output looks like the one shown (using the circuit shown as DUT, above, with R1=1000Ω, C1=0.05μF).

To make a frequency domain measurement (i.e., a Bode plot), select the "Frequency" radio button, select the start frequency, the stop frequency and the number of data points, then hit the "Get Data" button. The resulting screen will look something like the one below (the actual results will depond on the DUT). The magnitude and phase are shown on the same graph, with the scale for the magnitude plot on the left and that for the phase on the right.

>> load mySweepData       % the variables loaded are the vectors f, mag and phs.
>> semilogx(f,mag)
>> xlabel('Freq. (Hz)')
>> ylabel('|Vout|/|Vin|)
>> ylabel('|Vout|/|Vin|')
>> title('|Vout|/|Vin| vs f')
		

Note that the variable mag is the numeric ratio of |Vout|/|Vin|, not the dB ratio.

>> load mySweepData
>> semilogx(f,mag)
>> xlabel('Freq. (Hz)')
>> ylabel('|Vout|/|Vin|)
>> ylabel('|Vout|/|Vin|')
>> title('|Vout|/|Vin| vs f')
		

>> semilogx(f,phs)
>> xlabel('Freq. (Hz)')
>> ylabel('Phase, \theta, \degree')
>> ylabel('Phase, \theta, degrees (^o)')
>> title('Phase, \theta, degrees (^o) vs f')
		

To show together (i.e., a Bode plot) use subplots.

>> subplot(2,1,1)
>> semilogx(f,db(mag))
>> ylabel('Mag (dB)');
>> title('Bode Plot')
>> grid on
>> subplot(2,1,2);
>> semilogx(f,phs);
>> ylabel('Phase (^o)');
>> xlabel('Freq. (Hz)')
>> grid on
		

Caveats

Notes:

Waveforms in App may appear different than waveforms on MDO34

The image on the left is a screenshot from the MDO34, and the image on the right is the corresponding screen as shown on the App. The reason they appear to be very different is that the oscilloscope uses separate scales for the two waveforms (500 mV/div for Vin, and 7.8 mV/div for Vout), while the App uses the same scale for both.