Lab07-makeup

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

7

Uploaded by MajorTreeLyrebird3

Report
Lab 07 - RC Circuit I (Make-up version) Edit this cell and provide the information requested: Your name: Partha Pritom Ghosh Your student number: 12303244 Partner's name: In [7]: %reset -f import numpy as np import data_entry2 import matplotlib.pyplot as plt Part A - FAMILIARIZE, Part 1 - Overview of your resistor-capacitor (RC) circuit and the oscilloscope tutorial The experimental goal for this lab is to determine the capacitance of a capacitor being used in a Resistor- Capacitor circuit by measuring the time constant of the capacitor’s voltage decay curve. We will be looking at how the voltage drop across a discharging capacitor varies with time in an RC (Resistor-Capacitor) circuit. 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$$ Part B - FAMILIARIZE, Part 2 - Make an initial set of measurements In [8]: de1 = data_entry2.sheet("lab07_data") Sheet name: lab07_data.csv Part C - FAMILIARIZE, Part 3 - Develop your measurement strategy for further measurements In [9]: # 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) u_tau = [0.00022066 0.00027718 0.00023553 0.00027082] s tau = [0.00039005 0.00048994 0.00058283 0.00067015] s Relative uncertainty u_tau/tau = [0.56572848 0.56573298 0.40411159 0.40411618] Part D - MEASURE & ANALYZE - Collect additional data and create a scatter plot In [10]: # Step 1: Find the limits of the data: xmin = np.min(RVec) # use the np.min function to find the smallest x value xmax = np.max(RVec) # same for max #print (xmin, xmax) # Step 2: Generate a bunch of x points between xmin and xmax xpoints = np.linspace(xmin, xmax, 200) # gives 200 evenly spaced points between xmin and xmax #print(xpoints) # Step 3: Calculate the model values given your input to the slope: slope = 0.0000000933667 # Your estimate of the slope. ypoints = xpoints * slope # this calculates the yvalues at all 200 points. # Step 4: plot the curve. We plot this as a red line "r-" : plt.plot(xpoints, ypoints, "r-", label = "T=RC") # Let's plot our data with the model: plt.errorbar(RVec, tau, u_tau, fmt="bo", markersize = 3, label="Experimental data") plt.title("Time Constant vs Resistance") plt.xlabel("Resistance(Ω)") plt.ylabel("Time Constant(s)") plt.legend() plt.show() #Residuals Plot # Step 1: Calculate the model at each x-datapoint ymodel = slope * RVec # y = mx at each x_i # Step 2: Calculate the residual vector ResVec = tau - ymodel # Step 3: Plot the residual vector against the x-data vector
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
plt.errorbar(RVec, ResVec, u_tau, fmt="bo", markersize = 3) # Step 4: Add a R = 0 x-axis (horizontal line) to the plot plt.hlines(y=0, xmin=xmin, xmax=xmax, color='k') # draw axis at y = 0. # Add axis labels and title, and show the graph plt.title("Time Constant Vs Resistance") plt.xlabel("Resistance(Ω)") plt.ylabel("Residual = data - model (N)") plt.show() # Calculate chi-squared chi2 = np.sum((ResVec/u_tau)**2)/(len(ResVec)-1) print ("Slope: ", slope, "F^-1") print ("Weighted chi-squared: ", chi2) ## Keep track of chi-squared based on changing the slope dec = data_entry2.sheet('chi2-1')
Slope: 9.33667e-08 F^-1 Weighted chi-squared: 0.00852760630553976 Sheet name: chi2-1.csv In [11]: # Best slope m_best = 0.0000000933667 m_min = 0.0000000933664 u_m = m_best - m_min print("Slope uncertainty:",u_m, "F^-1") #Calculation for Capacitance Capacitance = 1 / m_best print("Capacitance is:", Capacitance, "F") print("Uncertainty in Capacitance is:", u_m, "F") Slope uncertainty: 3.0000000000298715e-13 F^-1 Capacitance is: 10710456.726006167 F Uncertainty in Capacitance is: 3.0000000000298715e-13 F Part E - COMPARE, SUMMARIZE, REFLECT The experimental goal for this lab is to determine the capacitance of a capacitor being used in a Resistor-
Capacitor circuit by measuring the time constant of the capacitor’s voltage decay curve. The Capacitance with uncertainty we achieved is: 10710456.7 +- 3.0E-13 F Following the chi-squared rule, we achieved a uncertainty which is lower than 1 meaning our uncertainty is an overestimate. We could repeat our measurements, change the scale to explore more with data to improve our results We could take more wider difference points to get the maximum slope and for even distribution on both sides to improve our experiment further better. 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. Upload the HTML document to the lab submission assignment on Canvas. In [12]: display_sheets() Sheet: de1 File: lab07_data.csv R t1 u_t1 t2 u_t2 V1 u_V1 V2 u_V2 Units Ω s s s s V V V V 0 4000 -100E-6 0.0002 400E-6 0.0002 0.836 0.002 0.232 0.002 1 5000 -100E-6 0.0002 400E-6 0.0002 0.788 0.002 0.284 0.002 2 6000 -200E-6 0.0002 500E-6 0.0002 0.904 0.002 0.272 0.002 3 7000 -200E-6 0.0002 500E-6 0.0002 0.864 0.002 0.304 0.002 Sheet: dec File: chi2-1.csv slope chi2 Units F^-1 0 0.0000000933667 0.00853 1 0.0000000933669 0.00854 2 0.0000000933664 0.00852
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