Saturday, April 25, 2015

Inverting Differentiator

Inverting Differentiator

In this lab, we use an op amp (OP 27) and a capacitor to create an inverting differentiator. This means that the output voltage V_o is (a multiple of) the negative derivative of the input voltage V_in, or V_o = -RC*(dv_i/dt), where R is the feedback resistance, C is the capacitor capacitance, and v_i is the input voltage. If the input voltage v_i = Acos(ωt), where A is the input amplitude and ω is the angular frequency, then its derivative is (dv_i/dt) = -Aωcos(ωt). Thus the output voltage is V_o = RCAωsin(ωt).
We wire the circuit according to the diagram above using a 470 nF capacitor, and a 470 Ω (464 Ω measured) feedback resistor.
We will be applying three sinusoidal waves for the input. Their amplitudes are all 100 mV and are centered at zero (offset = 0). The frequencies will vary from 1 kHz, 2 kHz, and 500 Hz.
First we solve for the expected output voltages V_o1, V_o2, and V_o3, which correspond to the 1 kHz, 2 kHz, and 500 Hz waves, respectively. Earlier we saw that the output of the voltage is V_o = RCAωsin(ωt). Since the input frequency is given in hertz, we will need to convert angular frequency to linear frequency using ω = 2πf. Therefore the output voltage can be rewritten as V_o = 2πfRCAsin(2πft).
The numbers were plugged in for the three inputs and we obtained the three theoretical time-varying output voltages.

Here is a picture of our circuit, ready to be analyzed. The long orange wires measure the input voltage V_i on the oscilloscope and are on channel 1 (C1) on the WaveForms software. The yellow wire is connected to the input voltage V_i. The two top green wires are connected to the output pin and ground, respectively to measure the output voltage V_o which is on channel 2 (C2) on the software. The white and brown wires provide the -/+ 5 V rail voltages. The bottom green wires are both connected to ground (the second is redundant).


Sinusoidal Wave - Input: 100 mV @ 2 kHz
Here we see the input (orange) and output (blue) voltages. The input voltage is 100 mV at 2 kHz. We see that the blue wave is the negative derivative of the input multiplied by some constant. However, from examining the waves, we see there are two errors. The input voltage is actually not a cosine wave but a sine wave. Second, the amplitude is much greater than we expected. The first problem can be fixed by simply changing the phase angle of the input wave but this does not concern us much. We are more interested in seeing the input become differentiated. However, the amplitude does not match what we expected. We are supposed to be getting an output amplitude of around 0.2776 V but we are observing an amplitude of about 2.5 V!
After double checking everything, we notice the capacitor we used was not 470 nF but 4.7 µF (4.24 µF measured). This means that the capacitance was off by a factor of 10. We must take this into consideration.
Looking more closely at the graph, we see the input amplitude is 100 mV with a little offset. The output amplitude is obtained by taking the average of the wave peaks. We obtain an output of (2.35+2.4)/2 = 2.375 V. Recalculating what the output amplitude should be, A_output = 2πfRCA = 2π(2000)(464)(4.24E-6)(0.100) = 2.4723 V. Comparing this to our theoretical value 2.375 V, we get a percent error of 3.9 %. This makes our predictions accurate, and we now regain trust in our inverting differentiator.


Sinusoidal Wave - Input: 100 mV @ 1 kHz
Now we repeat the experiment for a sinusoidal voltage input of 100 mV with a 1 kHz frequency. We calculate the output amplitude once again as done previously as A_output = 2πfRCA = 2π(1000)(464)(4.24E-6)(0.100) = 1.2361 V. Looking at the graph, we see the input has an amplitude of 100 mV (with a small offset). Taking the average of the top and bottom peaks we find the amplitude is (1.1+1.25)/2 = 1.175 V. Compared to our theoretical value, we have a 4.9 % error, which again is acceptable.


