Professional Documents
Culture Documents
Acquire around 1000 samples of the signals and show a plot of these signals.
As we did in previous sessions, the left and right audio outputs were
connected respectively to the A0 and A1 inputs of the Arduino while its serial
communication was initialized to 115200 bits per second. The requested plot
can be seen below.
However, in this case, it might be more practical to work with the same
signal, but as a function of time rather than sample number. Therefore, the
sample rate is,
Thus, it was possible to plot the two channel signal as a function of time to
then be able to get the Fourier Transform in subsequent exercises. Making use
of 1000 samples, the requested plot can be seen below.
Making use of the FFT function on Python, both the frequency and amplitude of
the fundamental Fourier component were obtained, as well as it spectrum, as
can be seen below. For this purpose, the same properties were used as in the
previous exercise.
Analogously, for the R channel, we get a similar graph and fundamental
frequency.
Acquire around 1000-2000 samples of the signals and show a plot of these
signals.
To be able to see the trend of the mystery signal, I have plotted several
graphs. In the first one there are 2000 samples and then, 500 and 100. A0 and
A1 refer again to the left and right channels, respectively.
Determine the frequency and amplitude of the largest-amplitude Fourier
component of each signal using the FFT; show the resulting graph of the FFT
spectra. [Hint: These frequencies should be the same, and somewhere in the
range 600 - 800 Hz.]
For both left and right signals, the FFT shows their fundamental frequency and
amplitude are the same, 632 Hz and 0.96, respectively.
Calculate how many samples per 'cycle' of this high-frequency mystery signal
you expect to measure at the maximum sampling rate of your Arduino.
The maximum sampling rate of the Arduino is calculated through the maximum
baud-rate, which for this case it is 115200 baud, that is, the maximum speed
at which the Arduino can transfer data to the computer. By calculating the
total number of discrete “times” at which we get a different sample, and
dividing it by the difference between the last and first “time” value of the
time vector, it is possible to obtain the maximum sampling rate of the
Arduino:
Determine the maximum voltage gain that you would expect to be able to apply
equally to both signals before they saturate, nominally exceeding the 0-5 V
limit of both the amplifier output and the Arduino analog inputs. Explain why
you would not want to apply a larger gain than this.
If the voltage gain is defined as Voltage gain = Vout/Vin, the maximum voltage
gain will be determined by the maximum Vout
QUESTION 2
Using the frequency_generator.py code and your Arduino, demonstrate that each
of your unity-gain buffers functions as intended; producing a voltage-gain of
1, and phase-shift of zero.
First of all, we will analyse the left audio channel, where both voltages have
been plotted below for the first 0.30 and 0.10 seconds, respectively.
Again, we obtain a voltage gain very close to the unit. This conclusion is
drawn from the first to graphs. Subsequently, we get a phase-shift very close
to zero. Hence, writing it in a proper way, the phase-shifts are, for both
left and right cases:
For doing this task, and following the diagram, I have built the following
setup:
As we can see in the setup above, I have used the same 1 MΩ resistor for every
R1 and R2 in order to get Vout = V2 – V1. Substituting with the real Arduino
voltages, and under these parameters, we should obtain Vout = 5 – 3.3 = 1.7 V
Making use of the methods used in the first Electronics session, such as the
Python function read_arduino, it has been possible to obtain the value of
Vout. After doing a couple of arrangements in the original code to measure
more voltage samples (100) and plotting them against the sample number, the
results we get are described below.
Measuring Vout
In this graph we can see the voltage read in each sample. It is a bit noisy
but nevertheless we can get the average value of the voltages as well as its
standard error. Hence,
Which is a bit far from the expected value Vout = 1.7 V. Let us find why. For
doing so we would like to know what the real values of both V1 and V2 are.
Applying this last method in order to measure each input voltage V1 and V2
directly from their respective 3.3 V and 5 V slots to the A0 input in the
Arduino, the results we obtain are:
According to these results, the real expected value Vout = V2 – V1 would be:
Although this value is not within the real Vout error interval, it is much
closer to the real one obtained previously. This fact might be due to the
resistance values or perhaps, to the circuit internal connections, but be that
as it may, we can consider this difference as negligible.
QUESTION 4
Acquire 1000-2000 samples of the V1 and Vout signals using your Arduino, and
show a plot of these signals. Ensure that it is made clear which signal is
which.
The experimental setup to respond this question has been the following (with
R1 = R2 = 1 MΩ):
Thus, setting V1 and Vout as the A0 and A1 slots in the Arduino, respectively,
we can use an analogous procedure to the one used in Question 2, with the same
Python and Arduino codes. For doing so, I have plugged a jumper where the
diagram says Vout connected to A1 and another jumper where there is the node
connection between the unity-gain buffer and the R1 from above to A0 in order
to read the right voltage values. Now, we can see the obtained plots below for
2000, 500 and 100 samples respectively.
I wanted to say that for this setup, I plugged the ground jumper from the
transformer into the second group of resistors which also made a potential
divider. If I had plugged it directly into ground, the signal shape would have
changed but the rest of the parameters such as the phase-shift would have
remained the same.
QUESTION 5
Acquire 1000-2000 samples of the V1 and V2 signals using your Arduino, and
show a plot of these signals. Ensure that it is made clear which signal is
which. Determine the frequency and amplitude of the largest-amplitude Fourier
component of each signal, and show the FFT spectra - do the results match what
you found previously, before connecting the signals to the amplifier?
As usual, A0 is the left channel (V1) and A1 the right one (V2).
Acquire and plot 1000-2000 samples of the Vout signal. Take the FFT of the
acquired signal and show the resulting graph of the FFT spectrum. Comment on
the result. [Hint: Remember that the resolution of the Arduino analog input is
~5 mV, and your differential amplifier only has unity voltage gain.]
We can then notice that all the graphs from this exercise as from the previous
one are very similar, practically the same, so in this case the differential
amplifier doesn’t change the original V1 and V2 from their corresponding
buffers. We should recall that all of the resistors have the same value. That
is why we would start to see a few differences in the next question.
QUESTION 6
Acquire and plot 1000-2000 samples of the Vout signal. Take the FFT of the
acquired signal and show the resulting graph of the FFT spectrum. State any
values determined, and comment on the result.
To achieve the new voltage gain I have substituted R1 with R1 = 100 kΩ.
Finally, we obtain the same plots as above but with the difference that all of
the voltage values have been multiplied by 10, which follows what we expected
by changing only the resistors.
Besides, in the FFT spectrum the fundamental frequency is still the same as in
Question 5, but its amplitude has also been multiplied by 10, due to the
change of resistors.
QUESTION 7
State the overall designed gain of your instrumentation amplifier as both the
voltage gain, and in dB units.
Acquire and plot 1000-2000 samples of the Vout signal. Take the FFT of the
acquired signal and show the resulting graph of the FFT spectrum.
Then, making use of the codes and FFT analysis we have also used in previous
questions (such as the second or the fourth) we have been able to obtain the
requested plots. These codes had been arranged by removing the A1 output,
which is empty in this exercise. The 2000 samples of the Vout signal are
plotted below.
The signal simply behaves as the emission of a different intensity peak at a
given time. The FFT spectrum is also plotted below.
Increase the number of samples to around 20000. Determine the FFT and plot the
resulting spectrum so as to clearly show the main frequency components of the
signal.
The main frequency components are now very clear from this plot. Again, we see
the fundamental frequency is at around 631 Hz, but there are others such as
around 10 Hz, 200 Hz, 300 Hz, 500 Hz and 830 Hz.