Author Topic: Tripped up by my over-reliance on the LM317 (trap for young players?)  (Read 1234 times)

0 Members and 1 Guest are viewing this topic.

Offline mindcrimeTopic starter

  • Supporter
  • ****
  • Posts: 394
  • Country: us
Lately I've been working on a project involving a Raspberry Pi, and I have a requirement to be able to connect it to two power supplies (for example, a USB "power bank" device and a mains powered USB charger) and have it automatically switch to and from the "preferred" source as that source comes and goes.

OK, getting something working on that front was an adventure in it's own right, and FSM willing I'll write up that whole story debacle one of these days. But anyway, in the end I did have a device working, with a big "but".

The issue was, if I killed and re-added one of the sources by physically yanking the USB cable out of the corresponding device, and plugging it back in, all worked perfectly. Note that one of my requirements is that the Pi not glitch or reboot as a result of the switch in power sources.

Then I started testing with what happened if I took the AC mains powered charger and unplugged it from the wall. Aaaaand you can probably guess where this is going. It didn't work. The charger has enough internal capacitance and apparently either intentional current limiting and/or just really high output impedance, to the point that instead of a really crisp edge to signal the transition in the signal, you get a sort of a stepped, jaggedy ramp down instead. And that affected the timing of my switching and causes the Pi to reboot. Rut roh!

"So", I think to myself, "maybe I just need a different power supply that has behavior more in line with what I'm expecting."  With that thought in mind I start rummaging through the big ole box of old power supplies in the Closet of Despair and eventually drag out some random "13 point something" volt power supply that's rated for 3A or so. Of course I can't run a Pi off of 13.x volts, so I figure I'll hack together a quick little board to down-regulate the voltage to about 5.1 or so and call it good.

I reach, out of instinct, for my old friend the LM317, whack in a resistor and a potentiometer, connect it to the grumbly old 13.whatever supply, twiddle the pot a bit and get a nice, beautiful 5.2 volts. Perfect. Hack up a connector to connect it to the Pi, plug it in and... the Pi starts to boot! Yay! We're saved.

Yeah, no. The Pi *starts* to boot, but gets part way through the boot cycle and reboots. Wut? And here's where my stupidity kicks in. I convinced myself that the problem was most likely that this ancient, creaky old power supply just had too much ripple in it's output or something and the Pi was finally getting tired of it and throwing it's hands up and saying "da fuq?"

So I toss that decrepit old supply back in the Closet of Despair (I mean, there's a reason why it's called the Closet of Despair to begin with, ya know?) and move on.

Later that night I'm about to crawl into bed when this weird, random thought flitters into the edge of my consciousness: "Don't LM317's have automatic thermal shutdown if they overheat? And wasn't I running that with no heatsink? Can an an LM317 even power a Pi on its best day? What's the max current rating for an LM317 again???"

Right. Today I get home from work, set that experiment up again (braving another visit to the Closet of Despair) and tape a thermocouple to the LM317 and attach it to my thermometer. And turn on the Pi. And watch the temperature go up... and up.... and up... and up... and *reboot*.

Yeah. Not much question now. Double checked the datasheet and the LM317 is rated for 1.5A. That's a touch light to run a Raspberry Pi.

Anyway... now I know. So I ordered some LM338 regulators that can handle 5A (7A burst), a box of TO-220 heat sinks and some thermal paste. Soon I'll have a proper regulator and can get back to answering the question of "Does this power supply serve my purpose better than the RAV Power USB charger I was using?"

The moral of this story? The ubiquitous LM317 is your friend, but... it's not magic. It has limits. Like a 1.5A (approx) current limit and a maximum temperature. And that handy thermal cutoff feature which helps avoid destroying components, but which can really trip you up if you aren't thinking about thermal factors.

« Last Edit: June 22, 2022, 12:46:53 am by mindcrime »
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3025
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
1.5A is a tiny part of the story, that 317 can do 1.5A **if you can keep it cool**.