Sinusoidal Wave - Input: 100 mV @ 50 Hz
Finally, we repeat the experiment with an input wave of amplitude 100 mV at 500 Hz. The theoretical value is once again calculated. A_output = 2πfRCA = 2π(500)(464)(4.24E-6)(0.100) = 0.6181 V. Looking at the graph, we see the same input wave with its same offset. We look at the blue wave and take an average of the peaks again to find the amplitude of the output. The calculations give our output amplitude to be (0.7+0.55)/2 = 0.625 V. Comparing to our theoretical value, we obtain a 1.1 % error.

Data Chart
This chart shows the data obtained from the three graphs above. The percent error (% difference above) is below 5%, so our predictions had good accuracy. The graphs all show a phase difference of roughly a quarter of a period, as expected.

Monday, April 20, 2015

Passive RC Circuit Natural Response

Passive RC Circuit Natural Response

In this lab we observe the natural response of the RC circuit shown above which has a 5 V DC source. The resistance of the resistors are R1 = 0.983 kΩ and R2 = 2.18 kΩ, and the capacitor has capacitance C = 22.5 µF.
First, we will find the natural response by opening a switch (disconnecting the source). Second by applying a switching step voltage from an arbitrary waveform generator (WaveForms). Lastly, we will simply short the voltage source to observe the response. We will then use the graph to find the time constant of the circuit and compare it to theoretical values.

Opening the Switch (Disconnecting the Source)
For the first part, the switch is opened by disconnecting the voltage source. In the picture, the red wire on the + rail supplies +5 V while the black wire on the - rail provides ground. The switch is opened by quickly disconnecting the voltage supply wire.


We obtain the following graph and find the initial time and its corresponding voltage. The voltage before the switch is opened, V0, can be calculated using a voltage divider, V0 = [2.18 kΩ/(2.18 kΩ + 0.983 kΩ)]*(5 V) = 3.4461 V. Compared to our initial voltage from our graph, V0 = 3.408 V has a 1.1% error. This occurs at the time t0 = -61.5 ms. To find our time constant, we refer to the equation governing the natural response of an RC circuit, V(t) = V0*exp(-t/τ), where τ = RC is the time constant. We can solve for the time constant by first finding the voltage when t = τ. When this happens, our equation is simplified to V(t) = V0*exp(-1). Plugging in the V0 obtained from the graph, we get V(t) = 3.408*exp(-1) = 1.2537 V. This means that when the voltage has dropped to this value, the time will be equal to one time constant. Looking through the graph we search for this voltage and corresponding time. The closest available point is 1.256 V, occurring at tf = -11 ms. Now we can solve for our time constant finding the time change between these two voltages t = tf - t0 = -11 ms - (-61.5 ms) = 50.5 ms. To compare this to the theoretical value, we take a look at the circuit and notice that when the switch is opened, all of the energy is dissipated into resistor R2. Therefore the time constant is τ =  R2*C = (2.18 kΩ)*(22.5 µF) = 49.05 ms, which has an error of 3.0 %.


Square Wave Switch (Virtual Short Circuit)
Next we use a square wave at a low frequency to provide a step switching. The wave has a 2.5 V amplitude with a 2.5 V offset, making it go from 5 V to 0 V at 1 Hz. We let the wave run and capture the graph for one down step switch in voltage.


We use the same technique as the previous time and find that the experimental time constant has changed to τ = 15.5 ms. If we examine the circuit closely, it has changed from the last time. Instead of disconnecting the source (opening the circuit), we are switching the voltage from 5 V to 0 V, which is about equivalent to short circuiting the source. Therefore, when we calculate the theoretical time constant, we must take resistor R1 into account. So the theoretical time constant now is calculated as τ = Req*C = [R1*R2/(R1+R2)]*C = (0.6775 kΩ)*(22.5 µF) = 15.24 ms. Comparing this value now with our experimental value we get a 1.7 % error.


Shorting the Source Physically

Lastly, we find the natural response of the circuit by physically short circuiting the source. The yellow wire is providing 5 V to R1, The red wire is connected to ground and the free end is then connected quickly to the same node to short circuit the power source. The same theoretical time constant τ = 15.24 ms applies here since the capacitor voltage is dissipated by both resistors.


