0% found this document useful (0 votes)
9 views

Lab 2

This document discusses capturing signals with an oscilloscope and analyzing them using numerical analysis software and spreadsheets. It describes connecting an oscilloscope and voltmeter to capture square and sine waves from a waveform generator and saving the data files. Key measurements of the signals are recorded.

Uploaded by

Eremas Kotipe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lab 2

This document discusses capturing signals with an oscilloscope and analyzing them using numerical analysis software and spreadsheets. It describes connecting an oscilloscope and voltmeter to capture square and sine waves from a waveform generator and saving the data files. Key measurements of the signals are recorded.

Uploaded by

Eremas Kotipe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

ELEX 3525 : Data Communications

2015 Fall Session

Signal Capture and Analysis

Introduction Software

e purpose of this lab is to capture waveforms with a Numerical Analysis Software


digital oscilloscope and analyze the captured signals
using numerical analysis soware and spreadsheets. Numerical analysis soware allows us to carry out a
You’re already familiar with measurements of de- much wider range of signal-processing and analysis
terministic signals such as sine and square waves. than we could do on an oscilloscope.
However, some signals are unpredictable (random) For this lab you we will use Matlab or the free
and we cannot describe them as voltages or currents and largely compatible alternatives FreeMat or Oc-
as functions of time. tave. Many other soware packages, both commer-
However, we can describe their statistics, which are cial and open-source, are also available. Some of
summaries of some relevant feature of the signal such the most popular include Mathematica, Maple, Math-
as the fraction of time it has a certain voltage (the CAD, and R1 .
“probability density”) or the amount of power the sig- All of these programs have high-level language fea-
nal contains at certain frequencies (the “power spec- tures such as support for working with complex vec-
trum”). tors and matrices that allows us to analyze signals
Examples of these random signals include speech with relatively little programming.
and noise sources.
In this lab we will study two deterministic and one Spreadsheets
random signal and measure some of their statistics in-
cluding the probability density. You are probably already familiar with spreadsheets
You will measure the statistics of the three wave- from previous courses. ey are useful for manipu-
forms that can be generated by the lab’s waveform lating and presenting limited amounts of data and for
generator: a square wave, a sine wave, and Gaussian formatting numerical data for reports.
noise: For this lab you can use Microso Excel or Libre-
Office Calc.
WUYEVI :TT

CSV Files
WMRI :TT
Text files contain printable characters that form read-
+EYWWMER able text. On the other hand, “binary” files contain
:VQW data in formats that are only meant to be read and
RSMWI
written by soware.
A common text file format for exchanging nu-
You will capture these waveforms with a digital os-
merical data between programs is called comma-
cilloscope. en you will use Matlab to compute his-
separated values (CSV). Each line of the file corre-
tograms that estimate the probability density func-
sponds to one row of a matrix or table and the values
tions of the waveforms. e histogram data will be
for each column are separated by commas.
imported into a spreadsheet that you will use to plot
Here’s an example of a CSV file with data that could
the histograms, compute the RMS powers from the
be used to fill a table consisting of four columns and
probabilities and compare them to the powers mea-
three rows:
sured using an RMS voltmeter and the oscilloscope’s
1
measurement function. See Wikipedia for a more complete list.

lab2.tex 1
617 :SPXEKI ;EZIJSVQ 617 :SPXEKI ,MWXSKVEQ 617 :SPXEKI

(MKMXEP GWZ GWZ )\GIP


1EXPEF +VETL
WGSTI *MPI *MPI

;EZIJSVQ 617
617 :SPXEKI
+IRIVEXSV :SPXQIXIV

2.6,2.6, 1.3, .006 and only measure the average value of a signal. For
9.7, 1.734e-2, 1.1, 3 these DMMs the voltage reading only corresponds to
-0.3, .87, 0.45, 22 the RMS voltage when the signal is a sine wave.
Set up the waveform generator for a square-wave
Strings can also be included in CSV files by quoting output at a 1 kHz frequency with a 6 Vpp level and
them although in this lab we will restrict ourselves to zero offset.
CSV files with numerical values. Use the ’scope’s Measurement menu to add fre-
quency and Vrms (RMS), Vavg (average) and Vamp
Procedure (peak-to-peak amplitude) voltage measurements to
the display.
Waveform Capture Use the Acquire menu to set the memory Depth to
140 kSamples. Use the Scale control in the Horizontal
As shown below, connect the output of the waveform controls section for a sampling rate of 1 MHz. ese
generator to both Channel 1 of the ’scope and the values will be visible in the status line at the top of the
voltmeter so you can view the waveform and measure display.
its voltage on the DMM simultaneously. e ’scope
Press the Horizontal scale knob to switch to de-
will sample the input signal and digitize it (convert
layed trigger mode. is will show a portion of the
it to a number). e RMS voltmeter will allow you
captured samples. Adjust the horizontal scale so you
to measure the RMS voltage independently of the
can view a few cycles of the square wave:
’scope.

