# Is this a viable Voltage Regulator design?

I'd like to power a Raspberry Pi 1.0 Model B and a USB HDD enclosure from a 12V DC, 2.5A power supply. The USB HDD enclosure accepts 12V directly, but doesn't state how much power it consumes. The HDD I intend to put in it states it needs 12V DC, 0.55A and 5V DC, 0.55A. Presumably the USB-SATA controller needs a small amount as well, so I'd round up and say that call comes to 1.2A (0.55A + 0.55A + 0.1A for the USB-SATA). The Raspberry Pi doesn't have a constant consumption, but this FAQ says that a recommended supply would be 5V DC, 1.2A and an average consumption would be 5V DC, 0.5A.

Based on that information, I was going to attempt to use an LM317 to regulate the 12V DC down to 5V DC for the Raspberry Pi. I want to validate a few things.

1. Short of a full blown switching supply circuit, is there anything better I can do than a voltage regulator?
2. That I did the power calculations correctly and have enough supply current
• Can I simply sum the 5V current and 12V current that the HDD needs?
• 0.55A @ 12V DC + 0.55A @ 5V DC + 0.1A @ 12V DC = 1.2A @ 12V DC
• Can I model the Raspberry Pi as a 10 Ohm load resistor?
• 5V / 0.5A = 10 Ohm
• Should I instead model it at the maximum draw?
• 5V / 1.2A = 4 1/6 Ohm
3. That the LM317 will not overheat if I don't use a heatsink
• The Raspberry Pi will be on constantly, but will be idle most of the time. Only a single GPIO pin will be used, and it will source very little current (1.6mA on top of what the Raspberry Pi draws).
4. That I have selected the correct resistors to minimize the power draw from the LM317 circuit itself. I'm using this datasheet.
• For my first pass I used really big R2 to minimize the current in the voltage divider controlling the adjustment pin. However, I didn't account for the Iadj current. Although small, multiplying it by a large resistor changed the voltage significantly
• The math got pretty messy when I included the Iadj term.
• Vo = 1.25(1 + R2/R1) + IadjR2
• Vo = I2R2 + I1R1
• I2 = Iadj + I1
• So that means that...
• R1 = (-5R2)/(-4*Vo+5+4IadjR2)
• I1 = (Vo-IadjR2)/(R2+R1)
• Which gives me enough data to graph I1 as R2 changes. I found the minimum I1 to be at 37.5K Ohm for R2, but that lead to a ridiculously large value for R1. So I compromised at the closest E12 resistor values to 30K Ohm for R2. Which were 33K Ohm for R2 and 56K Ohm for R1. My calculations say that should produce 5.2V DC and only draw 0.02mA for the adjustment resistors.
5. Is the simulation done by circuit lab close enough to reality that I could build it and have it work
• I used the maximum value for Iadj in my calculations (100uA), but the typical value is 46uA. I'm not certain if that is linear to the voltage or current of the LM317. Either way, the math didn't 100% line up with the simulation. simulate this circuit – Schematic created using CircuitLab

The results of the simulation are below:

• Vo = 5.212V DC
• I1 = 21.48uA
• I2 = 121.5uA
• Iload = 521.2mA

Calculations for selected values of R2

Vo  5   V
Vo  I2*R2+I1*R1 V   Equ 1

