Wednesday, March 29, 2017

Lab 11

Blog sheet Week 11: Strain Gauges
Part A: Strain Gauges:
Strain gauges are used to measure the strain or stress levels on the materials. Alternatively, pressure on the strain gauge causes a generated voltage and it can be used as an energy harvester. You will be given either the flapping or tapping type gauge. When you test the circle buzzer type gauge, you will lay it flat on the table and tap on it. If it is the long rectangle one, you will flap the piece to generate voltage.
1. Connect the oscilloscope probes to the strain gauge. Record the peak voltage values (positive and negative) by flipping/tapping the gauge with low and high pressure. Make sure to set the oscilloscope horizontal and vertical scales appropriately so you can read the values. DO NOT USE the measure tool of the oscilloscope. Adjust your oscilloscope so you can read the values from the screen. Fill out Table 1 and provide photos of the oscilloscope.

Table 1: Strain gauge characteristics

2. Press the “Single” button below the Autoscale button on the oscilloscope. This mode will allow you to capture a single change at the output. Adjust your time and amplitude scales so you have the best resolution for your signal when you flip/tap your strain gauge. Provide a photo of the oscilloscope graph.
Part B: Half-Wave Rectifiers
1. Construct the following half-wave rectifier. Measure the input and the output using the oscilloscope and provide a snapshot of the outputs.
2. Calculate the effective voltage of the input and output and compare the values with the measured ones by completing the following table.
3. Explain how you calculated the rms values. Do calculated and measured values match?

4. Construct the following circuit and record the output voltage using both DMM and the oscilloscope.
5. Replace the 1 µF capacitor with 100 µF and repeat the previous step. What has changed?
Part C: Energy Harvesters
1. Construct the half-wave rectifier circuit without the resistor but with the 1 µF capacitor. Instead of the function generator, use the strain gauge. Discharge the capacitor every time you start a new measurement. Flip/tap your strain gauge and observe the output voltage. Fill out the table below:
2. Briefly explain your results.
3. If we do not use the diode in the circuit (i.e. using only strain gauge to charge the capacitor), what would you observe at the output? Why?
4. Write a MATLAB code to plot the date in table of Part C1.

Flick plot:
x=[10 20 30];
y1=[26 102 61];
y2=[103 346 603];
y3=[375 430 350];
y4=[2800 2300 3000];
plot(x,y1,'o-',x,y2,'s-')
xlabel('Duration (s)')
ylabel('Output Voltage (mV)')
legend('1 Flick per second','4 Flicks per second')


Tap plot:
plot(x,y3,'o-',x,y4,'s-')
xlabel('Duration (s)')
ylabel('Output Voltage (mV)')
legend('1 Tap per second','4 Taps per second')


Monday, March 20, 2017

Lab 10

In this week’s lab, you will collect more data on low pass and high pass filters and “process” them using MATLAB.
PART A: MATLAB practice.

1. Open MATLAB. Open the editor and copy paste the following code. Name your code as FirstCode.m
Save the resulting plot as a JPEG image and put it here.
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)


2. What does clear all do?

Clear all simply clears the command window.

3. What does close all do?

Close all clears the command window and closes all MATLAB figures and graphs etc.

4. In the command line, type x and press enter. This is a matrix. How many rows and columns are there in the matrix?

There is one row and 5 columns in the matrix x.
x =
     1     2     3     4     5


5. Why is there a semicolon at the end of the line of x and y?
The semicolon keeps the x and y from being displayed in the command window when the code is ran.

6. Remove the dot on the y = 2.^x; line and execute the code again. What does the error message mean?
It means that with out the period multiple values of x and y cannot be calculated.

7. How does the LineWidth affect the plot? Explain.
This is how thick the line on the plot is going to be.

8. Type help plot on the command line and study the options for plot command. Provide how you would change the line for plot command to obtain the following figure (Hint: Like ‘LineWidth’, there is another property called ‘MarkerSize’)

x = [1 2 3 4 5];

y = 2.^x;

plot(x,y,'r-o','Linewidth',5,'markersize',15)
xlabel('Numbers', 'FontSize', 12)

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