We use the same analysis as before and find the experimental time constant to be τ = 16 ms. This has an error of 5.0 %. The error here is probably on the borderline of being unacceptable. However, since this whole process is happening in a matter of milliseconds, the error is probably due to the time it takes to actually plug the shorting wire in.

Here we see a summary of the measurements (on the left) and the theoretical time constant calculations on the right.

Capacitor Voltage-Current Relations

Capacitor Voltage-Current Relations

In this lab, we wire the circuit in the diagram above and predict the voltage though the capacitor V_c with regards to the input voltage V_in. First, we will apply a sinusoidal wave for V_in, predict the capacitor voltage V_c and then compare it with the observed capacitor voltage. Next we repeat the experiment using a different frequency wave, and finally will do it using a triangle wave.

Here we see the circuit wired up with wires connected for ground and measuring channels for the Analog Discovery.


Above is the equation for current in the circuit. We can integrate it and multiply it by the inverse of the capacitance to get the voltage across the capacitor. Plugging in the two frequencies we will be using, we can find the equations for the two sinusoids.


Sinusoidal - 2V input @ 1 kHz
We use WaveForms software to apply a sinusoidal signal for V_in with amplitude of 2 V at 1 kHz. In the oscilloscope window, C1 (orange) shows the signal for the input voltage V_in, C2 (blue) shows the voltage across the capacitor V_c, and M1 (red) shows the current through the resistor i_r. We see that the capacitor voltage has an integral relationship with the current as predicted earlier. However, the amplitude of the voltage is about 1 V. Compared to our predicted voltage of 2.8 V, our voltage has a tremendous error of 64%!

Sinusoidal - 2V input @ 2 kHz
The experiment is now repeated for a frequency of 2 kHz. Again we see that the capacitor voltage is a multiple of the integral of the current. We obtain a voltage amplitude of 1.5 V. Compared to our predicted value of 1.4, we have a 7.1% error, which is still a bit higher than we would like, but still a lot better than our previous try.

Triangle - 4V input @ 100 Hz
A triangle wave of 4 V amplitude at 100 Hz frequency is now used. Qualitatively speaking, we see the capacitor voltage looks more like the derivative of the current than the integral. The current takes on the form of a piecewise function that remains linear and constant in slope magnitude but reverses its sign. The integral of a linear function is a quadratic function. If we look at the peaks, where the current switches directions, we see that the voltage has a slightly curved shape. 


The current is given by the piecewise function above, and likewise, the voltage is also a piecewise function and the integral of the current multiplied by the inverse of the capacitance. The period of the function is 10 ms and the ranges of each function are given in terms of the period T.

We believe that the flat regions in the voltage graph are indicative of the time periods when the capacitor is full and cannot gain any more voltage.

Monday, April 13, 2015

Temperature Measurement System Design

Temperature Measurement System

In this lab we design a temperature measurement system using a thermistor that creates a resistance change. This resistance change is then converted to a voltage change using a wheatstone bridge. Finally the voltage change is amplified using a difference amplifier.


Balancing the Wheatstone Bridge Circuit

The wheatstone bridge circuit was wired according to the diagram above. Measured resistance values are given. Ideally, all the resistors should have equal resistances. Also, they should all have a value close to the nominal resistance of the thermistor, that is, the resistance of the thermistor at room temperature (about 25 °C). A potentiometer is wired in series with resistor R_a to help balance the wheatstone bridge. This is used to fine tune the circuit so that the potential difference between a and b is V_ab = 0 V. 

Here we see the wheatstone bridge circuit, wired according to the diagram above.

A multimeter is used to measure the output voltage V_ab. A constant source voltage V_s of 5 V is then applied using the Analog Discovery. The potentiometer knob is then adjusted until the potential is 0 V +/- 20 mV. When the thermistor is held, its resistance decreases until it reaches body temperature (about 37 °C) to about 10.8 kΩ. This creates a potential difference between nodes a and b. The maximum voltage, after warming up the thermistor between pressed fingers for about 30 seconds, was -244 mV. The negative sign indicates that the node a is at a higher potential than node b.


 Difference Amplifer

