Crude comparator sensing above VCC (or below 0V)  with discretes - Page 1
Forum section: electronics / beginners

author: Buriedcode
author_rank: Super Contributor
timestamp: September 15, 2024, 09:34:43 pm
content: Posting this in beginners, because its been a loong time since I studied classic analogue circuits, it might help beginners and students - since it deals with basic transistor stuff - and it's not really a critical problem, more of a curiosity.A number of years back I designed a crude, but somewhat effective circuit for charging capacitors using a flyback converter - not the TV kind (DIY transformer 1:12), but I did use it for a xenon strobe (250-300V) as well as lower voltage apps. It was based on a 555, using a crude transistor/diode based current limiting, so the on-time was controlled by peak current, but the off time was fixed. This made it a bit better than just a standard 555 circuit with fixed on/off itmes which can't keep track of inductor current, and relies on VCC, L, and the on time of the 555 to set the peak current.Now, I realise there are thousands of cheap controllers that will do this just very well, but as with all side projects, I wondered if I could still use the 555 as acrude MOSFET driver and SR latch, but improve upon it by making it pseudo resonant. Again, this is hardly practical, but I didn't want it to turn into an x-y problem, its more for my own understanding of what can be done "really cheap" using discretes.Essentially my idea was, instead of a fixed off-time - we wait for the inductor current in the secondary to fall to 0, or wait for the primary switching node to drop back down to VCC before we turn the switch on again. I'll still be peak current setting the on-time, but the off-time will vary as the output voltage rises, and the secondary current falls quicker.So this sent me down a rabbit hole of thinking about ways to sense this using discretes - sure an LM393 could work, and will be far better, but what using transistors? Essentially I'll be looking to sense when the switching mode drops from >VCC to VCC, or a current sense on the secondary going from <0V to 0V. My only idea as this point is a PNP current mirror, or an actual comparator, with thresholds set by resistors.Again, this is more about learning than anything practical (and because I get kind of hooked on certain ideas until I'm satisfied I've thought of enough solutions). Plus this isn't a DC/DC converter designed for a smooth regulated output - it'll charge a cap up to a preset voltage then stop. Only turned back on once the cap voltage drops below a certain amount. And I chose a flyback rather than boost because I may be shorting this output cap out. Doesn't have to be pretty, but it woudl be nice if there some some efficiency and a form of current control so it doesn't draw too much.

author: magic
author_rank: Super Contributor
timestamp: September 16, 2024, 06:50:46 am
content: For sensing above VCC:1. The simplest solution, if you can live with 600mV offset voltage: connect PNP base to VCC, emitter to the signal through a resistor.2. For lower offset voltage: connect the base to 600mV below VCC, using an identical PNP as a diode at similar bias current.3. An NPN differential pair with emitter followers to level-shift away from the rail, see LM358 input stage (but upside down).4. An NPN differential pair loaded with folded cascode, see AD797 simplified schematic for example.editActually, the last two may not work very well as they will probably show phase reversal for inputs greater than VCC+300mV or so.

author: Buriedcode
author_rank: Super Contributor
timestamp: September 16, 2024, 03:33:32 pm
content: Thanks for the reply.Your suggestions:1) This was my immediate thought however, the issue I have is that.. when charging very large capacitors, the first few cycles of the converter increase the voltage on the output cap very little - say we have a 330V photoflash cap, of 470uF for a large xenon tube. For a reasonable current limit on the converter of say 2A peak (or less if we want to stress the batteries less for a longer charging time), it'll take a while for that cap to reach >5V.Because of the turns ratio of the transformer, the voltage reflected back on the primary will be the cap voltage/turns. Given a 1:12 transformer, when the output cap is just starting up, say its 2V. The reflected voltage is 2/12 = 167mV. This will of course be much smaller when the output cap is *just* starting. So the ~0.7V Vbe drop would be too much. It will however work well once the output cap is 0.7*12 = ~8VInitially I thought of just having an RC circuit set the maximum off time, a timeout, so if the reflected voltage doesn't trigger the next on time, the RC circuit will, then, once the cap is charging nicely, its triggered by the reflected voltage again and increases frequency.2) this seems to be what I've thought off, and is actually what triggered me to post the question. See the attached image.Initially Q3 was a diode, to bias Q2 so that the transistor is just at the point of turn on. But it occured to me that the diode Vf won't be exactly the same as Q2's Vbe, so a matched transistor wired as a diode. Of course I quickly realised this is a current mirror and I'm a moron for not seeing it sooner. My only worry is how to limit the current for Q2 - emitter resistor? Since the emitter voltage in that circuit could reach >40V, with a base voltage of VCC-0.6 (~12V?).It's a nice idea - just two transistors - albeit perhaps have to be matched in some way and R6 can be adjusted to provide the correct bias so that the 555's trigger isn't activated unless the switch node goes to VCC or below.3/4) I'll have to look more closely at these, but this sort of thing is great - revisiting this stuff, and doing tests with a breadboard and scope is always fun, a good excuse to sit down and test these things with a breadboard and tinker. As I said, its been years since I studied analogue transistor circuits and I embarrassed at how much I have forgotten (don't use it, you lose it) so I thought messing about with a circuit like this would be a valuable exercise rather than throw DC/DC controllers or even just comparators at the problem.Cheers!

author: langwadt
author_rank: Super Contributor
timestamp: September 16, 2024, 03:57:14 pm
content: something silly like this:

author: magic
author_rank: Super Contributor
timestamp: September 17, 2024, 09:11:36 pm
content: Quote from: Buriedcode on September 16, 2024, 03:33:32 pmI'm afraid you will find these options completely disappointing. They are used in opamps, but only to get to the rail and maybe a few hundred mV beyond, no further. The problem is that an NPN emitter follower or a differential pair requires its collector to be higher than the emitter to work, and if the base (and emitter) can go a few volts above VCC there is no longer any easy way to supply power to the collector.This seems to leave us with options involving a PNP and signal applied to the emitter. Then the transistor simply draws power from the input signal itself.One more simple option that may perhaps work is to connect an NPN emitter follower to the "control voltage" pin of 555 and a PNP to the NPN's emitter. The PNP's emitter voltage ends up close to 2/3·VCC. Then add a resistor from the emitter to the transformer and an equal resistor from the collector to ground and collector voltage will cross 1/3·VCC roughly when the transformer is at VCC.