# [SOLVED]Switching LM317 on/off

Status
Not open for further replies.

#### Xenobius

##### Member level 3
Hi,

I have specifically 20x LM317 constant current circuits which drive LEDs and I would like to turn them on and off using a microcontroller.
Would you put some mosfet before the LM317 to shut it down? or perhaps after? Or would you do it differently?
If so how do I choose a mosfet which can take 30v @ 600mA ?

Perhaps you are aware of another IC which can give constant current but with Enable pin?

Thanks

#### KlausST

##### Super Moderator
Staff member
Hi,

it seems you did not do an internet search.

* selecting a MOSFET: just go to the distributor of your choice and input your values. Or any Mosfet manufacturer..
* If you want multi chanel constant current LED driver, why not do a search for them? (@ distributor, IC manufacturer..) There are many ready to buy ICs. Farnell lists more than 400 different ...

***
I don´t know your application.. but why do you need 20 independent constant current sources when they are controlled commonly?.
Isn´t a comon voltage controller plus 20 resistors more simple? or just 20 resistors?

Klaus

#### Xenobius

##### Member level 3
Hi Klaust,

In the end the simple solution was 20x LM317 constant current circuits. Now I had the chance to continue working on the project and realised that I need to be able to switch them on and off depending on what I need.
Since you asked, this is a UV exposure box that I wanted to build for a long time and firstly I need to choose between top/bottom or both. I will have 20 circuits or 7x leds configured in horizontal rows so I might need to alternate to reduce the UV power by half. Technically as you say, I can commonly control 5circuits at a time (2 for bottom and 2 for top)

Since I bought some stuff such as the power supply and leds, these cannot be changed now however I am building the circuit so its ok so do more research on ready made ICs

#### KlausST

##### Super Moderator
Staff member
Hi,

I´ve read "mosfet before the LM317" and "mosfet which can take 30v @ 600mA"
thus I assumed it was 20 x 30mA = 600mA. This was wrong as I see now.

***
140 LED circuit.
Still unclear how much MOSFETs you want to use...

To ease design I´d use N-CH MOSFETs and low side switching.

Klaus

#### FvM

##### Super Moderator
Staff member
Although LM317 has no enable pin, the output can be nearly switched off (1.25V output voltage) by pulling the sense pin to ground. In a constant current circuit, you'd add a series resistor (e.g. 1K) between shunt and sense pin and a small signal pulldown MOSFET.

Xenobius

### Xenobius

points: 2

#### d123

Hi,

Shame it has to be 30V capable... Micrel MIC29502 (there are lower current versions such as the 1.5A MIC29152 or the 3A MIC29302) is only 26Vin, but 5A out, and is adjustable from 1.25 V and has a logic level enable pin. Such an LDO would save on LDO + MOSFET... If you don't have the LM317s yet, checking Microchip Technologies' - or other manufacturer's who produce these parts - LDO offering may bring up a single-IC solution closer to the 36Vin level.

Last edited:

#### crutschow

Here's the LTspice simulation of FvM's suggested circuit:

#### KlausST

##### Super Moderator
Staff member
Hi,

Why not switching the cathode of the LED?

Klaus

#### Xenobius

##### Member level 3
Whoa! I think that's it! I am going to use an NPN transistor PMBT3904 and I will test it out and let you know how it goes!

#### KlausST

##### Super Moderator
Staff member
Hi,

Why no N-Ch logic level MOSFET? It may switch several 10s of Amperes without heatsink.

Klaus

With a high ohmic gate drive resistor and an additional C from Drain to Gate you may enable "soft swtiching" to reduce EMI and to reduce current overshot. ..but increased power dissipation during switching...not during ON time.

#### Xenobius

##### Member level 3
Well I believe the 2N7000 is to drive the ADJ to GND rather than to pass current through it. Now as for soft switching - this is interesting because I will have in total 20x circuits all drawing 600mA each at once and I think the PSU won't be excited in the long run. How would you modify the circuit please to achieve soft switching?

#### Xenobius

##### Member level 3
Hi,
I tested this circuit out and it works almost perfectly When I switch on the power supply I can see the leds flicker once and turn off immediately. From then on, switching on and off the transistor works as expected.

My questions now are, how can I make it slow start and remove that flicker on startup?

Thanks all

#### stenzer