According to the design specifications, a rise in output voltage of at least 2 V is required. Since the potential difference V_ab ranged from 0 mV to 244 mV, a difference amplifier with a gain of at least 10 is desired (which would yield an output of 2.44 V theoretically). To be safe, 10 kΩ and 150 kΩ resistors are used (measured resistances above) to give a gain of 15. The gain is the ratio of the feedback resistor R_2 to an input resistor R_1 where R_1 = R_3 and R_2 = R_4. The calculated gain is 149.8 kΩ/ 9.80 kΩ = 15.29. Therefore, the output voltage of the difference amplifier should be 15.29 times the potential difference between V_a and V_b, V_out = 15.29 (V_b - V_a).


The pictures above show the difference amplifier circuit with and without the wires needed for voltage supplies, ground, and measuring channels. 


To test if the difference amplifier is functioning correctly, the output voltage was measured for varying input voltages. V_a was kept constant at 300 mV while V_b was varied from 100 mV to 500 mV in 50 mV increments. The theoretical voltages are shown as well as the measured values. The accuracy of the experiment is reasonable, at a max of 6% error. 

Here is a plot of the output voltage vs difference input voltage, V_out vs V_ab (title on graph should be changed). We see that the slope of the line is -15.34 with a great accuracy (R^2 = 1.00). The measured voltage V_ab was opposite sign than expected indicating that the wires used for measuring voltage must have been reversed. Ommiting the negative sign, our measured gain is 15.34, which has a 0.3 % error.


Putting it all Together

Now that both circuits are functioning properly, the node voltages of the wheatstone bridge V_a and V_b are connected to the inputs of the difference amplifier (long orange wires). This should convert the resistance change in the thermistor into a small voltage change in the wheatstone bridge which is then amplified by the difference amplifier. The voltage should start at 0 V +/- 20 mV and have a change of at least 2 V.


This video shows the voltage changes as the thermistor goes from room temperature to body temperature. Channel 1 is the potential difference coming from the wheatstone bridge V_ab, and Channel 2 shows the output voltage V_out after being amplified by a factor of 15.34. We see that it originally starts at 0 V +/- 20 mV and rises up to about -3.56 V as it goes to body temperature (omitting negative signs). The wheatstone bridge gives a max V_ab of -244 mV (negative because node a is actually at higher potential than b). Theoretically, after this this voltage is amplified it should be -244 mV * 15.29 = -3.73 V, Compared to our measured output voltage of -3.56 V, we see that our percent error is 4.6%.


Sunday, April 5, 2015

Summing Amplifier and Difference Amplifier

Summing Amplifier

In this experiment, we wire a summing amplifier (OP 27) as shown above. The summing amplifier takes two voltage inputs V_a and V_b and and sums up a multiple of the signals according to the values of the feedback resistor to the input resistors. Thus V_out = -(R3/R1)*(V_a + V_b), where R3 is the feedback resistor and R1 = R2 are the input resistors. We use a 1.8 kΩ feedback resistor and two 3.6 kΩ input resistors (measured values shown above). The resistor ratio R3/R1 is theoretically 0.5, therefore according to the formula we expect our output voltage to be -0.5 the sum of the input voltages.

The circuit is wired according to the diagram with a multimeter connected to the output of the op and and ground to measure V_out (not labeled in previous diagram). We provide a constant 1 V for input V_b and vary the other input voltage V_a from - 4 V to 5 V.


Here we see the data values for the measured input and output voltages as well as the theoretical output voltage calculated as V_out_theo = -(1.74 kΩ/ 3.5 kΩ)*(V_a + V_b) =  -0.50*(V_a + V_b). The actual measured output values are close to the theoretical values with no more that 5.46 % error.