You are on page 1of 17

QUESTION 1

 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.

 Determine the frequency and amplitude of the fundamental Fourier component of


each signal using the fast Fourier transform (FFT); show the resulting graph
of the FFT spectrum. [Hint: In most cases these frequencies should both be
close to 88 Hz]

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.

Fundamental frequency at 88.1550656907753, with amplitude 0.44937564100743027.

 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.

To respond this exercise, I have made use of the plot_opamp_signals function


we learnt in the laboratory session and applied it to measure both the left
and right channel signals. It is expected to obtain a voltage-gain of 1
because the input (A0 in the Arduino) and output (A1) voltages are the same,
as well as a phase-shift of zero. That is because the input and output signals
are in phase, that is, their graphs are superposed, so the difference of their
tops, for example, must be zero. In this case it is close to it as we shall
see.

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.

As we can see, the trend is as expected, with a voltage-gain very close to 1.


But let us look closely at the FFT analysis for the left channel.
There is a fundamental peak at the same generated frequency of around 88 Hz,
whose amplitudes vary very little from the input and output signals. Here we
obtain the value of the phase-shift, which, according to the graphs showed, is
very little as well and close to zero.

Analogously, for the right audio channel, we get:

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:

Phase-shift = 6 +/- 3 degrees


QUESTION 3

 Connect the inputs to voltages supplied by the fixed-voltage outputs of your


Arduino such that V1=3.3 V and V2=5 V. Acquire and plot suitable data to
determine a value for Vout with an uncertainty. Comment on the result.

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,

Vout = 1.748 +/ 0.001 V

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:

V1 = 3.2337 +/- 0.0005 V


V2 = 5.0 +/- 0.0 V

According to these results, the real expected value Vout = V2 – V1 would be:

Vout,exp = V2 – V1 = 1.7663 +/- 0.0005 V

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.

As we can see, they are completely out of phase.


 Determine the phase-shift between the pair of signals, and comment on the
result.

Doing a FFT analysis which follows the same method as in Question 2, it is


possible to get the phase-shift between the two signals. However, as we can
see from the previous exercise, both signals are out of phase, so we expect to
obtain a phase-shift of around 180 degrees. Let us verify this by doing the
analysis.

As we can see, there is a peak at 88 Hz, which is right according to the


generated signal. Therefore, the phase-shift is:

Phase-shift = 187 +/- 3 degrees

According to the expected value of Phase-shift = 180 degrees, this result


agrees with it. Moreover, looking at the drawn diagram above, it was also
expected to get the same signal intensity but out of phase, as the same
resistance values were used and there was an op-amp in between the V1 and Vout
readings, turning the signal around.

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).

Then, the FFT analysis is plotted below.


Hence, the largest-amplitude Fourier component of each signal is the same
frequency for both. Their fundamental frequency is found to be 632 Hz with
0.168 amplitude. As we can observe from Question 1, the fundamental frequency
remains the same but their amplitudes vary. Besides, the voltage vs. time
plots above are also different from the ones found in Question 1.

 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.

I have taken R1 = R2 = R = Rgain = 1 MΩ in order to simplify calculus. Hence,


we can state that the designed voltage gain according to these parameters is

Vgain = (1 + 2R/Rgain)*R2/R1 = (1 + 2)*1 = 3

Subsequently, it is possible to calculate the overall designed gain:

Gain = 20*log10(Vgain) = 20*log10(3) = 9.542425094… dB

 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.

The experimental setup follows the diagram below.

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 resulting plot is, therefore, the one below.

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.

You might also like