help: charging a supercap through a transistor

Started by mikewax, October 09, 2016, 07:35:21 AM

Previous topic - Next topic

mikewax



Hello anyone,
i'm puzzled by this, please see the picture. i'm charging and discharging a supercap with an olimex328 and three transistors. the olimex 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) 10% faster (57s) than it's supposed to (64s). when the switch is set to Q3 (position 2) the circuit completes the cycle 38% faster (40s) 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 agreed to within 1 second.

switch position 1: time for capacitor to cycle from 1 to 2.56 to 1 = 64s
time i observed: 57s

switch position 2: cycle time 64s
time i observed: 40s

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


Gerrit

The time is still in spec, checked some data sheets and a cap can be 20% less, try with some more caps if you have them. and off course also the resistance from the transistor and the resistor have a tolerance

mikewax

Quote from: Gerrit on October 09, 2016, 10:34:39 PM
The time is still in spec, checked some data sheets and a cap can be 20% less, try with some more caps if you have them. and off course also the resistance from the transistor and the resistor have a tolerance

thanx yeah that's right it seems the rating is just off by 10%. but what really puzzles me is that when the negative lead is connected straight to ground the cycle time is 57s. when it's connected to ground through the transistor the cycle time is 40s. that's 30% faster. this is incomprehensible. and no matter how i change out the resistors i get the same result. the same disparity. i swapped out the transistor Q3 and it still happens the same way. i'm starting to doubt my sanity.