9. What happens if you change the line for x to x = [1; 2; 3; 4; 5]; ? Explain.

For this code, the array for "x" becomes a vertical one instead of a horizontal one; ie., there is one column with 5 rows instead of 5 columns with one row. The corresponding output is shown below:

x =

     1
     2
     3
     4
     5
However, this change in the x array does not change the values for "y" and thus the plot remains the same.

10. Provide the code for the following figure. You need to figure out the function for y. Notice there are grids on the plot.

plot(x,y,'k:s','Linewidth',5,'markersize',15)
xlabel('Numbers', 'FontSize', 12)

ylabel('Results', 'FontSize', 12)
x
GridLineStyle = '--'
grid on


11. Degree vs. radian in MATLAB:

a. Calculate sinus of 30 degrees using a calculator or internet.
The calculated value of sin 30 is .5.

b. Type sin(30) in the command line of the MATLAB. Why is this number different? (Hint: MATLAB treats angles as radians).
MATLAB uses radians as a default measurement and if the user wants degrees they just have to change the code a bit. Below, the code and the output are displayed for "sin(30)."
>> sin(30)

ans =

   -0.9880

c. How can you modify sin(30) so we get the correct number?

Using just "sin" will be accurate for values in radians, but to get values for degrees, "sind" can be used instead. The MATLAB input and output are displayed here:
>> sind(30)

ans =

    0.5000

12. Plot y = 10 sin (100 t) using Matlab with two different resolutions on the same plot: 10 points per period and 1000 points per period. The plot needs to show only two periods. Commands you might need to use are linspace, plot, hold on, legend, xlabel, and ylabel. Provide your code and resulting figure. The output figure should look like the following:
Graph: Sinusoidal curve of how the coarse would normally appear
To obtain this graph, the following code was entered into MATLAB:

t=linspace(0,4*pi/100,10);
y=10.*sin(100.*t);
plot(t,y,'r-o')
hold on
t2=linspace(0,4*pi/100,1000);
y2=10.*sin(100.*t2);
plot(t2,y2,'k')
xlabel('Time (s)')
ylabel('y function')
legend('Coarse','Fine')

Note that the upper value of the linspace command for the two different t values is 4*pi/100. this is because the graph is of the first 2 periods and the period of a sinusoidal function is 2pi/b where "b" is the coeffecient of "t" in the sin function (y=Asin(bt)). So, to show two periods, 2pi/ b was multiplied by 2 to get 4pi/100.

13. Explain what is changed in the following plot comparing to the previous one.
Graph: Function with a maximum value of 5, and what it would normally look like

So for the updated graph, the fine value has a set maximum of 5 now, as opposed to the original function that had a maximum value of 10. Because there are values that would normally be about the 5, the new graph just flattens out at the maximum.

14. The command find was used to create this code. Study the use of find (help find) and try to replicate the plot above. Provide your code.

t=linspace(0,4*pi/100,10);
y=10.*sin(100.*t);
plot(t,y,'r-o')
hold on
t2=linspace(0,4*pi/100,1000);
y2=10.*sin(100.*t2);
%plot(t2,y2,'k')
xlabel('Time (s)')
ylabel('y function')
legend('Coarse','Fine')
I=find(y2<5);
t3= t2(I);
y3= y2(I);
plot(t3,y3,'k')

To obtain the graph from 13, the above code was entered. the "find" code finds the indices of the values of a vector that are above or below a certain value. For this function, we used "find" to find the values for y2 that were less than 5, where y2 was the smooth function for 10sin(100t). With these indices found, we called these values to the new matrices of t3 for time and y3 for the y values of the function. Then we plotted y3 with respect to t3 to get the graph displayed above.

PART B: Filters and MATLAB
1. Build a low pass filter using a resistor and capacitor in which the cut off frequency is 1 kHz.
Observe the output signal using the oscilloscope. Collect several data points particularly around the cut off frequency. Provide your data in a table.

