Monday, March 20, 2017

Week Ten

Not Shocking People Whilst Using MATLAB

Week Ten

%1 
clear all;
close all;
x = [1 2 3 4 5];
y = 2.^x;
plot(x, y, 'LineWidth', 6)
xlabel('Numbers', 'FontSize', 12)
ylabel('Results', 'FontSize', 12)

clear all; %2 clear all removes prior variable and function definitions

close all; %3 closes any prior command based windows (i.e. plot, ext.)

x = [1 2 3 4 5]; 

y = 2.^x;

plot(x, y, 'LineWidth', 6)

xlabel('Numbers', 'FontSize', 12)

ylabel('Results', 'FontSize', 12)

%4 when typing x and pressing enter, the prior logged values for x appear
%the matrix has one row and five colomns.

%5 the semicolon is used when defining the function, which without it, would
%the values would not be stored and the plot function nor defined

%6 If a . is not used before the power, the x values will be read as a whole
%matrix instead of being recognized individually.

%7 It affects the thickness of the line that is plotted

%8
clear all; 
close all; 
x = [1 2 3 4 5];

y = 2.^x;

plot(x, y, '-rO','LineWidth', 5,'markersize',18)

xlabel('Numbers', 'FontSize', 12)

ylabel('Results', 'FontSize', 12)



%9
clear all; 
close all; 
x = [1; 2; 3; 4; 5;];

y = 2.^x;

plot(x, y, '-rO','LineWidth', 5, 'markersize',18)

xlabel('Numbers', 'FontSize', 12)

ylabel('Results', 'FontSize', 12)



%The plot stays the same, as these colons are already expressed when the .
%is placed before the ^

%10
clear all; 
close all; 
x = [1 2 3 4 5];

y = 2.^x;

plot(x, y, ':ks','LineWidth', 6, 'markersize',14)
grid on
xlabel('Numbers', 'FontSize', 12)

ylabel('Results', 'FontSize', 12)



%11
%a : on google calculator
%sin(30)=0.5

%b
%sin(30) = -0.9880
%They are differenct because google automatically calculates sin using
%degree values inside the parenthesis, whereas when in MATLAB, sin(x) is a
%radian command, while sind(x) is using degrees

%c
%sind(30) = 0.5000

%12
clear all;
close all;
t = linspace(0,0.12,10);
y = 10*sin(100*t);
u = linspace(0,0.12,1000);
z = 10*sin(100*u);

plot(t,y,'-ro')
hold on
plot(u,z,'-k')

xlabel('Time(s)')
ylabel('y function')
legend('Course','Fine')



%13 
%Differences: Two plots were formatted atop one another using the hold on
%command, the variables were defined using intervals of range of values,
%there was a legend added.

%14
clear all;
close all;
t = linspace(0,0.12,10);
y = 10*sin(100*t);
u = linspace(0,0.12,1000);
z = 10*sin(100*u);
f=find(z>5)
z(f)=5
plot(t,y,'-ro')
hold on
plot(u,z,'-k')

xlabel('Time(s)')
ylabel('y function')
legend('Course','Fine')


PART B
1.

2.
%PART B
%2

clear all;
close all;
f=[.1 .2 .3 .4 .5 .6 .7 .8 .9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2]
v=[3.25 3.82 3.66 3.58 3.5 3.4 3.3 3.2 3.07 2.96 2.85 2.75 2.63 2.53 2.45 2.35 2.28 2.2 2.12 2.05]

plot(f,v,'-ro')

xlabel('frequency(KHz)')
ylabel('V out(V)')
grid on


3.
fc= 1/(2*3.141593*7500*0.000000022)
fc =

  964.5753

%The voltage at 965 is 3

clear all;
close all;
f=[.1 .2 .3 .4 .5 .6 .7 .8 .9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2];
v=[3.25 3.82 3.66 3.58 3.5 3.4 3.3 3.2 3.07 2.96 2.85 2.75 2.63 2.53 2.45 2.35 2.28 2.2 2.12 2.05];
c=find(v>3)
v(c)=3
plot(f,v,'-ro')

xlabel('frequency(KHz)')
ylabel('V out(V)')
grid on


%4
clear all;
close all;
f=[.1 .2 .3 .4 .5 .6 .7 .8 .9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2];
v=[3.25 3.82 3.66 3.58 3.5 3.4 3.3 3.2 3.07 2.96 2.85 2.75 2.63 2.53 2.45 2.35 2.28 2.2 2.12 2.05];
c=find(v>3)
v(c)=3
plot(f,v,'-ro')
hold on
y=[.1 .2 .3 .4 .5 .6 .7 .8 .9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2];
u=[3.25 3.82 3.66 3.58 3.5 3.4 3.3 3.2 3.07 2.96 2.85 2.75 2.63 2.53 2.45 2.35 2.28 2.2 2.12 2.05];
plot(y,u,'--k')
legend('output with cutoff','output')

