-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab3.html
119 lines (94 loc) · 8.13 KB
/
lab3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="description" content="ece3400 : ">
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
<title>BasantKhalil Ece3400 Wiki</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/Basant-khalil/Maze-Mapping-Robot.git">View on GitHub</a>
<h1 id="project_title">Lab 3</h1>
<h2 id="project_tagline"></h2>
<h2>
<a href="https://pages.github.coecis.cornell.edu/bak94/ece3400/index.html" class="btn">Home</a>
<a href="https://pages.github.coecis.cornell.edu/bak94/ece3400/lab1.html" class="btn">Lab 1</a>
<a href="https://pages.github.coecis.cornell.edu/bak94/ece3400/lab2.html" class="btn">Lab 2</a>
<a href="https://pages.github.coecis.cornell.edu/bak94/ece3400/lab3.html" class="btn">Lab 3</a>
<a href="https://pages.github.coecis.cornell.edu/bak94/ece3400/lab4.html" class="btn">Lab 4</a>
</h2>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h3>
Lab 3: Filtering and FFT</h3>
<h3>Objectives:</h3>
<ul>
<li>Implement ADC conversion.</li>
<li>Use interrupts to control the sampling frequency of the ADC signal.</li>
<li>Build a microphone circuit.</li>
<li>Build an amplifier circuit.</li>
<li>Build a high pass filter.</li>
<li>Use FFT to identify frequencies using Matlab.</li>
<li>Use FFT to identify frequencies on the Arduino.</li>
</ul>
<h3>Materials:</h3>
<ul>
<li>1 Robot and circuits from last lab</li>
<li>1 Microphone</li>
<li>1 LM358 op-amp</li>
<li>3 100 k𝛺 resistors</li>
<li>1 4.02 k𝛺 resistor</li>
<li>1 75 k𝛺 resistor</li>
<li>1 49.9 𝛺 resistor</li>
<li>1 2.7 k𝛺 resistor</li>
<li>1 100 pF capacitor</li>
<li>1 0.22 𝜇F capacitor</li>
<li>2 2.2 𝜇F capacitors</li>
<li>1 0.1 𝜇F capacitor</li>
<li>Jumper wires</li>
</ul>
<h3>Simulating Filters:</h3>
<p>Before we began working on our circuits, we first simulated some filters in LTSpice. We simulated both a high pass and a low pass filter. The first image below is the low pass filter. We simulated a frequency sweep from 1Hz to 10kHz. The transfer function generated can be seen below the circuit. We next simulated a high pass filter, as seen in the third image. Again, we simulated a frequency sweep, and the transfer function is shown in the fourth image below. Finally, we added an op-amp to simulate the filter we built for the lab. This circuit can be seen in the fifth image. This was again simulated; the transfer function for this circuit is shown in the filter section of this page.</p>
<img src="/bak94/ece3400/images/lab 3 lowpass.png">
<img src="/bak94/ece3400/images/lab 3 lowpass res.png">
<img src="/bak94/ece3400/images/lab 3 high pass.png">
<img src="/bak94/ece3400/images/lab 3 highpass res.png">
<img src="/bak94/ece3400/images/lab 3 opamp filt.png">
<h3>The Microphone Circuit:</h3>
<p>We next implemented the microphone circuit. This circuit was fairly simple. We use a 4.02 k𝛺 resistor connected to the 5V rail to properly bias the microphone. We then used a 0.22 𝜇F capacitor to filter out the DC component of the voltage generated by the microphone. We connected this output to an analog pin on the Arduino and used ADC to convert the signal into a digital signal we could process. The circuit can be seen below. We then sent the data through the serial port to a computer running Matlab, which ran a FFT and produced a spectrum. The spectrum can be seen in the second image below. In reality, the unamplified circuit response is very weak. While the produced spectrum looks good, we had to hold a loud phone playing a 500 Hz tone directly next to the microphone to get this response. If we just played the sound off a computer nearby, there would be almost no peak at all.</p>
<img src="/bak94/ece3400/images/lab 3 no amp circuit.JPG">
<img src="/bak94/ece3400/images/lab 3 no amp.png">
<h3>The Amplifier:</h3>
<p>We next built an amplifier circuit so we would get a stronger signal than the microphone alone could provide. A diagram of the circuit can be seen below, and the actual implementation can be seen in the second image below. After implementing the circuit, the response measured by the Arduino was much stronger. This can be seen in the third image below, which is a Matlab plot of the FFT of the data recorded. This circuit was very difficult to get right. Often small tweaks would result in a very poor signal. It was essential to ensure that all the connections were solid. Again, the image shows the result after holding a phone close to the microphone, as that resulted in the clearest signals.</p>
<img src="/bak94/ece3400/images/lab 3 amp circuit diagram.png">
<img src="/bak94/ece3400/images/lab 3 no filt.JPG">
<img src="/bak94/ece3400/images/lab3 amp no filter.png">
<h3>The Filter:</h3>
<p>We next build the high pass filter we had previously simulated. We connected the filter to the output of the amplifier circuit. We chose to use a 2.7 k𝛺 resistor and a 0.1 𝜇F capacitor so that our cutoff frequency would be just over 500 Hz. The expected cutoff frequency was 589.46 Hz. This circuit can be seen in the image below. We then ran a frequency sweep from 100 - 2000 Hz to determine the frequency response. We measured the voltage both before and after the filter and divided the results to produce a transfer function. This transfer function can be seen in the second image below. Also pictured is the transfer function from the simulated circuit. Both transfer functions show a similar shape, but the experimental data reaches its cutoff frequency earlier. This may be due to imprecision in the resistance and capacitance of the resistor and capacitor. Additionally, the experimental data is very noisy, as there was background noise in the room, and the circuit is not incredibly precise.</p>
<img src="/bak94/ece3400/images/lab 3 final circuit.JPG">
<img src="/bak94/ece3400/images/lab 3 bode.png">
<h3>FFT through Matlab:</h3>
<p>To gather frequency data, we initially sent the data over the USB to a computer running Matlab. We used a Matlab program to read the data and perform a FFT on the data, producing a spectrum. All the above frequency data was collected in this way. Testing with Matlab allowed us to ensure that our circuit was performing correctly, as we could see what the frequency measured was.</p>
<h3>FFT through Arduino:</h3>
<p>We later switched to performing the FFT directly on the Arduino, using a library. This is necessary because we will need to identify specific frequencies during the final challenge. We will not have a computer connected to the Arduino during this time, so all of the calculations must be done on the microcontroller. The disadvantage of using the Arduino to perform FFT is that the data is not as informative. Instead of knowing the frequency of each peak, we only know what bin it falls in. This can be mapped to frequency, but it is much less precise than the FFT from Matlab. The spectrums from measuring 500 Hz, 700 Hz, and 900 Hz can be seen below. The primary peak is clearly shifting to different bins as the frequency increases. Again, this data was recorded with a loud phone playing the frequency close to the microphone, as a loud signal was required to get a clear response.</p>
<img src="/bak94/ece3400/images/lab 3 ard fft 500.png">
<img src="/bak94/ece3400/images/lab 3 ard fft 700.png">
<img src="/bak94/ece3400/images/lab 3 ard fft 900.png">
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p class="copyright">Maze-Mapping-Robot maintained by <a href="https://github.com/Basant-khalil/Maze-Mapping-Robot.git">Basant Khalil</a></p>
<p>Published with <a href="https://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
</body>
</html>