# Basic maths: 10k? resistor, 5V voltage, 100µF cap=0.76 second LED fadeout

As an exercise in basic EE and basic maths, i want to fade out a LED with a capasitor. I wonder if anybody could peer-review my calculations?

Given i am using a 10k? resistor and a standard LED in series, and in parellel with a 100µF cap, all in a 5V circuit, shouldn’t my timeout be 0.76 seconds?

• Mr. Ohm (V=IR), thus I=V/R
• Mr. Kirchhoff (V=V1+V2), thus a 1.2V front voltage LED turns off at 5V=1.2V+VacrossCap=VacrossCap=3.8V.

Charge C = FV
Charge C = I
t
Time t = FV/I = 0.0001F3.8V/(5V/10000?) = 0.76s

+=?

Have you had calculus yet? A capacitor discharging through a resistor is an exponential function. (Since the current is not constant, you cannot use C = I x t except for "one instance" in-time.)

The non-linear LED further-complicates things. ...It's over my head, and it's been long time since I've had calculus. It might be as simple as a discontinituity when you hit the LED cut-off voltage (with an "ideal" LED) and the current suddenly drops to zero, but I'm not sure. Or, it might involve two simultaneous equations until you hit the discontinuity????

That was good, thanks. Stack Exchange is fantastic.

DVDdoug: Have you had calculus yet?

LOL i admit my calculus is rubbish, after so many years since highschool. That's why i'm doing such basic math now, and also looking for peer support here. Thanks for it DVDdoug, i appreciate it! This is great exercise.

Now that the day is drawing to night, and it's getting darker, i can empirically see that the 0.76 seconds is too short a time for my LED's fadeout; it seems to be above 1 second.

DVDdoug: A capacitor discharging through a resistor is an exponential function. (Since the current is not constant, you cannot use C = I x t except for "one instance" in-time.)

That's right, it makes sense; the LED is fading, and that is exactly the reason why it's getting less and less bright; the current is dropping... and thus it's bleeding the charge in the cap slower and slower.

My amended calculation, assuming an exponential decay of current, is -10000?0.0001F*ln(1.2V/5V)=1.43s. That seems to correlate better with sense-based observations. Next, maybe i should build a tool, using Arduino, a light-dependant-resistor and *millis(), that would measure the time it takes for the LED to fade 8)

suggest build it and just try a few values!

I agree what mmcp42 wrote.

Some leds are very well visible with only 0.5mA or even less. I think that one led can be 10 times longer visible than an other led.

The circuit schematic is too far away, but let me guess : The capacitor is in parallel with the LED. The switch is in parallel with the LED. The resistor is not used.

AmbiLobe:
The circuit schematic is too far away, but let me guess :
The capacitor is in parallel with the LED.
The switch is in parallel with the LED.
The resistor is not used.

@AmbiLobe: Do you mean how my circuit was built? The resistor was used; the cap is in parellel with LED and the resistor, which are in series together. See the attached schematic.

led fadeout with a cap.fzz (5.27 KB)

The RC time constant is 1 second.

Thank you for the schematic diagram. The math is like this after the switch is released: There are three nodes : S1 Anode GND The LED Anode has about 2v as a diode drop. Treat it as a voltage source of 2v. The resistor has 3 volts time = t = 0 seconds The peak current at t=0 is i(0) = v/r = 3/10k = 0.3mA The current decays exponentially

i(t) = i(0) * e^(-t/rc) rc = 10k * 100uF = 10^4 * 10^-4 = 1 second e = 2.7182 a constant from science education

e^-1 = 1/e = .632

e^-2 = 1/(e*e) = .632 * .632 = .40 e^-4 = .16 e^-8 = .0256

after 1 second i = .3mA * .632 = .189 mA after 2 seconds i = .3mA*.16 = 48 micro amps (uA) after 8 seconds i = .3mA*.0256 = 8uA

Conclusion : your math was wrong. The LED will be dim with .3mA. Its power is 2v*.3mA = 0.6 milliwatts This is a dim bulb.

See the attached schematic.

You short the supply into the capacitor - add a small value resistor in series with the switch if you want to avoid welding it shut and resetting the Arduino!

MarkT:

See the attached schematic.

You short the supply into the capacitor - add a small value resistor in series with the
switch if you want to avoid welding it shut and resetting the Arduino!

Oh, so it’s not good to let caps suck in energy as they please, without controlling it? As explained f.ex. here. Hmm i guess (V=IR) if at the beginning time t0 the voltage jumps to 5V, the resistance is (theoretical) 0, then the current is infinite, until the capasitor starts to build resitance as it’s charge increases. Is this it?

Thanks MarkT for bringing this to my attention!

I love these little electronics and Arduino, it’s such a great way to get (back) into math and so many other wonderful things

This discussion reminds me of this classical problem.

The charge on a capacitor is given by q=CV The energy stored in a capacitor is 1/2 C*V*V (one half C Vsquared)

Assuming perfect capacitors, perfect wires (0 resistance), and a perfect switch.

We charge a 1 farad capacitor to 1 volt and disconnect it from the charging source. Its charge is then C*V = 1 coulomb and its energy is .5 * 1 * 1 * 1 = .5 joules.

Now we use a switch to connect the capacitor in parallel with another 1 farad capacitor. Since charge must be conserved our 1 coulomb of charge is now divided between the two capacitors. So the voltage on each is q/C or .5 volts and the energy stored in each is then .5 * 1 * .5 * .5 = .125 joules. So the total energy in the two capacitors is .125 * 2 = .25 joules.

Question is what happened to the missing .25 joules of energy?

The math is all fun, but when you need to quickly play, you need SPICE

"Question is what happened to the missing .25 joules of energy?"

During the time that current flowed from one capacitor into the next capacitor, a magnetic field was changed. The energy went into that magnetic field during an impulse. A resonance then occurs without damping, and the oscillation lasts forever. The missing energy is tossed about forever, outside of the capacitive energy.

The ESR of the capacitor also comes into play, which limits the current flow out of the cap to some extent.

How come you're not using a transistor ? You can make it fade out nicely then!

cjdelphi: How come you're not using a transistor ? You can make it fade out nicely then!

Did you refer to me? Because i want to learn this stuff :) Transistors will come later 8)

Yes, the missing 0.25j goes into RF radiation from the magnetic field changes as the charge bounces between the caps, into resistive losses in the wires, losses in the dielectric, and losses in the ESR of the capacitors.

If you had two perfect capacitors with superconducting plates and superconducting wire and no losses in the dielectric, it would take a long time to stop ringing, but eventually it would radiate away as RF.

It might be interesting to connect the circuit as below, use the digital pin to charge and discharge the capacitor, and the analog pin to measure the voltage across the cap. It probably won’t be perfect, but I’d bet it would come pretty close to producing the classic charge/discharge curve (example here).

Yes mace, the led discharging through the cap gives a short pulse not so much fade. .

Using a transistor you fill a capacitor with the button press and as that slowly discharges (connected to the base of a transistor) will gently fade out the led...

If you want automatic a 555 can be used to "breathe" ..