# Life size LM317

In one of my previous videos, we looked at how buck converters work. And in the modern day, they are among the most popular group of power supplies, switch mode power supplies. And that is for good reason: they are incredibly effecient. In the same category are boost converters, which are very similiar in function, but increase the input voltage instead. Now, while all of these switching supplies are amazing, they have one disadvantage, and that is the noise that they produce from switching. In most all cases, this is fine because our electronics are largely digital nowadays, but for analog electronics, especially circuits dealing with audio, the noise can become a big problem. That’s where linear regulators come in. They have extremely low output noise and are also much simpler to make aswell. So why don’t we use linear regulators all of the time? Well in this video I will show you how a linear regulator works, as well as why you would and wouldn’t want to use one.

To start, we should take a look at one of the most well known linear regulator ics ever made: the LM317. If you look anywhere online, you are bound to find at least a few circuits with this ic. The best place to look to find out how this regulator works is the functional block diagram in its datasheet. We can see that it is made up of a comparator and a darlington transistor. There is also a 1.25 volt offset on the non-inverting input of the comparator represented by the zener diode. Anyways, based on the diagrams we can already easily see how it works. First, remember that op amps always try to keep both inputs equal, so since it is in a buffer configuation, it will try to drive the transistor to output a voltage equal to the non-inverting input. The reason why a darlington transistor is used instead of just a solitary transistor is that a darlington transistor will have a higher output current. Remember that transistors will have gain based on flowing current, so two transistors together will have a higher current gain.

Let’s use some numbers to provide an example for you. Let’s say that the input is 12 volts, and we put a 5 volt signal on the adjust pin. Because of the voltage offset, the non-inverting input will be at 6.25 volts. Now to keep both inputs equal, the op-amp will start driving the transistor to reach an output voltage of 6.25 volts. Now we can see the problem that linear regulators face, and that is the power loss as heat. So while we have a 6.25 volt output, we also droppped 5.75 volts through the regulator to get that output. Let’s say for example that our circuit was drawing 1 amp through it, that means we have 5.75 watts of power loss as heat. And this only gets worse with higher voltage drops and higher currents, thus it creates a need for a heatsink if the load is large enough. So you will have to manage your heatsink and load carefully because the recommended operating temperature for the LM317 is 0 to 125 degrees celcius. Another disadvantage is that the minimum voltage it can output is 1.25 volts because of the offset, and that the datasheet recommends a minimum of at least 3 volts drop across the regulator.

However, the heat dissipation is just about its only main disadvantage. Let’s setup an example circuit to explain some of its advantages. Luckily, the datasheet already provides us an example circuit that we can build ourselves. After building the circuit, we can already see the first main advantage, and that is the low part count required to operate the circuit. Even the adjust pin can be driven by simply using a voltage divider derived from the output. And after hooking the output up to my oscilloscope we can see that the output really is quite stable, even when we change the load or change the output voltage.

However, we can still take this project a step further, by implementing the internal circuit of the LM317 ourselves. We will be using the LM358 as our op-amp, and the IRLZ44N mosfet as our transistor. The reason why I didn’t use a pair of npn transistors was because 1. the mosfet is simpler to use, and 2. it has a surface for easily mounting a heatsink. And so I simply removed the LM317 from the circuit and placed the two new parts into its place. The inverting input went to the source pin on the mosfet, thus completing our buffer. The non-inverting input was connected to the middle of the voltage divider. However, it wasn’t working as expected, and the output was essentially connected to 0 volts. However, it did work when driven by a voltage source directly. So how does the LM317 manage to allow the use of a resistor divider? Let’s review the LM317’s diagram to see what we are missing. Looking at the diagram we can now understand the purpose of the diode and the current source. Without those two components, the op-amp will always try to output a voltage that is a division of what it is currently, lowering the output overtime. The diode and the current source, on the other hand, will work together to basically copy the voltage on the divider. The current source will change its output voltage in whatever way necessary to always have 10 microAmps of current flowing through it. And, ignoring the diode for a moment, since voltages in parallel should be equal, the current source will match the resistor divider. However, we still have the output division problem, so we can add a diode to force the current source to output a voltage slightly higher than the resistor divider. We have a few options for a diode, first we can simply put a normal diode with the cathode facing the resistor divider, or have that same diode with the cathode facing the current source. They both technically work, but the LM317 does it in the best way, it has the diode’s cathode facing the current source, but the diode is also a low voltage zener. The reason why this is the best way is because the zener will provide a predictable voltage drop, whereas a typical diode will either have a massive reverse voltage breakdown, or have a varying voltage drop depending on factors like current or temperature. The reason why the current doesn’t just flow through the diode is because the voltage is higher, and we all know that current will flow from higher to lower voltages. And since the current from the source is so low, it won’t affect the resistor divider much. So, the combination of these two parts allows for a simple way to copy the voltage divider’s output.

So, for our circuit, we need to pick two parts that will function as our current source and zener diode. The LM334 is a suitable current source that will give us a 10 microAmp output. The LM385 is a 1.25 voltage reference IC, but it functions as a zener diode as seen from the diagram. Now we can see that varying the potentiometer will allow us to pick the output voltage, and it stays stable even when the load changes. If you want to see the full schematic, feel free to look at the link in the description.

The only thing left to do is solder this circuit properly together and make a linear power supply out of it. So I soldered all of the components together and also added a current and voltmeter display. Now we have a linear power supply that can provide a clean output voltage. It is basically just a large, sort of lifesize LM317 powersupply.

If you enjoyed this video and found it helpful, please consider subscribing so that you can see my other videos. Have a good one.