Voltage Drop for a Discharging Capacitor
# loading the data set
volts<- read.csv("Volts.csv")
A capacitor is a device that stores electrical energy in an electric field. It is a passive electronic component with two terminals. Capacitors typically discharge slowly when a resistor is connected to each leg. The resistor must be rated for the same or higher voltage than the capacitor can store for this method of discharge in order to work safely. Let’s take a look at the summary of the Voltage Drop for a Discharging Capacitor:
summary(volts)
## X Voltage Time
## Min. : 1.00 Min. :1.240 Min. :0.000
## 1st Qu.:13.25 1st Qu.:1.956 1st Qu.:0.245
## Median :25.50 Median :3.199 Median :0.490
## Mean :25.50 Mean :3.873 Mean :0.490
## 3rd Qu.:37.75 3rd Qu.:5.381 3rd Qu.:0.735
## Max. :50.00 Max. :9.213 Max. :0.980
View(volts)
Upon reviewing the .csv file, one can see that as time progresses, the voltage drop decreases. Based on the file, is there a correlation between average rate of voltage decay for capacitors over time?
Let’s analyze the original volt.csv file.
#mean
mean(volts$X, na.rm = TRUE)
## [1] 25.5
mean(volts$Voltage, na.rm = TRUE)
## [1] 3.873356
mean(volts$Time, ra.rm = TRUE)
## [1] 0.49
#median
median(volts$X, na.rm = TRUE)
## [1] 25.5
median(volts$Voltage, ra.rm = TRUE)
## [1] 3.1986
median(volts$Time, ra.rm = TRUE)
## [1] 0.49
I will compare the voltage decay by creating two new data frames with a subset of the columns and rows.
halfvolts<-subset(volts[c(1:25),c("X","Voltage","Time")])
View(halfvolts)
secondhalfvolts<-subset(volts[c(26:50),c("X","Voltage","Time")])
View(secondhalfvolts)
summary(halfvolts)
## X Voltage Time
## Min. : 1 Min. :3.268 Min. :0.00
## 1st Qu.: 7 1st Qu.:4.203 1st Qu.:0.12
## Median :13 Median :5.435 Median :0.24
## Mean :13 Mean :5.723 Mean :0.24
## 3rd Qu.:19 3rd Qu.:7.066 3rd Qu.:0.36
## Max. :25 Max. :9.213 Max. :0.48
#mean
mean(halfvolts$X, na.rm = TRUE)
## [1] 13
mean(halfvolts$Voltage, na.rm = TRUE)
## [1] 5.723144
mean(halfvolts$Time, ra.rm = TRUE)
## [1] 0.24
#median
median(halfvolts$X, na.rm = TRUE)
## [1] 13
median(halfvolts$Voltage, na.rm = TRUE)
## [1] 5.4353
median(halfvolts$Time, ra.rm = TRUE)
## [1] 0.24
summary(secondhalfvolts)
## X Voltage Time
## Min. :26 Min. :1.240 Min. :0.50
## 1st Qu.:32 1st Qu.:1.538 1st Qu.:0.62
## Median :38 Median :1.936 Median :0.74
## Mean :38 Mean :2.024 Mean :0.74
## 3rd Qu.:44 3rd Qu.:2.453 3rd Qu.:0.86
## Max. :50 Max. :3.129 Max. :0.98
#mean
mean(secondhalfvolts$X, na.rm = TRUE)
## [1] 38
mean(secondhalfvolts$Voltage, na.rm = TRUE)
## [1] 2.023568
mean(secondhalfvolts$Time, ra.rm = TRUE)
## [1] 0.74
#median
median(secondhalfvolts$X, na.rm = TRUE)
## [1] 38
median(secondhalfvolts$Voltage, na.rm = TRUE)
## [1] 1.9361
median(secondhalfvolts$Time, ra.rm = TRUE)
## [1] 0.74
#Scatter plot of volts
plot(volts$Time, volts$Voltage,xlab = 'Time', ylab = 'Voltage', main = 'Volts', ylim = c(0,10), pch = 20 , col='blue')
#Scatter plot of half volts
plot(halfvolts$Time, halfvolts$Voltage, xlab = 'Time', ylab = 'Voltage', main = 'Half Volts', ylim = c(0,10), pch = 20 , col='red')
#Scatter plot of second half volts
plot(secondhalfvolts$Time, secondhalfvolts$Voltage, xlab = 'Time', ylab = 'Voltage', main = 'Second Half Volts', ylim = c(0,10), pch = 20 , col='green')
# Box plot of volts
boxplot(volts, col="blue")
#Box plot of half volts
boxplot(halfvolts,col="red")
#Box plot of second half volts
boxplot(secondhalfvolts,col="green")
#Histogram of volts in respect to time
hist(volts$Time, xlab = 'Time', ylab = 'Voltage', main = 'Volts', ylim = c(0,10), pch = 20 , col='blue')
#Histogram of volts in respect to Voltage
hist(volts$Voltage, xlab = 'Time', ylab = 'Voltage', main = 'Volts', ylim = c(0,10), pch = 20 , col='blue')
#Histogram of half volts in respect to time
hist(halfvolts$Time, xlab = 'Time', ylab = 'Voltage', main = 'Volts', ylim = c(0,10), pch = 20 , col='red')
#Histogram of half volts in respect to voltage
hist(halfvolts$Voltage, xlab = 'Time', ylab = 'Voltage', main = 'Volts', ylim = c(0,10), pch = 20 , col='red')
#Histogram of second half volts in respect to time
hist(secondhalfvolts$Time, xlab = 'Time', ylab = 'Voltage', main = 'Volts', ylim = c(0,10), pch = 20 , col='green')
#Histogram of second half volts in respect to voltage
hist(secondhalfvolts$Voltage, xlab = 'Time', ylab = 'Voltage', main = 'Volts', ylim = c(0,10), pch = 20 , col='green')
Based on the data provided, the mean voltage drop of the original .csv is 3.87V with an average time of 0.49 seconds. The initial voltage drop of at t = 0 is 9.2128V. Half volts had an average voltage drop of 5.723V with an average time of 0.24 seconds. Second half volts had an average voltage drop of 2.024V with an average time of 0.74 seconds. The capacitor discharge equation is V = Voe-(t/RC).When t = RC, V = Vo/e = 0.37 Vo and the product RC is known as the time constant for the circuit. The bigger the value of RC, the slower the rate at which the capacitor discharges. The average rate of voltage drop is dependent in respect to time.
#BONUS
volts<- read.csv("https://raw.githubusercontent.com/sagreen131/R-Week-3/master/Volts.csv")