Puzzler... - Page 1
Forum section: electronics / projects

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: July 24, 2015, 09:27:48 am
content: Hi guys, I have question that I need some help with. See the attached circuit diagram.So.. I have a V regulator fed by 9V battery and USB. I have designed a MOSFET auto toggle system for when the USB is plugged in. In short, it switches Q3 ON, thus, switching Q5 OFF, disconnecting the battery from the regulator input.It all works fine except... (working from battery only) when I push the power button, somehow, the 5V USB input net is pulled up by 2 volts, thus activating the MOSFET Q3, disconnecting the battery. Vin discharges as does the Q3 gate, allowing it to power back up, only for it to repeat over and over. I end up with a typical discharge curve when it disconnects the battery as I would expect. As soon as it has discharged sufficiently, Q5 switches back on and Vin reaches fully on, the USB input net (Q3 gate) is pulled up again and so on..I tried replacing the MOSFET Q4 on the USB input with a 1N4148 Diode thinking it was maybe a MOSFET characteristic causing stray capacitance / inductance but alas, no joy. This problem was still there.Removing either MOSFET Q3 or Q5 allows me to fix it quick and dirty, but I don't then have a USB switch over, and current will always be drawn from the battery even when the USB is plugged in.Any thoughts?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 24, 2015, 03:22:06 pm
content: The black background is just about unreadable, and none of the arrows (or superfluous antiparallel diodes) printed correctly. Can you make that readable?

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: July 27, 2015, 07:25:39 am
content: I didn't realise it was that bad....Anyway, I have attached a new schematic image. White BG.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 27, 2015, 01:21:55 pm
content: Still can't tell the polarity:Is the symbol actually broken, or is that a printing error?Also, the general layout looks poor (connections going every which way, there's no sense to it), and none of the connections or functions are labeled. So your "puzzle" is almost as good a puzzle to the trained eye, as-is...Tim

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: July 27, 2015, 01:47:45 pm
content: Ok, so bog standard FDY301NZ Mosfets. Drain is cathode side.I've broken the circuit up and made the whole thing bigger.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 27, 2015, 02:38:34 pm
content: Hmm..So, you want "+5V" or "+9V" to go into the converter, and which one is used depends on which ones are present?What are BAT_TOG and POWER BUTTON IN?As shown:- D6 in series with Q5 seems peculiar..- Q3 can turn off* Q5, which happens when +5 is available.*Q5 is wired as a source follower, so it will only pull within about 1.5V of +9V. Probably not a big deal, but it is a loss of efficiency.- Q4 is always off, but because it's used as a diode, that doesn't matter. Will cost some efficiency (~0.7V?).- R17 superfluous (unless discharging the +5V is desirable somewhere).- I'm guessing SW2 momentarily turns on U1, and then some external circuitry turns on BAT_TOG, then turns itself off when no longer needed.- And POWER BUTTON IN is a startup signal for it, except that it will come up at the same time as +3V3 (not delayed; so if this signal is edge triggered, it probably won't start), and Q2 is a source follower (though as long as Vin is the stated range, it will always be saturated as such).- If +9V is absent and +5V is present, D6 prevents back-flow through Q5. This might be beneficial if there's stuff out there that shouldn't be powered, but seems unnecessary if +9V is from a battery that must be physically absent for this to go down.- Q3 turns on (and pulls Q5 off) when +5V is only 0.8V or so, so if +5V rises slowly, Vin will brown out (to about 0.8V minus Q4 diode drop, pretty much zero) then track as it gets up to nominal. C7 is pretty small, so this may be significant even under hot-plugging conditions.Speaking of hot-plugging, D6 prevents reverse-polarity on +9V, and Q4 (as a diode) prevents reverse polarity on +5V. If +9V is a battery, then it's probably okay with respect to turn-on transients (due to battery ESR), but +5V may overshoot (due to charging C34, and C7 via Q4), causing a large current surge through Q4 and a modest (but probably not dangerous) voltage overshoot.It might be desirable to add a TVS (e.g. SMAJxxA series -- 9.0V would be minimum, around 12V maximum given the Vgs(max) ratings of those transistors; if that were fixed seperately, up to 28V could be used, limited by U1's input range), and additional filtering / bulk in parallel with C7 (say, an aluminum electrolytic of 10-47uF?).I would suggest dumping the chain of MOSFETs and using a battery manager / power controller / power-OR circuit instead -- these come with the facilities to drive MOSFETs (sometimes N-channel, usually P) with nearly zero voltage loss, and can include the over/under voltage detection and current limit protection that make a circuit very safe.Tim

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: July 27, 2015, 03:14:56 pm
content: Quote from: T3sl4co1l on July 27, 2015, 02:38:34 pmBAT_TOG is as you guessed, the regulator enable pin (microcontroller switched). POWER_BUTTON_IN is power button sense. Buffered Input to Microcontroller and used for powering down the circuit. IE. it switches BAT_TOG low when required.Quote from: T3sl4co1l on July 27, 2015, 02:38:34 pmUsed to prevent possible back charging of the battery when USB is plugged inQuote from: T3sl4co1l on July 27, 2015, 02:38:34 pmThe drop across Q5 is roughly .5/.6 of a volt. Tolerable for the application. What's curious is that the Gate voltage of Q5 is lower than the Source Voltage by about .5V again. Considering Vgsth needs to be (quoted) min +0.4V to turn on, this has perplexed me slightly. Gate of Q5 (drain of Q3) is tied to +9 via a 1M resistor.The power source toggle works. The problem I'm having is that (when no USB connected) the Gate of Q3 is floating to +2V when I push the power button (despite the fact it's supposed to be at 0V - pulled to ground via R17). Thus, switching Q5 Off and powering the circuit down. The gate of Q3 is then pulled to 0V once the circuit has discharged, Q5 switches back on, and the process repeats itself.Quote from: T3sl4co1l on July 27, 2015, 02:38:34 pmAgain, about 0.6V and tolerable.Quote from: T3sl4co1l on July 27, 2015, 02:38:34 pmThis should be pulling the Gate of Q3 low when the USB is disconnected.Quote from: T3sl4co1l on July 27, 2015, 02:38:34 pmI'm not sure I understand this bit ^^. The battery will always be present, +9V PP3 battery. The +9 doesn't go anywhere else in the circuit except for what's on the schematic.Quote from: T3sl4co1l on July 27, 2015, 02:38:34 pmWhen the USB is plugged in, the voltage at Vin decreases slowly from +9 to +5. I haven't scoped it for excessive transients. (should probably check it out though).Quote from: T3sl4co1l on July 27, 2015, 02:38:34 pmDesign is already on PCB, so can't make changes (at least not right now). The quick fix was to remove Q3, but I then don't have a power source toggle. It will always draw from battery unless battery is physically removed.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 27, 2015, 04:43:19 pm
content: Quote from: MyElectronsFellOut on July 27, 2015, 03:14:56 pmIt seems to be unlikely that you'd be limited by leakage, but using a "power" device, versus e.g. CD4000 series logic, gives some possibility. If nothing else, it seems the transistors are within spec (1uA max D-S leakage, and G-S for +/- 4.5V).Ed: oh, and also... is your meter 10Mohm (give or take), or is it Hi-Z on that range? Try measuring with two meters at once and see what the effect on the circuit is.I'd also suggest using smaller resistors, or stronger drive (e.g., CD4000 series logic), to give stronger gate signals. 1M resistor means, any capacitive coupling from nearby terminals goes right on through.And sensitivity to leakage, including on-board leakage. Apparently, "no-clean" fluxes can leave residues in the 100kohm range. That would be pretty damning here.QuoteOk, what does that have to do with the power button?Leakage sounds like Q4 going backwards. Which again, should be 1uA max, but maybe there's something else here I don't know about.QuoteOh, it looks weird paired with the diode-strapped transistor transistor.QuoteUnder what load? I'm assuming this needs to withstand the ~200mA the converter is capable of. If you're using it for flea farts, the brown-out rate will be quite slow indeed, but it will still be present.Not that you'd ever expect USB to be anything other than on or off, but it's an operating condition which clearly wasn't considered, but should be standard part of circuit analysis.It's easy, I'd dare say trivial, to arrange a circuit which meets limited constraints, at DC.It's equally as easy, almost trivial, to have such a circuit be utterly useless when one considers that those voltages aren't simply magically there forever, but have to be connected, disconnected, ramped, may change quickly or slowly, may be forward or reversed, etc. In other words, the dynamics.Dynamics are, by no means, a matter of infinite complexity. Statics are to addition what dynamics are to solving polynomial roots. Harder, but easy given a simple toolkit and sufficiently simple (or simplifiable) problems (e.g., the quadratic equation, and a system that can be simplified to second order).(Which isn't just analogy; polynomials are used to solve RLC circuits and such. The behaviors of a circuit like this aren't really DC nor steady-state AC, so it is still an analogy. But just because it's nonlinear doesn't mean, in this case, that it's intractable.)QuoteWhat means "can't make changes"?PCBs are exactly as changeable as you put your mind to. Perhaps you don't know the construction methods associated with, shall we say, extensive circuit modifications?Most simple, of course, being the cutting of traces, and patching in of bodge wires. But depending on board area and resources, you can add quite a lot, with some amount of effort (example: scratching the soldermask off a ground pour area, then carving it up into a footprint and traces for a new component), let alone if you add another tiny board with more components on it, and wire that up to everything.Depending on circumstances, there's also the option of breadboarding circuits like this, probably using breakout boards to handle the SMT parts. Obviously that's in hindsight, but, by the sound of it, the stage this should've been in..Tim

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: July 28, 2015, 06:50:55 am
content: Ok, so I can "hack" a board, but I'd rather not go mental just yet. As for breadboarding, I built a prototype of this circuit (minus the regulator) using large THT components to verify that the 'logic' of the circuit worked, and it did.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 28, 2015, 03:26:47 pm
content: Including the problem in question? So this scenario was tested on the breadboard, and not found to occur? So it's new on the PCB?Tim

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: July 29, 2015, 08:32:03 am
content: Indeed. I can't see any other way that the 5V rail could float to 2V like I described. And it's only a problem when you don't have the USB connected.Logically; If USB 5V is disconnected then, Vgate Q3 should == 0V.Battery is connected so Vgate Q5 (VDrain Q3) == ~ 8V. Vsource Q5 (Vin) == ~ 8.3V.All good so far, then when pushing the power button;Vsource Q5 (Vin) drops by about .2V as REGEN is now connected, drawing current & switching on the regulator.But;At the same time, Vgate of Q3 now floats to ~+2V, pulling gate of Q5 to ground, switching Q5 off, shutting everything down until nearly full discharge allows it to power back up.When the gate floats high, (on the scope) it's simultaneous with the slight drop at Vin and looks like a sharp switching curve rather than a steady charging curve. The two mosfets Q5 and Q3 are about ~2cm apart on the board with the other components in the schematic in various positions around them so I'm ruling out flux residue as I've also cleaned the board to be sure.Current Leakage does sound like a winner, but I'm not sure which component(s) are the culprits.As an aside, the 5V USB does power an FTDI chip. The chip is only powered when the USB is plugged in but I am constantly firing data across the serial comms regardless of whether the USB is connected or not.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 29, 2015, 04:02:29 pm
content: Quote from: MyElectronsFellOut on July 29, 2015, 08:32:03 amSo it's not floating up at all, it's getting hit with a transient?QuoteI've seen this happen before: the RXD/TXD pins drive current into the FTDI's input protection diodes, partially powering it (if the logic level is 3.3V CMOS, expect ~2.5V). That should be on its LVCC, and its +5VCC should be another diode drop below that (due to reverse biasing its internal LDO). But ~1.8V would account for the observation.Ideally, you should disable TXD (from MCU to FTDI) when it's off, or disable the logic with a level shifting type logic buffer. A simple way: connect a diode (BAT54?) from FTDI TXIN to MCU TXOUT, and a pullup resistor (10k max?) from FTDI +3.3V to TXIN.Tim

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: July 29, 2015, 08:51:21 pm
content: Quote from: T3sl4co1l on July 29, 2015, 04:02:29 pm

author: MyElectronsFellOut
author_rank: Regular Contributor
timestamp: August 07, 2015, 08:51:16 am
content: An update on this problem.Turns out the FTDI is the culprit here. Or to be specific, the MCU. I'm using an ATmega2560V. Also, using the Arduino bootloader to upload code over USB. The bootloader seems to be doing something that is pulling the TXD0 pin from the micro high (+3.3V) at startup. This is partially powering the FTDI and the +5V usb rail is pulled to the +2V.I bypassed the bootloader and and flashed my source HEX in via ISP and voila! problem solved. However, I like uploading over USB.Does anyone have experience with the STK500 bootloader for Arduino? I'm trawling through it to see if I can modify to prevent the TXD0 pin from being set HIGH at startup...