xlabel('frequency(KHz)')
ylabel('V out(V)')
grid on

Monday, March 13, 2017

Week Nine

Not Shocking People After Spring Break

Week Nine

1. Measure the resistance of the speaker.

We measured 8.6 Ohms, while online is says this model of speaker offers 32 Ohms.

2. Build the following circuit using a function generator setting the amplitude to 5V (0V offset). What happens when you change the frequency? (video)


Figure 1: Frequency of AC Voltage applied to a speaker.

Figure 2: Circuit Layout

Figure 3: Frequencies compared speaker output.

3. Add one resistor to the circuit in series with the speaker (first 47 Ω, then 820 Ω). Measure the voltage across the speaker. Briefly explain your observations.



Figure 4: Observations while placing resistors in parallel with speaker. The higher the resistor, the lower the amplitude. Therefore, the lower the volume.

4. Build the following circuit. Add a resistor in series to the speaker to have an equivalent resistance of 100 Ω. Note that this circuit is a high pass filter. Set the amplitude of the input signal to 8 V. Change the frequency from low to high to observe the speaker sound. You shouldnot hear anything at the beginning and start hearing the sound after a certain frequency. Use 22 nF for the capacitor.

a.
Figure 5: Video explaining the operation of the high pass  filter connected to the speaker.

b. & c.
Figure 6: V_out measured and V_out/V_in Calculated with respect to frequency increasing.

d. It looks like the cutoff frequency is 5000 with the voltage V_out capping off at 0.014V.
e. 
Figure 7: Plot of Frequency v. Output. The climax of the curve shows the critical frequency of the circuit.

f. The Cutoff Frequency according to our plot and theoretical calculations is 5000 Hz.
g. As the frequency increases, to a high 2000 Hz, the voltage amplitude takes on a significant enough value to be audible to human ears. However, when the frequency reaches 5000 Hz, the voltage reaches its cutoff point and begins to decrease. 

5. Design the circuit in 4 to act as a low pass filter and show its operation. Where would you put the speaker? Repeat 4a-g using the new designed circuit.

We would place the speaker in parallel with a capacitor, the pair of which would be in series with a resistor. 

a.
Figure 8: Video explaining the operation of the low pass filter.

b. & c.
Figure 9:V_out measured and V_out/V_in Calculated with respect to frequency increasing in a low pass circuit.

d. The cutoff frequency is at 1000, capping off at .596 V.
e.
Figure 10: Plot of Frequency v. Output of a low pass circuit. The climax of the curve shows the critical frequency of the circuit.

f. According to the plot, our cutoff frequency is at 1000.
g. The low pass filter works in a way where the capacitor works as an extremely high resistance to low frequency signals, making them pass to the speaker, whereas high frequency will pass through the capacitor, and not to the speaker, as can be seen above. 

6. Construct the following circuit and test the speaker with headsets. Connect the amplifier output directly to the headphone jack (without the potentiometer). Load is the headphone jack in the schematic. “Speculate” the operation of the circuit with a video.


Figure 11: Video with speculation of the operation of the circuit.


Friday, March 3, 2017

Week Eight

Week Eight

NOT SHOCKING PEOPLE

Steps of Rube Goldberg Circuit

Figure 1: Video of Rube Goldberg Function

Circuit Explanation

Figure 2: Step 1: The Pressure sensor is pressed by a weighted object.
Figure 3: Step 2: The light of the LED connected to the OR gate turns on, informing the user that we must begin applying heat to the temperature sensor. 
Figure 4: The gate mentioned in step 2
Figure 5: Image of AND gate on bottom and driver on top. The and gate inputs are connected to the relay input is parallel and the pressure sensor. When both of these are active the counter will begin to function.
Figure 6: Step 3: The heat provided to the temperature sensor allows for a voltage and  current to flow into the ompamp, amplifying the current, allowing the relay to switch on. 
Figure 7: Step 4: Once the and gate is satisfied with two active inputs, then the driver begins to send signals to the counter, which then sends signal to the digital display, starting the count up from 0 to 9 and then repeating.
Figure 8: Step 5: Once the relay is active, current is applied to a motor which spins this mechanical apparatus, knocking over something important and making something happen for somebody else.


Struggles


One struggle we faced was getting the relay to switch while connected to the temperature sensor. We noticed that there was not enough voltage going between the temperature sensor output to the relay (only 1V). We first tried to fix this with a 741 amplifier being placed between the two, but that did not amplify the current enough to switch on the relay. Instead, we used an opamp to amplify, which introduced our next problem.

Another struggle we faced was applying the proper gain to the opamp to switch the relay on, even though we knew it could work, we were concerned why it wasn't. What we had found was that we were applying too small of a voltage to the voltage input to power the opamp. After increasing the opamp voltage to 20 V, the amplified voltage and current was able to reach the appropriate amplitude to switch the relay on.