##### Full Member level 4
Hi,

you can get rid of the start up flicker by connecting the gate of M1 towards ground by means of a high valued resistor (~100 k$\Omega$). This defines a GND potential at the gate of M1 at the start up of your circuit.

To soften the turn-on use a series resistor between your control signal source and the gate of M1, further place a capacitor between the gate and ground. This leads to a delayed start up by the RC time constant of your series resistor and shunt capacitor ($\tau$ = R_ser $\cdot$ C). Choose R_ser and C to meet the MOSFET's threshold voltage after a desired time.

Choose R_ser small compared to your (start up) shunt resistor.

greets

#### Xenobius

##### Member level 3
Hmm hold on, if I ground it, M1 will not turn on which in turn allows the LM317 to function and turn on the LEDs. If I pullup the gate using 100K it will not be enough on startup and it will still flicker.

As for slow start - thanks I will try tonight - attached my circuit for testing tonight

#### Attachments

• 52.4 KB Views: 12
Last edited:

#### stenzer

##### Full Member level 4
Hi,

Hmm hold on, if I ground it, M1 will not turn on which in turn allows the LM317 to function and turn on the LEDs. If I pullup the gate using 100K it will not be enough on startup and it will still flicker.
Ok, yes of course you have to use a pull up resistor for initially turning the LM317 on (my fault). At which supply have you connected the pull up resistor?

greets

#### Xenobius

##### Member level 3
Ok so on my breadboard I used a simple voltage divider to get around 5v to mimic my microcontroller but in the real application I will have a dedicated 5v regulator which I can pullup to. I can see however that a pullup (which depends on having 5v) will still need a fraction of a second to turn on which will make it flicker anyhow. I still need to try the pullup tonight however so my last post is all theory for now.

#### Xenobius

##### Member level 3
Ok so on my breadboard I used a simple voltage divider to get around 5v to mimic my microcontroller but in the real application I will have a dedicated 5v regulator which I can pullup to. I can see however that a pullup (which depends on having 5v) will still need a fraction of a second to turn on which will make it flicker anyhow. I still need to try the pullup tonight however so my last post is all theory for now.
Right so I did the test and it did work however completely opposite to what I wanted. With the transistor off, the LM317 is going to switch perfectly on and all leds are on. However once I trigger the transistor, the LEDs will DIM slowly almost to OFF but never completely OFF.

I was thinking - what if I drive the transistor with PWM ? Say full duty cycle will keep them off and as I lower the duty cycle over a period of 2 seconds they should completely be ON. Would that work? Would it damage the LEDs ?

#### stenzer

##### Full Member level 4
Right so I did the test and it did work however completely opposite to what I wanted. With the transistor off, the LM317 is going to switch perfectly on and all leds are on. However once I trigger the transistor, the LEDs will DIM slowly almost to OFF but never completely OFF.
For which constellation does your circuitry results in the dimming? Which resistor values have you used? I assume you are not able to put the adjust pin completeley towards ground. By having a look at figure 6 of the transistor datasheet [1] you can see that a voltage emitter saturation voltage of about 100 mV remains (for Ic/Ib = 10), thus your LM317 is not completely turned of.

I was thinking - what if I drive the transistor with PWM ? Say full duty cycle will keep them off and as I lower the duty cycle over a period of 2 seconds they should completely be ON. Would that work? Would it damage the LEDs ?
The LEDs will not be damaged.

[1] https://assets.nexperia.com/documents/data-sheet/PMBT3904.pdf

greets

#### stenzer

##### Full Member level 4
What's the resulting collector emitter voltage when you are triggering the BJT?

#### Xenobius

##### Member level 3
For which constellation does your circuitry results in the dimming?
I don't understand this phrase. I connected the circuit as in the attached image above and I can see my leds bright immediatelly as the power is turned on, and slowly they dim. The current too (as expected) goes down from 600mA down to almost 50mA (using analog needle gague so cannot be 100% accurate).

As for resistor values, as those indicated in the schematic, ie: 100uF and 10K. My concern was not the values and the timing - I could tweak those eventually. My concern was that as the transistor slowly turned on, the leds started to dim (as would be expected) but that's not what I had in mind - but rather the opposite to slowly turn on the current.

If PWM works I will try that tonight and let you know. Thanks for now

Status
Not open for further replies.