Use the DMM to measure the RMS value of the


Note that the multimeters in the lab are are RMS- waveform. It should match the ’scope measurement
responding. Some DMMs are average-responding value.

2
Plug a flash drive into the connector on the front 0,-1.520000e+00,
1,-1.760000e+00,
of the ’scope. Press the printer icon on the top right 2,-2.040000e+00,
of the panel to capture an image of the display. e 3,-2.240000e+00,
image file name will be displayed briefly.
Use the Storage menu to save the captured data to You can read the waveform data from the CSV
your flash drive. Under “Storage” select CSV for the waveform sample file using the commands:
file type, Channel 1 for the source, “Maximum” for
the Data Depth and enable Parameter Save. s=csvread('Newfile1.csv');
Press Save to select the folder (directory) and file s=s(3:140002,2);
name under which to save the file. If you wish, you
can create a new folder on the flash drive and a new which will read the CSV file and the extract 140,000
file name. rows from the second column starting at the third
Record the date and time, the type of waveform, row. You may have to prefix the file name with the
the voltage shown on the DMM, the three measure- drive letter and folder name.
ment values on the ’scope and the names of the image Plot the first 2000 samples of the waveform to make
and waveform capture files. You will need this infor- sure you captured and have read the waveform cor-
mation for your report. rectly:
Change the signal generator to a sine-wave out-
put and check that (peak-to-peak) voltage is still 6 V. plot(s(1:2000))
Check that the average (DC) voltage is approximately
zero. Use the File->Save As menu item in the plot win-
Repeat the steps above, saving image and wave- dow or use the Windows ‘Snipping’ tool to save this
form capture files and recording the various instru- plot to an image file (.png format) so that you can
ment readings. include it your report later.
Now configure the waveform generator for (Gaus- Compute the mean and RMS values of the captured
sian) noise output with a level of 1.3 Vrms and zero waveform:
offset. Again, save the image and waveform capture
mean(s)
files to your flash drive and record the same informa-
std(s)
tion as before.
You should now have three sets of voltage readings,
three display files and three waveform files. Compute the Histogram
e rest of the lab can be done without test equip- e ’scope uses an A/D converter which quantizes the
ment but you should try to do as much of it as possible input signal into discrete voltage levels.
during the lab session in case you need to repeat some e measured voltages can only have certain spe-
of your measurements. cific values separated by steps equal to the quantiza-
tion step size. For example if the input voltage was
Import Samples into Matlab 1.63 volts and the step size was 0.08 volts, the ’scope
might measure this as 1.60 or 1.68 volts.
Run Matlab, Freemat or Octave. Use the cd com-
When computing the histogram of the signal we
mand to change to the directory where you have
should use a bin width equal to the step size to make
copied the files for this lab (e.g. a folder on your H:
sure we include exactly one voltage range per bin.
network drive).
We can find the step size by examining the voltage
e CSV file saved by the ’scope should start with levels measured by the ’scope. e Matlab function
two rows of information that we need to skip, fol- unique() returns a sorted list of the unique values
lowed by the sample number and the voltage as shown in the input. Assuming we have at least two values
below: separated by the step size we can find the step size as
X,CH1,Start,Increment,
the minimum difference between successive unique
Sequence,Volt,-3.5000000000e-005,5.0000000000e-010, values:

3
ssize=min(diff(unique(s))) We can use a spreadsheet to do this calculation on
the histogram values stored in the CSV file.
where the sequence of unique, diff and min opera- Run Excel or LibreOffice Calc. Open the CSV file
tions compute the minimum difference between suc- (File->Open) which will result in a spreadsheet with
cessive unique measured voltages. two columns, the first with the bin counts and the sec-
e step size can then be used to compute the num- ond with the bin voltages. Note: Immediately save the
ber of histogram bins we should use: file in .xls format or you will lose all your work when
you exit the program!
nbin=(max(s)-min(s))/ssize + 1 Enter a formula at the bottom of the first column to
compute the total number of samples (this should be
Compute a histogram of the voltage waveform us- 140,000). Add additional cells with formulas that di-
ing the hist() function: vide by this value to convert the bin counts to proba-
bilities2 . ese should sum to 1. en add additional
[n,v]=hist(s,nbin);
cells that compute the square of each bin voltage mul-
tiplied by the probability of that voltage. Compute the
which will return a vector n with the number of sam-
sum of these scaled squared voltages. is is the mean
ples values in each histogram bin and a vector v with
square voltage. Finally, compute the square root of
the voltages at the midpoints of each bin.
the mean square voltage. is is the RMS voltage of
We can then export the histogram to a CSV file by
the waveform.
opening a file for writing:
Here is an example showing the spreadsheet
fo=fopen('lab2square.csv','w') columns containing bin voltages, bin counts, bin
probabilities and scaled squared voltages. e bot-
and writing the values to the file as strings separated tom row contains sums of the bin counts, probabili-
by commas, two per line: ties, and the mean-square and RMS voltages.

fprintf(fo,'%f, %d\n',[v;n])

and closing the file:

fclose(fo) Repeat using the histogram bin counts for the sine
and Gaussian noise waveforms, importing their data
Repeat for the sine wave and Gaussian noise cap- into different sheets of the same document (Data-
ture files, saving them to different CSV files and >Get External Data or Import->Sheet from File).
recording your results for the mean and standard de- Compare your results to the values read from the
viation (rms voltage). You can use the cursor keys ’scope and DMM.
and/or the command history window to repeat pre-
vious commands and minimize typing. Plot Histograms
Create two line graphs (charts) with curves showing
Compute RMS Voltage
the values of the sine wave and Gaussian noise his-
e RMS (root mean square) voltage of a signal is de- tograms. Use Insert->Chart, set the chart type to an
fined as the square root of the mean (average) of the XY Line graph and use the voltages as the X values
square of the voltage. In cases where different volt- and the histogram sample counts as the Y values. Add
ages have different probabilities we must scale each an accurate title, sub-title and X and Y axis labels. Ad-
voltage (or its corresponding power) by the proba- just the chart properties so it is formatted as shown
bility of that power and then compute the sum. For below.
example, if 20% of the values had a power of 0.3W 2
To insert a reference to an absolute rather than relative cell,
and 80% had a power of 0.2W then the average power prefix the cell and/or row with a dollar sign ($). For example,
would be . × . + . × . = . + . = .. $A$101.

4
Example Graph Title (Y vs X)

Ident if y t he Wavef orm

1800
1600
Y-Axis Variable (symbol) (Units)

1400
1200
1000
800
600
400
200
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
Sample Voltage (x) (Volts)

Signal Bandwidth and Voltage Measurement • A signal switches randomly between two levels,
-2V and +1V. e level is +1V 30% of time and -
You may find that the power of the noise measured 2V 70% of the time. What is the average voltage?
by the DMM does not match the power measured by What is the RMS voltage? Draw the probability
the ’scope. is is because the noise power is dis- density function (you can draw impulses whose
tributed over a bandwidth of many tens of MHz while heights correspond to the probability of a partic-
the DMM only responds to signals at low (audio) fre- ular voltage).
quencies 3 . is means the DMM cannot follow the
actual input signal and measures a smaller voltage • If the ’scope has a 12-bit A/D converter, how
than is present at the input. many different voltage levels can it resolve? If
On the other hand, the bandwidth of the ’scope the display was set to ±4 V, approximately what
(also many tens of MHz) is close to the bandwidth of minimum voltage difference would you expect
the noise so the ’scope measurement is closer to the to see between the sampled voltages?
actual value.

Lab Report
Pre-Lab Report
Upload three files to the dropbox folder for this lab:
Submit a report containing a title, the lab number,
1. the histogram CSV file for the sine wave input in
your name, your student number, and the answers to
CSV (.csv) format
the following questions:
2. the Excel (or LibreOffice Calc) spreadsheet file
• What are the average and RMS voltages of a in Excel (.xls) format (any version) containing
square and sine sine wave as a function of the the three sheets and three charts
waveform’s peak-to-peak voltage?
3. your report in PDF (.pdf) format
3
e DMM frequency response specifications are in the Spec-
ifications chapter in the manual available on the course web site Your report should include:

5
• student and lab identification as described in the
first lab,

• plots of the first 2000 samples of each of the three


sampled waveforms,

• the two histograms created by your spreadsheet


(use copy and paste rather than the ’snip’ tool),

• a table comparing the RMS voltages measured


by the DMM, the ’scope and computed from the
histogram for each of the three waveforms

You might also like