Frequency (Hz)
Output rms Voltage (V)
10
0.838
50
0.847
100
0.849
200
0.838
300
0.820
400
0.797
500
0.768
600
0.737
700
0.709
800
0.680
850
0.668
900
0.648
950
0.637
1000
0.625
1050
0.607
1100
0.599
1150
0.583
1200
0.573
1300
0.545
1400
0.516
1500
0.493
Table: Low pass filter frequency and resulting output voltage
*Input is 1 V peak to peak, or 0.707 rms V.
2. Plot your data using MATLAB. Make sure to use proper labels for the plot and make your plot line and fonts readable. Provide your code and the plot.

MATLAB Code:

F=[10 50 100 200 300 400 500 600 700 800 850 900 950 1000 1050 1100 1150 ...
    1200 1300 1400 1500]
Vout=[.838 .847 .849 .838 .820 .797 0.768 .737 .709 .680 .668 .648 .637 ...
    .625 .607 .599 .583 .573 .545 .516 .493]
plot(F,Vout,'LineWidth', 3)
xlabel('Frequency (Hz)')
ylabel('rms Output (V)')
title ('Output Voltage Vs Frequency: Low Pass Filter')












Graph: Low pass filter and resulting output voltage

3. Calculate the cut off frequency using MATLAB. find command will be used. Provide your code.

MATLAB Code:

F=[10 50 100 200 300 400 500 600 700 800 850 900 950 1000 1050 1100 1150 ...
    1200 1300 1400 1500];
Vout=[.838 .847 .849 .838 .820 .797 0.768 .737 .709 .680 .668 .648 .637 ...
    .625 .607 .599 .583 .573 .545 .516 .493];
plot(F,Vout,'LineWidth', 3)
xlabel('Frequency (Hz)')
ylabel('rms Output (V)')
title ('Output Voltage Vs Frequency: Low Pass Filter')
hold on
c=find(Vout<.707*.838);
d=c(1);
CutoffFrequency=F(d)

MATLAB Output:
CutoffFrequency =

        1150

4. Put a horizontal dashed line on the previous plot that passes through the cutoff frequency.

Graph: Low pass filter frequency with respect to voltage
5. Repeat 1-3 by modifying the circuit to a high pass filter.




      5.1. 
Frequency (Hz)
Output rms Voltage (V)
10
0.030
50
0.048
100
0.072
200
0.163
300
0.235
400
0.301
500
0.369
600
0.423
700
0.467
800
0.516
850
0.532
900
0.549
950
0.568
1000
0.582
1050
0.596
1100
0.610
1150
0.622
1200
0.634
1300
0.655
1400
0.678
1500
0.689
Table: High pass filter frequency and the resulting output voltage



      5.2.
MATLAB Code:

F=[10 50 100 200 300 400 500 600 700 800 850 900 950 1000 1050 1100 1150 ...
    1200 1300 1400 1500];
Vout=[0.030 .048 .072 .162 .235 .301 .369 .423 .467 .516 .532 .544 .568 ...
    .582 .596 .610 .622 .634 .655 .678 .689];
plot(F,Vout,'LineWidth', 3)
xlabel('Frequency (Hz)')
ylabel('rms Output (V)')
title ('Output Voltage Vs Frequency: High Pass Filter')

Graph: High pass filter frequency with respect to voltage

    5.3  Calculate the cut off frequency using MATLAB. find command will be used. 
F=[10 50 100 200 300 400 500 600 700 800 850 900 950 1000 1050 1100 1150 ...
    1200 1300 1400 1500];
Vout=[.030 .048 .072 .162 .235 .301 .369 .423 .467 .516 .532 .544 .568 ...
    .582 .596 .610 .622 .634 .655 .678 .689];
plot(F,Vout,'LineWidth', 3);
xlabel('Frequency (Hz)');
ylabel('rms Output (V)');
title ('Output Voltage Vs Frequency: Low Pass Filter');
x=find(Vout>.549);
c=F(s);
cutoff= min(c)

cutoff =

   950





Thursday, March 16, 2017

Lab 9

1. Measure the resistance of the speaker. Compare this value with the value you would find online.

