NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Basic Electronics » Power from USB: current limiter with an op-amp
April 09, 2009 by wayward |
I bought a bigger breadboard and rigged an USB hub underneath it for easier access to my laptop's USB when tinkering. USB has a well-defined voltage at very nearly around 5V, so I thought I could use it to power the circuit as well. There is a limit on 100mA for USB-powered devices unless you signal to the USB host that you need more power (allocated in steps of 100mA up to 0.5A), but I am satisfied with 100mA at the moment. However, I am wary not to draw more than that, which could happen if I for example short-circuited Vcc to GND somewhere on the breadboard -- it might fry my laptop's USB host. Those are supposed to limit the current by themselves, but I really do not wish to learn it the hard way. I was using a two-transistor current limiter until I discovered that the C-E juncture on the pass transistor plus a resistor produce a voltage drop of almost 1V. That is unacceptable! My input voltage is 5V and I need 5V on the output. Anyhow, a friend helped me find the following schematic: I have all the parts needed for this, including a TI TLV2461 op-amp and a 3.3V zener. And I have more questions. :)
Thanks for your time and sorry if I am not making myself clear! Zoran |
---|---|
April 09, 2009 by wayward |
I forgot to ask the most important question of all. Suppose I do short-circuit the breadboard. Voltage on the Rsense will overshoot that on the noninverting input and the op-amp will switch off. When it does so, Rsense will lose the current and its voltage will drop to zero. Then the op-amp will switch to high output again, and we'll have a loop. I am afraid this sort of oscillation on the output would actually damage the microprocessor far worse than anything else. Are these oscillations too great to be filtered by a fairly large capacitor? |
April 09, 2009 by wayward |
Should be "noninverting" -- zener is connected to + on the op-amp. |
April 11, 2009 by mrobbins (NerdKits Staff) |
Hi Zoran, Great question! There are lots of complicated analog parts here so let me try to break it down. Please let me know if I miss anything: Yes, you can draw 5V from the USB port to power your projects, but there are current limits as you suggest. Personally, I've accidentally shorted +5 to GND on the USB connector, and all that seems to happen is a warning message in my kernel log about too much current, and that the USB host controller is shutting down the port. While I do believe that they build them to be fairly robust to such incidents, I would not rule out the possibility that there are configurations that would result in serious or permanent damage to your computer. In fact, I suspect that the easiest way to do damage would be to connect a higher-voltaged power source -- maybe a 12V wall DC adapter -- to the port and fry it in that fashion. The fact that you're putting a hub in the middle might help but depends very much on how the hub itself was designed. The circuit you linked to, at least in the way that "load" and "sense" are labeled, is a constant current source. As you may know, there are three rules of ideal op-amps:
Since the zener and load resistor basically present a constant 3.3V at the non-inverting (+) input, the op-amp will act to make the voltage at the inverting (-) input equal, by adjusting its output. Essentially regardless of what the load is, the voltage across the "sense" resistor will be forced to be equal to 3.3V, so the current through the load will be forced to be 3.3/Rsense. This math only breaks down if Rload is too large. In the case shown, if the op-amp can truly output 5.0V, and with a normal NPN forward base-emitter drop of about 0.6V, saturation of the op-amp would start to occur when the load had (4.4-3.3)=1.1 volts across it. Since the same current flows through the load and sense resistors, this means that you will have problems if Rload >= Rsense/3. In any case, this is a current source the way it is drawn... but if you simply set Rload=0 and change the word "sense" to "load", you now have a voltage source! To your specific questions: Yes, the pass transistor still has a voltage drop, but that voltage drop is inside the feedback loop, so it ultimately has no effect on the voltage at the (-) terminal. The output of the op-amp will increase itself to counter out any increase in the base-emitter voltage drop of the transistor. (This is one of the many awesome things about feedback!) I'm not sure about your zener diode having such a non-linear curve, but I believe that this can be the case particularly with lower-voltage zener diodes. Since you do have good reason to believe that your input is really 5V, yes, you could replace it with a two-resistor divider. But I thought you wanted 5V in the first place! As far as your concern about oscillations: you're definitely thinking in the right direction, although your proposed cure would actually make things worse. Your circuit looks like it has a gain of (Rload+Rsense)/Rsense -- which I proved earlier can't be any higher than 4/3 with your current numbers if you don't want to saturate the op-amp. The op-amp you picked is unity-gain stable, which means it can handle a gain of 1... and in general, any op-amp that's unity-gain stable will also be stable at higher gains. However, adding a big capacitor at the output of a op-amp might be a bad idea, because it actually can slow down the response. Now, it depends on exactly where you put it in your circuit, but I suggest you take a look at two places in your op-amp datasheet: page 25 where the discuss "driving a capacitive load", and Figure 36 on page 22, which shows "phase margin versus load capacitance". Actually, Analog Devices (a company that makes a bunch of op-amps, ADCs, DACs, and other parts) has a neat online tool called Op-Amp Stability Effects when Driving Capacitive Loads. In short, adding capacitance at the output of an op-amp has a detrimental effect on the stability of your amplifier, and can cause oscillations, because it slows down the response of the whole feedback loop to the point where, as you mention, it just keeps overshooting one way or the other. (If you have a non-zero "Rload" in that picture, then you might be fine.) To modify the example of one of my professors for my feedback class, imagine steering a car as you're driving down the highway. You're the feedback amplifier, looking with your eyes (measuring at the inverting input), and commanding the steering wheel. You're able to make small, quick adjustments to keep centered in your lane. But now imagine that your power steering drops out, and even more than that, the steering wheel suddenly gets tremendous inertia. Now, instead of making quick, easy adjustments, you'll be forced to work hard just to get the steering wheel where you want it, and these extra troubles could slow your reaction down enough that you get "out of phase" with yourself, and you end up oscillating your way down your lane, or crashing altogether. (You're not allowed to slow down, either!) Anyway, adding more capacitance may seem like it's always the solution, but there are some cases (like op-amps) where it can actually cause oscillation. So you probably still want to know if there is a good solution to your current-limiting problem. Let me think about that a bit and get back to you! Mike |
April 12, 2009 by wayward |
Mike, this is a very thorough answer! I don't fully understand everything you mention here, but I like it that way; I'll have more food for thought. I will follow up later if I really can't figure something out on my own, for sure, but just now I feel like a little kid who was just given a hard candy to chew on. (bites) Oh, and yes, if you do come up with a good way to limit the current, by all means, share! Even just bare ideas are more than welcome. (I lack the theoretical and practical understanding to come up with ideas of my own at this stage, but I can wire things up and burn a few parts merrily, all for the sake of learning.) Zoran |
October 04, 2009 by mikedoug |
Hey, Mike, did this go any further? I had the idea this evening to take one of my old cell phone chargers (USB based), cut the head off the cable, and use the GND & +5 wires to power my circuitry. (I was going to send you an email when I thought to check the board). Can you just use the GND/+5 directly into the power ports on the bread board? -- skip the voltage regulator -- I assume one of those beasts actually sit inside the USB wall wort? If the current exceeds the wall wort's limitations, I'll live with a burned up wall wort. That said, how would one calculate the amount of current in-use by the circuitry -- a link to information would be sufficient. However, is there a real threat to the circuitry itself of using the power in this fashion? Thanks! |
October 06, 2009 by rusirius |
mikedoug, Here's one thing to keep in mind... If the USB hub is "powered" or "active", then it actually "disconnects" from the PC's power supply and uses its own... In other words, even if something WERE to get fried, it would only be the hub, not the PC's root hub... If on the other hand it's not powered, (i.e. no walwart of it's own) then it does use the PC power and could potentially have an issue... As pointed out, it is current limited and shouldn't ever be a problem, though as Mike pointed out, some sort of crazy feedback situation where you sent 12v or something through it could certainly damage it.. Shorting it out won't... As for the op-amp stuff, analog was where I fell asleep.. LOL.. I suck at it.. so I'm afraid I'm not much help there... |
October 07, 2009 by mikedoug |
heh... Umm... I don't even know what an op-amp is. :) I'm not there yet. Though my long-time electronics TEACHER dad would be so proud that I think I finally understand all this voltage, current, resistance, and EVEN the transistor! Not just "what" they do, but finally HOW/WHY it works -- which really helps cement the WHAT. :) MikeDoug |
Please log in to post a reply.
Did you know that NerdKits make a great gift? Learn more...
|