Question about LM317

Go To Last Post
30 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I just joined AVR Freaks, so thank you for accept me and a... hi.

 

I got here because searching for answer to a question I've found this topic: https://www.avrfreaks.net/forum/...

 

As that is an old, 2010 topic, I think it's good to start a new one. But if i'm wrong, please excuse, tell me and I can fix it.

 

My question is what if I set LM317 to a Vout greater than what I have as Vin, can it damage the 317?

 

I'm asking that because I wish to set 317 using variable resistors (like LDR ou thermistor).

 

 

Thank you.

 

P.S.: Please excuse my horrible English.

This topic has a solution.
Last Edited: Fri. Jan 14, 2022 - 05:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to AVRFreaks!

 

rmlazzari wrote:
My question is what if I set LM317 to a Vout greater than what I have as Vin, can it damage the 317?

No, you can not set it higher then Vin!  (The actual output will be a bit lower then Vin)

 

From the datasheet:

8.4.2 Operation With Low Input Voltage
The device requires up to 3-V headroom (VI – VO) to operate in regulation. The device may drop out and
OUTPUT voltage will be INPUT voltage minus drop out voltage with less headroom.

Jim

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

If you want something you've never had...

...you must be willing to do something you've never done!

Lets go Brandon!

Last Edited: Fri. Jan 14, 2022 - 03:50 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The LM317 can not be configured to have a VOUT greater than VIN. If your have a given input voltage and set the ADJUST resistors for an output  greater than the input, the output will still never go above about 3V less than VIN.

It will not damage the LM317 (if the current/power limits are not exceeded).

David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


rmlazzari wrote:
My question is what if I set LM317 to a Vout greater than what I have as Vin, can it damage the 317?
Yes by a few fault conditions.

The Art of Electronics 3rd Edition | by Horowitz and Hill

Download a sample chapter

[page 37]

Figure 9.14. Application hints for the LM317-style three-terminal adjustable regulator, described in §9.3.4.

More fault conditions :

  • current injection
  • brownout causes over-volt

Recommend a voltage clamp, crowbar, or zener diode on voltage regulator's output (a relative few voltage regulators are two-quadrant [current source and sink])

 

P.S.

rmlazzari wrote:
P.S.: Please excuse my horrible English.
Not as I comprehend your post.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Thank you, everybody!

Last Edited: Fri. Jan 14, 2022 - 04:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The datasheet recommends to use a variable resistor as R2. It means as greater is that resistance R2, greater is Vout. I'd like the opposite: greater resistance, less output voltage.

I'd like to use that to make a little led brighter as the environment gets brighter. If the room is dark, there's no need to a searchlight, it's needed only a small, tiny bright point.

So I thought to make R2 with a fixed value and replace R1 with a LDR...

 

I've found, through Internet, circuits using LDR to trigger a 555 but I'd like not an ON or OFF circuit but a proportional circuit. No need for linearity, just brighter or not so brighter.

 

Thanks again, as it does not blows 317 out, I'll try it...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rmlazzari wrote:
wish to set 317 using variable resistors (like LDR ou thermistor).

 

You can use Thermistor as R2 in #4 picture.

As for LDR, you can try with a transistor for current amplification. Put LDR from some plus (fixed?) to a base, and use C-E instead of R2.

 

Edit: do not touch R1

Last Edited: Fri. Jan 14, 2022 - 05:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

grohote wrote:

rmlazzari wrote:
wish to set 317 using variable resistors (like LDR ou thermistor).

 

You can use Thermistor as R2 in #4 picture.

As for LDR, you can try with a transistor for current amplification. Put LDR from some plus (fixed?) to a base, and use C-E instead of R2.

 

Edit: do not touch R1

 

Humm... it could be a better idea. @frog_jr said Vout > Vin doesn't burns 317 but using a NPN could be easy, too. +5v to LDR and the other LDR pin to the base. The base to a fixed resistor and after that to GND. Emissor to GND, collector to led's cathode, led's anode to fixed R and then to +5v... It can be a little hard to find base resistor value to create that divider but it can be less wierd than using the 317.

 

Thank you, grohote.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The datasheet does not necessarily require a variable resistor---that may just be the way it is presented to explain forming the output voltage to be able to calibrate it.   

Yes you can change either R1, R2, or both...it is merely a calculation of the equation for the LM317. 

Especially note the fact you are not trying to set a particular, precise,  voltage at all.

 

In fact you could use something else like a transistor driver---you don't need the LM317, you just need a driver of some sort.

The LM317 is convenient since it has various temperature and current protections that a transistor does not (if you are talking about about higher currents, like 1 amp, 800ma)

 

If you are making an led headlamp, the LM317 is a poor choice, due to low efficiency---you are wasting battery power.

If you are using batteries, use a switching regulator instead---you will get have much less energy waste.

 

Are you talking about a 500ma or 1 amp led?   Or a 4 ma led? The lM317 is very inefficient for that, as the LM317 requires its own power to operate (and losses of the resistors).

So give it some good thought---how much waste is tolerable?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

R1 does have important function in regulator, and cannot be changed a lot from declared value of 240 ohms.

R2 can be, with 10k a regulation to 20++ V is possible.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


rmlazzari wrote:

I'd like the opposite: greater resistance, less output voltage.

I'd like to use that to make a little led brighter as the environment gets brighter.

I think this will work, make the resistor here your LDR and the load your LED...

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

If you want something you've never had...

...you must be willing to do something you've never done!

Lets go Brandon!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim, please- this is constant current regulator.

Ordinary LDR is declared as "10k" which mean a lot more at dark.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

grohote wrote:
Ordinary LDR is declared as "10k" which mean a lot more at dark.

Yes the OP wants more brightness when the room is lite, less in the dark.  Please read his post again....

More light, more current, brighter LED!

The OP is confused, he/she thinks LED brightness is controlled by voltage, when it is current that controls the brightness!

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

If you want something you've never had...

...you must be willing to do something you've never done!

Lets go Brandon!

Last Edited: Fri. Jan 14, 2022 - 08:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In each case, R2 can not be greater than 240 ohm.

It can be as low as 0.8 ohm but you can not use a LDR here, sorry.

Last Edited: Fri. Jan 14, 2022 - 08:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

LDR Photoresistors are light sensitive resistors whose resistance decreases as the intensity of light they are exposed to increases.

 

Nowadays...due to cadmium, stay away, they are often banned, hard to get, or hard to legally get rid of (don' t let someone gift you 10000 of them!!) , or maybe high price due to all of this.

 

Use a photodiode instead  (more sensed light---> more photodiode diode current)

 

Yes, you'd like to control (sense) the led current, then your detector only needs to monitor room light

If you don't control (sense) led current, then you should monitor both room light and the led light output.

 

Note also the LED can make a "good enough" room light detector.  So you can be clever and use it to momentarily sense the room light (like 20 microseconds), then go back to illumination.  The monitoring will never be visible to the person.     You can do that with an AVR ADC, or possibly with pure analog circuits (sample/hold). 

 

A novel microprocessor interface circuit is described which can alternately emit and detect light using only an LED, two digital I/O pins and a single current limiting resistor. This technique is first applied to create a smart illumination system that uses a single LED as both light source and sensor.

https://www.merl.com/publication...

 

also

https://mitxela.com/projects/aut...

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Fri. Jan 14, 2022 - 10:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
This technique is first applied to create a smart illumination system that uses a single LED as both light source and sensor.
Similar for UART.

Very Low-Cost Sensing and Communication Using Bidirectional LEDs | Publication - TR2003-35 | Mitsubishi Electric Research Laboratories

due to

Bi-directional LED communication | Tools and Tips | The Embedded Muse 385

and

Tools and Tips | The Embedded Muse 386

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Are you talking about a 500ma or 1 amp led?   Or a 4 ma led?

 

We are talking about a red led, 20mA, 2.2v dropout, very common, and that, if the brightness is adequate during the day, at night, in the dark room, it looks like a movie spotlight, of those from 20th Century Fox.. .still it would be nice to find this led at night, but without glare that dazzles the view.

 

Because it is so small, I figured I could build a mini peer-to-peer circuit, using an LM317 TO-92. But here the question arises: what if the sun shines directly on the trinket I'm assembling (a lamp for the bedroom), the resistance of the LDR will be so small that the 317 will be set to have more than 5v at the output. And the input is 5v...

 

In fact, the fixture almost all uses 12v. There is 5v in the circuit only because that's the maximum the touch switch (TTP223) can handle. And the led I'm talking about isn't the main light producer for the room, it's just a stand-by monitor, to help to find the lamp in the dark.

 

The NPN idea, say BC548, sounds good... tomorrow I will try to find a resistor to form a resistive divider with the LDR so that the output in the middle of this divider goes to the base of the transistor. I'll try it with a 1Mohm trimpot, for starters... let's see.

 

As for changing voltage or current (yet) I don't know enough about electronics, all I did was put a led like this one in a variable source with 5v and I decreased the voltage until the led turned off... which happened close to 2.5 v.

 

avrcandies wrote:

how much waste is tolerable?

 

I feed everything with 110vac...

 

 

Anyway, I really appreciate the participation of the people of this AVR Freaks, even more for being such a basic question about a such unimportant gadget!

 

 

Thank you all a lot!

 

(Automatic translation: Google Translate.)

Last Edited: Fri. Jan 14, 2022 - 11:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Use a photodiode instead  (more sensed light---> more photodiode diode current)

 

I didn't know that device. I'd like to use what I have here, in my recycling box. But I've got curious about this photodiode...

 

Thank you for the tip!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should consider using an AVR, because:

 

Light is not simple, everything has a curve

Ten lights does not look 10 times brighter than one light ...in a room of constant brightness

One hundred lights look much less than 100 brighter than one light  

 

The LDR had its own curve...double the light is not double the resistance.

You might get lucky and have these crazy curves cancel each other out

 

You eye will think a dim led is much brighter when in a dim room, a room half as bright will not make the light seem twice as bright.

An AVR is good for sorting all of this out!

 

That IS a benefit of having a simple dumb brightness knob...none of this matters too much, since you just adjust the knob to make yourself happy---you are taking care of all of these curves.

You are a pretty smart sensor (though horrific accuracy).

 

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

They say that a picture is worth a thousand words.
Well... sorry for the slightly blurry images, a new cell phone is about to arrive.

 


Here's the lamp. The LED that shines very brightly in the dark is the one at the base of the luminaire. Here it is on because the light is on stand-by.

 

 


When you touch the surface on this LED, the LEDs that actually light up the room light up.

 

 


This is the base of the light fixture, the box that contains the components.

The mechanical pencil is there to give you an idea of the size of this box.

Please note that there is not much space in this box.

Inside the box, left side, there is the 12v source. Right side, the pcb I've made.

 


Here the TTP223 added the stand-by LED and a resistor. Even with this resistance being of such a high value (4k7) the stand-by led shines very brightly.

(Potentiometer is to set the leds of the strips.)

 


Here the schema. Please note the unusual value of the stand-by LED resistance.

I've built the pcb with room for TIP122 or IRFZ44N and a pull-down resistor. The final version is with IRFZ44N (TIP122 gets too hot) and no pull-down resistor.

I don't show the 110/220vac -> 12vdc in the schema because I forgot that.

 

I'd like to add the 5mm LDR at the top of that box.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


 

The schematic you show is wonderful to look at.  Don't touch the LM317--you need the 5V voltage to drive the relay.

Add something specific for the standby LED  

 

Do you know the ohms of your LDR in bright & dim light?  The LDR curve may work against you

 

Try this little circuit on 5V....the pot tunes the LED to what you want.   Can't say how well the dimming vs room light will track

 

Brighter room light, lowers the LDR resistance , turning on the transistor more, increasing the LED drive.  (brighter room---->brighter LED

You may also play with the 470 ohms (say 200 to 1 k ohms)

Any little NPN (2N2222, 2N3904...) will work

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Jan 15, 2022 - 03:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


rmlazzari wrote:

I'd like to add the 5mm LDR at the top of that box.

 

Keep in mind LDRs are inverse log response, so a smooth linear action will be hard to achieve.  A trimpot set single decision point should be do-able.

 

You also need to consider self-feedback, as the lamp you have is very bright, and reflected light will likely reach the LDR.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Who-me wrote:

rmlazzari wrote:

I'd like to add the 5mm LDR at the top of that box.

 

Keep in mind LDRs are inverse log response, so a smooth linear action will be hard to achieve.  A trimpot set single decision point should be do-able.

 

You also need to consider self-feedback, as the lamp you have is very bright, and reflected light will likely reach the LDR.

 

 

I thought about that too, dear Who-me, but when the lamp is on, the LDR is inactive.

 

And as for linearity, in this case it is not that important, the important thing is that the stand-by LED dims its brightness when the room in which the lamp is is dark, and that it increases its brightness when the room is bright.

 

But as a curiosity, if in the future someone consults this topic, in the LDR datasheet, here , it brings a formula to "flat" your curve. It says there that it is necessary to write down the resistance of the LDR with 10 lux and with 100 lux. The formula, from the (little) that I could understand, is log(R10lux / R100lux)...

 

 

---

 

Finally, I found the following solution: instead of using another tiny LM317 just to control the stand-by LED, I put the LDR in series with this LED on the transistor collector. I also put in series another 1kohm resistor, to avoid that when the LDR resistance gets too small (because it is under strong light, for example, from the Sun), the LED burns out.

 

 

Since linearity isn't very important in this case, everything was working fine until... nightfall. In total darkness, the LED brightness became very, very dim. I measured the LDR resistance and it was giving about 1M, 1M2ohm. So I added a constant 1M resistor in parallel to the LDR and it was acceptable.

 

Even so, I have some doubts: will this circuit, over time, not burn the LDR? The maximum it dissipates, according to the datasheet, is 100mW... Another question is about the sink capacity of the TTP223. His datasheet (here) says that when his I/O pin is "0", if I understand this datasheet correctly, his sink capacity is 8mA... It has been more than 24 hours since the luminaire has been plugged in and in stand-by. And neither the LDR nor the TTP223 chip are even warm... Anyway... will it be that way and with the resistors in these values, the circuit won't burn in a week or two?

 

Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The LDR resistance may not scale well as series element for what you need for the LED itself...you certainly don't need 100k type values, and wonder how low it will go (how close to 100 ohms) in room light.

Try the circuit shown in #21 ...it's only adding 2 components.  Then the current does not flow through the LDR itself & the LDR resistance can be at a different scaling thna the little circuit's "resistance".

will this circuit, over time, not burn the LDR?

At very bright intensity, the resistance will be low(er), so that is more stress on the part.  But you have 1K in series, so that inherently prevents damage. 

his sink capacity is 8mA..

With 1k on the base & 5V & vbe drop, you are Ok for the source spec of 4ma (you are not using sinking at all).  Note these are not limits; those would be posted under absolute max ratings.  The 4/8 ma values are somewhat more concerned with the Pin Vdelta at those currents.

(If I sink 8ma, my  pin won't rise to more than 0.6V, source up to 4 ma, pin won't fall below 2.4V)---really, they should give a nice graph, not one catchall number. You take what they give, or dig out your curve tracer.

They created the chart assuming you are just connecting logic, rather than a "load' to the pin, hence limited info.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Jan 16, 2022 - 10:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

avrcandies wrote:

With 1k on the base & 5V & vbe drop, you are Ok for the source spec of 4ma (you are not using sinking at all).

 

Your post reassured me, avrcandies. I don't have (yet) knowledge to know if it's Ok.

 

 

avrcandies wrote:

Try the circuit shown in #21

 

I'm grateful but I think for now I'll stick with the resistors in parallel/series solution. Here's why: Little space.

From left to right, LDR, 1M resistor, 1k resistor and (hacked) TTP223.

(Hacked to get a minimum LED, 2mm x 2mm glued in the touch surface, meaning, you can see this led when you look at the top of the box)

 

And here (please, click) a small demo. Please excuse the image quality. Notice what happens when I tap the LDR with my finger. Also when I tap the led...

 

 

Anyway, all this discussion serves to show me that I still have a lot, a lot to learn...

 

Thank you and all the participants!

Last Edited: Sun. Jan 16, 2022 - 11:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Here's why: Little space.

I bet you can squeeze a transistor and trimpot  in---you just need to reenergize yourself...when the time feels right, give it a shot. 

 

Get this t-shirt:

 

Never Stop Building

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

rmlazzari wrote:

... but I think for now I'll stick with the resistors in parallel/series solution.

 

That's fine, those two resistors is a simple and common way to define the LDR 'operating point'.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IMPORTANT!

 

I made a huge mistake in the drawing of post #23.

Please forgive me and disregard that drawing.

 

The correct one is this one, below. Grateful.

 

Last Edited: Mon. Jan 17, 2022 - 01:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This time, I should object on BC548 use /will try to provide a better schematic/.

 

It should be in a Schmitt-trigger configuration, because a relay activation needs well-defined "saturation" transistor current.

 

Edit: One measure may be using Darlington transistor.

Last Edited: Mon. Jan 17, 2022 - 07:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BC548 

The 2N2222 is a junk barrel part (like a paper clip) , but is good for around 800 ma & is often used for on/off control

The 2N3904 is a junk barrel part (like a paper clip) , and is good for around 200 ma and often used when working with signals rather than "larger" on/off  driving

Both of these cost in the range of pennies, and you might find either at around 100 for a $1.50.

 

The BC548 is rated more for 100 ma and only 30V vs the others 40V, and lower bandwidth, so it doesn't even make it into the barrel !!...but is ok if you don't need much.  I'd probably never order BC548 when I can get the others for only 1-2 penny.

They are prob used in toys where saving even 1/3 cents can be a big deal.  

 

Your switch module outputs a distinct logic high/low...I'd say it will be fine with a just transistor (unless the switch has a slooow rise/fall time) 

 

Note: instead of a clunky relay you could use a P MOSFET

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!