The resistance of our speaker was about 18.8 Ohms, how ever we noticed it was moved even a little it would change the resistance, so our DMM ended up varying from about 13-20 ohms. Looking online, most speakers have a resistance of either 4, 8 or 16 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)

Image: Simple Speaker Circuit Diagram


Frequency (Hz)
Observation
1
No sound
15
Quiet chirping sound
222.22
Quiet low pitched hum
1000
High pitched hum
23000
No sound
Table: Sound observations from the varying frequency

Video: Explanation of the Effect of Varying frequency.

As stated in the table above, very low frequency and very high frequencies were inaudible from the speaker. In the range of audible frequencies, the lower ones had a lower pitch, and as the frequency was gradually increased, the pitch of the sound from the speaker increased. This increase was not gradual, but occurred in step-like increments. 

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.


Resistance (Ω)
Oscilloscope output over speaker (V)
Observation
47
1.2
Same pitch as without resistance, but it is quieter
820
0.16
The pitch still remains the same, and it is even quieter.
Table: Voltage across certain resistances and what was observed

This data shows that the resistance values of a circuit involving a speaker do not have an apparent impact on the pitch of the resulting sound. This means that the resistance does not affect the frequency of the voltage. Resistance, does, however, affect volume i.e.; the higher the resistance 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 should
not hear anything at the beginning and start hearing the sound after a certain frequency. Use 22 nF for the capacitor.
Image: Speaker Circuit Diagram with a Capacitor

a. Explain the operation. (video)
Video: Operation of the High pass filter


b. Fill out the following table by adding enough (10-15 data points) frequency measurements. Vout is measured with the DMM, thus it will be rms value.

Frequency (Hz)
Vout (rms) (mV)
Vout (rms)/ Vin (rms) (mV)
0
1
.18
20
1
.18
100
2
.3536
500
2
.35
1000
5
.884
1500
6
1.061
2000
7
1.238
2500
8
1.45
3000
9
1.59
3500
10
1.77
4000
11
1.95
5000
12
2.12
10000
12
2.12
15000
8
1.45
20000
6
1.061
Table: Varying frequency and the measured output
c. Draw Vout/Vin with respect to frequency using Excel.

Graph: Vout/Vin and frequency

d. What is the cut off frequency by looking at the plot in b?

The cut-off frequency from this set of data appears to be about 8000 Hz. This can be seen in the graph above and the two graphs below because the cut-off frequency is where the Vin/Vout stops increasing with respect to frequency.

e. Draw Vout/Vin with respect to frequency using MATLAB.

Vout/Vin Vs Frequency


Graphs: Top one is Vout/Vin with respect to frequency, Bottom is loglog graph with same values

f. Calculate the cut off frequency theoretically and compare with one that was found in c.

Our calculated value for the cut-off frequency was 72kHz, while our observed cut-off frequency was about 8000 Hz. This large discrepancy could have been avoided if we had tested larger values for Frequency instead of assuming that this apparent downward trend after 8000 Hz would continue.

g. Explain how the circuit works as a high pass filter.

A high pass filter blocks waves of lower frequencies from passing while allowing higher frequency waves, depending on the setting of the filter, to pass. This means that the the input and output voltages for the higher frequency waves should be about the same. the result of this is that the higher frequencies are audible, and the lower ones are silenced.

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.
5a.
5b. Low pass filter
Frequency (Hz)
Vout (rms) (V)
Vout (rms)/ Vin (rms) (V)
0
.001
.001707
20
.286
.0505
100
.287
.0507
220
.29
.0512
500
.297
.05249
650
.32
.0565
700
.326
.0576
750
.331
.05848
830
.329
.058
1000
.315
.0556
1500
.293
.0518
3000
.239
.0472
5000
.197
.0348
10000
.116
.0205
15000
.069
.012
20000
.042
.0074
Graph: Low pass filter with varying frequency

5c.
Graph: The x axis is the frequency in Hz, and the y-axis is the Vout/Vin voltage

e. 

Graphs:  Top one is Vout/Vin with respect to frequency, Bottom is loglog graph with same values

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.
Image: Circuit Diagram with a Microphone and Headphone Jack