real time oscilloscope spectrum analyzer and matlab

12
Traditionally, the analog and digital IC design engineers like to read electrical signals in the time domain using measurement instruments like real time oscilloscopes while RF and microwave engineers like to study signals in the frequency domain using instruments like spectrum analyzers. There are also EMC/ EMI, signal integrity engineers who need to understand the signal in both domains to understand the system characteristics and get their job well done. Nowadays, technology advancement like high speed SerDes technologies relentlessly pushing the signal transmitting through the ICs in a faster and faster data rate with shorter and shorter rise and fall time, requiring the IC designers to understand the signal in both time and frequency domains to avoid unpleasant surprises. This article is trying to understand a typical clock- like signal measured and interpreted in different domains and try to correlate the different results produced from different sources such as measurements, analytical math equations or Matlab functions bridged by Discrete Fourier Transforms(DFT). 1. Theoretical backgrounds A 100MHz square-wave can be represented either in time domain as shown in Figure 1 using a real time scope or in frequency domain as shown in Figure 2 using scope “FFT math function” or in Figure 3 using spectrum analyzer.

Upload: shujun-pan

Post on 26-Mar-2015

679 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Real Time Oscilloscope Spectrum Analyzer and Matlab

Traditionally, the analog and digital IC

design engineers like to read electrical

signals in the time domain using

measurement instruments like real time

oscilloscopes while RF and microwave

engineers like to study signals in the

frequency domain using instruments like

spectrum analyzers. There are also EMC/

EMI, signal integrity engineers who need to

understand the signal in both domains to

understand the system characteristics and

get their job well done. Nowadays, technology advancement like high speed SerDes technologies

relentlessly pushing the signal transmitting through the ICs in a faster and faster data rate with shorter

and shorter rise and fall time, requiring the IC designers to understand the signal in both time and

frequency domains to avoid unpleasant surprises. This article is trying to understand a typical clock-

like signal measured and interpreted in different domains and try to correlate the different results

produced from different sources such as measurements, analytical math equations or Matlab functions

bridged by Discrete Fourier Transforms(DFT).

1. Theoretical backgrounds

A 100MHz square-wave can be represented either in time domain as shown in Figure 1 using a real

time scope or in frequency domain as shown in Figure 2 using scope “FFT math function” or in Figure

3 using spectrum analyzer.

Page 2: Real Time Oscilloscope Spectrum Analyzer and Matlab

Figure 1: 100MHz square wave measured using real time scope

Figure 2: 100MHz square wave spectrum using scope FFT function

Figure 3: 100MHz square wave spectrum measurement using spectrum analyzer

From measurement perspective, the time domain representation is simply a digitized signal amplitude

versus discrete time sequences which can be mathematically expressed as while its frequency

Page 3: Real Time Oscilloscope Spectrum Analyzer and Matlab

domain representation can be a power spectrum plot versus discrete frequency points expressed as

and they can be converted to each other through DFT and IDFT. Given a time sequence

with , its DFT is defined as:

, (1)

and the IDFT is defined as:

, (2)

The calculated DFT coefficients are complex numbers and are often post-processed

and presented in terms of amplitude spectrum or power spectrum as was defined in (3) and (4),

respectively.

(3)

(4)

When use the real time scope to capture a record length of time period T and DFT it to obtain its

frequency information, the valid maximum frequency content is decided by the scope sampling rate up

to according to the Nyquist sampling theory and the frequency resolution is decided by the inverse

of the record length . The record length is decided by both the scope sampling rate and the memory

depth used. As was mentioned in [1], they are related to each other through (5):

(5)

Where, is the record length or captured time information period, is the memory depth used or

the sampling points acquired and is the scope sampling rate.

For example, when 400000 points of data is captured for a 100MHz input signal under a sampling

rate of 80GSa/s, the maximum valid frequency content is up to 40GHz( with

). The record length is calculated to be 5us (400kpts/80GSa/s) which, in turn, resulted in a frequency

resolution of 200kHz (1/5us).

2. Application examples

An ideal rectangular pulse train can be expressed using its pulse width , period and amplitude as

for and for the rest. It’s Fourier coefficients can be calculated

Page 4: Real Time Oscilloscope Spectrum Analyzer and Matlab

as:

(6)

However, actual clock-like digital signals usually have certain rise/fall time as shown in Figure 4 whose

analytical representation can be simplified as a trapezoidal waveform(assuming a symmetrical rising

and falling edge) with a linear ramping width of . Accordingly, its Fourier coefficients can be

calculated as:

(7)

In Matlab, DFT coefficients can be calculated using the function , where are

N complex coefficients with the frequency index representing DC and different

harmonics. Since the returned coefficient vector in Matlab has a starting index of 1, the 1st coefficient

, represents the DC at , represents the positive frequency contents

and is folded into . In other words, the returned

