0% found this document useful (0 votes)
59 views

An Arduino Investigation of Charging and

Uploaded by

dharbiswarup1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

An Arduino Investigation of Charging and

Uploaded by

dharbiswarup1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

SSN 2379-5980 (online)

An Arduino investigation of charging and


discharging of RC circuit
Debankur Basak

Abstract. We describe the method of calculating the voltage change while charging and
discharging of a capacitor using an Arduino. The values are obtained in the serial monitor of
the Arduino IDE. Then the experimental results are plotted in python.

1. Introduction
Arduino is an open source electronics platform developed by Massimo Banzi and his collaborators,
initially intended for educators involved with electronics and robotics projects, but also for
hobbyists looking for some affordable hardware and easy-to-use software. The potential of the
Arduino technology in physics education has only recently been recognized. While the classical
experiment is done using a voltmeter and a stopwatch, this procedure is tedious and prone to
human errors. This project represents an alternative procedure in which the voltage, the current,
and the time are all measured electronically with the help of an Arduino Uno microcontroller
board.The main objective of this Arduino investigation of the RC circuit is the experimental
verification of the formulas for the time-varying voltage and electric current for the charging
or discharging capacitor. A secondary objective is to provide an alternative to more expensive
commercial laboratory materials and, at the same time, to expose the students to the underlying
electronics and computer programming that would have otherwise been hidden from sight. Most
students are usually excited by Arduino-based physics labs, especially those with some prior
knowledge and interest in programming.1

2. Experiment
The voltage on the capacitor is measured using the Arduino analog pin A0, and the electric
potential on the other side of the resistor is measured using the Arduino analog pin A5. The
analog-to-digital converter on the Arduino board provides a number in the 0–1023 range, which
has to be converted to a voltage in the 0–5 V range. By subtracting one electric potential from
the other, we find the voltage drop on the resistor. We divide this voltage drop by the resistance
to find the electric current through the resistor. The time, the voltage on the capacitor, and the
electric current in the RC circuit branch are measured by the Arduino Uno board and sent to
the PC, through the USB cable, about every second. If the Arduino Integrated Development
Environment does not automatically recognize the serial port to which the Arduino Uno board
is connected, we have to specify it using the Tools—Serial Port menu. After the Arduino code
is typed, verified (compiled), and uploaded to the Arduino Uno board, in order to access the
experimental data we have to open the Serial Monitor window using the Tools—Serial Monitor
LEDGER VOL ()

menu. New numbers will be printed about every second, and all the information will scroll up
when the screen is full. Once the experimental run is over, we have to uncheck the Autoscroll
option in the Serial Monitor window. Afterward all the experimental data of interest is selected
(with the help of the mouse), copied (using the Ctrl–C key shortcut), and pasted into another
program for analysis.
Then paste that to a .dat file. Then we have used a python code to plot the data evaluated.
While doing the charging part we only need to click on the serial monitor on the top right of the
Arduino IDE. While we note the values of the voltages we can find after some time the value of
the voltage reaches a certain limiting value in out case it was a value close to 5V . Which means
that our capacitor is charged. Now we need to close the serial monitor and unpin the 5V pin to
the GND pin in the Arduino what that dows is it discharges all the charges that was stored in
the capacitor. Now quickly open the Arduino IDE the time starts from 0 as you open the serial
monitor. Now again note the values of the voltages as they go near to zero. Copy vales upto that
and store them in a separate .dat file. Use those data to plot the discharging part.

Fig. 1. Diagram of the RC Circuit

3. Working
3.1. Charging—Initially the capacitor was uncharged. We call time t = 0 the time when we
upload the sketch to the Arduino. Positive charge appears on one plate and negative charge on
the other. The potential difference between the plates ultimately becomes equal to the maximum
value of voltage through the 5V pin i.e 5V . The whole process takes some time and during this
time there is an electric current through the Jumper wires and the Arduino. The resistance of the
connecting wires and the internal resistance of the Arduino taken together is R. The capacitor
has capacitance C. Suppose the charge on the capacitor and the current in the circuit are q and i
respectively at time t. The potential drop on the capacitor is q/C and on the resistor it is Ri. Also,
the charge deposited on the positive plate in time dt is

dq = i dt

SSN 2379-5980 (online)


1
LEDGER VOL ()

dq
i=
dt
Using Kirchchoff’s loop law,2
q
+ R i −E = 0
C
q
Ri = E −
C
dq EC − q
R =
dt C
Z q Z t
dq 1
= dt
0 E!C − q 0 CR
q t
1− = e− C R
EC
−t
q = E C (1 − e− C R )
q
now we know that, C is V , so,
t
V = E (1 − e− C R )

This gives the voltage on the capacitor at time t. As t increases, V also increases. The maximum
V is obtained, in principle, at t = ∞ and its value is EC.
3.2. Discharging—Now the jumper wire is displaced from the 5V pin and quickly placed
on the GND pin and the serial monitor is quickly turned on, the reading of the capacitor getting
discharged is then noted. Again there is a flow of charge through the Jumper wires and hence
there is a current. Suppose a capacitor of capacitance C has a charge Q. At t = 0, the plates are
connected through a resistance R . Let the charge on the capacitor be q and the current in the
circuit be i at time t. Using Kirchhoff’s loop law2
q
− Ri = 0
C
dq
Here i = dt because the charge q decreases as time passes.

dq q
R = −
dt C
dq 1
= − dt
q CR
Z q Z t
dq 1
= − dt
0 q 0 CR
q t
ln = −
Q CR
t
q = Q e− C R

SSN 2379-5980 (online)


2
LEDGER VOL ()
q Q
Now C is V and C is E we can write,
t
V = E e− C R
In principle, discharging is complete only at t = ∞.Where its value is 0.

4. Codes used

Fig. 2. Arduino IDE code

Fig. 3. Python Code for plotting the data of charging part

SSN 2379-5980 (online)


3
LEDGER VOL ()

Fig. 4. Python Code for plotting the data of discharging part

5. Conclusion
This gives the voltage on the capacitor as a function of time. As t increases,V also increases. The
maximum V is obtained, in principle, at t = ∞ and its value is EC

Fig. 5. Plot for charging of a capacitor

SSN 2379-5980 (online)


4
LEDGER VOL ()

This gives the voltage on the capacitor as a function of time. As t increases,V decreases. The
minimum value of V is obtained, in principle, at t = ∞ and its value is 0

Fig. 6. Plot for discharging of a capacitor

Notes and References


1 Calin Galeriu, Cheryl Letson, and Geoffrey Esper. An Arduino Investigation of the RC Circuit.. doi:

10.1119/1.4917435
2 H.C Verma. Concept of Physics Part-2.

SSN 2379-5980 (online)


5

You might also like