# Capacitor Discharge Timing

Discussion in 'The Projects Forum' started by AlkaAka, Jul 1, 2013.

1. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0
Hello! First post here and I'm looking forward to many more

As per the title, I (think) I know the circuit to control capacitor voltage discharge, a simple capacitor connected to + and gnd with a resistor tied around it on a switch. Switch is thrown and the cap begins to discharge.

I've done a few calculations using 9v power supply and a 220u capacitor. It seems a 50k resistor will have a time constant of 11 seconds. I think for my needs, that will be the longest time constant I would need. I intend on putting a 50k potentiometer to use for variability.

However, I'd like to throw and LED into the mix with a forward current of 25ma and forward voltage of 2.2v.

When the switch is open and the capacitor is fully charged, the LED should be at full brightness. When the switch is thrown, the LED will dim as the cap loses brightness. I assume an LED and it's limiting resistor would go between the cap and ground and the drain resistor would still go from 9v to ground? Does the addition of the LED and current limiting resistor affect the discharge time?

Also, is there any way to linearize the discharge time? The time constant is a measurement of discharge of ~63% of the voltage making appear logarithmic. Is there a way to smooth it out?

Thanks!

EDIT: Something like this, but with a switch between 9v and the time potentiometer (oops)

Last edited: Jul 1, 2013
2. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0
I just realized a fatal flaw.. the switch should go between 9v and the rest of the circuit, not just the discharge resistor.

Jul 22, 2007
1,758
98
4. ### crutschow Expert

Mar 14, 2008
20,430
5,785
You circuit has more than one fatal flaw.

In your circuit the 50k pot goes between 9V and ground. It has no effect on the timing of the current through the capacitor and LED. The time-constant of that is approximately 330Ω 8 220μF = 73ms

The circuit will also only pulse once when energized. There is no path to reset the capacitor since the LED is reversed biased for any capacitor current in the opposite direction.

5. ### deco75943531 New Member

Jul 2, 2013
5
0
LED and its current limiting resistor would go between the cap and the floor drain resistance will still go from 9V to ground

6. ### #12 Expert

Nov 30, 2010
18,093
9,682
The first problem I see is that you can't run current backwards through an LED and expect anything predictable. LEDs are represented by a diode symbol because they ARE diodes. When calculating in the forward direction, you can treat the LED as a voltage drop, not a resistor. Just remove 2.2 volts from the equation.

The way to "linearize" the change of voltage on a capacitor is to use a constant current regulator. V=I/C Constant current into a constant size of capacitor causes a constant (linear) rate of voltage change.

Meanwhile, I wrote all the equations for time, resistance, and capacitance so they would be easy to use and eliminate making simple math mistakes every time you need an equation.

Metalmann likes this.
7. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0
blueroomelectronics - If I'm reading what the 555 timer does correctly, it will hold at 0V until triggered, at which point it will put out a constant voltage for a set time? I'm looking for something that will hold high until triggered, at which point the voltage will decrease over a set time.

crutschow - Yeah as I was thinking about it more last night I realized more and more how wrong I was. I'm only looking for one pulse when triggered from the switch. Would closing the switch not re-energize the capacitor (assuming a circuit that was set up properly)?

#12 - So the voltage used in the equation would now be 6.8V due to the diode. As far as a constant current source, could I use a regulator? Or a transistor circuit like this:

Would the 'load' be the entirety of the cap/resistor/LED circuit? Thanks for the link to the equations! Definitely helpful.

Thank you all for the useful responses!

8. ### wayneh Expert

Sep 9, 2010
15,150
5,533
I'm still confused about what you're actually trying to do. One way to get pseudo-linearity is to use less of the decay curve. I mean, the range between 80% and 70% charge looks more linear than the range from 90 to 60%. But of course there will be less dimming effect from using the smaller range.

Unless you have a very large capacitor, the LED current will cause it to dim quickly. The current-limiting resistor must be sized to prevent burning the LED at 100% charge, but will quickly be too much resistance to allow the LED to keep going brightly. I've used big capacitors at high voltage and the LED will glow dimly for a long time after a few seconds of brightness.

9. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0
wayneh - Forgetting the whole cap circuit, the function of the idea is to have a push button that, when pushed, will cause an LED to linearly dim at a rate determined by a potentiometer. When the button is released, independent of where the LED is in it's dimming progress, the LED will go back to the initial brightness - immediately or at the same rate as it dimmed, whatever is easiest as that part isn't as important.

Perhaps a discharged cap is not the best way to do this?

10. ### wayneh Expert

Sep 9, 2010
15,150
5,533
Aha, got it. Since you apparently need dimming over 10-30 seconds, that pretty much rules out using the stored energy in a capacitor. You could get one big enough, but it would not be cheap, elegant or linear.

I'm sure there may be a more clever approach, but here's my solution. Use an RC tank for the timing. The switch, when off, allows the capacitor to charge from the battery. Pressing the switches removes the battery so that the capacitor discharges.