Power Dissipation is the phrase of importance, 13 - 5 = 8v you have to lose, at 1.5A that is 12W you have to get out of the TO-220 fast and continuously.

You need some fairly substantial passive heatsinking to get that 12W discarded, or a smaller heatsink and a modest fan.

~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 
The following users thanked this post: SeanB, mindcrime

Offline mindcrimeTopic starter

  • Supporter
  • ****
  • Posts: 394
  • Country: us
1.5A is a tiny part of the story, that 317 can do 1.5A **if you can keep it cool**.

The thing is, even 1.5A is borderline for a Pi, at least if it's running full tilt. IIRC the recommendation is to use a supply capable of sourcing 3A, which is approximately twice what the LM317 can handle.

That said, your point is valid. And with sufficient heat-sinking and fan, I might be able to scrape by with the LM317. But I think going with the LM338, and a good heatsink, and possibly a fan, will give me a little bit more margin for error.

And in the end, this might all be a waste, because this power supply might have the same crappy turn-off behavior as the other one. But that's OK. I'm simultaneously pursuing another strategy to try and account for the lack of that nice crisp falling edge on the signal that I was expecting. Early indications are that this approach will work ( a small scale simulation on the breadboard works anyway), but the acid test will be doing it with the Pi running and see if it can handle the switch without rebooting.

I'm tellin' ya... I've dabbled in hobby electronics on and off for probably close to 40 years now and I've probably learned more in the last two months than I did in the previous 40 years combined. :-) This has been a challenging, but educational, process.

 

Offline bdunham7

  • Super Contributor
  • ***
  • Posts: 7861
  • Country: us
That said, your point is valid. And with sufficient heat-sinking and fan, I might be able to scrape by with the LM317. But I think going with the LM338, and a good heatsink, and possibly a fan, will give me a little bit more margin for error.

For running a Raspberry Pi I wouldn't think you'd need a linear regulator.  A buck converter or a DC-DC converter module would be simpler and more efficient.

https://www.mouser.com/datasheet/2/468/RPM_3_0-1398189.pdf
A 3.5 digit 4.5 digit 5 digit 5.5 digit 6.5 digit 7.5 digit DMM is good enough for most people.
 

Offline mindcrimeTopic starter

  • Supporter
  • ****
  • Posts: 394
  • Country: us
That said, your point is valid. And with sufficient heat-sinking and fan, I might be able to scrape by with the LM317. But I think going with the LM338, and a good heatsink, and possibly a fan, will give me a little bit more margin for error.

For running a Raspberry Pi I wouldn't think you'd need a linear regulator.  A buck converter or a DC-DC converter module would be simpler and more efficient.

https://www.mouser.com/datasheet/2/468/RPM_3_0-1398189.pdf

I didn't have any handy when all of this was going on.  I actually ordered a few that just came in earlier today. I have some of those SEPIC converters coming as well. I started down the linear reg path just because I always have a few 317's in the parts box.

Ideally I'll be switching back to a 5V supply anyway, and won't need any of this down regulation stuff. This was really just an experiment to see if I might get lucky and find a Closet of Despair part that would, by happenstance, be more suitable for what I was doing. I'm not going to invest a whole lot in trying to work with 13V as my main supply if I can help it.

« Last Edit: June 22, 2022, 02:08:37 am by mindcrime »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19529
  • Country: gb
  • 0999
A series resistor before the input capacitor on the regulator can help dissipate some of the power, so it doesn't all get burned inside the regulator. Aim for a voltage drop which will give 3V higher, than the regulator's output voltage at maximum load and minimum acceptable input voltage.

Example: your power supply is 12V, when fully loaded with the maximum load of 1.5A and the output voltage is 5V.
5 + 3 = 8V
12V - 8V = 4V
R = V/I = 4/1.5 = 22/3R, so use 2R7, or 2R4.
P = VI = 1.5*4 = 6W, so use a much higher power resistor, say 8W, or 10W.