R2 (Ohm)    R1 (Ohm)    Vo (Equ 2)  I1  I2  Vo (Equ 1)  R2/R1
1.000000E+00    3.333422E-01    5.000000E+00    3.749900E+00    3.750000E+00    5.000000E+00    2.999920E+00
2.000000E+00    6.667022E-01    5.000000E+00    1.874900E+00    1.875000E+00    5.000000E+00    2.999840E+00
5.000000E+00    1.666889E+00    5.000000E+00    7.499000E-01    7.500000E-01    5.000000E+00    2.999600E+00
1.000000E+01    3.334222E+00    5.000000E+00    3.749000E-01    3.750000E-01    5.000000E+00    2.999200E+00
2.000000E+01    6.670224E+00    5.000000E+00    1.874000E-01    1.875000E-01    5.000000E+00    2.998400E+00
5.000000E+01    1.668892E+01    5.000000E+00    7.490000E-02    7.500000E-02    5.000000E+00    2.996000E+00
1.000000E+02    3.342246E+01    5.000000E+00    3.740000E-02    3.750000E-02    5.000000E+00    2.992000E+00
2.000000E+02    6.702413E+01    5.000000E+00    1.865000E-02    1.875000E-02    5.000000E+00    2.984000E+00
5.000000E+02    1.689189E+02    5.000000E+00    7.400000E-03    7.500000E-03    5.000000E+00    2.960000E+00
1.000000E+03    3.424658E+02    5.000000E+00    3.650000E-03    3.750000E-03    5.000000E+00    2.920000E+00
2.000000E+03    7.042254E+02    5.000000E+00    1.775000E-03    1.875000E-03    5.000000E+00    2.840000E+00
5.000000E+03    1.923077E+03    5.000000E+00    6.500000E-04    7.500000E-04    5.000000E+00    2.600000E+00
1.000000E+04    4.545455E+03    5.000000E+00    2.750000E-04    3.750000E-04    5.000000E+00    2.200000E+00
2.000000E+04    1.428571E+04    5.000000E+00    8.750000E-05    1.875000E-04    5.000000E+00    1.400000E+00
3.000000E+04    5.000000E+04    5.000000E+00    2.500000E-05    1.250000E-04    5.000000E+00    6.000000E-01
3.500000E+04    1.750000E+05    5.000000E+00    7.142857E-06    1.071429E-04    5.000000E+00    2.000000E-01
3.600000E+04    3.000000E+05    5.000000E+00    4.166667E-06    1.041667E-04    5.000000E+00    1.200000E-01
3.700000E+04    9.250000E+05    5.000000E+00    1.351351E-06    1.013514E-04    5.000000E+00    4.000000E-02
3.750000E+04    2.760827E+20    5.000000E+00    4.527628E-21    1.000000E-04    5.000000E+00    1.358288E-16
3.300000E+04    5.600000E+04    5.286607E+00    1.910112E-05    1.191011E-04    5.000000E+00    5.892857E-01

Simulation Results:
R1  R2  Vo  I1  I2  Iload
56K Ohm 33K Ohm 5.212V  21.48uA 121.5uA 521.2mA

• Making R2 larger makes the behavior very dependent on the IQ current of the LM317, while only making a very small difference in total power consumption -- I suggest making R2 smaller (1k ?). – jp314 Dec 7 '15 at 1:14
• Total power in the LM317 will be quite high -- (12-5)*0.5 A or worse. It will definitely need a heatsink, and you'll have to be careful when the RPi is booting or refereshing firmware -- it'll likely draw more power then. – jp314 Dec 7 '15 at 1:15
• @jp314 It's been a long time since I've taken any EE classes. Can you define or explain what the IQ current is? – Huckle Dec 7 '15 at 1:39
• @Huckle The quiescent current (IQ) is the "baseline" current that a component draws while idle and enabled. In this case the quiescent current exits the the lm317 at the ADJ pin, affecting the resistor divider and thus destablizing load regulation (the output voltage). – jms Dec 7 '15 at 1:55
• TLDR: possible but not very advisable unless you also need a space heater. Get or build a switching (buck) regulator instead; it will have much better efficiency. – Fizz Dec 7 '15 at 1:59

Buy a decent car usb charger. It will (most likely) be a complete 12V to 5V switching regulator, with filtering caps and everything. Better efficiency compared to a linear reg like the LM317.

The LM317 will use Voltage In * Current In = Power Used, part of which will be wasted in heat (Voltage In - Voltage Out) * Current In = Wasted Power. If we plug in the numbers, 12V * 0.75A = 9 Watts, of which (12V - 5V) * 0.75A = 5.25 Watts. That means 5.25 Watts of heat, which will kill a LM317 without a heatsink. And that's only 42% efficient.

A Switching regulator typically has 80~90% efficiency. Since we know you need 3.75 Watts of power on the output (5V * 0.75A), we can figure out the input power. Take the output power, and multiply it by the inverse of the efficiency percentage. 3.75W * (1 / 0.85) = 4.42 Watts of input power. Since we know the input voltage, we can reverse the power formula, that's 4.42W / 12V = 0.37 Amps. So you can use a smaller 12V power supply. And since it's only 15% of wasted heat (in this case 4.42 - 3.75 = 0.67 Watts), a heatsink is rarely needed.

