Showing posts with label LM317. Show all posts
Showing posts with label LM317. Show all posts

Sunday, November 12, 2017

A Simple Current Source and An Ode the Resistor


This isn't really a post about using a variable voltage regulator as a current regulator. This is actually a reflection on the lowly resistor's simple but amazing ability to transform a voltage into a current and vice-versa. 

Before I get into the wonders of the resistor, I am going to discuss how to make a voltage regulator into a current regulator. I'll use the venerable and classic LM317 as the example regulator but any three terminal variable regulator will work the same way 

Figure 1. Voltage Regulator.

It was originally meant to be a voltage regulator, says so right in the name. The LM317 adjusts it's output (by internally adjusting a pass transistor -- pretend it sets a resistor between IN and OUT) until the voltage between ADJ and OUT is 1.25V. It uses negative feedback. Essentially, if you stay inside the drop out voltage and other data sheet limitations, VR1 (the voltage across resistor R1) will be 1.25V. 

That makes operation as an adjustable voltage regulator straight forward. The resistor divider formed by R1 and R2 will have 1.25V across its top resistor. You know the math to find the rest. 


Of course the resistor sizes set the current through the divider. The current through the divider is VOUT/(R1+R2). Since we know the voltage difference between VOUT and VADJ is 1.25V and this is the voltage across R1, 1.25V/R1 will give the same result. These equations are approximations since they do not include the current that flows into the ADJ terminal. That is a reason to keep the current in the resistors up -- so this error doesn't become relatively important. Many versions of the 317 insist on at least 10mA(!) of output current. If you have to burn some extra current to meet that criteria it might as well be wasted in the resistor divider.

Figure 2. Current Regulator.

Notice what happened there. The current flowing through R1 keeps flowing through R2 (ignoring a small bit that gets lost into the ADJ pin). That's just Kirchoff's current law. R2 doesn't have anything to do with setting the current. So R2 can be replaced by a circuit that needs to consume that current. An LED is a very common circuit to place there. LEDs have reasonably constant brightness if the current through them is kept constant. This circuit does a decent job of holding the current constant across temperature and voltage. 

Did you see what R1 did in that circuit? As long as 1.25V was across it, a constant current flowed through it. It acted as a voltage to current converter. That function is inherent in the definition of a resistor--Ohm's law. 

V=IR

The voltage put across the resistor generates a predictable current through the resistor. The resistor acts as a voltage-to-current converter. And it works the other direction. 

I=V/R

A current forced through a resistor generates a predictable voltage across the resistor. 


Figure 3. Current to Voltage Converter.

Here is an example of the resistor being used as a current-to-voltage converter. For this to work well, the two current sources need to be well matched. This is a way to get a small floating voltage. The result is that VOUT is 50mV lower than VIN.


Figure 4. Voltage to Current Converter.

Here's an example of the resistor being used as a voltage-to-current converter. The voltage across the resistor is the difference between the power supply and the MOSFET drain (the gate is at the same potential), that is, VDD-VGS. That current gets mirrored over the other MOSFET. Just a different way of thinking about a classic circuit. 


Wednesday, May 16, 2012

Boost Regulator Soft Start

I am using the soft start circuit more-or-less straight from the LM317 datasheet

Soft Start using an LM317. Takes 300msec to reach 9V.

I started by adjusting the resistors to give a 9V output and use 1mA of bias current. It turns out the LM317 requires 10mA of output current to regulate. It's right there in the datasheet, but I missed it until I started to put the circuit together and couldn't figure out why it wasn't regulating. So I went for 10mA of current. Which seems like a lot. Maybe I should make an improved 317.

10mA. Ouch!

My intention is to soft start both the power supply for the compensator and the reference voltage. I used a diode model I had handy; I don't think the diode itself is particularly important.

Soft Start simulation results.


This entry is just a quick note. I ordered parts from Mouser and have started actually building the LED driver. I had trouble finding comparators of the needed speed at a price I could stomach. I'm going to try using the op-amps and only buy comparators if I need to. 

The approach to building the circuit will be to make the linear regulator with soft-start and use it to provide references. Then make the triangle-wave generator and see if I can really get a 400kHz triangle wave out it. Then make the boost regulator, but drive it from a pulse generator to check it out. Then pull the whole thing together. 

Then design a battery charger and interface and an on/off switch. Then install the beast in the trailer. 

I intend to publish photos of the building and verification process next week. I will also publish the schematic as it now is. I switched to direct current control and didn't document the change. It's not a big change, but it lowers the operating voltage and therefore the power requirements.

Late addition. I soldered the linear regulator and soft-start (and resoldered after finding I needed more LM317 current as explained above). I'm actually hitting 9.2V for input voltages above about 11V, that's less than 5% error.  The scope shot shows lower because my waveform generator only goes up to 10V. The soldering is not the best I've done. I could blame the re-solder, but I'm out of practice. I will have to do better when I put the triangle wave generator on here. I'm trying to decide if I use sockets for that part. It would make soldering safer.


9V regulator with soft start.

Soft start in operation. A bit faster than expected, but close enough. 


Miscellaneous tidbit for this week. I use this alias in my .cshrc.
alias big 'find . -type f -exec ls -s1k {}  \; | sort -gr | head'

And this one in a .bashrc.
alias big='find . -type f -exec ls -s1k '{}'  \; | sort -gr | head'

I don't remember now if the syntax is different for the different shells or just how they have drifted.
big gives a sorted list of the ten largest files in the current hierarchy


Bruce McLaren

Tuesday, February 21, 2012

LEDs Inside a Trailer

White LEDs are a good choice to light the inside of a boy scout trailer. They are low power. They do not produce too much light. They are inexpensive. They can be operated from a 12V battery. They are physically resilient.

The schematic shows four units of four LEDs and the associated circuitry. The unit can be repeated as many times as needed (four in this schematic). The LEDs are arranged in two parallel stacks of two series LEDs (2S2P). A stack of two LEDs will always operate with a battery voltage as low as 11.1V (4.4V for each LED, 1.3V across the resistor, 1V dropout). Two stacks will match close enough for this application while keeping the total current through the regulator below half it's rated capability. The LM317 is a nice adjustable regulator that I am using as a linear current regulator. Using a 33Ω resistor across the 1.2V reference results in 36mA of current. 

Schematic of four four LED units.


To implement this design, I obtained the following from Mouser. I bought 1000 resistors, so they are essentially free per piece. Each four LED unit costs $1.41, 16 LEDs costs $5.64.

Manufacturer Description Part Number Price
Cree White LED CP41B-WGS-CK0P0154 $0.30
Fairchild Adj. Regulator LM317LZ $0.17
Xicon 33Ohm 1/4W, 5% 291-33-RC $0.009

Construction

I breadboarded this circuit to get an idea of the brightness and so I would have a reference to drop LEDs into during construction to verify which direction they are pointing. I find these square LEDs difficult to orient.

One four LED unit on a breadboard.


The troop's adult quartermaster and I decided one light placed approximately every 30cm would be enough illumination for unloading the trailer at night. When I started to wire up the 16 or so LEDs that would be needed, I discovered this approach is a headache. Lots of branching and back and forth wiring is needed. Not a bad solution, but I can do better.

Next week I do better. Anyone for a boost switch mode DC-DC converter?

I've been listening to the Digikey/DesignNews "180 days of Education" For the last several weeks. The microcontroller lectures (the first two weeks) were worth the time. They are basic to intermediate level lectures well presented. The sensors lectures of the third week just didn't seem as useful to me. Probably worth listening to, but not necessarily. I will find the time to hear the next lectures.

Bruce McLaren