Use an op-amp to watch the voltage on the capacitor on one input. The other input will watch the voltage across a resistor that is in series with your LED and the output of the op-amp. The op-amp will thus reduce the current to the LED as the voltage on the capacitor drops. This could be set to be quite slow; the capacitor discharges only via the op-amp (very slowly) and the adjustable resistor. Power for the LED comes from the battery via the op-amp.

I'd draw this out but I don't have a drawing tool handy. Hopefully you can follow. It's a standard constant-current op-amp circuit with a falling reference voltage provided by the RC tank.

By choosing the gain of the op-amp circuit, you can choose what percentage of the RC curve will give you full dimming of the LED. So for instance I think you could get the LED to fully dim when the capacitor voltage falls from 100% to just 80% or so. This would give a more nearly linear dimming than a deeper discharge.

Sep 30, 2009
5,877
3,351
12. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0
Do you mean something like this?

I may be a bit confused by the in series part as I don't think the LED can be strapped across the - and output of the opamp? The circuits I looked up for an op amp constant current circuit all had transistors connected to the output of the op amp at the base. Would they be used as switching transistors?

13. ### wayneh Expert

Sep 9, 2010
15,150
5,533
The negative poles of the capacitor and the variable resistor both go to ground. The op-amp input watches the voltage on the positive pole.

The output goes to the LED to R1 to ground. The negative input will watch the voltage on top of R1, which is proportional to the current thru the LED.

You need to amplify that voltage. Figure out its maximum value for the resistance and current at max LED brightness, and divide that value into the supply voltage. That will be the gain you need to apply. Look up basic op-amp circuits to see how to apply the gain - it's just adding a few resistors.

AlkaAka likes this.
14. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0

9V supply input, 20mA max for brightness of LED, 4.7k limiting resistor.

Gain = Va/V = I*R/V = (0.02 * 4700)/9 = ~10.

To get a gain of 10, R2 = 9k and R3 = 1k using gain = 1 + R2/R3.

How's it look now? I assume there is a minimum discharge setting with this circuit, but is it still completely completely dependent on the time constant or does that now change since the introduction of the om-amp?

Thanks!!!!

15. ### wayneh Expert

Sep 9, 2010
15,150
5,533
It's still ruled by RC! I haven't spent time on any of the math but the circuit looks OK. Are you going to build it?

16. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0
Absolutely! I need to put a few different value caps in my next order to try them out, but I'll report back when I get results.

Thanks for holding my hand and guiding me through!

17. ### wayneh Expert

Sep 9, 2010
15,150
5,533
R1 is too big, I think. D1 will drop maybe 3V, leaving 6V to drop across R1, which thus needs to be 6v/0.02A = 300Ω for the 20mA current.

I'm having a mental block about the op-amp gain configuration. R3 needs to be larger than R2 but something's missing and I can't put my finger on it. Kind of distracted by our holiday.

18. ### WBahn Moderator

Mar 31, 2012
23,362
7,085
How about something along these lines:

This is just something I threw together, so I may well have overlooked somethng obvious.

The idea here is that when the switch is released, it shorts the capacitor and the opamp holds a voltage of Vo at it's output. You set Vo to something like 5V to 7V by way of R1 and R2. You then set the full-scale brightness to whatever you want with R3.

When the button is pushed (and the switch therefore opened) the capacitor charges at a constant rate given by (Vcc-Vo)/R. Since this rate is constant, the opamp output decreases from Vo linearly and, therefore, the LED current decreases linearly until the opamp output gets down to Vd, the LED forward voltage drop, at which point it is completely extinguished. The opamp output will continue to drop, but that is fine as long as you don't exceed the maximum reverse bias voltage of the LED.

You can, of course, make the timing resistor, R, adjustable.

The dependence of the dimming rate upon the resistance will not be linear, but the actualy dimming will be.

Another thing I like about this circuit is that it does not require or assume rail-to-rail operation of the opamp. I think it also provides some degree of automatic compensation for variations in Vcc, but a slightly modified circuit that uses a zener for R1 instead would be better, since then I think the timing would be pretty immune to variations in Vcc and only the full-scale brightness would be affected.

File size:
13.2 KB
Views:
75
19. ### AlkaAka Thread Starter New Member

Jul 1, 2013
9
0
wayneh - Thanks, I will correct the LED resistor!

WBahn - Thank you for the idea! Seems logical with your explanation. You mention that resistance will not linearly be related to the dimming rate. Do you know of any equation that could be used to figure out that rate?

Thanks again

20. ### WBahn Moderator

Mar 31, 2012
23,362
7,085
The current is

I = (Vcc-Vo)/R

That is the rate that the capacitor will charget at:

Q=CV
I=dQ/dt = C dv/dt

dv/dt = I/C = (Vcc-Vo)/(RC)

The amount of time that it will take the LED to extinquish is the amount of time it takes to got from Vo down to Vd, s0

T = (Vo-Vd)/(dt/dt) = RC * (Vo-Vd)/(Vcc-Vo)

So while the rate is not linearly related to the resistance, the time to extinguish is, which is nice and probably more useful.