Lab08

html

School

University of British Columbia *

*We aren’t endorsed by this school

Course

119

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

html

Pages

8

Uploaded by MajorTreeLyrebird3

Report
Lab 08 - RC circuits II Edit this cell and provide the information requested: Your name: Partha Pritom Ghosh Your student number: 12303244 Partner's name: Desmond Chai In [2]: %reset -f import numpy as np import data_entry2 import matplotlib.pyplot as plt PART A - INTRO For today's experiment, our experimental goal is: A comparison between a high-precision determination of the capacitance of your capacitor from the slope of a τ versus R graph and the capacitance measured directly using a capacitance meter. We will use an analytic expression for the best fit of a model function to your τ vs R data, from the Prelab. We will be using a variable resistor, switch, capacitor, oscilloscope and voltage source for this experiment. An oscilloscope is a tool to measure voltage as a function of time, meaning the graphing calculator version of a multimeter. connect a switch and resistor in series to the power supply. connect the capacitor to the resistor in parallel connect the oscilloscope to the capacitor in parallel connecting the red wire to the positive side of the power supply and black wire to the negative side of the power supply. In terms of scales, setting the vertical scale to (20mV/1cm) and horizontal scale to (1ms/1cm) For setting up CH1 in oscilloscope screen, Couple=DC, ProbeType=Vol,1X, BandWidth=Full, Sample=Normal. Clicking on CH2 multiple times turns the channel on or off. The Trigger Setting from top to bottom are:- Edge(not Slope); Source=ch1; Edge=Fall; Couple=DC adjust the voltage level and screen by moving levels accordingly t=0 corresponds to the time that the signal crosses the trigger voltage threshold and the flag shows the V=0 line for channel 1. In order to collect signal, close and hold the closed circuit switch, press "Single SE!Q" so that scope is ready to collect one triggered event. Finally release the circuit switch. Record values of the changing V1, V2, t1, t2 along with their uncertainties u_V1, u_V2, u_t1, u_t2 respecrtively. When the switch is closed, the voltage source provides current to the resistor while also charging the capacitor. When the switch is reopened, the voltage source is no longer in the circuit and the capacitor behaves as a power source, discharging through the resistor. The oscilloscope is used to monitor the capacitor voltage. time constant, = RC 𝜏 , which characterizes the rate at which the capacitor voltage is reduced based on the measurement of the times (t1 and t2) and voltages (V1 and V2) of any two points along the curve,
The ratio of the charge ($Q$) on the conductors to the voltage difference between the conductors ($V_C$) is known as the capacitance ($C$), $$ C = \frac{Q}{V_C} $$ the formula for time constant is: $$ \tau = \frac{t_2 - t_1}{\ln (V_1/V_2)}.$$ the formula for uncertainty in time constant is: $$ u\_\tau = \tau \sqrt{\left(\frac{u\_\Delta t}{\Delta t}\ right)^2 + \left(\frac{u\_\ln W}{\ln W}\right)^2}. $$ SI unit for time is in seconds (s) SI unit for voltage is Volt(V) Chi-squared formula : $$\large \chi_w^2 = \frac{1}{N-P} \sum_{i=1}^N \left[ \frac{y_i - f(x_i) }{u\ _y_i} \right]^2$$ In the simplest case of a one-parameter linear model, $y=mx$, we wish to minimize chi-squared with respect to $m$ to find the best fit slope $$ \frac{d\chi^2(m)}{dm} = 0.$$ $$ m = \frac{\sum_{i=1}^N \frac{x_iy_i}{(u\_y_i)^2}}{\sum_{i=1}^N \frac{x_i^2}{(u\_y_i)^2}} $$ So given our $x$ and $y$ data plus the uncertainty in $y$, we are able to analytically solve for the best fit slope using this equation! The uncertainty in this slope can be determined from the uncertainties in the data by uncertainty propagation. The result is: $$ u\_m = \sqrt{\frac{1}{\sum_{i=1}^N \frac{x_i^2}{(u\_y_i)^2}}} .$$ Since the term $\sum_{i=1}^N \ frac{x_i^2}{(u\_y_i)^2}$ appears both in $m$ and $u\_m$, it is convenient for notation and coding purposes to define a placeholder variable $$ Z = \sum_{i=1}^N \frac{x_i^2}{(u\_y_i)^2} $$ such that $$ m = \frac{1}{Z} \sum_{i=1}^N \frac{x_iy_i}{(u\_y_i)^2} $$ $$ u\_m = \sqrt{\frac{1}{Z}} .$$ PART B - FAMILIARIZATION & IMPROVEMENT REFLECTIONS We can improve the slope uncertainty by reducing u_y(higher precision for individual data points), increase the number of points(sum gets bigger) and use of a large range of x points. In order for improvements for the measurement techiques for new data collected today, use as much of the oscilloscope screen as you can during taking measurements for better precision. The order in which cursors are placed usually impact the measurement and the Gaussain PDFs for each quantity. The first cursor if its time or voltage must be lower and placed in the cross-over or turnover moment to record the maximum measurement and then following the other cursor placing it in a position that intercepts or connects the first cursor point in a way that gives the maximum precision and wider distrubtion and equal distribution. the first cursor follows the rectangular and second one gaussain. In order on zooming in and ou for the axes to get the best possible relative uncertainty, it depends on the number of the data points we have and recording with the maximum difference gives us a better precision. if the voltages approaches to zero, the W reaches to 0 as a result the u_W reaches the maximum value of 0 too giving us a best precision the most accurate data and the initial value.
PART C - DATA COLLECTION In [6]: de2 = data_entry2.sheet("lab08_RC_Circuit_II") Sheet name: lab08_RC_Circuit_II.csv In [8]: # python calculations from the analytic formula from above # Run me to calculate the time constant based on your values of t1, t2, V1 and V2 deltat = t2Vec - t1Vec # difference in time between points W = V1Vec / V2Vec # ratio of voltage lnW = np.log(W) # taking the logarithm - note that np.log(X) calculates ln(X) in Python tau = deltat / lnW # calculating the time constant # Use this cell to calculate the uncertainty in time constant found # Subproblem 1: propagation of u_deltaT u_deltat = np.sqrt( u_t1Vec**2 + u_t2Vec**2 ) # Subproblem 2: propagation of u_W # - Recall that W was defined in an earlier code cell u_W = W * np.sqrt( (u_V1Vec/V1Vec)**2 + (u_V2Vec/V2Vec)**2 ) # Subproblem 3: propagation of u[lnW] ulnW = u_W / W # correct this equation # subproblem 4: propagation of u_deltaT/lnW to get u_tau u_tau = tau * np.sqrt((u_deltat / deltat)**2 + (ulnW / lnW)**2) # correct this equation print("u_tau =",u_tau, "s") print("tau =",tau, "s") print("Relative uncertainty u_tau/tau = ",u_tau/tau) # Now calculate Z, m, and u_m # calculations for the analytic best fit here: Z = np.sum( (RVec * RVec) / u_tau**2) # calculate sum(x_i*x_i/(u_y_i)^2) ### FILL IN THESE TWO MISSING STEPS (calculate m and u_m) ### # Calculate best fit slope m = (1 / Z) * (np.sum( (RVec * tau) / u_tau**2)) print("m is:", m, "F")
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
# Calculate uncertainty in best fit slope u_m = np.sqrt( (1 / Z) ) print("u_m is:", u_m, "F") # Print the best fit slope and uncertainty print("Best fit slope m = ", m, "±", u_m) # Find max and min slopes based on m and u[m] mMax = m + u_m # slope at maximum of 68% CI mMin = m - u_m # slope at minimum of 68% CI """ Construct the models for plotting; calculate residuals """ ymodelBest = m * RVec # best fit model ymodelMax = mMax * RVec # max model ymodelMin = mMin * RVec # min model res = tau - ymodelBest # calculate residuals (best fit) wres2 = (res/u_tau)**2 # weighted residuals squared """ Calculate chi-squared """ N = len(RVec) # number of data points P = 1 # number of parameters chi2 = np.sum(wres2) / (N - P) # calculate chi-squared print("chi2 = {:.4f}".format(chi2)) """ Plot data and fits """ plt.errorbar(RVec, tau, u_tau, marker='.', linestyle='', color='k') plt.plot(RVec, ymodelBest, label="best fit") plt.plot(RVec, ymodelMax, label="max fit") plt.plot(RVec, ymodelMin, label="min fit") plt.xlabel('Resistance(Ω)') plt.ylabel("Time Constat(s)") plt.title("Time Constant Vs Resistance") plt.legend() plt.show() """ Plot residuals for the best fit """ plt.errorbar(RVec, res, u_tau, marker='.', linestyle='') plt.hlines(y=0, xmin=np.min(RVec), xmax=np.max(RVec), color='k') # draw axis at y = 0. plt.xlabel("Resistance(Ω)") plt.ylabel('Residuals') plt.title('Residuals plot (best fit, $\chi^2$={:.4f})'.format(chi2)) plt.grid() plt.show() u_tau = [4.11197480e-05 4.62201681e-05 6.35039516e-05 3.57146641e-05 6.74296340e-05] s
tau = [0.00051431 0.0006135 0.00074416 0.00042206 0.00083689] s Relative uncertainty u_tau/tau = [0.07995187 0.07533796 0.08533631 0.08461965 0.08057174] m is: 1.041327578780829e-07 F u_m is: 3.768694872968154e-09 F Best fit slope m = 1.041327578780829e-07 ± 3.768694872968154e-09 chi2 = 0.0421
PART D - DATA ANALYSIS AND COMPARISON We used this time for the (horizontal time devision) to 200us/1cm and for the vertical voltage division to 20mV/1cm to maximum and collect wider measurements with better precision and to oberseve the maximum osciiloscope. we got out chi-squared value close to 0.0421 which is lower than 1 showing that the uncertainties are likely to be overestimated but however, when comparing with the previous lab where we got 0.00852. This time we got it more closer to 1, showing that the uncertainties got more better evenly distrbuted and organised. there is no trend in the data hence showing evenly scattered while comparing with other group, they got a capacitance of 1.030E-7 F with an uncertainty of 5.7E-10 F while we got a gradient (m) which is also the capacitance of 104.1 F with an uncertainty of 3.8E-9 F. This shows we could closer values but our one is of lower uncertainty thus showing more accuracy and precision in the data sets of measurements. When comparing with previous lab, we got a capacitance with uncertainty of 10710456.7 +- 3.0E-13 F thus this time the data got improved and we got better results through repetation and changing techniques. PART E - IMPROVEMENTS In order to make chi-squared more closer to 1 and get a better relative uncertainty, we can reduce u_y(higher precision for individual data points), increase the number of points(sum gets bigger) and use
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
of a large range of x points. In order for improvements for the measurement techiques for new data collected today, use as much of the oscilloscope screen as you can during taking measurements for better precision. Take points over a wider range We can take more wider difference in resistance values to get more wider data and hence lesser uncertainty and maximum difference values for better precision and accuracy. PART F - Finishing Things Off We got a capacitance of 104.1E-09 +- 3.8E-09 F through our sope of T vs R graph. We got a capaticance of 99.4E-09 +- 1.4E-09 using a digital multimeter Our Experimental goal for this experiment was comparison between a high-precision determination of the two capacitances. We can conclude that they are close enough to prove our data and measurements as accurate and efficient as possbile but improvements mentioned above can be done to make it more closer. Submit Steps for submission: 1. Click: Run => Run_All_Cells 2. Read through the notebook to ensure all the cells executed correctly and without error. 3. File => Save_and_Export_Notebook_As->HTML 4. Inspect your exported html 5. Upload the HTML document to the lab submission assignment on Canvas. In [4]: display_sheets() Sheet: de2 File: lab08_RC_Circuit_II.csv Units 0 1 2 3 4 5
6 7