Вы находитесь на странице: 1из 93

Lab

2 Digital Signal Processing


Final Write-Up
A/D Converters, Fourier Series, Error Analysis
(Quantization, Clipping, Aliasing), and Nyquist Plots

Joshua Beckerman
Dr. Glauser
MAE 315 Mechanical and Aerospace Engineering Lab
October 30, 2015


Beckerman Lab 2 Digital Signal Processing

Table of Contents

1. Abstract 3

2. Introduction 4

3. Procedure . 16

4. Results/Discussion 34

5. Conclusion 53

6. Works Cited 54

7. Appendix 55

Page | 2
Beckerman Lab 2 Digital Signal Processing

1. Abstract

The purpose of this lab is to gain an in-depth understanding of Digital Signal Processing,
its uses, and how to analyze various signals and data input. DSP is an umbrella under which
there are many sub-categories: Filtering, Sources of Error, Methods of Conversation (between
Analog and Digital), and Numerical Analysis. DSP is used in an extensive range of applications,
but most include the need for collecting data in a manner that cannot be otherwise visually
inspected and obtained.

This lab ties together several real-world examples of DSP and sources of error that can be
seen without the need for an oscilloscope. One such example is that of the electric guitar. The
analog signal is generated by the vibration of the springs, which is captured by the pick-ups (a
form of transducer) and sent out of the guitar. It is then up to the equipment to convert this signal
to a digital format so it can be processed down the road. This lab will look into the mechanism
by which all of this occurs in a way that helps to explain many aspects of DSP.

In this lab, we will see a variety of waveforms and sources of error. We will be testing
Sine Waves, Square Waves, and Triangle Waves and the effects that Clipping, Quantization, and
Aliasing have on these waves and the signal output from a program called LabVIEW. Following
the experiment, an in-depth comparative analysis based on the signal output will be crucial to
understanding how waveforms can be affected by various parameters.

By the end of the lab, we will have a greater comprehension of how waveforms can be
filtered for particular desired frequencies and what the effects that has on the waveform. We will
see how simulated waves compare to generated waves. We will also know how to perform a
Fourier Analysis on a given waveform as well as how the reconstruction it yields can help to
interpret a signal.

All of the information within this lab is of great concern to Mechanical and Aerospace
engineers because, without DSP, engineers would only have crude methods for measuring the
phenomena with which they are concerned. In addition to know why DSP is important, the
information on sources of error and anti-aliasing will be crucial for obtaining accurate and
reliable results.

Page | 3
Beckerman Lab 2 Digital Signal Processing

2. Introduction

The goal of this entire endeavor is to acquire a greater understanding of Digital Signal
Processing (DSP) and its applications within the field of engineering and elsewhere. This
understanding would not be complete without a close look at how digital signals can be analyzed
in a manner that addresses any associated error and uncertainty. In order to interpret much of the
data extracted from these signals, one must also become familiar with Fourier Analysis, a
powerful computational tool that closely approximates any well-behaved function. Each aspect
of the lab just mentioned will be explained in depth within this section such that information
presented in the subsequent sections can be put into context.

The first and most pertinent question to this lab is What is Digital Signal Processing?
Before looking at anything else, an understanding of this subject is absolutely necessary. Signal
Processing is based on the collection of information. When performing any kind of experiment,
the need for accumulating and interpreting data is unavoidable. Whether the measured parameter
varies in discrete increments or continuously is a key, determining factor as to how that data can
be recorded.

If something changes in discrete increments, it means that it only varies in multiples of a


smallest possible step. This can be explained by the simple example of a person walking up a
flight of stairs (Fig. 2.1). If we were to measure the vertical distance that person is off the ground
each time they walk up another step, we would be
measuring their height in discrete increments. Even if
the person climbing the stairs were to skip a step or two
at some random point in their ascent, their change in
altitude over any interval can be quantified in some
multiple of steps. In contrast, a parameter varying
continuously would be the same example, but instead of Figure 2.1 - Visualization of discrete increments

climbing stairs, the person is riding an escalator. We http://thumbs.dreamstime.com/z/running-up-stairs-d-people-man-p erson-3 7800654.jpg

would be measuring their ascent as a function of time and, though escalators normally move at a
constant speed, that rate could change at certain points along the interval if the escalator were to
speed up and slow down. Digital signal processing is the collection of information when the

Page | 4
Beckerman Lab 2 Digital Signal Processing

given data can be measured in discrete increments. Conversely, analog signals are those that vary
continuously and cannot necessarily be broken down into discrete increments or data points.

The difficulty lies within the fluidity of the world in which we live. In our daily lives,
nothing is actually discrete. All things in the macroscopic levels of physics, chemistry, biology,
etc. vary in an infinitely continuous way that makes data points simply a manifestation of the
limitations of the collection method chosen. Considering this lab is concerned primarily with
DSP and not the philosophical interpretations of the world around us, we will leave this
argument simply with the understanding that DSP is always limited by the number of data points
that can be collected. This then begs the question if that recreation of an actual event accurately
represents the event the data came from. (Keep this concept in mind when aliasing is discussed
later in this section.)

Once a conceptual understanding of Digital Signal Processing has been established, we


look to find out how it is implemented and why it is so important to engineers (among others). In
practice, DSP is used to collect data that cannot be explained or analyzed purely by inspection.
Applications for such a broad approach can range from the music industry to racecar data
acquisition, from heart monitors and pacemakers to Anti-Lock Braking Systems (ABS). The
importance of DSP can be summed up in the following conclusion: Digital Signal Processing is
an extremely effective method of understanding the world around us, quantifying phenomena
that cant be measured with a ruler (or a stopwatch or a thermometer), and instantaneously
interpreting that data by some set of predefined governing laws that give rise to an autonomous
and predefined reaction which was archived for those particular conditions.

For engineers, DSP is a revolution in the field. Before such capabilities existed, engineers
could only rely on full-scale experiments, hand-calculated predictions, and an educated guess-
based system of trial and error. When the engineers at Tesla Motors were developing the Model
S, they understood the power of Digital Signal Processing. The Model S is an electric,
production sedan that has sensors for every aspect of its operation. In fact, because the Model S
is controlled by a powerful onboard computer that communicates with Teslas Roadside
Assistance, most issues can be diagnosed and solved remotely by a Tesla employee in a fraction
of the time. Tesla technicians have access to numerous data sets in order to see exactly when and

Page | 5
Beckerman Lab 2 Digital Signal Processing

why something failed. Though this is only one scenario, it can be easily extrapolated that the
engineering-based offerings of DSP are only limited by the variety and accuracy of sensors
available for interpreting physical phenomena.

In data acquisition and DSP, there is an inherent need for a


device that measures a physical quantity (e.g. force, pressure,
temperature, etc.) and often outputs an electrical potential
difference, another kind of physical quantity. A transducer does
just that. A transducer is most generally an electrical device that
converts one form of energy to another1. One example of how a
transducer might function is by using a copper-wound permanent
magnet with a ferrite core to pick-up the frequency of a
vibrating metal
string. This exactly
Figure 2.2: Wiring D iagram of Electric Guitar how the transducer
http://entertainment.howstuffworks.com/electric-guitar1.htm on an electric guitar
interprets a signal. As the musician changes the
frequency of a given string, the vibration induces a
current in the magnetic pickup via a mechanism
known as inductance. The electrical signal is then Figure 2.3: MESA Engineering Electric Guitar Amplifier

sent to an amplifier, which is still reading an analog signal.

Since the transducer is still outputting an analog signal (and


since this discussion is about Digital Signal Processing), it is time to
look at the next link in the chain of DSP: the A/D converter. The
Analog-to-Digital Converter is a device that does exactly what one
might expect it to, convert an analog signal to a digital signal so that it
might be processed. At its most basic level, the A/D Converter inputs
an analog signal, which is varying continuously, and integrates the
data over the continuous sum of points. When this integration occurs,
the converter assigns a weighted value for each established, sampled
data point based on all points collected. Those values are generally

Page | 6
Figure 2.4: Les Paul Traditional with Humbucker Pickups
Beckerman Lab 2 Digital Signal Processing

integers and are assigned in such a way that they can be read by whatever computer is reading
the digital signal.

We can use the example of the electric guitar to illustrate how an A/D Converter can be
used. Since weve already established that the signal leaving the guitar is an analog signal, this
examination will start at the exit of the guitar chord jack. If, instead of plugging into an
amplifier, a musician wanted to establish a hardwired connection from the guitar to a computer
and record directly into ProTools, Garageband, or another similar software, how what they do it?
The answer is an A/D Converter. There are a number of devices on the market for such an
occasion. What is the advantage of this? one might ask. The answer lies within the power of
digital signals themselves. Digital signals are the building blocks of computer input and can
therefore be manipulated as such. Programs such as Garageband have the incredible ability to
simulate any guitar, amplifier, or acoustic environment that has been programmed into the digital
library. When the program receives the digital signal from the A/D Converter, it plays the signal
through a combination of filters that create distortion, warmth, bite, delay, wah-wah, etc. (all
potentially desirable sounds that could come from a guitar setup).

A/D Converters vary in type, ability, mechanism, and accuracy. For the purposes of this
lab, we will be looking at one with 13 bit variable
resolution and a range of 10 volts. These two parameters
are quite important when using this family of devices.
When talking about bits, we are referring to a function of
the number of intervals available for resolution. In an
effort to repurpose an earlier metaphor, this is equivalent

to only stepping on 10 of the steps when climbing a flight 3


Figure 2.5: 3 bit A/D e.g. 2 levels can resolve to 5/8
th

of stairs. If there are 20 steps total, only half of the http://ecs.syr.edu/faculty/glauser/mae315/notesNrefs/compdata/Daq.html

information about the staircase will be collected.


However, it is accepted practice to have at least enough steps to identify the smallest interval in
the set. In addition, the voltage range can be thought of as the total height of the staircase.

Now looking back at A/D converters, the number of bits and the voltage range directly
relates back to the resolution by Eqn. 2.1:

Page | 7
Beckerman Lab 2 Digital Signal Processing