Anyway the LM317 is just a distraction. You should work in fixing your voltage switching circuit so it will work off the 5V power supply and not reboot when the voltage is slowly ramped up/down.
 
The following users thanked this post: mindcrime

Online wraper

  • Supporter
  • ****
  • Posts: 16867
  • Country: lv
Yeah. Not much question now. Double checked the datasheet and the LM317 is rated for 1.5A. That's a touch light to run a Raspberry Pi.

Anyway... now I know. So I ordered some LM338 regulators that can handle 5A (7A burst), a box of TO-220 heat sinks and some thermal paste. Soon I'll have a proper regulator and can get back to answering the question of "Does this power supply serve my purpose better than the RAV Power USB charger I was using?"

The moral of this story? The ubiquitous LM317 is your friend, but... it's not magic. It has limits. Like a 1.5A (approx) current limit and a maximum temperature. And that handy thermal cutoff feature which helps avoid destroying components, but which can really trip you up if you aren't thinking about thermal factors.
LM338 without a heatsink will behave exactly the same. Current rating without considering power dissipation means nothing.
 
The following users thanked this post: mindcrime

Offline bdunham7

  • Super Contributor
  • ***
  • Posts: 7861
  • Country: us
This was really just an experiment to see if I might get lucky and find a Closet of Despair part that would, by happenstance, be more suitable for what I was doing. I'm not going to invest a whole lot in trying to work with 13V as my main supply if I can help it.

OK, if you are hacking something temporary together from spare parts, you can use two LM317 or LM7805 in parallel if they are attached to the same heat sink right next to each other.  A dropping resistor wouldn't hurt either, depending on what you have in your closet.  I keep chunks of aluminum around for one-off heatsinks, even if temporary.  My closet overflows... :)
A 3.5 digit 4.5 digit 5 digit 5.5 digit 6.5 digit 7.5 digit DMM is good enough for most people.
 
The following users thanked this post: mindcrime

Offline mindcrimeTopic starter

  • Supporter
  • ****
  • Posts: 394
  • Country: us

Anyway the LM317 is just a distraction. You should work in fixing your voltage switching circuit so it will work off the 5V power supply and not reboot when the voltage is slowly ramped up/down.


Yep. I have already thrown together a circuit that can detect when the voltage drops by a small delta and then send a signal that can be used to switch a transistor or whatever.  I believe if I tune it carefully enough, I can detect the falling edge soon enough and do the switching so that nothing bad will happen. Adding a larger reservoir capacitor on the output of my board to provide more buffering might also help.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16621
  • Country: us
  • DavidH
1.5A is a tiny part of the story, that 317 can do 1.5A **if you can keep it cool**.

Power Dissipation is the phrase of importance, 13 - 5 = 8v you have to lose, at 1.5A that is 12W you have to get out of the TO-220 fast and continuously.

You need some fairly substantial passive heatsinking to get that 12W discarded, or a smaller heatsink and a modest fan.

A TO-220 package *by itself* can handle about 2 watts, and this applies just as much to the higher current 3 amp LM350 and 5 amp LM338 as the 1.5 amp LM317.
 

Offline mindcrimeTopic starter

  • Supporter
  • ****
  • Posts: 394
  • Country: us
Re: Tripped up by my over-reliance on the LM317 (trap for young players?)
« Reply #10 on: June 22, 2022, 03:53:47 pm »
Quote from: Wraper
LM338 without a heatsink will behave exactly the same. Current rating without considering power dissipation means nothing.

A TO-220 package *by itself* can handle about 2 watts, and this applies just as much to the higher current 3 amp LM350 and 5 amp LM338 as the 1.5 amp LM317.

Absolutely. That's why I ordered a box of TO-220 heatsinks and a new tube of thermal paste.

I know I already have some heat sinks here somewhere, but I'll be darned if I could find one the other night. I desperately need to reorganize / straighten / label my parts collection... *sigh*
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf