LM317 not working as expected

Hardware noob here...

I have a 12V regulated power supply feeding an Arduino uno.

My sketch is just analogWrite(9,255) which puts 5V out of pin 9.

Pin 9 runs through a circuit with a 2n2222 to increase the voltage up to Vin. (Imgur: The magic of the Internet is the circuit)

So, I have 11.7V coming into the breadboard I'm doing now. The point of my breadboard is to lower that 11.7V to 10V.

I send that 11.7 to the LM317, using this diagram; Imgur: The magic of the Internet

Should be Vout=1.25V(1+(R2/R1))

With R1=1K and R2=1K I would expect 1.25*(1+1)=2.5V but I actually get 2.84V. That could be my multimeter, something weird in the circuit, I dono, I don't think that's too bad.

Now, replacing R2 with a 6.8K resistor, I would expect 1.25*(1+6.8 )=9.75V. I actually get about 7V

Being the noob that I am, I just kept plugging bigger resistors in for R2 until I got to 100K. With a 100K for R2, I get Vout=9.5V

At that point I figured it was best to stop trying to blow things up, and just ask here.

Any advice?
Thanks for reading!

Some things:

  1. You need to measure your resistors, you can't just go by the nominal values and expect accurate results. You'll find that your resistors aren't exactly 1K.
  2. You need to load down the output by at least 5 - 10mA otherwise the returned quiescent current will cause the voltage to rise higher than you expect. Just put a 1K resistor on the output.

For that chip to work then the input voltage has to be at least 3V bigger than the output voltage. That is what the data sheet says. So you can't have the situation where:-

The point of my breadboard is to lower that 11.7V to 10V.

The point of my breadboard is to lower that 11.7V to 10V.

I guess a more fundamental question is what is the 10V PWM signal going to drive. Even if you had enough voltage margin to use the LM317, I don't think I've ever seen a circuit where someone tried to drive a PWM signal into the input pin of a linear voltage regulator circuit and I would be very surprised if it would even work.

So what you have presented is a possible solution to a 'problem' which is not a good one, so what are you trying to drive with the PWM 10vdc signal? There may be a very simple but effective solution, such as a voltage divider.
Lefty

Adding a 1k resistor to the output didn't change anything, but thanks for the tip, I'll keep that in mind.

I found where it shows that I need at least a 3V difference, but boy was that worded weirdly. Maybe it's in English somewhere else on the sheet.

Did a little research, and I started looking for a "low-dropout" voltage regulator. So far I'm not finding one to suit my needs, but i'll keep looking.

Do you have a recommendation off the top of your head?

You ninja'd me, lefty. I'm going to use it to do the dimming function of 2 different meanwell led drivers, ELN60-48P and ELN60-27P
(Making separate circuits for each, so just one driver for this example)

Here's a link to my first post, which goes into greater detail about what I'm doing. http://arduino.cc/forum/index.php/topic,155564.0.html#msg1166302

Thanks for taking a look!

Longarms:
You ninja'd me, lefty. I'm going to use it to do the dimming function of 2 different meanwell led drivers, ELN60-48P and ELN60-27P
(Making separate circuits for each, so just one driver for this example)

Here's a link to my first post, which goes into greater detail about what I'm doing. http://arduino.cc/forum/index.php/topic,155564.0.html#msg1166302

Thanks for taking a look!

I think you going way overboard on your 'solution'. The 11.7vdc pwm signal probably could be wired directly into the dimmer without a problem, however if your concerned you could just wire the 11.7 voltage from your Vin pin through two series diodes where it connects to the top of the collector resistor of your transistor switching circuit, which should drop the voltage pretty close to +10vdc. Using a voltage regulator is this case is just silly even if it could be made to work which I have serious doubts about.

Also do be aware that the PWM signal will be inverted by the switching transistor such that 100% arduino pwm analogWrite() output will be a 0% PWM input to your dimmer circuit, so you will have to deal with that 'inversion' in your sketch software.

Lefty

Longarms:
Adding a 1k resistor to the output didn't change anything, but thanks for the tip, I'll keep that in mind.

You did hook the other end of the resistor to ground, right? It's to put a minimal load on the regulator's output.

Lefty, I'm probably definitely going overboard, 'cause I don't really know what I'm doing. Now, keeping that in mind, what exactly do you mean by two series diodes? Two diodes in series? What kind of diode? Why are two diodes better than one voltage regulator (if it worked)?

Yeah, my sketch actually has analogWrite(9,~255); but for simplicity I left that tid-bit out, and as usual, I had to explain it anyway.. so much for simplicity. I should stop taking shortcuts...

Afremont, Hmmm...maybe? I went from Vout to R1k to multimeter to ground.

I should probably stop posting to this thread, as the question was answered and it's sidetracking now.

Through testing different R2s, I see that when Vin-Vout>3, the regulator works normally, so I'm just using it wrong.

Feel free to join in on my project guidance post, though.

Longarms:
Lefty, I'm probably definitely going overboard, 'cause I don't really know what I'm doing. Now, keeping that in mind, what exactly do you mean by two series diodes? Two diodes in series?

Yes, Vin > anode > cathode > anode > cathode > resistor > collector of transistor.

What kind of diode? Why are two diodes better than one voltage regulator (if it worked)?

Any IN400x type diode would be fine, each diode will have a constant forward voltage drop of around .6vdc so two will give 1.2vdc voltage drop so 11.7 - 1.2 = 10.5vdc, three is series would give you 9.9vdc, your choice.

Why are two diodes better than one voltage regulator (if it worked)?

Linear voltage regulators are designed to power circuitry not to control the signal level of a PWM control signal, that's like using a sledge hammer to hang a picture hook. It's simply the wrong tool for the job at hand
Lefty

Yeah, my sketch actually has analogWrite(9,~255); but for simplicity I left that tid-bit out, and as usual, I had to explain it anyway.. so much for simplicity. I should stop taking shortcuts...

Afremont, Hmmm...maybe? I went from Vout to R1k to multimeter to ground.

That's what I was afraid of, the resistor represents a load so it shunts the output to ground. You then measure the voltage with your meter with the + lead at the output of the regulator and the - lead to ground. Without any load, it's common for many regulators to have a rise in the output voltage.

The LM317 is an interesting device. It can be used as a constant current source instead of constant voltage. What it is doing is outputting whatever voltage is required (assuming it can of course) to drive enough current thru R1 and R2 to create a voltage of 1.25V at the adjustment terminal. So R1 can be chosen to create the 1.25V drop and then R2 would be replace by your circuit that you wanted to feed a constant current thru, such as a string of LEDs.

EDIT: For example, if you wanted to drive 20mA thru a stack of LEDs, you would use a 62.5 Ohm resistor for R1. This is a basic Ohm's Law calculation where E=1.25V, I=.02A and R is the unknown.

Lefty, Alright, i'll be picking up some diodes tomorrow and we'll see how it goes. Thanks.

Afremont, after reading your post at least 5 times, I still mostly don't understand anything, but it sounds scary. Someday I'll understand, thanks for trying to educate me!

Longarms:
Afremont, after reading your post at least 5 times, I still mostly don't understand anything, but it sounds scary. Someday I'll understand, thanks for trying to educate me!

Sorry about that. The first part just says that you can't really trust what you read as the output of the regulator until you place a load on it. The data sheet says that the "typical" minimum load is 3.5mA, but that is not the number you get to use. You have to pick the worst-case number from the MAX column that says 10mA. To accomplish this, you can just put a resistor on the output to ground. Try that again with your 1k resistors for R1 and R2 and see if it's closer to 2.5V when you put a load on it. But again, your resistors will likely be 10% tolerance so the true value could be that much off either way. You will need to use something along the lines of 250 Ohms for the load resistor to get 10mA load out of 2.5V, but a 1k resistor will draw 2.5mA and may place enough of a load on it for you to see the effect.

The second paragraph attempts to tersely explain what the LM317 is really up to and how to make use of that for driving a stack of LEDs.

Here is a link to a voltage calculator that you might find helpful:
http://www.reuk.co.uk/LM317-Voltage-Calculator.htm
Here is the current calculator version:
http://www.reuk.co.uk/LM317-Current-Calculator.htm

Awesome links. Loving the charts, calculating resistance values is becoming my most hated aspect of electronics.