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.

Flipping Strength
Min Voltage (V)
Max Voltage (V)
Low
-2
4.4
High
-27.2
14.4


Tapping Strenght
Min Voltage (V)
Max Voltage (V)
Low
-1
1.8
High
-4
24.8

Table 1: Strain gauge characteristics
Picture: Low tapping on the sensor

Picture: High tapping on the sensor


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.



Picture: Single Wave of Tapping Gauge

Picture: Single Wave of Flicking Gauge


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.






Picture: Oscilloscope reading of the half-wave rectifier

2. Calculate the effective voltage of the input and output and compare the values with the measured ones by completing the following table.

Effective Rms
Calculated
Measured
Input
7.07
7.25
Output
3.54
3.63

3. Explain how you calculated the rms values. Do calculated and measured values match?

The rms value of the input is calculated by by dividing the peak to peak input voltage by the square root of 2 as a simplification of the following integral for a  sin wave:

Equation: RMS Equation as Found on Wikipedia
f_{\mathrm {rms} }=\lim _{T\rightarrow \infty }{\sqrt {{1 \over {T}}{\int _{0}^{T}{[f(t)]}^{2}\,dt}}}.

Because an integral describes the area under a curve, it is clear that the area of the output wave should be half of that of the input. So the simplified integral calculation for the output becomes the input peak to peak voltage divided by the quantity of 2 times the square root of 2.

With this calculation and the measurements at the output, there appears to be an apparent consistency within a reasonable margin of error.

4. Construct the following circuit and record the output voltage using both DMM and the oscilloscope.

Oscilloscope
DMM
Output Voltage (P2P) (V)
9.6
2.725
Out Put Voltage (Mean) (V)
.225
3.9

5. Replace the 1 µF capacitor with 100 µF and repeat the previous step. What has changed?

Oscilloscope
DMM
Output Voltage (P2P) (V)
.596
.125
Out Put Voltage (Mean) (V)
Jumps from 2 to-4
6.44

With a higher capacitance, the range of the oscillations was significantly decreased, but the mean of the output voltage significantly increased presumably because the stronger capacitor stored more voltage. It also became difficult to get a consistent reading particularly for the output voltage mean. we hypothesize that this might be caused by the capacitor's function of storing and releasing voltage.

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:

Time (s)
Output (mV)
1 Flip per Second
10
26
1 Flip per Second
20
102
1 Flip per Second
30
61
4 Flip per Second
10
103
4 Flip per Second
20
346
4 Flip per Second
30
603


Time (s)
Output (mV)
1 Tap per Second
10
375
1 Tap per Second
20
430
1 Tap per Second
30
350
4 Tap per Second
10
2800
4 Tap per Second
20
2300
4 Tap per Second
30
3000

2. Briefly explain your results.

We noticed when doing the flips and taps per second, that if you hit it harder at first then not as hard the time after it started to decrease even though it was still being hit. After noticing this, it helped reason why some of our numbers ended up seeming off in perspective to the values before.

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?

There is little to no change in the graph, because the diode only allows the positive part of the wave to pass through and without it the wave ends up canceling itself out.This is because if only a positive input is allowed to effect the output, it can continue to increase the voltage, but if the negative portion of the wave passes through as well the output voltage would have a tendency to make a small increase followed by a small decrease and repeating this in a cyclical pattern resulting in no net gain in voltage.

4. Write a MATLAB code to plot the date in table of Part C1.

Flick Gauge MATLAB Code:

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

Graph: Flick Gauge Voltages After Different Intervals of Consistent Flicking

Tap Guage MATLAB Code:

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

Graph: Tap Gauge Voltages After Different Intervals of Consistent Tapping


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