Maker Pro
Maker Pro

charging a supercap through a transistor

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
monofull.png

Hello anyone,
i'm puzzled by this, please see the picture. i'm charging and discharging a supercap with an arduino and three transistors. the arduino continually measures the voltage across the cap. if Vcap goes over 2.56V it sets the transistors to drain the cap and if Vcap goes under 1V it sets them to charge the cap. so it just cycles up to 2.56V and down to 1V, up & down forever.
but my stopwatch measurements are way off. when the switch is set to ground (position 1) the circuit completes a whole cycle (1 to 2.56 to 1) in 57s. when the switch is set to Q3 (position 2) the circuit completes the cycle in 40s, 30% faster than it's supposed to. it's just unreal.

the code goes like this:

switch is set to either 1 or 2

1- power up
2- set DIO_3 HIGH
loop{
4- check Vc
5- if Vc < 1, set DIO_1 LOW, DIO_2 HIGH (charging). red LED on, yellow off
6- if Vc > 2.56, set DIO_1 HIGH, DIO_2 LOW (draining). yellow on, red off
}

i power the circuit on, wait a minute for the cycle to stabilize, then measure the period. i used many online calculators. they all calculated to 57 +/- 1 second.
when the cap is grounded through the Q3 transistor, the cycle invariably is 40 +/- 1 second.

can someone tell me what i'm doing wrong?
thanx, louie
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,769
Joined
Nov 17, 2011
Messages
13,769
It's not obvious to me. I have questions:

How do you "check Vc"? I suppose you measure AIO_1-AIO_2, right? Have you compared the voltages on these lines for the 2 positions of the switch using a separate voltmeter (multimeter)?
Are both parts of the cycle (charge/discharge) affected by the change in the switch's position in the same way or is there an difference (asymmetry, e.g. charge time is the same but discharge varies or vice versa)?

The collector-emitter voltage of Q3 will introduce an offset compared to the switch being in position 1. This may also affect the measurement by the arduino.
 

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
How do you "check Vc"? I suppose you measure AIO_1-AIO_2, right? Have you compared the voltages on these lines for the 2 positions of the switch using a separate voltmeter (multimeter)?

thanx, no actually i haven't. i didn't even think of that, because on my first test, my stopwatch matched the calculated period so i assumed the arduino was making an accurate measurement of the cap voltage.

Are both parts of the cycle (charge/discharge) affected by the change in the switch's position in the same way or is there an difference (asymmetry, e.g. charge time is the same but discharge varies or vice versa)?

yes there is an asymmetry. when it's connected through the transistor Q3, charging happens 34% faster and discharging happens 15% faster.

The collector-emitter voltage of Q3 will introduce an offset compared to the switch being in position 1. This may also affect the measurement by the arduino.

i been rollin it around in my brain but i can't figure how the VCE could alter the value of VC like this.

mike
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,769
Joined
Nov 17, 2011
Messages
13,769
so i assumed the arduino was making an accurate measurement of the cap voltage.
Don't assume, verify :D The results may hint to the issue you're experiencing. Especially watch the voltage on AIO_2.

I suppose you measure AIO_1-AIO_2, right?
How about this question?

i been rollin it around in my brain but i can't figure how the VCE could alter the value of VC like this.
Nor do I. It's just an observation to be kept at the back of your mind. If you measure Vcap=V(AIO_1)-V(AIO2), see above remark, Vce is eliminated from the measurement.

yes there is an asymmetry. when it's connected through the transistor Q3, charging happens 34% faster and discharging happens 15% faster.
Sorry, I didn't make my intention clear. Let me try again: With the switch in position 1, you have a duty cycle DC1. With the switch in position 2, does the duty cycle change noticeably?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
With the switch in position 1, the lower side of the capacitor is at ground and the emitter of Q3 is at Vc WRT ground. This will set up a current through Q2 based on Vc and the 15Ω resistor.

When the switch is in position 2, and the cap is discharging there will be a drop of Vce of Q3 in addition to the voltage of the capacitor. So the voltage seen at the emitter of Q2 will be higher and the discharge will happen faster since it will draw more current.

Bob
 

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
ok yeah the duty cycle TCHARGE/TTOTAL = 74.5% directly grounded, and 69.5% grounded thru Q3, and yes VC = AIO1 - AIO2. and i am intending to get a new voltmeter later today. thanx :)
 

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
With the switch in position 1, the lower side of the capacitor is at ground and the emitter of Q3 is at Vc WRT ground.
i'm not following here. the emitter of Q3 is connected directly to ground so it should be at 0.

This will set up a current through Q2 based on Vc and the 15Ω resistor.
well during the charging state DIO2 is set high so the base of Q2 is at 5V so there's not supposed to be any current thru Q2 at that point.

When the switch is in position 2, and the cap is discharging there will be a drop of Vce of Q3 in addition to the voltage of the capacitor. So the voltage seen at the emitter of Q2 will be higher and the discharge will happen faster since it will draw more current.
D-OH! of course. i didn't figure that. that explains why it's discharging faster.

i still don't get, though, why it would be charging nearly 30% faster than it's supposed to. maybe when i get a good voltmeter i'll get a clue. THANX.
 

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
Don't assume, verify :D The results may hint to the issue you're experiencing. Especially watch the voltage on AIO_2.

well i assumed wrong. WAY wrong. the problem is the voltage across Q3. during charging VCE is about 40mV. when it starts to discharge, VCE drops to minus 800mV and slowly rises, while discharging, to -400mV, at that point it goes back to charging again and VCE stays around 40mV.
so i guess it means the the resistance in one direction, RCE, is not the same as the resistance in the other direction, REC. this does make sense, since it's a BJT. VCE = 40mV and VEC = 800mV.
so AIO2 = -800mV but the actual value that the input port is reading is 0, so the atmega chip isn't seeing the right voltage. i guess.
that's quite a relief. but i still haven't solved the problem. is there another way to do this?
thanx, mike
 

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
so i took another 2222a transistor and added it to the circuit at the exact same spot as the first one, only with the E and C reversed. now i have two Q3s connected together and facing each other like dancers to accomodate the current flowing in each direction. so the circuit works better but not much. i think i'll start another thread since the question has changed.
thanx Harald :)
 
Top