That said, the USB Enclosure will typically have it's only 12V to 5V regulator to power the Hard Drive's 5V rail, so you shouldn't need to calculate for that.

• This is actually a really good idea. Considering the rest of this project is comprised of stuff I already had around the house it will fit right in. – Huckle Dec 7 '15 at 6:05

I'll try to go in order of your questions:

1) Not really. For DC voltage regulation, you're sort of limited to linear regulators for low-power applications, and switching regulators for high-power applications, or where efficiency matters. The LM317 is only $0.45, so I can see the appeal, but if you aren't budget limited, you could check out smaller switching regulators, such as the TRS1-2450. It's easily found online (such as Adafruit). You can see a datasheet here. It's internally limited to ~2.5A, but I doubt you'd ever really use more than 1A with an RPi. 2) With a linear regulator, yes you did the calculation correctly. A linear regulator "burns-off" the voltage overhead (7V when going from 12V to 5V), but the current through the regulator is (largely) conserved from the input to output side. The LM314 has an adjustment pin that makes it slightly different, but counting µA is pointless here. The second and third parts of your question are related. The RPi is probably better modeled as an active load. The voltage across it will always be (close to) 5V, but the current through it will vary, so a variable resistor is a better model. For this case, check out typical consumption for the RPi. It's typically around 500mA, and a couple GPIOs won't change that much. I doubt you'd ever go much higher than an amp, unless you're doing some serious bitcoin hashing on an RPi cluster. 3) Let's assume a steady-state current output from the LM317 of .75A. With a 12V input and a 5V output, you get a power dissipation of (12 - 5)V * .75A = 5.25W  In the worse case scenario of a 1.2A continuous draw, it goes up to 8.4W. You could check out this guide on linear regulator power considerations, but for over ~2.5W, I'd recommend a heatsink. They're about$1 and a ton of insurance. The LM317 has a thermal overload shutdown, just in case, so if you see brownouts, that might be the cause. Also, according to the datasheet, the max dissipative power is 20W. For the TRS switching regulator, you should be fine, since it's far more efficient (>84%).

4) I wouldn't worry too much here. Think about it this way. The RPi will consume ~500mA, so if the voltage divider consumes even 5mA (so resistor values of 1K from the 5V source), it's only 1% of the consumption of the RPi. Anything larger minimizes this even more.

However, the Iadj pin is actually quite important. Looking at the given equation:

Vo = 1.25 * (1 + R2 / R1) + R2 * Iadj


We can see that the value of Iadj and R2 can change the output voltage regulation. First, looking at the datasheet, Iadj can vary from anywhere between 0 (no minimum stated, but unlikely a negative value) to 100µA. You could use a trimpot here instead of two resistors, and with a DMM, calibrate the system under load so it provides exactly 5V down to some arbitrary precision. Alternatively, we can recognize that if we can tolerate ±5% variance (.25V according to this post), then R2 * Iadj shouldn't allow for more than a 500mV difference (5.25 - 4.75). Calculating R2's maximum value then:

500mV = R2 * Iadj
500mV = R2 * 100µA
R2 = 500mV / 100µA = 5kΩ


So now we can place some safe bounds using the guideline values for R2. We probably don't want it too much lower than 1K, and maybe not higher than 5k (unless calibrated with a trimpot). 4.7K is a convenient value in the standard series, but check out what standard values work for R1 as well so that R2 / R1 satisfies the equation adequately. Also, keep two things in mind: First, the typical application circuits are generally a pretty good starting point, and may likely work best for you. Professional engineers spent a decent amount of time making them, so gain whatever insight you can from them. Second, standard resistors have, IIRC, a limit of 10% deviation from their nominal value. Again, another argument in favor of trimpot + calibration.

4) Simulation is probably fine. The best way to check would be to build it (literally less than \$1 for the whole thing) and check it with a multimeter. You can simulate the RPi load with, as you suggested, a couple resistors that simulate the current loads you expect.

Hopefully this helps with designing the regulator!