=
2(# !" !"#$!!)

(2.1)

If this A/D Converter is using its maximum resolution and maximum voltage range, the
resolution could be easily found:

5 10
= (!"!!)
2048 2

(2.1)

In the discussion about software like Garageband, there was a brief mention of filtering
the digital signal after it is sent to computer. This is a vague term and requires some parsing. In
Digital Signal Processing, filtering is a method of selecting, rejecting, extracting, and modifying
certain frequencies from a raw input. When it comes to DSP, there are four basic types of filters:
High-Pass Filters, Low-Pass Filters, Band-Pass Filters, and Band-Reject Filters.

In the procedure of this lab, we are only


concerned with Low-Pass Filter. This filter is used
specifically for cancelling out frequencies that exceed
the Cut-Off Frequency. The cut-off frequency is set to
wherever the desired frequencies end. In an ideal Low-
Pass Filter, everything would be eliminated
immediately from the selecting frequency, onward. In
reality, filters are not ideal and must taper off to some

Figure 2.6: Effect of Low-Pass Filter extent (see Fig. 2.6).


http://www.audiodope.org/en/help/low_pass_filter%20freq%20response.gif

When it comes to actually creating and using


Low-Pass Filters, its important to be aware of how they are set up in a circuit. To create a Low-
Pass Filter, all that is needed is for the input voltage to
be in series with a resistor and in parallel with a
capacitor, then exiting out the other side of the circuit.

Page | 8
Figure 2.7: Low- and High-Pass Filter Wiring Diagrams

http://tuxgraphics.org/toolbox/circuit-design-rc.gif
Beckerman Lab 2 Digital Signal Processing

The order of this setup is very important because, if it were to instead to be reversed (input
voltage in series with a capacitor and in parallel with a resistor) it would then be a High-Pass
Filter (see Fig. 2.7 for wiring diagrams of Low- and High-Pass Filters).

Just as the set-up of Low- and High-Pass


Filters are opposites, so are their effects. When a
High-Pass Filter is connected to a digital signal, all
frequencies less than the cut-off frequency are
eliminated (see Fig. 2.8).

Another important filtering technique worth


mentioning here is the Band-Pass Filter. This filter, as
do all others, selects certain parts of the frequency

Figure 2.8: Effect of High-Pass Filter (see Fig. 2.9). What is unique about the Band-Pass,
http://www.its.bldrdoc.gov/fs-1037/images/hpfiltec.gif though, is that it is far more selective about the
frequencies that it picks up. One very common
example is the FM Tuner on a radio. At any given moment, there are radio waves of all
frequencies flying through space, being broadcast from all
over. An FM Tuner is a Band-Pass filter that allows the radio
operator to select a specific frequency to tune into. If it
werent for the Band-Pass Filter, radio would sound like a
jumbled mess because the radio would be attempting to pick
up all available frequencies at once.

The opposite of a Band-Pass Filter is something


known as a Band-Reject Filter (or Band-Stop Filter). The Figure 2.9: Effect of Band-Pass Filter

http://bis.babylon.com/?rt=GetFile&uri=!!XVQ3V8DTBT&type=0&index=17

Band-Reject Filter enables the user to eliminate a certain


range of frequencies. The advantage to this is that if, for
some reason, a certain section of the frequency spectrum is
considered to be inaccurate or undesirable in the final
analysis. The effect of the Band-Reject Filter can be seen in


Figure 2.10: Effect of Band-Page
Reject |F 9
ilter

http://www.its.bldrdoc.gov/fs-1037/images/bsfltr4c.gif
Beckerman Lab 2 Digital Signal Processing

Fig. 2.10.

In the Results section, it will become apparent that another advantage of using a filter of
some sort is that it also cleans up some of the plots by eliminating the background information.
Filters not only have the ability to remove targeted parts of a signal, but they can also change the
signal. When considering the signal of an electric guitar, running a signal through a filter can
create distortion (literally meaning a distorted form of the original signal). This distorted tonal
output is considered desirable for musicians like Jimmy Page (of Led Zeppelin) and Jack White
(of The White Stripes), but far less desirable for Howard Shore as he listens to the final recording
of the London Philharmonic Orchestra performing the soundtrack to The Lord of The Rings
(which he composed and produced).

Now that the concept of filtering has become clearer, we can look at another way that
digital signals can be an altered representation of event they are describing: error. Error is a
broad term that describes any number of issues, but we are particularly concerned with the error
in Digital Signal Processing that alters a signal in a way that is generally unintentional or
unwanted.

The first source of error that will be examined is called Quantization Error. Quantization
results as a drop in the resolution of the data due to an insufficient number of bits to accurately
show the changes in data this is equivalent to measuring the weight of an average person in
tons. When we think of this as a change in resolution, it is easy to
understand what is going on here. This source of error can be
thought of as switching from an IMAX viewing experience to the
old, 40lb. Sony that still plays your favorite VHS tapes: the
quality is not nearly as good and you will be getting a much more
abstract representation of what was actually going on in reality.
We will see an example of quantization error in the experiments.
Fig. 2.11 shows the general graphical explanation of what is
happening when quantization error occurs. We can extrapolate
Figure 2.11: Explanation of Quantization Error from this that increasing the number of bits will generally
http://www.diracdelta.co.uk/science/source/q/u/quantization%20error/quantization-0 01.gif
decrease the amount of quantization and decreasing the number

Page | 10
Beckerman Lab 2 Digital Signal Processing

of bits will increase the likelihood of quantization. This is of course a scale that is relative to the
size of the increments being measured and the advantage to increasing the number of bits will
diminish as the minimum signal intervals are accounted for.

The next source of error to be discussed is Clipping. Clipping is a form of error that is
reliant on the maximum range of the A/D converter. This means that if the converter cannot read
data greater than a specific value, it will
automatically interpret that data as the
maximum readable value. This is
difficult concept to grasp so a metaphor
may be of some use here. At every
carnival, fair, or theme park, there is a

game that is incredibly simple yet Figure 2.12: Example of Clipping Error

recognizable. This game goes by a http://modernmixing.com/wp-content/uploads/2014/06/clipping2-1024x438.png

number of names: High Striker, Strength Tester, and Strongman Game are a few. The game is
fairly basic. Hit the pad with the hammer hard enough to knock the puck into the bell (the pad
and the puck are connected via a lever) and you win a prize. Generally, its very hard to actually
hit the bell because the odds are stacked against you because the lever provides very little
mechanical advantage, which means that we can assume this game is an accurate measure of
strength. Now imagine that, in his prime, Muhammad Ali (one of the greatest heavyweight
boxers of all time) approaches the Strength Tester and hits the bell on his first try. Since
Muhammad Ali input more than the maximum measureable force, we cannot know how hard he
hit the pad. The force with which he hit the pad, in DSP terms, is equivalent to the force
necessary to ring the bell no more, no less (see Fig. 2.12).

The final source of error we will be looking at is


called Aliasing. Aliasing is based on rate of collection
and the understanding that too slow a rate will
misrepresent the analog signal. In stop-motion video,
the goal is to take advantage of aliasing and portray
things that could not be interpreted any other way. For

Figure 2.13: Use of aliasing in clay animation


Page | 11
http://13thdimension.com/wp-content/uploads/2014/05/Gumbypic.jpg
Beckerman Lab 2 Digital Signal Processing

example, Gumby (the American clay animation franchise) would not exist without the possibility
of aliasing. Though aliasing has its constructive applications, it is detrimental to data collection
the majority of the time.

In Digital Signal Processing, aliasing occurs when the sample rate, or sample frequency,
is too low to collect the true behavior of the signal. Another example of aliasing is a strobe light.
If you were to turn of all the lights in the room so that it is pitch black and flash a strobe light on
your hand as you move it, you would not be able to see its path. If you were to move your hand
from side-to-side, then in a circle, both at the same frequency as the strobe light, it would look
exactly the same.

The main way that aliasing can be avoided is by increasing the sampling rate of the data
collection method. A general rule of thumb is that the greatest frequency that can be resolved
accurately by DSP is a frequency that is equivalent to half of the sampling rate:


=
2

(2.2)

Aliasing can be observed in Fig 2.14. If


the original signal is shown in red and the
sampling rate is only high enough to capture the
blue data points, then the resulting interpreted
signal will be shown in blue. Also, Nyquist
Aliasing plots can be very helpful in

understanding how an aliased signal can be Figure 2.14: Example of DSP Aliasing

https://svi.nl/wikiimg/Aliasing-plot.png

represented (see Fig 2.15). We will see plots such as


this in the Results section.

Finally we will talk about how these digital


signals can be interpreted: Any (reasonable) signal can

Page | 12

Figure 2.15: Generalized Nyquist Aliasing Plot


Beckerman Lab 2 Digital Signal Processing

be represented by an infinite sum of sine and cosine waves. Based on this statement, there is a
method of analysis specifically designed for such purposes. This numerical method is called
Fourier Analysis.

Fourier Analysis is used to reconstruct harmonic signals so that computers can interpret
them. The reason for performing such an analysis is not always so clear. It is important to
understand that, though a string of data points can be useful in some situations, a governing
function that applies to an entire subset of data is far more versatile and (for its uses in most DSP
applications) a function is the only way extract and interpret the desired information.

Fourier Analysis is analytically based on the following:

http://mathworld.wolfram.com/FourierSeries.html (2.3)

Where a0, an, and bn are coefficients that are unique to the waveform of the digital signal being
inputted. For our uses in this lab, we will be using the Sine, Square, and Triangle Waves. Table
2.1 below provides the Fourier coefficients necessary. The derivation of the coefficients for the
Triangle Wave has been added to Appendix C.

A 0 A n B n
Sine Wave
0 0 a

Square Wave
0 0 ()

Triangle Wave
0 0 ()

Table 2.1: Analytical Results for Coefficients of Fourier Series of Each Waveform.

The importance of the Eqn. 2.3 is that this equation is a transformation from one
domain to another. The domain of a function is a set of all possible values for the independent
variable. The original domain a digital signal is the time domain, but the Fourier Transform then
takes that signal and breaks it up into a set of frequencies within the frequency domain.

The concept of multiple domains is very abstract and is best understood by looking at Fig. 2.16:

Page | 13
Beckerman Lab 2 Digital Signal Processing

Figure 2.16: The original digital signal, f, is shown here.


https://en.wikipedia.org/wiki/Frequency_domain#/media/File:Fourier_transform_time_and_frequency_domains_(small).gif

The first term of the Fourier Series, n = 1, is represented by


the blue wave function and represents the first approximation
of the signal.

Successive values of n determine additional wave functions


that each applies to another distinct frequency within the
signal that help to define the reconstruction.

Here, we shift the signal and its graphical Fourier Series to a


new domain.

This new domain, the frequency domain, spreads each term in


the series to its appropriate frequency.

The waves of the Fourier Series are represented by a vertical


line in the frequency domain.

This new domain shows a transformed version of the original


signal so that it can be broken up into its individual
frequencies.

Page | 14
Beckerman Lab 2 Digital Signal Processing

The final measure of this report, which must be discussed, is the concept of uncertainty.
Uncertainty is the quantifiable error inherent in the devices and methods used to measure and
calculate result data. In this lab, uncertainty will be determined using a method known as the
Zeroth Order of Uncertainty. This method is crucial for understanding the accuracy of the
experiment and for those reviewing the results to assess the overall scope of the claims that can
be made when analyzing those results. Zeroth Order of Uncertainty is found using the following
equation:

!"
!,! = ( !,!! )!
!!!

(2.4)

Equation 2.4 Where u0 is the Zeroith Order of Uncertainty of y if y is a function of variables x


through xi.

We will see how Zeroith Order of Uncertainty plays a role is found specifically for the
parameters with which we are concerned in the Results section.

Page | 15
Beckerman Lab 2 Digital Signal Processing

3. Procedure

3.1 Overview

The focus of this experiment is twofold, Digital Signal Processing (DSP) and
Fourier Analysis. In order to gain a thorough understanding of both topics, you will be using
simulated and generated waveforms (sine, square, and triangle waves) to draw comparisons
between raw data and theory. You will also see white noise, which is a non-harmonic function. A
computer program called LabVIEW will create the simulated waves and a B&K Function
Generator will create the generated signals seen in this lab.

Throughout the lab, there will be sources of error associated with the digitization of data
that must be acknowledged and explained. You will also look at how to minimize those errors
using filters (e.g. analog low-pass filter). The sources of error addressed in this lab are clipping,
quantization, and aliasing. All of these data sets and comparisons will be presented in the
Results section along with the relative uncertainty of each technique.

3.1.1 Necessary Instrumentation

National Instruments system with LabVIEW


A/D Converter
o 13 bit Maximum Resolution
!""" !"#$%&!
o 48 kS/s !"#$%&
Maximum Sample Rate

o AI FIFO (Auto Increment First In-First Out) 512 Bytes


o Input Range 10 Volts
o Working Voltage 10 Volts
o Input Impedance 144 k
Function Generator (B&K Sine and Square Wave Generator)
Krohn-Hite 3905A Multichannel Filter
1 SMB (Sub-Miniature Version B) to BNC (Bayonet NeillConcelman) Adapter Cable

Page | 16
Beckerman Lab 2 Digital Signal Processing

3.1.2 Goals of Experiment

Gain an understanding of Signal Digitization and Quantization.


Experience Aliasing, Filtering, Clipping, and Quantization Error first-hand.
Gain an understanding of Fourier Analysis.
Learn the importance of computer simulations in laboratory environments.

Page | 17
Beckerman Lab 2 Digital Signal Processing

3.2 Simulation (Using DSP Sim on LabVIEW)

3.2.1 Digital Oscilloscope Simulation

In this section, you will not be using any equipment for measurement or generation (e.g.
oscilloscope or A/D converter). Instead, use the LabVIEW simulation to digitally generate
signals within the confines of the program. Remember, it is important to save the data files (both
graphs) for each wave and individual experiment.

Simulation 1: Basic Sine Wave

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.1 into the LabVIEW Simulator

Input Function

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF


Table 3.1: Inputs for Simulation 1 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

Page | 18
Beckerman Lab 2 Digital Signal Processing

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

3.2.2 Fourier Analysis Simulation

In this section, you will be using two other waveforms, the triangle wave and the square
wave. These will each have plots in the frequency and time domains.

Simulation 2: Square Wave, Filter On

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.2 into the LabVIEW Simulator

Input Function

Function Square Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering ON

Cut-off Frequency 10 kHz



Table 3.2: Inputs for Simulation 2 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.

Page | 19
Beckerman Lab 2 Digital Signal Processing

4. Measure the difference in time, t2 t1, of the Square Wave on the top plot using the
cursor (peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Simulation 3: Square Wave, Filter Off

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.3 into the LabVIEW Simulator

Input Function

Function Square Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF


Table 3.3: Inputs for Simulation 3 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Square Wave on the top plot using the
cursor (peak to peak). Use this to find the period, T, and then calculate the frequency, f.

Page | 20
Beckerman Lab 2 Digital Signal Processing

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Simulation 4: Triangle Wave, Filter On

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.4 into the LabVIEW Simulator

Input Function

Function Triangle Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering ON

Cut-off Frequency 10 kHz



Table 3.4: Inputs for Simulation 4 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Triangle Wave on the top plot using the
cursor (peak to peak). Use this to find the period, T, and then calculate the frequency, f.

Page | 21
Beckerman Lab 2 Digital Signal Processing

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Simulation 5: Triangle Wave, Filter Off

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.5 into the LabVIEW Simulator

Input Function

Function Triangle Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF



Table 3.5: Inputs for Simulation 5 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Triangle Wave on the top plot using the
cursor (peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

Page | 22
Beckerman Lab 2 Digital Signal Processing

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

3.2.3 Simulation Error: Quantization Error and Resolution

Simulation 6: Quantization Error and Resolution, Controlled

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.6 into the LabVIEW Simulator

Input Function

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering ON

Cut-off Frequency 10 kHz



Table 3.6: Inputs for Simulation 6 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

Page | 23
Beckerman Lab 2 Digital Signal Processing

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Simulation 7: Quantization Error and Resolution, Changed

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.7 into the LabVIEW Simulator

Input Function

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 4 bit

Bipolar Range 10 volts

Low-Pass Filtering ON

Cut-off Frequency 10 kHz



Table 3.7: Inputs for Simulation 7 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably

Page | 24
Beckerman Lab 2 Digital Signal Processing

significant peak in the Fourier Space.

Simulation 8: Quantization Error and Resolution, Changed

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.8 into the LabVIEW Simulator

Input Function

Function Square Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 4 bit

Bipolar Range 10 volts

Low-Pass Filtering ON

Cut-off Frequency 10 kHz



Table 3.8: Inputs for Simulation 8 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Square Wave on the top plot using the
cursor (peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Page | 25
Beckerman Lab 2 Digital Signal Processing

3.2.3 Simulation Error: Clipping

Simulation 9: Clipping, Control

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.9 into the LabVIEW Simulator

Input Function

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF



Table 3.9: Inputs for Simulation 9 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Page | 26
Beckerman Lab 2 Digital Signal Processing

Simulation 10: Clipping, Changed

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.10 into the LabVIEW Simulator

Input Function

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 4096 samples

Resolution 12 bit

Bipolar Range 1.0 volts

Low-Pass Filtering OFF


Table 3.10: Inputs for Simulation 10 into LabVIEW

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Page | 27
Beckerman Lab 2 Digital Signal Processing

3.3 Experiment (Using DSP Exp on LabVIEW)

In this section, you will be doing the experiments with equipment that will generate real
waves and measure those waves, using the computer to acquire and analyze actual signals via an
A/D converter.

3.3.1 Digital Signal Acquisition (Digital Time History and Spectra)

Experiment 11: Sine Wave Baseline

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.11 into the Function Generator and LabVIEW VI.

Function Generator

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 8192 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF


Table 3.11: Inputs for Experiment 11 into Function Generator and LabVIEW VI

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

Page | 28
Beckerman Lab 2 Digital Signal Processing

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

3.3.2 Anti-Aliasing and Filtering

Experiment 12: Anti-Aliasing and Filtering

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.12 into the Function Generator and LabVIEW VI.

Function Generator

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 900 Hz

Number of Samples 8192 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF


Table 3.12: Inputs for Experiment 12 into Function Generator and LabVIEW VI

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

Page | 29
Beckerman Lab 2 Digital Signal Processing

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Experiment 13: Anti-Aliasing and Filtering, Krohn-Hite Filter

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.13 into the Function Generator and LabVIEW VI.

Function Generator

Function Sine Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 900 Hz

Number of Samples 8192 samples

Resolution 12 bit

Bipolar Range 10 volts

Krohn-Hite Low-Pass Filter ON

Cut-off Frequency 10 kHz



Table 3.13: Inputs for Experiment 13 into Function Generator and LabVIEW VI

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Sine Wave on the top plot using the cursor
(peak to peak). Use this to find the period, T, and then calculate the frequency, f.

Page | 30
Beckerman Lab 2 Digital Signal Processing

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

3.3.3 Fourier Analysis Experiment

In this section, you will be exploring the applications of Fourier Analysis using Square
and Triangle Waves in both the time and frequency domains.

Experiment 14: Fourier Analysis Experiment

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.14 into the Function Generator and LabVIEW VI.

Function Generator

Function Square Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 8192 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF



Table 3.14: Inputs for Experiment 14 into Function Generator and LabVIEW VI

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Square Wave on the top plot using the

Page | 31
Beckerman Lab 2 Digital Signal Processing

cursor (peak to peak). Use this to find the period, T, and then calculate the frequency, f.

1 1
= =
! !

5. On the bottom plot, use the cursor to get a value for the frequency at each reasonably
significant peak in the Fourier Space.

Experiment 15: Fourier Analysis Experiment

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.15 into the Function Generator and LabVIEW VI.

Function Generator

Function Triangle Wave

Frequency 600 Hz

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 25 kHz

Number of Samples 8192 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filtering OFF


Table 3.15: Inputs for Experiment 15 into Function Generator and LabVIEW VI

3. Press the Run Arrow at the top of the LabVIEW toolbar.
4. Measure the difference in time, t2 t1, of the Triangle Wave on the top plot using the
cursor (peak to peak). Use this to find the period, T, and then calculate the frequency, f.

Page | 32
Beckerman Lab 2 Digital Signal Processing

1 1
= =
! !

On the bottom plot, use the cursor to get a value for the frequency at each reasonably significant
peak in the Fourier Space.

Experiment 16: Fourier Analysis Experiment

1. Make sure that the Write to file command is set to Yes and that the file that will be
written is appropriately named before continuing to the next step.
2. Put the information from Table 3.16 into the B&K function generator and LabVIEW VI.

B & K Function Generator

Function White Noise

Frequency All

Amplitude 6.0 volts

Acquisition Control

Sampling Frequency 40 kHz

Number of Samples 8192 samples

Resolution 12 bit

Bipolar Range 10 volts

Low-Pass Filter ON

Cut-off Frequency 10kHz



Table 3.16: Inputs for Experiment 16 into Function Generator and LabVIEW VI

3. Press the Run Arrow at the top of the LabVIEW toolbar.

Page | 33
Beckerman Lab 2 Digital Signal Processing

4. Results/Discussion

In this section, the LabVIEW output from each experimental run in the procedure will be
presented within the context of what it was meant to show (e.g. aliasing, clipping, filtering, etc.).
This output will also have an accompanying description and at least one plot to explain what is
occurring in during that event.

4.1 Uncertainty in Results Parameter Symbolic Solution

In an effort to report all Time, t [s]


!,! =
results with as much accuracy as 2
possible, it is crucial to give the
Voltage, V [volts]
appropriate uncertainties !,! =
2(# !" !"#$!!)
associated with each measurement
Frequency, f [Hz]
technique. The parameters that !,! =
2
require uncertainties are shown in
Table 4.0 on the right along with n !,! = !"#$!% !"#!$#"%&'
their associated symbolic
Bn ! !
uncertainties. These uncertainty ! !
!! = +
functions were calculated and are !,! !,!

presented alongside the results for


each simulation. Table 4.0: List of parameters and associated uncertainties

4.2 Fourier Analysis Reconstructions

As explained in the Introduction, Fourier analysis is a powerful tool for approximating


functions using Sine and Cosine Waves. In order to do this, it is necessary to first derive the
coefficients of that particular waveform. Once the coefficients are found, see Table 2.1 for
coefficients of all waveforms used in this lab, we can use them to reconstruct those waveforms in
an accurate manner. The first wave that should be described is the simplest: the Sine Wave.

Page | 34
Beckerman Lab 2 Digital Signal Processing

Any given Fourier reconstruction is made up of a combination of sines and cosines that
approximate a given function. When that function is simply a Sine Wave, it can be approximated
using a Sine Wave (see Fig. A1).

In the time
domain, we can see a
green, Sine Wave
reconstruction. We
cannot see the blue
wave that is under the
reconstruction
because the Fourier
plot is a perfect patch.
The blue wave that is

not visible is the plot Figure A1: Reproduced from Appendix A

of the actual data


points from Simulation 1. We can then look to the frequency domain to see one peak at 600Hz.
This singular peak represents the singular function present in the Fourier transform into this
domain, thus proving the statement above. Aside from the fact that this simulation is not
perfectly ideal, there are no other notable sources of error. The results of Simulation 1 are shown
in Table 4.1a and Table 4.1b.

Time Domain Frequency Domain

Peak 1 t 0.1371s 2E-5s Frequency f 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage V 5.13V 4.9E-3V

Peak 2 t 0.1387s 2E-5s
V 6.0V 4.9E-3V
Period T 0.0016s 2E-5s
Frequency f 625Hz 3.05Hz

Table 4.1a: Simulation 1 Results, Time Domain Table 4.1b: Simulation 1 Results, Frequency Domain

Page | 35
As discussed earlier, an ideal Fourier plot in the frequency domain would show a vertical
line instead of a peak. The reconstruction is an idealized version of the actual data and the point
on this graph above the peak represents where that vertical line would extend. The differences
between actual and reconstructions in the frequency domain plot can be explained by the
associated uncertainty values. Those values and their uncertainties are shown below in Table
4.1c.

Fourier Reconstruction

a 5.13V 4.9E-3V
n*f0 598.1Hz 1.9Hz
Bn 5.13V 4.9E-3V
Table 4.1c: Uncertainties in Frequency Domain with Respect to Sine Wave Fourier Reconstruction

These graphical conventions follow for any other reconstructions in the frequency
domain performed in this lab.

For the Square Wave, it is clear that this waveform cannot be reconstructed with either
one sine or one cosine function (see Fig. A3). Instead, there will be a series of waves that make
up a reconstruction. In the time domain, we can see the original blue Square Wave, which are the
actual data points
from Simulation 3.
We can also see
several reconstructed
waves that approach
the shape of the
square wave as the n
value increases. We
can then look to the
frequency domain to
see several peaks (one

at ~600Hz, ~1800Hz, Figure A3: Reproduced from Appendix A

~3000 Hz, and so on).


Beckerman Lab 2 Digital Signal Processing

These additional peaks represent each of the terms present in the Fourier transform function in
this domain, thus proving the statement above. Aside from the fact that this simulation is not
perfectly ideal, there are no other notable sources of error. The results of Simulation 3 are shown
in Table 4.3a and Table 4.3b.

Time Domain Frequency Domain

Peak 1 t 0.1392s 2E-5s Frequency 1 f1 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage 1 V1 6.534V 4.9E-3V
Peak 2 t 0.1408s 2E-5s Frequency 2 f2 1801Hz 3.05Hz
V 6.0V 4.9E-3V Voltage 2 V2 2.508V 4.9E-3V
Period T 0.0016s 2E-5s Frequency 3 f3 3003Hz 3.05Hz
Frequency f 625Hz 3.05Hz Voltage 3 V3 1.006V 4.9E-3V

Table 4.3a: Simulation 3 Results, Time Domain Table 4.3b: Simulation 3 Results, Frequency Domain

As discussed earlier, an ideal Fourier plot in the frequency domain would show a vertical
line instead of a peak. The reconstruction is an idealized version of the actual data and the points
on this graph above the peaks represent where those vertical lines would extend. The differences
between actual and reconstructions in the frequency domain plot can be explained by the
associated uncertainty values. Those values and their uncertainties are shown below in Table
4.3c.

Fourier
n=1 n=3 n=5
Reconstruction
a 6.534V 4.9E-3V 2.508V 4.9E-3V 1.006V 4.9E-3V
n*f0 598.1Hz 1.9Hz 1801Hz 1.0Hz 3003Hz 3Hz
Bn 8.319V 14.5V 1.064V 0.85V 0.256V 0.917V
Table 4.3c: Uncertainties in Frequency Domain with Respect to Square Wave Fourier Reconstruction

Page | 37
Beckerman Lab 2 Digital Signal Processing

Since the Triangle Wave is fairly close to sine and cosine functions, this waveform will
be reconstructed very closely with only a few sine functions (see Fig. A5). In the time domain,
we can see the original blue Triangle Wave, which are the actual data points from Simulation 5.
We can also see
several reconstructed
waves that approach
the shape of the
triangle wave as the n
value increases. We
can then look to the
frequency domain to
see several peaks (one
at ~600Hz, ~1800Hz,
~3000 Hz, and so on).

These additional Figure A5: Reproduced from Appendix A

peaks represent each


of the terms present in the Fourier transform function in this domain, thus proving the statement
above. Aside from the fact that this simulation is not perfectly ideal, there are no other notable
sources of error. The results of Simulation 5 are shown in Table 4.5a and Table 4.5b.

Time Domain Frequency Domain

Peak 1 t 0.1421s 2E-5s Frequency 1 f1 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage 1 V1 4.158V 4.9E-3V
Peak 2 t 0.1438s 2E-5s Frequency 2 f2 1801Hz 3.05Hz
V 6.0V 4.9E-3V Voltage 2 V2 .5479V 4.9E-3V
Period T 0.0017s 2E-5s Frequency 3 f3 3003Hz 3.05Hz
Frequency f 588Hz 3.05Hz Voltage 3 V3 .1304V 4.9E-3V

Table 4.5a: Simulation 5 Results, Time Domain Table 4.5b: Simulation 5 Results, Frequency Domain

As discussed earlier, an ideal Fourier plot in the frequency domain would show a vertical
line instead of a peak. The reconstruction is an idealized version of the actual data and the points

Page | 38
Beckerman Lab 2 Digital Signal Processing

on this graph above the peaks represent where those vertical lines would extend. The differences
between actual and reconstructions in the frequency domain plot can be explained by the
associated uncertainty values. Those values and their uncertainties are shown below in Table
4.5c.

Fourier
n=1 n=3 n=5
Reconstruction
a 4.158V 4.9E-3V 2.508V 4.9E-3V 1.006V 4.9E-3V
n*f0 598.1Hz 1.9Hz 1801Hz 1.0Hz 3003Hz 3Hz
Bn 3.370V 14.5V .0958V 0.85V .0326V 0.917V
Table 4.5c: Uncertainties in Frequency Domain with Respect to Triangle Wave Fourier Reconstruction

4.3 Filtering

In Simulation 2, we saw a Square Wave with a Low-Pass Filter (see Figure A2).
With the low-pass filter, there are obvious changes in the appearance of both the time and
frequency domains.
Looking at in the
time domain, it can
be seen that the
shape of the Square
Wave is now
somewhat off.
Specifically, the
sharp corners have
now become
rounded and even

overshot the Figure A2: Reproduced from Appendix A

amplitude of the
original wave. In the frequency domain, we see that the peaks disappear after the cutoff
frequency, 10kHz. In addition, the other minor spikes in between the important peaks have been

Page | 39
Beckerman Lab 2 Digital Signal Processing

filtered out. The results of Simulation 2 are shown in Table 4.2a and Table 4.2b.

Time Domain Frequency Domain

Peak 1 t 0.1392s 2E-5s Frequency 1 f1 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage 1 V1 6.534V 4.9E-3V
Peak 2 t 0.1408s 2E-5s Frequency 2 f2 1801Hz 3.05Hz
V 6.0V 4.9E-3V Voltage 2 V2 2.508V 4.9E-3V

Period T 0.0016s 2E-5s



Frequency f 625Hz 3.05Hz

Table 4.2a: Simulation 2 Results, Time Domain Table 4.2b: Simulation 2 Results, Frequency Domain

In Simulation 4, we saw a Triangle Wave with a Low-Pass Filter (see Figure A4). With
the low-pass filter, there are slight changes in the appearance of the time domain. By contrast,
the frequency domain looks very similar to that of the unfiltered (with exception of the peaks
disappearing after the cutoff frequency). Looking at in the time domain, it can be seen that the
shape of the Triangle Wave is now somewhat rounded on the tops. The results of Simulation 4
are shown in Table 4.4a and Table 4.4b below.

Figure A4: Reproduced from Appendix A

Page | 40
Time Domain Frequency Domain

Peak 1 t 0.1405s 2E-5s Frequency 1 f1 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage 1 V1 4.156V 4.9E-3V
Peak 2 t 0.1421s 2E-5s Frequency 2 f2 1801Hz 3.05Hz
V 6.0V 4.9E-3V Voltage 2 V2 .535V 4.9E-3V

Period T 0.0016s 2E-5s



Frequency f 625Hz 3.05Hz

Table 4.4a: Simulation 4 Results, Time Domain Table 4.4b: Simulation 4 Results, Frequency Domain

4.4 Errors in Digital Signal Processing: Quantization Error

In Simulation 6, we reproduced the same Sine Wave as in Simulation 1. This run is meant
to act as a baseline test for us to be able to make comparisons to the next experiments results.
Because this is a simulation and the inputs were identical, no description is needed. In any case,
the plot of Simulation 6 is provided in Fig. A6 below for completeness.

Figure A6: Reproduced from Appendix A

The results from Simulation 6 have also been given in Table 4.6a and Table 4.6b. You
will notice that they are similar results to Simulation 1. The only differences are the points
chosen for sampling.


Time Domain Frequency Domain

Peak 1 t 0.1421s 2E-5s Frequency f 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage V 5.128V 4.9E-3V

Peak 2 t 0.1438s 2E-5s
V 6.0V 4.9E-3V
Period T 0.0017s 2E-5s
Frequency f 588Hz 3.05Hz

Table 4.6a: Simulation 6 Results, Time Domain Table 4.6b: Simulation 6 Results, Frequency Domain

As mentioned, these results do not contain any sources of significant error, but will be a
good control group for comparison.

In Simulation 7, this is the first exposure to quantization error. We can see in Fig. A7 that
this plot does not look like a normal Sine Wave, as in Simulation 6. Instead, we see a very
interesting shape that resembles a piecewise function that is imitating the harmonic behavior of a
Sine Wave. It is important to keep in mind that the only parameter changed between Simulation
6 and Simulation 7 was the number of bits (the resolution of the A/D converter). This means that
the uncertainty in voltage measurement will be greater.

Figure A7: Reproduced from Appendix A


Time Domain Frequency Domain

Peak 1 t 0.1423s 2E-5s Frequency f 598Hz 3.05Hz


V 5.3V 1.25V Voltage V 4.925V 1.25V

Peak 2 t 0.1440s 2E-5s
V 5.3V 1.25V
Period T 0.0017s 2E-5s
Frequency f 588Hz 3.05Hz

Table 4.7a: Simulation 7 Results, Time Domain Table 4.7b: Simulation 7 Results, Frequency Domain

In Simulation 8, we see quantization error again, but this time on a Square Wave. We can
see in Fig. A8 that this plot does not look like a normal Square Wave, especially when compared
to Simulation 3. Instead, we see a very interesting shape that resembles a piecewise function that
is imitating the
harmonic behavior of
a Square Wave. Just
as in Simulation 7, it
is important to
remember that the
only parameter
changed in Simulation
8 was the number of
bits (the resolution of
the A/D converter).

This means that the Figure A8: Reproduced from Appendix A

uncertainty in voltage measurement will be greater. Something new to note in this graph is that
there is a unique oscillation about its amplitude at 6.0V. This is interesting because, in a standard
Square Wave, this part of the wave should be flat.


Time Domain Frequency Domain

Peak 1 t 0.1425s 2E-5s Frequency 1 f1 598Hz 3.05Hz


V 5.4V 1.25V Voltage 1 V1 6.504V 1.25V
Peak 2 t 0.1442s 2E-5s Frequency 2 f2 1801Hz 3.05Hz
V 5.4V 1.25V Voltage 2 V2 2.421V 1.25V
Period T 0.0017s 2E-5s

Frequency f 588Hz 3.05Hz


Table 4.8a: Simulation 8 Results, Time Domain Table 4.8b: Simulation 8 Results, Frequency Domain

4.5 Errors in Digital Signal Processing: Clipping

Much like in Simulation 6, Simulation 9 is meant for a basis of comparison for the
following experiment in order to draw conclusions about what exactly happens to a Sine Wave
during clipping. This being said, the plot of Simulation 9 is provided in Fig. A9 below for
completeness.

Figure A9: Reproduced from Appendix A

The results from Simulation 9 have also been given in Table 4.9a and Table 4.9b. You
will notice that they are similar results to Simulations 1 and 6. The only differences are the points
chosen for sampling.


Time Domain Frequency Domain

Peak 1 t 0.1437s 2E-5s Frequency f 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage V 5.130V 4.9E-3V

Peak 2 t 0.1454s 2E-5s
V 6.0V 4.9E-3V
Period T 0.0017s 2E-5s
Frequency f 588Hz 3.05Hz

Table 4.9a: Simulation 9 Results, Time Domain Table 4.9b: Simulation 9 Results, Frequency Domain

As mentioned, these results do not contain any sources of significant error, but will be a
good control group for comparison.

In Simulation 10, this is the first exposure to clipping. We can see in Fig. A10 that this
plot does not look like a normal Sine Wave, as in Simulation 9. Instead, we see a very interesting
shape that looks more a Square Wave with rounded edges. It is important to keep in mind that
the only parameter changed between Simulation 9 and Simulation 10 was the bipolar voltage
range. This means that any data that exceeds 1.0V will be literally clipped off the top of the
wave.

Figure A10: Reproduced from Appendix A


Time Domain Frequency Domain

Peak 1 t 0.1437s 2E-5s Frequency f 598Hz 3.05Hz


V 6.0V 4.9E-3V Voltage V 5.130V 4.9E-3V

Peak 2 t 0.1454s 2E-5s
V 6.0V 4.9E-3V
Period T 0.0017s 2E-5s
Frequency f 588Hz 3.05Hz

Table 410.a: Simulation 10 Results, Time Domain Table 4.10b: Simulation 10 Results, Frequency Domain

4.6 Errors in Digital Signal Processing: Aliasing

Just as in each of the other two sections on sources of error, we will first create a baseline
plot against which we can compare the following experiment. Due to the nature of aliasing, we
will need to cease our simulations and begin the experimental procedures so that we can see this
error source. Experiment 11 is meant for a basis of comparison for the following experiment in
order to draw conclusions about what exactly happens to a Sine Wave during clipping. This
being said, the plot of Experiment 11 is provided in Fig. A11 below for completeness.

Figure A11: Reproduced from Appendix A


Beckerman Lab 2 Digital Signal Processing

The results from Experiment 11 have also been given in Table 4.11a and Table 4.11b.
You will notice that they are similar results to Simulations 1, 6, and 9. The only differences are
the points chosen for sampling.

Time Domain Frequency Domain

Peak 1 t 0.0069s 2E-5s Frequency f 600Hz 25Hz


V 4.4V 4.9E-3V Voltage V 5.908V 4.9E-3V

Peak 2 t 0.0086s 2E-5s
V 4.5V 4.9E-3V
Period T 0.0017s 2E-5s
Frequency f 588Hz 25Hz

Table 4.11a: Experiment 11 Results, Time Domain Table 4.11b: Experiment 11 Results, Frequency Domain

As mentioned, these results do not contain any sources of significant error, but will be a
good control group for comparison.

In Experiment 12, this is the first exposure to aliasing. We can see in Fig. A12 that this
plot does not resemble the Sine Waves weve seen up until now very much (if at all). Instead, we
see a very jagged
harmonic function
that looks alters its
offset as time goes on.
It is important to keep
in mind that the only
parameter changed
between Experiment
11 and 12 was the
sampling frequency.

Aliasing is Figure A12: Reproduced from Appendix A

much harder to visualize than other kinds of errors. For this reason, there are Nyquist Aliasing

Page | 47
Beckerman Lab 2 Digital Signal Processing

plots (as mentioned in the Introduction


section). All of the functions simulated or
created in this lab can, and do, have Nyquist
Aliasing Plots associated with them. These
can all be found in Appendix B, but the only
ones that will be reproduced within this
section are those that illustrate aliasing (see
Fig B12). In the aliasing plot shown, we can
see that the original frequency of 600Hz has
been dropped down to about 300Hz due to
aliasing. This is because signals can only be
accurately captured if the fundamental
frequency is less than half of the sampling
frequency. In this case, the sampling Figure B12: Reproduced from Appendix B

frequency is 900Hz. Half of 900 is 450, which


is less than 600, therefore aliasing occurs.

Due to this aliasing, the results of the experiment will not resemble those of any Sine
Wave seen thus far (see Table 4.12a and Table 4.12b).

chosen for sampling.

Time Domain Frequency Domain

Peak 1 t 0.2311s 5.56E-4s Frequency f 297Hz 0.9Hz


V 3.4V 4.9E-3V Voltage V 4.978V 4.9E-3V

Peak 2 t 0.2344s 5.56E-4s
V 3.1V 4.9E-3V
Period T 0.0033s 5.56E-4s
Frequency f 303Hz 0.9Hz

Table 4.12a: Experiment 12 Results, Time Domain Table 4.12b: Experiment 12 Results, Frequency Domain

We can see that these results match the skewed data from the plot above.

Page | 48
Beckerman Lab 2 Digital Signal Processing

In Experiment 13, we see aliasing again. We can see in Fig. A13 that this plot does not
resemble the Sine Waves weve seen up until now very much (if at all). Instead, we see a very
jagged harmonic
function. It is
important to keep in
mind that the only
parameter changed in
Experiment 13 is that
the Sine Wave is
being run through a
Krohn-Hite Filter,
which is of higher

quality than the one Figure A13: Reproduced from Appendix A

used in Experiment 12.

Again, it is helpful to show the Nyquist


Aliasing plot to show just how the signal is
being aliased (see Fig B13). In this particular
experiment we can see that the main difference
is that the signal does not change its offset over
time. This may be a good indication of that
higher quality filter.

For the same reasons as in Experiment


12, the results of the experiment will not
resemble those of any Sine Wave seen thus far
(see Table 4.13a and Table 4.13b).

Figure B13: Reproduced from Appendix B

Page | 49
Time Domain Frequency Domain

Peak 1 t 0.2311s 5.56E-4s Frequency f 300Hz 0.9Hz


V 2.1V 4.9E-3V Voltage V 5.522V 4.9E-3V

Peak 2 t 0.2344s 5.56E-4s
V 2.1V 4.9E-3V
Period T 0.0033s 5.56E-4s
Frequency f 303Hz 0.9Hz

Table 4.13a: Experiment 13 Results, Time Domain Table 4.13b: Experiment 13 Results, Frequency Domain

We can see that these results match the skewed data from the plot above.

4.7 Fourier Analysis Experiment

In Experiments 14 and 15, we are collecting data on a basic Square Wave without a filter
and a basic Triangle Wave without a filter, respectively. There are no new aspects to these data
sets, but instead they are collected so that they can be looked at in comparison to the simulated
Square Wave and simulated Triangle Wave. These data sets will be shown below, but there will
be no in-depth descriptions here due to the lack of contrasting information.

The plot of Experiment 14 is provided in Fig. A14 below.

Figure A11: Reproduced from Appendix A

Figure A14: Reproduced from Appendix A


Beckerman Lab 2 Digital Signal Processing

The results from Experiment 14 have also been given in Table 4.14a and Table 4.14b.

Time Domain Frequency Domain

Peak 1 t 0.0084s 2E-5s Frequency f 600Hz 25Hz


V 4.2V 4.9E-3V Voltage V 5.848V 4.9E-3V
Peak 2 t 0.0101s 2E-5s Frequency 2 f2 1825Hz 25Hz
V 4.2V 4.9E-3V Voltage 2 V2 2.406V 4.9 E-3V
Period T 0.0017s 2E-5s

Frequency f 588Hz 25Hz



Table 4.14a: Experiment 14 Results, Time Domain Table 4.14b: Experiment 14 Results, Frequency Domain

The plot of Experiment 15 is provided in Fig. A15 below.

Figure A11: Reproduced from Appendix A

Figure A15: Reproduced from Appendix A

The results from Experiment 15 have also been given in Table 4.15a and Table 4.15b.

Page | 51
Time Domain Frequency Domain

Peak 1 t 0.0082s 2E-5s Frequency f 600Hz 25Hz


V 4.6V 4.9E-3V Voltage V 4.648V 4.9E-3V
Peak 2 t 0.0099s 2E-5s Frequency 2 f2 1200Hz 25Hz
V 4.3V 4.9E-3V Voltage 2 V2 0.255V 4.9 E-3V
Period T 0.0017s 2E-5s

Frequency f 588Hz 25Hz



Table 4.15a: Experiment 15 Results, Time Domain Table 4.15b: Experiment 15 Results, Frequency Domain

In the final run, Experiment 16, we look at White Noise. White Noise is a non-harmonic
function. The randomness of this signal can be seen at first glance in Figure A16. Due to the
nature of this function, there is very little information that we can take away from it. No data was
directly collected during the lab session due to time constraints, as well as the nature of the signal
itself.

Figure A16: Reproduced from Appendix A


Beckerman Lab 2 Digital Signal Processing

5. Conclusion

As weve seen throughout this lab, there are a number of factors that are extremely
important when it comes to Digital Signal Processing and obtaining useful data in any type of
application. Harmonic waves are prevalent in many fields of study and without methods like
Fourier Analysis, there would be no way to properly examine and analyze them. Some of the
most notable results from this experiment can be found in the uncertainties in key parameters. In
other words, the accuracy of a processed signal is extremely dependent upon the proper choice of
bipolar range, sampling frequency, and number of bits. Improper selection of measurement
parameters can lead to large errors in aliasing, quantization, and clipping all of which can be
highly detrimental to obtaining reliable results.

In engineering, it is important to begin any type of analysis with the existing conditions,
parameters, governing laws, and constraints. Without such knowledge, a complete understanding
of the task at hand would be impossible. For this to be possible, there must be data and
explanations for any phenomena that occur within the system of interest. With Digital Signal
Processing, it is possible to obtain an unmatched level of sophistication within an engineering
analysis. Once the system is properly understood, then a solution is designed. Before a job is
completed, the new solution must be tested to confirm that in practice it performs as it was
designed. This is another instance within the basic design process that DSP presents itself.

It is apparent that the basic procedure of any engineering task, if done correctly, is
heavily reliant on accurate data acquisition and digital signal processing. For instance,
redesigning a cars suspension first requires an understanding of how the original suspension
performs and what the pitfalls are of that design. Then, an engineer might develop a new design
based on theoretical knowledge, prototypes, and computer modeling software. Before the new
car is sent out for mass production or to the racetrack, extensive testing is required once again in
order to confirm the calculations and assumptions made during the design process. This timeline
would not be possible with force transducers on the pushrods, shockpots on the dampers, strain
gauges on the chassis, and A/D converters to take all of this data and organize it in a way that
will improve the design process overall as well as the quality of the design produced by an
engineer.

Page | 53
Beckerman Lab 2 Digital Signal Processing

6. Works Cited

"(56) Signals and Systems in the Frequency Domain Fourier Series." MAE 315 - Mechanical and
Aerospace Engineering Laboratory Fall 2015. Ed. John-Michael Velarde. Syracuse
University Engineering and Computer Science, n.d. Web. 25 Oct. 2015.
<http://ecs.syr.edu/faculty/glauser/mae315/notesNrefs/Fourier/fourierpg.html>.
Brain, Marshall. "How Electric Guitars Work." How Stuff Works: Entertainment. How Stuff
Works, n.d. Web. 25 Oct. 2015. <http://entertainment.howstuffworks.com/electric-
guitar1.htm>.
Formosa, Dan. "How Tube Amps Work." Premier Guitar RSS. EPublishing, n.d. Web. 25 Oct.
2015. <http://www.premierguitar.com/articles/17116-how-tube-amps-
work?page=1%5C>.
"Roadside Assistance & Tech Support." Tesla: Support. Tesla Motors, n.d. Web. 25 Oct. 2015.
<http://www.teslamotors.com/support/roadside-assistance-tech-support>.
Rouse, Margaret. "What Is Analog-to-digital Conversion (ADC)? - Definition from
WhatIs.com." WhatIs.com. TechTarget, n.d. Web. 25 Oct. 2015.
<http://whatis.techtarget.com/definition/analog-to-digital-conversion-ADC>.
Rouse, Margaret. "What Is Transducer? - Definition from WhatIs.com." WhatIs.com.
TechTarget, n.d. Web. 25 Oct. 2015.
<http://whatis.techtarget.com/definition/transducer>.
"Use of Computer for Data Acquisition and Processing." MAE 315 - Mechanical and Aerospace
Engineering Laboratory Fall 2015. Ed. John-Michael Velarde. Syracuse University
Engineering and Computer Science, n.d. Web. 25 Oct. 2015.
<http://ecs.syr.edu/faculty/glauser/mae315/notesNrefs/compdata/Daq.html>.
Wallace, Hank. "How Do Guitar Pickups Work?" Atlantic Quality Design, Inc., How Do Guitar
Pickups Work? N.p., n.d. Web. 25 Oct. 2015. <http://www.aqdi.com/pickups.htm>.
Weisstein, Eric W. "Fourier Series." Wolfram MathWorld. Wolfram Alpha, n.d. Web. 25 Oct.
2015. <http://mathworld.wolfram.com/FourierSeries.html>.

Page | 54
Beckerman Lab 2 Digital Signal Processing

Appendices

A. Results Plots Time and Frequency Domains


1. Simulation 1: Basic Sine Wave A1
2. Simulation 2: Square Wave, Filter On A1
3. Simulation 3: Square Wave, Filter Off A2
4. Simulation 4: Triangle Wave, Filter On A2
5. Simulation 5: Triangle Wave, Filter Off A3
6. Simulation 6: Quantization Error and Resolution, Control A3
7. Simulation 7: Quantization Error and Resolution, Changed A4
8. Simulation 8: Quantization Error and Resolution, Changed A4
9. Simulation 9: Clipping, Control A5
10. Simulation 10: Clipping, Changed A5
11. Experiment 11: Sine Wave Baseline A6
12. Experiment 12: Anti-Aliasing and Filtering A6
13. Experiment 13: Anti-Aliasing and Filtering, Krohn-Hite Filter A7
14. Experiment 14: Fourier Analysis Experiment A7
15. Experiment 15: Fourier Analysis Experiment A8
16. Experiment 16: Fourier Analysis Experiment A8
B. Nyquist Aliasing Plots
1. Simulation 1 A9 9. Simulation 9 A11
2. Simulation 2 A9 10. Simulation 10 .. A11
3. Simulation 3 A9 11. Experiment 11 . A11
4. Simulation 4 A9 12. Experiment 12 . A11
5. Simulation 5 A10 13. Experiment 13 . A12
6. Simulation 6 A10 14. Experiment 14 . A12
7. Simulation 7 A10 15. Experiment 15 . A12
8. Simulation 8 A10
C. Derivation of Triangle Wave Fourier Series Coefficients A13
D. MATLAB CODE A18

Page | 55
Beckerman Lab 2 Digital Signal Processing

A. Results Plots Time and Frequency Domains

Figure A1: Simulation 1, Basic Sine Wave (with Fourier reconstruction graph overlaid).


Figure A2: Simulation 2, Sine Wave, Filter On.

Page | A1
Beckerman Lab 2 Digital Signal Processing

Figure A3: Simulation 3, Square Wave, Filter Off (with Fourier reconstruction graph overlaid).


Figure A4: Simulation 4, Triangle Wave, Filter On.

Page | A2
Beckerman Lab 2 Digital Signal Processing

Figure A5: Simulation 5, Triangle Wave, Filter On (with Fourier reconstruction graph overlaid).


Figure A6: Simulation 6, Quantization Error and Resolution, Control (Sine Wave).

Page | A3
Beckerman Lab 2 Digital Signal Processing

Figure A7: Simulation 7, Quantization Error and Resolution, Changed (Sine Wave).


Figure A8: Simulation 8, Quantization Error and Resolution, Changed (Square Wave).

Page | A4
Beckerman Lab 2 Digital Signal Processing

Figure A9: Simulation 9, Clipping, Control (Sine Wave).



Figure A10: Simulation 10, Clipping, Changed (Sine Wave).

Page | A5
Beckerman Lab 2 Digital Signal Processing

Figure A11: Experiment 11, Sine Wave Baseline.



Figure A12: Experiment 12, Anti-Aliasing and Filtering (Sine Wave).

Page | A6
Beckerman Lab 2 Digital Signal Processing

Figure A13: Experiment 13, Anti-Aliasing and Filtering, Krohn-Hite Filter (Sine Wave).


Figure A14: Experiment 14, Fourier Analysis Experiment (Square Wave).

Page | A7
Beckerman Lab 2 Digital Signal Processing

Figure A15: Experiment 15, Fourier Analysis Experiment (Triangle Wave).



Figure A16: Experiment 16, Fourier Analysis Experiment (White Noise).

Page | A8
Beckerman Lab 2 Digital Signal Processing

B. Nyquist Aliasing Plots

Figure B1: Simulation 1 Figure B2: Simulation 2

Figure B3: Simulation 3 Figure B4: Simulation 4

Page | A9
Beckerman Lab 2 Digital Signal Processing

Figure B5: Simulation 5 Figure B6: Simulation 6

Figure B7: Simulation 7 Figure B8: Simulation 8

Page | A10
Beckerman Lab 2 Digital Signal Processing

Figure B9: Simulation 9 Figure B10: Simulation 10

Figure B11: Simulation 11 Figure B12: Simulation 12

Page | A11
Beckerman Lab 2 Digital Signal Processing

Figure B13: Simulation 13 Figure B14: Simulation 14

Figure B15: Simulation 15

Page | A12
Beckerman Lab 2 Digital Signal Processing

D. Derivation of Triangle Wave Fourier Series Coefficients


A0 Derivation:
!!
1
! =
!

- is the function that describes the wave


= ( is the period of the wave function)

For a triangle wave, the function is a piecewise
- an integer multiplier of sinusoids used
to approximate the function
() = < <

- is the time in seconds [s]
() = + < <

= a grouping of constants for simplifying

() = < <

! !!
!!
1 ! !
! = ! + ! + !
!
! !!
! !

! !!
!!
1 ! 2 ! 2 2
! = + + 2 + 4
! ! !!
! !

1 ! 9 ! ! 4 ! 9 !
! = 0 + + 3 + + 16 + + 6
4 4 4 4

= 0

Page | A13
Beckerman Lab 2 Digital Signal Processing

An Derivation:
!!
1
! = cos
!
- is the function that describes the wave
= ( is the period of the wave function)

For a triangle wave, the function is a piecewise
- an integer multiplier of sinusoids used
to approximate the function
() = < <

- is the time in seconds [s]
() = + < <

= a grouping of constants for simplifying

() = < <


! !!
!!
1 ! !
! = ! cos + ! cos + ! cos
! ! !!
! !

! !!
!!
1 ! 2 ! 2 2
! = cos + + 2 cos + 4 cos
! ! !!
! !

! = !! + !! + !!
!
= cos
!

= = cos

= sin
=


! !
sin
= sin
! !

cos () !
= sin +
! !

!
= cos
!
!
sin
=
!

!
2 ! 2 =
!! = ! cos = ! 1 2
! =0

Page | A14
Beckerman Lab 2 Digital Signal Processing

2 ! ! 0 !
!! = sin + ! ! cos sin 0 + ! ! cos 0
! 2 2 2

= +

!! !! 3
2 2 2 2 =
! ! 2
!! = ! cos + cos = ! 1 + 2
! ! =
! ! 2
3
2 3 ! 3 ! 3 ! ! 2 sin 2 sin
2
!! = ! sin + ! ! cos sin + ! ! cos +
2 2 2 2 2 2


= + + + =

!! !! = 2
2 4 2 4
!! = cos cos = 1 2 3
! !! !! ! =
! ! 2
3
2 2 ! ! 3 ! 3 ! 3 4 sin 2 sin
!! = ! sin 2 + ! ! cos 2 sin + ! ! cos 2
2 2 2


= + +

= + +

+ =

Page | A15
Beckerman Lab 2 Digital Signal Processing

Bn Derivation:
!!
1
! = sin
!
- is the function that describes the wave
= ( is the period of the wave function)

For a triangle wave, the function is a piecewise
- an integer multiplier of sinusoids used
to approximate the function
() = < <

- is the time in seconds [s]
() = + < <

= a grouping of constants for simplifying

() = < <


! !!
!!
1 ! !
! = ! sin + ! sin + ! sin
! ! !!
! !

! !!
!!
1 ! 2 ! 2 2
! = sin + + 2 sin + 4 sin
! ! !!
! !

! = !! + !! + !!
!
= sin
!

= = sin

= cos
=


! !
cos
= cos
! !

sin () !
= cos +
! !

!
= sin
!
!
cos
=
!

!
2 ! 2 =
!! = ! sin = ! 3 2
! =0

Page | A16
Beckerman Lab 2 Digital Signal Processing

2 ! ! 0 !
!! = cos + ! ! sin cos 0 + ! ! sin 0
! 2 2 2

= +

!! !! 3
2 2 2 2 =
! ! 2
!! = ! sin + sin = ! 3 + 4
! ! =
! ! 2
3
2 3 ! 3 ! 3 ! ! 2 cos 2 cos
2
!! = ! cos + ! ! sin cos + ! ! sin + +
2 2 2 2 2 2


= + + =

!! !! = 2
2 4 2 4
!! = sin sin = 3 4 3
! !! !! ! =
! ! 2
3
2 2 ! ! 3 ! 3 ! 3 4 cos 2 cos
!! = ! cos 2 + ! ! sin 2 cos + ! ! sin + 2
2 2 2


= + + +

= + +

Page | A17
Beckerman Lab 2 Digital Signal Processing

E. MATLAB CODE

SIMULATION 1: BASIC SINE WAVE ............................................................................................ A19


SIMULATION 2: SQUARE WAVE, FILTER ON............................................................................. A20
SIMULATION 3: SQUARE WAVE, FILTER OFF ........................................................................... A21
SIMULATION 4: TRIANGLE WAVE, FILTER ON ......................................................................... A24
SIMULATION 5: TRIANGLE WAVE, FILTER OFF ....................................................................... A25
SIMULATION 6: QUANTIZATION ERROR AND RESOLUTION, CONTROL ................................... A27
SIMULATION 7: QUANTIZATION ERROR AND RESOLUTION, CHANGED ................................... A28
SIMULATION 8: QUANTIZATION ERROR AND RESOLUTION, CHANGED ................................... A29
SIMULATION 9: CLIPPING, CONTROL........................................................................................ A30
SIMULATION 10: CLIPPING, CHANGED ..................................................................................... A31
EXPERIMENT 11: SINE WAVE BASELINE................................................................................... A32
EXPERIMENT 12: ANTI-ALIASING AND FILTERING .................................................................. A33
EXPERIMENT 13: ANTI-ALIASING AND FILTERING, KROHN-HITE FILTER ............................. A34
EXPERIMENT 14: FOURIER ANALYSIS EXPERIMENT ................................................................ A35
EXPERIMENT 15: FOURIER ANALYSIS EXPERIMENT ................................................................ A36
EXPERIMENT 16: FOURIER ANALYSIS EXPERIMENT ................................................................ A37

Page | A18
Beckerman Lab 2 Digital Signal Processing

%Josh Beckerman
%Dr. Glauser
%MAE 315 - Mechanical and Aerospace Engineering Lab
%October 18, 2015

%Lab 2 - Digital Signal Processing and Fourier Analysis (Calculations)

clear all; close all; clc

% %% Wave Functions
%
% syms a t l
%
% %function to approximate any sine wave
% sinf = a*sin(pi*t/l); %0 < t < T
%
% %function to approximate any square wave
% squaref(1) = a; %0 < t < T/2
% squaref(2) = -a; %T/2 < t < T
%
% %function to approximate any triangle wave
% trianglef(1) = (2*a*t)/l; % 0 < t < T/4
% trianglef(2) = (-(2*a)/l)*t + 2*a; % T/4 < t < 3T/4
% trianglef(3) = ((2*a)/l)*t - 4*a; % 3T/4 < t < T

Simulation 1: Basic Sine Wave


%600Hz 6.0V Sine Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 10.0V
%No Low-Pass Filter

Sim1a = dlmread('Lab2_Plot1_10_8_2015dat.txt','\t',1,0);
Sim1a_t = Sim1a(:,1);
Sim1a_V = Sim1a(:,2);

Sim1b = dlmread('Lab2_Plot1_10_8_2015fft.txt','\t',1,0);
Sim1b_f = Sim1b(:,1);
Sim1b_V = Sim1b(:,2);

%Uncertainty
basic = ones(1,10);
u_V1 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim1a(2)-Sim1a_t(1))/2; %Half smallest increment of time

freq1 = 600; %in Hz

a = max(Sim1a_V);
l = 1/(2*freq1);

Page | A19
Beckerman Lab 2 Digital Signal Processing

n = 1;
%f1 = Reconstruct(Sim1a_t,sinf,l,n,a);
A0 = 0;
An = 0;
Bn = a;
SineRecon = Bn * sin((n*pi*Sim1a_t)/l);

figure(1);
subplot(2,1,1);
plot(Sim1a_t,Sim1a_V,Sim1a_t,SineRecon)
hold on
errorbar(Sim1a_t(1:10:100),Sim1a_V(1:10:100),u_V1,u_V1,'.b')
hold on
herrorbar(Sim1a_t(1:10:100),Sim1a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 1, Sine Wave'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim1a_t(1) Sim1a_t(70)])
ylim([-8 8])
axis on
grid on
legend('Simulation 1', 'Reconstruction n = 1')

subplot(2,1,2);
plot(Sim1b_f,Sim1b_V)
hold on
plot(n*freq1,Bn,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','b');
hold on
errorbar(Sim1b_f(1:50:500),Sim1b_V(1:50:500),u_V1,u_V1,'.b')
hold on
herrorbar(Sim1b_f(1:50:500),Sim1b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 1, Sine Wave'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
xlim([0 2000])
ylim([0 7])
axis on
grid on
legend('Simulation 1', 'Reconstruction n = 1')

Simulation 2: Square Wave, Filter On


%600Hz 6.0V Square Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 10.0V
%Low-Pass Filter On, 10kHz Cutoff Frequency

Sim2a = dlmread('Lab2_Plot2_10_8_2015dat.txt','\t',1,0); %read in simulation 2 V vs t

Page | A20
Beckerman Lab 2 Digital Signal Processing

Sim2a_t = Sim2a(:,1); %assign data to time
Sim2a_V = Sim2a(:,2); %assign data to volts

Sim2b = dlmread('Lab2_Plot2_10_8_2015fft.txt','\t',1,0); %read in simulation 2 V vs f


Sim2b_f = Sim2b(:,1); %assign data to frequency
Sim2b_V = Sim2b(:,2); %assign data to volts

%Uncertainty
basic = ones(1,10);
u_V2 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim2a(2)-Sim2a_t(1))/2; %Half smallest increment of time

figure(2);
subplot(2,1,1);
plot(Sim2a_t,Sim2a_V)
hold on
errorbar(Sim2a_t(1:10:100),Sim2a_V(1:10:100),u_V2,u_V2,'.b')
hold on
herrorbar(Sim2a_t(1:10:100),Sim2a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 2, Square Wave with Low-Pass Filter'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim2a_t(1) Sim2a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim2b_f,Sim2b_V)
hold on
errorbar(Sim2b_f(1:50:500),Sim2b_V(1:50:500),u_V2,u_V2,'.b')
hold on
herrorbar(Sim2b_f(1:50:500),Sim2b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 2, Square Wave with Low-Pass Filter'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 6])
axis on
grid on

Simulation 3: Square Wave, Filter Off


%600Hz 6.0V Square Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 10.0V
%No Low-Pass Filter

Sim3a = dlmread('Lab2_Plot3_10_8_2015dat.txt','\t',1,0); %read in simulation 3 V vs t

Page | A21
Beckerman Lab 2 Digital Signal Processing

Sim3a_t = Sim3a(:,1); %assign data to time
Sim3a_V = Sim3a(:,2); %assign data to volts

Sim3b = dlmread('Lab2_Plot3_10_8_2015fft.txt','\t',1,0); %read in simulation 3 V vs f


Sim3b_f = Sim3b(:,1); %assign data to frequency
Sim3b_V = Sim3b(:,2); %assign data to volts

%Uncertainty
basic = ones(1,10);
u_V3 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim3a(2)-Sim3a_t(1))/2; %Half smallest increment of time

freq3 = 600; % in Hz

a = max(Sim3a_V); %amplitude
l = 1/(2*freq3); %half the period
n = 1;

% f3 = Reconstruct(Sim3a_t,sinf,l,n,a);
SquareRecon1 = 0;
A0 = 0;
An = 0;
for i = [1:n]
BnSQ1 = ((2*a)/(i*pi))*(1-((-1)^i));
Recon = BnSQ1 * sin((i*pi*Sim3a_t)/l);

SquareRecon1 = SquareRecon1 + Recon;


end

n = 3;
SquareRecon2 = 0;
A0 = 0;
An = 0;
for i = [1:n]
BnSQ2 = ((2*a)/(i*pi))*(1-((-1)^i));
Recon = BnSQ2 * sin((i*pi*Sim3a_t)/l);

SquareRecon2 = SquareRecon2 + Recon;


end

n = 5;
SquareRecon3 = 0;
A0 = 0;
An = 0;
for i = [1:n]
BnSQ3 = ((2*a)/(i*pi))*(1-((-1)^i));
Recon = BnSQ3 * sin((i*pi*Sim3a_t)/l);

SquareRecon3 = SquareRecon3 + Recon;


end

n = 7;
SquareRecon4 = 0;

Page | A22
Beckerman Lab 2 Digital Signal Processing

A0 = 0;
An = 0;
for i = [1:n]
BnSQ4 = ((2*a)/(i*pi))*(1-((-1)^i));
Recon = BnSQ4 * sin((i*pi*Sim3a_t)/l);

SquareRecon4 = SquareRecon4 + Recon;


end

figure(3);
subplot(2,1,1);
plot(Sim3a_t,Sim3a_V,Sim3a_t,SquareRecon1,Sim3a_t,SquareRecon2,Sim3a_t,SquareRecon3,Sim3a_t,Squar
eRecon4)
hold on
errorbar(Sim3a_t(1:10:100),Sim3a_V(1:10:100),u_V3,u_V3,'.b')
hold on
herrorbar(Sim3a_t(1:10:100),Sim3a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 3, Square Wave'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim3a_t(1) Sim3a_t(70)])
ylim([-8 8])
axis on
grid on
legend('Simulation 3', 'Reconstruction n = 1','Reconstruction n = 3','Reconstruction n =
5','Reconstruction n = 7')

subplot(2,1,2);
plot(Sim3b_f,Sim3b_V)
hold on
plot(1*freq3,BnSQ1,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','g');
hold on
plot(3*freq3,BnSQ2,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','r');
hold on
plot(5*freq3,BnSQ3,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','c');
hold on
plot(7*freq3,BnSQ4,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','m');
hold on
errorbar(Sim3b_f(1:50:500),Sim3b_V(1:50:500),u_V3,u_V3,'.b')
hold on
herrorbar(Sim3b_f(1:50:500),Sim3b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 3, Square Wave'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 8])
axis on
grid on
legend('Simulation 3', 'Reconstruction n = 1', 'Reconstruction n = 3', 'Reconstruction n = 5',
'Reconstruction n = 7')

Page | A23
Beckerman Lab 2 Digital Signal Processing

Simulation 4: Triangle Wave, Filter On


%600Hz 6.0V Triangle Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 10.0V
%Low-Pass Filter On, 10kHz Cutoff Frequency

Sim4a = dlmread('Lab2_Plot4_10_8_2015dat.txt','\t',1,0);
Sim4a_t = Sim4a(:,1);
Sim4a_V = Sim4a(:,2);

Sim4b = dlmread('Lab2_Plot4_10_8_2015fft.txt','\t',1,0);
Sim4b_f = Sim4b(:,1);
Sim4b_V = Sim4b(:,2);

%Uncertainty
basic = ones(1,10);
u_V4 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim4a(2)-Sim4a_t(1))/2; %Half smallest increment of time

figure(4);
subplot(2,1,1);
plot(Sim4a_t,Sim4a_V)
hold on
errorbar(Sim4a_t(1:10:100),Sim4a_V(1:10:100),u_V4,u_V4,'.b')
hold on
herrorbar(Sim4a_t(1:10:100),Sim4a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 4, Triangle Wave with Low-Pass Filter'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim4a_t(1) Sim4a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim4b_f,Sim4b_V)
hold on
errorbar(Sim4b_f(1:50:500),Sim4b_V(1:50:500),u_V4,u_V4,'.b')
hold on
herrorbar(Sim4b_f(1:50:500),Sim4b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 4, Triangle Wave with Low-Pass Filter'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 6])
axis on
grid on

Page | A24
Beckerman Lab 2 Digital Signal Processing

Simulation 5: Triangle Wave, Filter Off


%600Hz 6.0V Triangle Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 10.0V
%No Low-Pass Filter

Sim5a = dlmread('Lab2_Plot5_10_8_2015dat.txt','\t',1,0);
Sim5a_t = Sim5a(:,1);
Sim5a_V = Sim5a(:,2);

Sim5b = dlmread('Lab2_Plot5_10_8_2015fft.txt','\t',1,0);
Sim5b_f = Sim5b(:,1);
Sim5b_V = Sim5b(:,2);

%Uncertainty
basic = ones(1,10);
u_V5 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim5a(2)-Sim5a_t(1))/2; %Half smallest increment of time

freq5 = 600; %in Hz

a = max(Sim5a_V);
l = 1/(2*freq5);
n = 1;

%f5 = Reconstruct(Sim5a_t,sinf,l,x,a);
TriRecon1 = 0;
A0 = 0;
An = 0;
for i = [1:2:n]
BnTr1 = ((8*a)/(pi^2))*((-1)^((i-1)/2))/(i^2);
Recon = BnTr1 * sin((i*pi*Sim5a_t)/l);

TriRecon1 = TriRecon1 + Recon;


end

n = 3;
TriRecon2 = 0;
A0 = 0;
An = 0;
for i = [1:2:n]
BnTr2 = ((8*a)/(pi^2))*((-1)^((i-1)/2))/(i^2);
Recon = BnTr2 * sin((i*pi*Sim5a_t)/l);

TriRecon2 = TriRecon2 + Recon;


end

n = 5;
TriRecon3 = 0;
A0 = 0;
An = 0;
for i = [1:2:n]

Page | A25
Beckerman Lab 2 Digital Signal Processing

BnTr3 = ((8*a)/(pi^2))*((-1)^((i-1)/2))/(i^2);
Recon = BnTr3 * sin((i*pi*Sim5a_t)/l);

TriRecon3 = TriRecon3 + Recon;


end

n = 7;
TriRecon4 = 0;
A0 = 0;
An = 0;
for i = [1:2:n]
BnTr4 = ((8*a)/(pi^2))*((-1)^((i-1)/2))/(i^2);
Recon = BnTr4 * sin((i*pi*Sim5a_t)/l);

TriRecon4 = TriRecon4 + Recon;


end

figure(5);
subplot(2,1,1);
plot(Sim5a_t,Sim5a_V,Sim5a_t,TriRecon1,Sim5a_t,TriRecon2,Sim5a_t,TriRecon3,Sim5a_t,TriRecon4)
hold on
errorbar(Sim5a_t(1:10:100),Sim5a_V(1:10:100),u_V5,u_V5,'.b')
hold on
herrorbar(Sim5a_t(1:10:100),Sim5a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 5, Triangle Wave'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim5a_t(1) Sim5a_t(70)])
ylim([-8 8])
axis on
grid on
legend('Simulation 5', 'Reconstruction n = 1','Reconstruction n = 3','Reconstruction n =
5','Reconstruction n = 7')

subplot(2,1,2);
plot(Sim5b_f,Sim5b_V)
hold on
plot(1*freq5,BnTr1,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','g');
hold on
plot(3*freq5,-BnTr2,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','r');
hold on
plot(5*freq5,BnTr3,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','c');
hold on
plot(7*freq5,-BnTr4,'Marker','*','MarkerSize', 15,'MarkerEdgeColor','m');
hold on
errorbar(Sim5b_f(1:50:500),Sim5b_V(1:50:500),u_V5,u_V5,'.b')
hold on
herrorbar(Sim5b_f(1:50:500),Sim5b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 5, Triangle Wave'; 'Frequency Domain'})
xlabel('Frequency [Hz]')

Page | A26
Beckerman Lab 2 Digital Signal Processing

ylabel('Voltage [V]')
ylim([0 6])
axis on
grid on
legend('Simulation 5', 'Reconstruction n = 1','Reconstruction n = 3','Reconstruction n =
5','Reconstruction n = 7')

Simulation 6: Quantization Error and Resolution, Control


%600Hz 6.0V Sine Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 10.0V
%No Low-Pass Filter

Sim6a = dlmread('Lab2_Plot6_10_8_2015dat.txt','\t',1,0);
Sim6a_t = Sim6a(:,1);
Sim6a_V = Sim6a(:,2);

Sim6b = dlmread('Lab2_Plot6_10_8_2015fft.txt','\t',1,0);
Sim6b_f = Sim6b(:,1);
Sim6b_V = Sim6b(:,2);

%Uncertainty
basic = ones(1,10);
u_V6 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim6a(2)-Sim6a_t(1))/2; %Half smallest increment of time

figure(6);
subplot(2,1,1);
plot(Sim6a_t,Sim6a_V)
hold on
errorbar(Sim6a_t(1:10:100),Sim6a_V(1:10:100),u_V6,u_V6,'.b')
hold on
herrorbar(Sim6a_t(1:10:100),Sim6a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 6, Sine Wave: 12 Bit Resolution'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim6a_t(1) Sim6a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim6b_f,Sim6b_V)
hold on
errorbar(Sim6b_f(1:50:500),Sim6b_V(1:50:500),u_V6,u_V6,'.b')
hold on
herrorbar(Sim6b_f(1:50:500),Sim6b_V(1:50:500),u_t,u_t,'.b')
hold on

Page | A27
Beckerman Lab 2 Digital Signal Processing

title({'Simulation 6, Sine Wave: 12 Bit Resolution'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
xlim([0 2000])
ylim([0 7])
axis on
grid on

Simulation 7: Quantization Error and Resolution, Changed


%600Hz 6.0V Sine Wave
%25kHz Sampling Frequency, 4096 Samples
%4 bit Resolution, Bipolar Voltage +/- 10.0V
%No Low-Pass Filter

Sim7a = dlmread('Lab2_Plot7_10_8_2015dat.txt','\t',1,0);
Sim7a_t = Sim7a(:,1);
Sim7a_V = Sim7a(:,2);

Sim7b = dlmread('Lab2_Plot7_10_8_2015fft.txt','\t',1,0);
Sim7b_f = Sim7b(:,1);
Sim7b_V = Sim7b(:,2);

%Uncertainty
basic = ones(1,10);
u_V7 = basic * 10/(2^4); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim7a(2)-Sim7a_t(1))/2; %Half smallest increment of time

figure(7);
subplot(2,1,1);
plot(Sim7a_t,Sim7a_V)
hold on
errorbar(Sim7a_t(1:10:100),Sim7a_V(1:10:100),u_V7,u_V7,'.b')
hold on
herrorbar(Sim7a_t(1:10:100),Sim7a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 7, Sine Wave: 4 Bit Resolution'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim7a_t(1) Sim7a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim7b_f,Sim7b_V)
hold on
errorbar(Sim7b_f(1:50:500),Sim7b_V(1:50:500),u_V7,u_V7,'.b')
hold on
herrorbar(Sim7b_f(1:50:500),Sim7b_V(1:50:500),u_t,u_t,'.b')

Page | A28
Beckerman Lab 2 Digital Signal Processing

hold on
title({'Simulation 7, Sine Wave: 12 Bit Resolution'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
xlim([0 2000])
ylim([0 7])
axis on
grid on

Simulation 8: Quantization Error and Resolution, Changed


%600Hz 6.0V Square Wave
%25kHz Sampling Frequency, 4096 Samples
%4 bit Resolution, Bipolar Voltage +/- 10.0V
%No Low-Pass Filter

Sim8a = dlmread('Lab2_Plot8_10_8_2015dat.txt','\t',1,0);
Sim8a_t = Sim8a(:,1);
Sim8a_V = Sim8a(:,2);

Sim8b = dlmread('Lab2_Plot8_10_8_2015fft.txt','\t',1,0);
Sim8b_f = Sim8b(:,1);
Sim8b_V = Sim8b(:,2);

%Uncertainty
basic = ones(1,10);
u_V8 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim8a(2)-Sim8a_t(1))/2; %Half smallest increment of time

figure(8);
subplot(2,1,1);
plot(Sim8a_t,Sim8a_V)
hold on
errorbar(Sim8a_t(1:10:100),Sim8a_V(1:10:100),u_V8,u_V8,'.b')
hold on
herrorbar(Sim8a_t(1:10:100),Sim8a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 8, Square Wave: 4 Bit Resolution'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim8a_t(1) Sim8a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim8b_f,Sim8b_V)
hold on
errorbar(Sim8b_f(1:50:500),Sim8b_V(1:50:500),u_V8,u_V8,'.b')
hold on

Page | A29
Beckerman Lab 2 Digital Signal Processing

herrorbar(Sim8b_f(1:50:500),Sim8b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 8, Square Wave: 12 Bit Resolution'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Simulation 9: Clipping, Control


%600Hz 6.0V Sine Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 10.0V
%No Low-Pass Filter

Sim9a = dlmread('Lab2_Plot9_10_8_2015dat.txt','\t',1,0);
Sim9a_t = Sim9a(:,1);
Sim9a_V = Sim9a(:,2);

Sim9b = dlmread('Lab2_Plot9_10_8_2015fft.txt','\t',1,0);
Sim9b_f = Sim9b(:,1);
Sim9b_V = Sim9b(:,2);

%Uncertainty
basic = ones(1,10);
u_V9 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim9a(2)-Sim9a_t(1))/2; %Half smallest increment of time

figure(9);
subplot(2,1,1);
plot(Sim9a_t,Sim9a_V)
hold on
errorbar(Sim9a_t(1:10:100),Sim9a_V(1:10:100),u_V9,u_V9,'.b')
hold on
herrorbar(Sim9a_t(1:10:100),Sim9a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 9, Sine Wave'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim9a_t(1) Sim9a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim9b_f,Sim9b_V)
hold on
errorbar(Sim9b_f(1:50:500),Sim9b_V(1:50:500),u_V1,u_V1,'.b')
hold on

Page | A30
Beckerman Lab 2 Digital Signal Processing

herrorbar(Sim9b_f(1:50:500),Sim9b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 9, Sine Wave'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Simulation 10: Clipping, Changed


%600Hz 6.0V Sine Wave
%25kHz Sampling Frequency, 4096 Samples
%12 bit Resolution, Bipolar Voltage +/- 1.0V
%No Low-Pass Filter

Sim10a = dlmread('Lab2_Plot10_10_8_2015dat.txt','\t',1,0);
Sim10a_t = Sim10a(:,1);
Sim10a_V = Sim10a(:,2);

Sim10b = dlmread('Lab2_Plot10_10_8_2015fft.txt','\t',1,0);
Sim10b_f = Sim10b(:,1);
Sim10b_V = Sim10b(:,2);

%Uncertainty
basic = ones(1,10);
u_V10 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim10a(2)-Sim10a_t(1))/2; %Half smallest increment of time

figure(10);
subplot(2,1,1);
plot(Sim10a_t,Sim10a_V)
hold on
errorbar(Sim10a_t(1:10:100),Sim10a_V(1:10:100),u_V10,u_V10,'.b')
hold on
herrorbar(Sim10a_t(1:10:100),Sim10a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Simulation 10, Sine Wave: Bipolar voltage +/-1.0V'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim10a_t(1) Sim10a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim10b_f,Sim10b_V)
hold on
errorbar(Sim10b_f(1:50:500),Sim10b_V(1:50:500),u_V10,u_V10,'.b')
hold on

Page | A31
Beckerman Lab 2 Digital Signal Processing

herrorbar(Sim10b_f(1:50:500),Sim10b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Simulation 10, Sine Wave: Bipolar voltage +/-1.0V'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Experiment 11: Sine Wave Baseline


%600Hz Sine Wave
%25kHz Sampling Frequency, 8192 Samples
%12 bit Resolution, Bipolar Voltage +/- 1.0V
%No Low-Pass Filter

Sim11a = dlmread('Lab2_Plot11_10_8_2015dat.txt','\t',1,0);
Sim11a_t = Sim11a(:,1);
Sim11a_V = Sim11a(:,2);

Sim11b = dlmread('Lab2_Plot11_10_8_2015fft.txt','\t',1,0);
Sim11b_f = Sim11b(:,1);
Sim11b_V = Sim11b(:,2);

%Uncertainty
basic = ones(1,10);
u_V11 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim11a(2)-Sim11a_t(1))/2; %Half smallest increment of time

figure(11);
subplot(2,1,1);
plot(Sim11a_t,Sim11a_V)
hold on
errorbar(Sim11a_t(1:10:100),Sim11a_V(1:10:100),u_V11,u_V11,'.b')
hold on
herrorbar(Sim11a_t(1:10:100),Sim11a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Experiment 11, Sine Wave'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim11a_t(1) Sim11a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim11b_f,Sim11b_V)
hold on
errorbar(Sim11b_f(1:50:500),Sim11b_V(1:50:500),u_V11,u_V11,'.b')
hold on

Page | A32
Beckerman Lab 2 Digital Signal Processing

herrorbar(Sim11b_f(1:50:500),Sim11b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Experiment 11, Sine Wave'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Experiment 12: Anti-Aliasing and Filtering


%600Hz Sine Wave
%900Hz Sampling Frequency, 8192 Samples
%12 bit Resolution, Bipolar Voltage +/- 1.0V
%No Low-Pass Filter

Sim12a = dlmread('Lab2_Plot12_10_8_2015dat.txt','\t',1,0);
Sim12a_t = Sim12a(:,1);
Sim12a_V = Sim12a(:,2);

Sim12b = dlmread('Lab2_Plot12_10_8_2015fft.txt','\t',1,0);
Sim12b_f = Sim12b(:,1);
Sim12b_V = Sim12b(:,2);

%Uncertainty
basic = ones(1,10);
u_V12 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim12a(2)-Sim12a_t(1))/2; %Half smallest increment of time

figure(12);
subplot(2,1,1);
plot(Sim12a_t,Sim12a_V)
hold on
errorbar(Sim12a_t(1:10:100),Sim12a_V(1:10:100),u_V12,u_V12,'.b')
hold on
herrorbar(Sim12a_t(1:10:100),Sim12a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Experiment 12, Sine Wave: 900Hz Sampling Frequency'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim12a_t(1) Sim12a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim12b_f,Sim12b_V)
hold on
errorbar(Sim12b_f(1:50:500),Sim12b_V(1:50:500),u_V12,u_V12,'.b')
hold on

Page | A33
Beckerman Lab 2 Digital Signal Processing

herrorbar(Sim12b_f(1:50:500),Sim12b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Experiment 12, Sine Wave: 900Hz Sampling Frequency'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Experiment 13: Anti-Aliasing and Filtering, Krohn-Hite Filter


%600Hz Sine Wave
%900Hz Sampling Frequency, 8192 Samples
%12 bit Resolution, Bipolar Voltage +/- 1.0V
%Krohn-Hite Filter

Sim13a = dlmread('Lab2_Plot13_10_8_2015dat.txt','\t',1,0);
Sim13a_t = Sim13a(:,1);
Sim13a_V = Sim13a(:,2);

Sim13b = dlmread('Lab2_Plot13_10_8_2015fft.txt','\t',1,0);
Sim13b_f = Sim13b(:,1);
Sim13b_V = Sim13b(:,2);

%Uncertainty
basic = ones(1,10);
u_V13 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim13a(2)-Sim13a_t(1))/2; %Half smallest increment of time

figure(13);
subplot(2,1,1);
plot(Sim13a_t,Sim13a_V)
hold on
errorbar(Sim13a_t(1:10:100),Sim13a_V(1:10:100),u_V13,u_V13,'.b')
hold on
herrorbar(Sim13a_t(1:10:100),Sim13a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Experiment 13, Sine Wave: Krohn-Hite Filter'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim13a_t(1) Sim13a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim13b_f,Sim13b_V)
hold on
errorbar(Sim13b_f(1:50:500),Sim13b_V(1:50:500),u_V13,u_V13,'.b')
hold on

Page | A34
Beckerman Lab 2 Digital Signal Processing

herrorbar(Sim13b_f(1:50:500),Sim13b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Experiment 13, Sine Wave: Krohn-Hite Filter'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Experiment 14: Fourier Analysis Experiment


%600Hz Square Wave
%25kHz Sampling Frequency, 8192 Samples
%12 bit Resolution, Bipolar Voltage +/- 1.0V

Sim14a = dlmread('Lab2_Plot14_10_8_2015dat.txt','\t',1,0);
Sim14a_t = Sim14a(:,1);
Sim14a_V = Sim14a(:,2);

Sim14b = dlmread('Lab2_Plot14_10_8_2015fft.txt','\t',1,0);
Sim14b_f = Sim14b(:,1);
Sim14b_V = Sim14b(:,2);

%Uncertainty
basic = ones(1,10);
u_V14 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim14a(2)-Sim14a_t(1))/2; %Half smallest increment of time

figure(14);
subplot(2,1,1);
plot(Sim14a_t,Sim14a_V)
hold on
errorbar(Sim14a_t(1:10:100),Sim14a_V(1:10:100),u_V14,u_V14,'.b')
hold on
herrorbar(Sim14a_t(1:10:100),Sim14a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Experiment 14, Square Wave'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim14a_t(1) Sim14a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim14b_f,Sim14b_V)
hold on
errorbar(Sim14b_f(1:50:500),Sim14b_V(1:50:500),u_V14,u_V14,'.b')
hold on
herrorbar(Sim14b_f(1:50:500),Sim14b_V(1:50:500),u_t,u_t,'.b')

Page | A35
Beckerman Lab 2 Digital Signal Processing

hold on
title({'Experiment 14, Square Wave'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Experiment 15: Fourier Analysis Experiment


%600Hz Triangle Wave
%25kHz Sampling Frequency, 8192 Samples
%12 bit Resolution, Bipolar Voltage +/- 1.0V

Sim15a = dlmread('Lab2_Plot15_10_8_2015dat.txt','\t',1,0);
Sim15a_t = Sim15a(:,1);
Sim15a_V = Sim15a(:,2);

Sim15b = dlmread('Lab2_Plot15_10_8_2015fft.txt','\t',1,0);
Sim15b_f = Sim15b(:,1);
Sim15b_V = Sim15b(:,2);

%Uncertainty
basic = ones(1,10);
u_V15 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim15a(2)-Sim15a_t(1))/2; %Half smallest increment of time

figure(15);
subplot(2,1,1);
plot(Sim15a_t,Sim15a_V)
hold on
errorbar(Sim15a_t(1:10:100),Sim15a_V(1:10:100),u_V15,u_V15,'.b')
hold on
herrorbar(Sim15a_t(1:10:100),Sim15a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Experiment 15, Triangle Wave'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim15a_t(1) Sim15a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim15b_f,Sim15b_V)
hold on
errorbar(Sim15b_f(1:50:500),Sim15b_V(1:50:500),u_V15,u_V15,'.b')
hold on
herrorbar(Sim15b_f(1:50:500),Sim15b_V(1:50:500),u_t,u_t,'.b')
hold on

Page | A36
Beckerman Lab 2 Digital Signal Processing

title({'Experiment 15, Triangle Wave'; 'Frequency Domain'})
xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Experiment 16: Fourier Analysis Experiment


%White Noise
%40kHz Sampling Frequency, 8192 Samples
%Low-Pass Filter On

Sim16a = dlmread('Lab2_Plot16_10_8_2015dat.txt','\t',1,0);
Sim16a_t = Sim16a(:,1);
Sim16a_V = Sim16a(:,2);

Sim16b = dlmread('Lab2_Plot16_10_8_2015fft.txt','\t',1,0);
Sim16b_f = Sim16b(:,1);
Sim16b_V = Sim16b(:,2);

%Uncertainty
basic = ones(1,10);
u_V16 = basic * 10/(2^12); %+/-10V Input Range, 12 Bit Resolution
u_t = basic * (Sim16a(2)-Sim16a_t(1))/2; %Half smallest increment of time

figure(16);
subplot(2,1,1);
plot(Sim16a_t,Sim16a_V)
hold on
errorbar(Sim16a_t(1:10:100),Sim16a_V(1:10:100),u_V16,u_V16,'.b')
hold on
herrorbar(Sim16a_t(1:10:100),Sim16a_V(1:10:100),u_t,u_t,'.b')
hold on
title({'Experiment 16, White Noise'; 'Time Domain'})
xlabel('Time [s]')
ylabel('Voltage [V]')
xlim([Sim16a_t(1) Sim16a_t(70)])
ylim([-8 8])
axis on
grid on

subplot(2,1,2);
plot(Sim16b_f,Sim16b_V)
hold on
errorbar(Sim16b_f(1:50:500),Sim16b_V(1:50:500),u_V16,u_V16,'.b')
hold on
herrorbar(Sim16b_f(1:50:500),Sim16b_V(1:50:500),u_t,u_t,'.b')
hold on
title({'Experiment 16, White Noise'; 'Frequency Domain'})

Page | A37
Beckerman Lab 2 Digital Signal Processing

xlabel('Frequency [Hz]')
ylabel('Voltage [V]')
ylim([0 7])
axis on
grid on

Published with MATLAB R2014a

Page | A38

Вам также может понравиться