coefficient vector [ corresponds to a frequency bin vector of

[ ]. Therefor, in order to plot the spectrum with frequency centered

properly at DC, the frequency bin must be manipulated to shift the negative frequency spectrum left-

wards or using Matlab build-in function .

Figure 4: 100MHz square waveforms

The 100MHz square wave mentioned in session 1 is used as the input signal of which the first 100 UI

Page 5: Real Time Oscilloscope Spectrum Analyzer and Matlab

data was plotted and shown in Figure 5.

Figure 5: 100MHz square waveform 1st 100UI v-t plot

For this waveform, the real time scope FFT function reports a fundamental spectrum power of 6.11dBm while the calculated results from equation (7), assuming a ramping time of 85ps and an amplitude of 1Vpp (according to the measured results shown in Figure 1, the average amplitude is about 1Vpp and 10% ~ 90% rise time is about 76ps resulting in an estimated ramping time of 85ps),

is about 6.08dBm. The results returned by the matlab is about 6.16dBm and the spectrum analyzer reports a value of 6.49dBm as was shown in Figure 3. While all the absolute values obtained through different methods as mentioned above are different, they are quite close to each other. The largest difference is reported by the spectrum analyzer whose results are generally considered as the most accurate one due to its excellent dynamic range. One thing worth mentioning is that the first three methods are all based on the time-domain information to report signal spectrum in frequency domain using FFT while the spectrum analyzer reports the signal spectrum directly in frequency domain based on band-pass filtering to separate different frequency contents. Figure 6 is the double-

sided spectrum plot calculated in Matlab using and equation (4).

Page 6: Real Time Oscilloscope Spectrum Analyzer and Matlab

Figure 6: 100MHz square waveform double-sided spectrum in A closer look at Figure 6 reveals that the fundamental spectrum has a value of about 3.1dBm instead of a value that is slightly larger than 6dBm. This is because both the real time scope and the spectrum analyzer report single-sided-spectrum(SSS) versus positive frequency instead of reporting the double-sided-spectrum(DSS) in both negative and positive frequency range. In order to obtain the SSS from

the DSS, equation (4) must be doubled in value for , thus a 3dB increase in terms of power spectrum as shown in Figure 7.

Page 7: Real Time Oscilloscope Spectrum Analyzer and Matlab

Figure 7: 100MHz square waveform single-sided spectrum in Matlab

In order to compare the Matlab results with those from the scope and the spectrum analyzer, the scope FFT raw data and the spectrum analyzer raw spectrum have been exported and plotted in Matlab

together with the Matlab of the scope measured v-t data. As can be seen from Figure 8 and Figure 9, the results match fairly well with each other in the whole frequency range.

Page 8: Real Time Oscilloscope Spectrum Analyzer and Matlab

Figure 8: 100MHz square waveform spectrum from Matlab and scope FFT

Figure 9: 100MHz square waveform spectrum from Matlab and spectrum analyzer 3. Conclusions

● Oscilloscope measures signals in the time domain displaying voltage as a function of time while

Page 9: Real Time Oscilloscope Spectrum Analyzer and Matlab

spectrum analyzer measures signals in the frequency domain displaying either power spectrum for periodic signals or energy spectrum for time-limited non-periodic signal as a function of frequency.

● Oscilloscope spectrum analysis is based on the time-domain information measured to report signal spectrum in frequency domain using FFT while modern spectrum analyzer reports the signal spectrum directly in frequency domain based on band-pass filtering to separate different frequency contents contained in the signal under test.

● Electrical signals can be represented in both the time domain and the frequency domain which can be transformed into each other using DFT and IDFT assuming its “periodicity”.

● N samples of time information can be transformed into N samples of Fourier

coefficients in the frequency domain using Matlab function as with the returned

coefficient vector index of [ 1 … … ] mapped to the frequency bin index of

[ 0 … - … -1]. Appendix: Sample Matlab source codes for generating Figure 5 ~ 9 % This piece of code takes in v-t waveforms from real-time scope and% calculates the DSS and SSS using FFT% The calculated results are then compared with the results from% real time scope build-in FFT functions and Spectrum Analyzer spectrums% v-t waveform: 100M_400k_200mv_1Vpp.ssf (space separated v-t with format “time amplitude”)% 100MHz square wave with 1Vpp, 80Gsa/s sampling rate and 400k points% at a vertical resolution of 200mV/Div% scope fft spectrum: Scope_FFT.ssf (space separated dBm-f with format “freq power_spectrum”)% SPA spectrum:SPA_100M_1V.ssf (one column power spectrum value only)% Created on: Jan. 2011% By: SJ Pan% Published at: https://sites.google.com/site/smithchart/articles/ clear allclose alla=load('100M_400k_200mv_1Vpp.ssf');t=a(:,1);v=a(:,2);v=v-mean(v);freq=100e6; % 100MHz square waveUI=1/freq/2; % UI in sTs=t(10)-t(9); % sampling periodSaPerUI=UI/Ts; % samples per UIRL=length(v); % sample sizepcent=85e-12/UI; % 85ps rise time % plot the waveform (figure1)

Page 10: Real Time Oscilloscope Spectrum Analyzer and Matlab

figure;plot(t,v);xlabel('Time(s)');ylabel('Amplitude(V)');title('Waveform from real time scope (100MHz/1Vpp 100UI)');axis([0 100*UI 1.1*min(v) 1.1*max(v)]) % plot the DSS (figure2)vfft=fft(v)/RL;fk=[-RL/2+1:1:RL/2]/(RL*Ts); % map the frequency bin to the frequencyvfft_s=fftshift(vfft);pvfft_s=vfft_s.*conj(vfft_s);Pdbm_s=10*log10(pvfft_s/50*1e3);figure;plot(fk,Pdbm_s); % double-sided-spectrumxlabel('Frequency(Hz)');ylabel('DSS power spectrum(dBm)');title('Double-sided spectrum plot');axis([-32e9 32e9 -110 10]) % plot the SSS (figure3)fk=[0:1:RL-1]/(RL*Ts); % map the frequency bin to the frequencypvfft=vfft.*conj(vfft);pvfft(2:RL)=pvfft(2:RL)*2; % change single-sided-spectrum to DSSPdbm=10*log10(pvfft/50*1e3);figure;plot(fk(1:RL/2+1),Pdbm(1:RL/2+1)); % plot DC + positive freqxlabel('Frequency(Hz)');ylabel('SS power spectrum(dBm)');title('Single-sided spectrum plot');axis([fk(1) 32e9 -110 20]) % plot spectrum in smaller span and compare with spectrum analyzer results (figure 4)% 1st, plot calculated results figuresubplot(2,1,2);span=300e6; % span 300MHzfcenter=100e6;idx_c=find(fk>=fcenter,1,'first');idx_start=find(fk>=(fcenter-span/2),1,'first');idx_stop=find(fk>=(fcenter+span/2),1,'first');subplot(2,1,1)plot(fk(idx_start:idx_stop),Pdbm(idx_start:idx_stop)); % double-sided-spectrumhold on[Pmax,idx_max]=max(Pdbm(idx_start:idx_stop));idx_max=idx_max+idx_start-1;

Page 11: Real Time Oscilloscope Spectrum Analyzer and Matlab

plot(fk(idx_max),Pdbm(idx_max),'ro','linewidth',2)text(fk(idx_max),Pdbm(idx_max),sprintf(' %.3f dBm',Pdbm(idx_max)),'HorizontalAlignment','left');xlabel('Frequency(Hz)');ylabel('SSS power spectrum(dBm)');title('Single-sided spectrum calculated from the v-t waveform');axis([fk(idx_start) fk(idx_stop) -100 20])% 2nd, import the spectrum from the spectrum analyzersss_SPA=load('SPA_100M_1V.ssf');subplot(2,1,2)[PmaxSPA,idx_maxSPA]=max(sss_SPA);plot(sss_SPA);hold onplot(idx_maxSPA,PmaxSPA,'ro','linewidth',2)text(idx_maxSPA,PmaxSPA,sprintf(' %.3f dBm',PmaxSPA),'HorizontalAlignment','left');xlabel('Frequency index');ylabel('Power spectrum(dBm)');title('Single-sided spectrum from spectrum analyzer');axis([0 length(sss_SPA) -100 20]) % plot calculated results together with the real time scope. (figure 5)figuresubplot(2,1,1);% plot the calculated SSSfk=[0:1:RL-1]/(RL*Ts); % map the frequency bin to the frequencypvfft=vfft.*conj(vfft);pvfft(2:RL)=pvfft(2:RL)*2; % change single-sided-spectrum to DSSPdbm=10*log10(pvfft/50*1e3);plot(fk(1:RL/2+1),Pdbm(1:RL/2+1)); % plot DC + positive freqxlabel('Frequency(Hz)');ylabel('SS power spectrum(dBm)');title('Single-sided spectrum calaculated from v-t waveform');axis([fk(1) 32e9 -110 20])% plot the exported scope resultsb=load('Scope_FFT.ssf');subplot(2,1,2);plot(b(:,1),b(:,2));xlabel('Frequency(Hz)');ylabel('SSS power spectrum(dBm)');title('Single-sided spectrum exported from scope');axis([fk(1) 32e9 -110 20]) % analytical resultsVe1=dftcn(1,UI,UI*2,pcent*UI,1); %coefficient at F1 using equationV1=max(abs(vfft(2:RL/2+1))); %coefficient at F1 from fftVe1dBm=10*log10((Ve1)^2/50*1e3)+log10(2); % DSS to SSSV1dBm=10*log10((V1)^2/50*1e3)+log10(2);

Page 12: Real Time Oscilloscope Spectrum Analyzer and Matlab

disp(sprintf('\nAnalytical/Matlab fft coefficients at F1: %.3f/%.3fV or %.3f/%.3fdBm(50Ohm/SSS).\n',Ve1,V1,Ve1dBm,V1dBm));