Deep Dive 2
Due Wednesday, June 11, 2025
Please pick one of the options below, and submit all supporting work on Canvas. This is strictly an individual assessment, so please work alone. Ilya will be happy to answer any questions during the deep dive, but it will be at his discretion if the answer is giving away too much. So please ask questions if anything is unclear; worst case, Ilya will say he cannot answer the question. You are not permitted to work together or get any help from other humans (or sentient machines), but you may use any other resources, including but not limited to our class notes, videos, the internet (including generative AI models), and textbooks.
OPTION 1: Build a Circuit
For this option, you will design and build an electrocardiogram (ECG) reader. This will involve building and characterizing an instrumentation amplifier and using it to record your own electro-cardiogram. If you choose this option, please talk to Ilya as soon as possible to get ECG electrodes. Make sure to show all work clearly to receive credit!
1. The schematic for an instrumentation amplifier is given in Fig. 1. It can be thought of as consisting of 3 stages, as shown in Fig. 2. Each stage has a specific purpose, which you will explore below. The goal of the device is to amplify the difference between two signals. The total gain of the instrumentation amplifier can be given as:
(1)
Figure 1: Instrumentation amplifier schematic.
Figure 2: Instrumentation amplifier schematic, broken into stages.
(a) Stage 1 is a buffering stage. (The 100 kΩ resistors are purely for safety, so as to limit the current that can possibly go to the body.) Find the gain of Stage 1 in terms of v1−v2 (i.e. if we call the output of the top op-amp v3 and the output of the bottom op-amp v4, we are looking for ).
(b) Stage 2 is an amplifier we studied in class. Find the gain of Stage 2 in terms of v3 − v4 (i.e. if we call the output of the op-amp in Stage 2 v5, we are looking for ).
(c) Stage 3 is a bandpass filter with gain. You do not have to characterize this part of the circuit. It will have a gain of relative to v5, which you can plug directly into Equation (1). Use values of C1 = 1µF, R5 = 200kΩ, C2 = 1nF, R6 = 1MΩ. This should give cutoff frequencies of 0.8Hz and 160Hz, and a gain of -5.
Plug your answers from parts 1(a) and 1(b), along with the given answer from part 1(c), into Equation (1), which will give you the total gain. Use a 10 kΩ potentiometer for R1, and choose values for R2, R3, and R4 such that the total gain is around 100 when R1 = 5 kΩ. Choose values in the 1 kΩ – 100 kΩ range. Keep in mind that not every possible value is available. Therefore, you may not get exactly a gain of 100. You don’t have to fine-tune your resistances (using parallel and series combinations) to get exactly 100, as long as it is reasonably close.
2. Now, you will build the circuit and measure your ECG. You will use the TL084CN op-amp that is in your kit, along with some alligator clips (available in the lab and in your kit) and ECG electrodes (that will be provided to you). Follow the steps below.
(a) First, build the circuit in Fig. 1. This should require just one TL084CN chip, as it is a quad op-amp. Take a photo of your final circuit.
(b) Next, using your AD2, supply +5 V and -5 V to the op-amp. Using the waveform. gen-erator, input a 10 mV, 1 Hz sine wave at v1, and ground at v2. Set your R1 potentiometer to 5 kΩ. Using the oscilloscope, measure the output. Do you get what you expect? If not, what is a potential reason for the discrepancy?
Using both channels of the oscilloscope, measure v1 and vout. Scale them so that both are clearly visible, and take a screenshot. In the screenshot, please make sure that axis labels are clearly visible, and please include the boxes on the right that show the volts/division for both channels.
(c) Finally, you are ready to measure the ECG. First, turn off the power supply and waveform. gen-erator, and disconnect the oscilloscope from v1. Then, attach the electrodes as illustrated to the right. Connect one electrode to your shoulder and v1, another to your other shoulder and v2, and the third to your lower right abdomen and to your circuit’s ground. Use alligator clips to make con-nections to the electrode tabs. Once all of the connections are made, turn on the power to the op-amps, and observe vout on the os-cilloscope. Play around with the scale (both time and voltage) of the output, and with the value of R1. When you get a nicely-visible ECG, take a screenshot. My ECG from this setup is shown in Fig. 3 as an example.
Figure 3: Sample ECG obtained using the setup in Fig. 1.
Submit your answers from Parts 1 (final gain equation (along with your work!) and choices for all resistor values), 2(a) (photo), 2(b) (observation and screenshot), and 2(c) (screenshot). Also, please state how long you spent on this assignment as a comment on your Canvas submission.
OPTION 2: Analyze a Circuit
For this option, you will characterize the non-ideal effects of an operational amplifier, namely the TL084CN in your kit. The specifications are below. Make sure to show all work clearly to receive credit!
1. For ideal op-amps, we assumed that Rin → ∞, Rout → 0, and A → ∞. Now, assume that Rout = 0, Rin = 1012, and A = 106
. Re-derive the gain of a standard inverting amplifier, shown in Fig. 4, assuming that R1 = 1 kΩ and R2 = 100 kΩ. Give your answer to 4 decimal places.
Figure 4: Inverting op-amp.
2. Here, we are going to explore the slew rate.
(a) Configure your op-amp as a buffer (unity gain). On your AD2, use the power supply, waveform. generator, and oscilloscope. Provide a supply of +5 V and -5 V, and a square wave input that oscillates between 0 V and 1 V. Using the oscilloscope, find the slew rate in V/µs (to 4 decimal places). Take a screenshot of your oscilloscope showing the waveform. that you used to find the slew rate.
(b) Based on your answer in part 2(a), at what frequency should the output look triangular, assuming the input is a square wave that oscillates between 0 V and 1 V and has 50% symmetry? Give your answer to 4 significant figures.
(c) At what frequency do you actually start noticing triangular behavior? If the frequency is lower or higher than predicted in part 2(b), why might this be? Take a screenshot of the oscilloscope at the frequency that the output starts looking triangular, and annotate the waveform. generator frequency on the screenshot.
3. Using a sine wave as your buffer input, find the gain-bandwidth product. Make sure to use an amplitude that will satisfy the slew rate (and show your calculations for how you chose this value). I recommend using a sweep and the FFT view in the oscilloscope. When you have found the GBP, record its value and report the amplitude of the sine wave that you used.
Submit your answers and work from Parts 1 (non-ideal gain), 2(a) (slew rate and screen-shot), 2(b) (frequency), 2(c) (annotated screenshot and discussion), and 3 (GBP and sine amplitude). Also, please state how long you spent on this assignment as a comment on your Canvas submission.
OPTION 3: Compression Algorithm
For this option, you will write MATLAB code to perform. rudimentary compression of an audio signal, and characterize its operation. The compression method you will use is to take the Fourier Transform, and to cut off high frequencies. By default, just taking the Fourier Transform. (using the FFT algorithm) creates no compression, as the signal will be the same length as the time-domain one. However, if we zero out all values beyond a given point, we will get compression since we only have to store the non-zero values. For example, if we take a Fourier Transform. that goes up to 20 kHz, and we cut everything off beyond 10 kHz, we achieve a compression ratio of 0.5. In general, we will define the compression ratio as
To judge whether our compression is good or bad, we will use a speech-to-text transcriber, and we will keep compressing until the transcription no longer matches the original. Here is an outline of what the code should do. Please make sure to include lots of comments in your code.
1. Read in an audio signal of your creation. For this assignment, please use spoken words (i.e. not music), and it must be a recording of your own voice speaking a short sentence.
2. Create a “speechClient” object using the “wav2vec2.0” speech model. This functionality is only available in MATLAB 2022b and beyond.
3. Apply this model to your original signal, using “speech2text”, to get a baseline.
4. Take the FFT of your signal. You will have to read the documentation of the “fft” function to figure this out.
5. In a loop, go through decreasing cutoff values, zero out the FFT beyond that frequency, and take the inverse FFT using the “ifft” function. Make sure to preserve conjugate symmetry so that the inverse FFT returns a real-valued signal.
6. For each iteration, use your “speechClient” object to transcribe the compressed signal, and keep looping until the transcription no longer agrees with your baseline transcription.
7. For each iteration, also keep track of the average confidence scores associated with each word in the transcription.
8. After the loop is complete, have MATLAB display:
(a) The compression ratio (using an “fprintf” statement),
(b) The final cutoff frequency (using an “fprintf” statement),
(c) A plot of the average confidence values vs the cutoff frequencies,
(d) A plot of the single sided Fourier spectrum of the original vs compressed signal.
9. At the very end, have MATLAB play back the original signal and the compressed signal that first fails the loop test. Additionally, display the transcripts and confidences of the original and the compressed signals.
10. As a final comment in your code, please describe whether your confidence plot from 8(c) makes sense, and if not, what are possible factors that cause this.
Overall, your code should find the cutoff to the nearest 100 Hz. Also, no values should be hard-coded, i.e. everything should be calculated dynamically. For example, your “fprintf” state-ment should not be fprintf(’Cutoff frequency: %.2f\n’, 1900), rather the 1900 should be replaced with a calculation.
Below are some sample outputs using my class demo “electrical engineering is the best” audio clip.
Figure 5: Transcripts of (a) original signal and (b) compressed signal that first failed the test.
Figure 6: Outputs after the compression task is complete.
Figure 7: (a) Graph of average confidence values, and (b) original and compressed spectra.
Submit your work as a single ZIP file that includes your MATLAB code (with comments!) and your recorded audio signal. I should be able to unzip your folder, add the “wav2vec2.0” file to the folder, and run your code, which should generate all of the outputs shown in Figs. 5, 6, and 7. Please ensure that your code can run using the test procedure described. Also, please state how long you spent on this assignment as a comment on your Canvas submission.
OPTION 4: Children’s Book
For this option, you will create a children’s book illustrating one of the 4 topics listed below. Note that some of the topics are compound (e.g. for the third choice, your book must include both sampling and aliasing, not just a subset of them). The book should be aimed at a child around 8 years old. A good validation of your work is to give your book to a friend who knows nothing about electrical engineering, and if they understand the concepts, that is a good sign.
• Impedance and phasors
• Fourier analysis
• Sampling and aliasing
• Compression and JPEG
– You must explain compression in general, and the JPEG algorithm specifically (which will take a little research).
Your book must conform. to the following guidelines.
• [5 points] Have a cover page with a title and illustration.
• [10 points] Have a minimum of 10 pages excluding the cover page.
• [20 points] Each page must contain an illustration and words.
• [55 points (15 points language, 40 points content)] The content must contain proper scien-tific explanations, but be written in language a child could understand.
– The content must not be dumbed down so much that information is omitted, e.g. saying that the Fourier transform. just tells us how much of each frequency is in a signal. You can say that it does indeed tell us how much of each frequency is in a signal, but you must go deeper than that.
• [10 points] The book must be neatly written or typed, using proper grammar.
– The illustrations must be neat and colorful.
– You may use any tools to create the illustrations, including generative AI models like DALL-E and Midjourney.
You may have to go beyond the contents of the class to fully explain some topics, for example you should include much more than what we learned to explain JPEG compression. However, the presentation of this is entirely up to you depending on the contents and style. of your book. If you are unsure whether your explanation is deep enough, you can (and should) ask Ilya. Below are a couple of examples, taken with permission from students’ work on the first deep dive.
For your submission, you must submit a single PDF document. If you wrote the book on paper, take photos or scan the pages. Compile everything into one PDF document. If you wrote the book digitally, you should be able to export into a PDF directly. Also, as a submission comment on Canvas, please state how long you spent on this assignment.