LM317L constant current

Thread Starter

KKRS_

Joined Oct 26, 2023
24
Hi everyone,

I am trying to make a circuit with lm317 to have a constant current. I would like to use it with both a constant voltage generator and a pulsed voltage generator. Now if I simulate this circuit I get these spikes (circuit 1). If I add capacitor C1 with a value >=300pF the disturbance disappears (circuit 2). I believe capacitor C1 composes a low-pass filter at about 2.1 Mhz but I do not understand why without it the visible spike in circuit 1 occurs.

I also cannot get down to 3.3V input with either a pulsed or continuous generator. I do not get the expected 5ma output from the regulator.

Can anyone help me with this?
 

Attachments

boostbuck

Joined Oct 5, 2017
1,043
If all you are doing is driving a led do you need a LM317 to limit the current? A resistor would be sufficient.
The LM317 has about a 1.5V dropout voltage, so 3.3V input may not have enough headroom for the load.
I'm not sure that the line transient response of the LM317 is going to allow clean current switching as you are attempting.
 

Thread Starter

KKRS_

Joined Oct 26, 2023
24
@ericgibbs
You are absolutely right I had completely forgotten it
@boostbuck
My input voltage range is from 3.3v to 24v, and that's a lot to handle with a resistor. My idea was to take advantage of LM317 to have a constant current in the led regardless of the input voltage. As for the transient, I don't understand it. Are there any other ways?
 

MrAl

Joined Jun 17, 2014
13,704
Hi everyone,

I am trying to make a circuit with lm317 to have a constant current. I would like to use it with both a constant voltage generator and a pulsed voltage generator. Now if I simulate this circuit I get these spikes (circuit 1). If I add capacitor C1 with a value >=300pF the disturbance disappears (circuit 2). I believe capacitor C1 composes a low-pass filter at about 2.1 Mhz but I do not understand why without it the visible spike in circuit 1 occurs.

I also cannot get down to 3.3V input with either a pulsed or continuous generator. I do not get the expected 5ma output from the regulator.

Can anyone help me with this?
Hi,

The reason for the spike could be because what you are seeing is what we refer to sometimes as a 'ghost' voltage. It is a voltage that shows up across a relatively high impedance driven from a similar or lower impedance, or even a higher impedance. In this case it could be caused by the small capacitance input to output of the LM317 (or similar IC). We call it a ghost voltage, but it is really there. It is just that its overall effect is usually very little if anything.
In this case, you might be worried about the reverse voltage across the internal LED of the opto coupler, and that is a valid concern. Since you swamped it with only 300pf to ground, the internal capacitance must be small. Another solution would be to put a fast diode in reverse to the opto internal LED. that will shunt anything lower than about -0.5v to ground.
If the capacitor works and is not affecting the speed you need, then why not just use it. A reverse diode will handle even a larger current however. It should be a fast diode like a Schottky, but if your speed is not an issue then a rectifier diode might work also.
 

BobTPH

Joined Jun 5, 2013
11,515
Another option is a 3V LDO + resistor. 2.7 if you cannot find one with a 300 mV dropout. The opto probably needs 1.5V or less since they are normally IR.
 
Last edited:

crutschow

Joined Mar 14, 2008
38,506
Below is the LTspice sim of a fairly fast, simple two-transistor, two-resistor current limiter that may work for you.
It limits the opto input current (bottom trace) to between 5mA to 5.6mA for an input form 3.3V to 24V.
The current limit is ≈0.65V/R1.

The bottom plot shows the variation in the current versus V+.
The current stays above 4.5mA down to about 2V.

1741452168497.png
1741452325322.png
 
Last edited:

Thread Starter

KKRS_

Joined Oct 26, 2023
24
@crutschow

Very interesting.
Can you attach the LTSpice simulation to this answer?


Below is the LTspice sim of a fairly fast, simple two-transistor, two-resistor current limiter that may work for you.
It limits the opto input current (bottom trace) to between 5mA to 5.6mA for an input form 3.3V to 24V.
The current limit is ≈0.65V/R1.

The bottom plot shows the variation in the current versus V+.
The current stays above 4.5mA down to about 2V.

View attachment 344045
View attachment 344046
 

crutschow

Joined Mar 14, 2008
38,506
It is entirely possible that the spike is a simulation artifact, and will not be present IRL.
I think it is probably due to parasitic capacitance feedthrough.
There will likely be some in the real circuit, but stray wiring capacitances to ground not shown in the simulation will tend to reduce the spike amplitudes.

My experience is that Voltage/current spikes in a simulation usually are due to the characteristics of the device model, not artifacts.
For example the leading-edge current spikes shown in my Post #7 simulation are likely due to the BJT junction charge/capacitances.
 

AnalogKid

Joined Aug 1, 2013
12,130
My experience is that Voltage/current spikes in a simulation usually are due to the characteristics of the device model, not artifacts.
My experience is so much less than yours that I tend to lump those two things together into "simulation s***".

ak
 
Last edited:

Art Vandelay

Joined Nov 1, 2024
140
My experience is that Voltage/current spikes in a simulation usually are due to the characteristics of the device model, not artifacts.
For example the leading-edge current spikes shown in my Post #7 simulation are likely due to the BJT junction charge/capacitances.
Is is practical to disable one or more of the model parameters in an attempt to remove the offending effect?

Say for example I observed this problem on an oscilloscope and I had no idea what was causing it. One approach I could try is to remove components one at a time, observe the effect and record the results.

Why not apply this method to a spice simulation? I could write a macro to do most of the work but I'm not sure the data is useful.
 

crutschow

Joined Mar 14, 2008
38,506
A nice simple solution is a Constant Current Regulator, simple in-line limiter with about the same overhead voltage as a 317:
Which is marginal for the OP's requirement of operating down to a 3.3V supply.
He also wants 5mA, not 10mA of current.
 
Last edited:

WBahn

Joined Mar 31, 2012
32,834
Hi everyone,

I am trying to make a circuit with lm317 to have a constant current. I would like to use it with both a constant voltage generator and a pulsed voltage generator. Now if I simulate this circuit I get these spikes (circuit 1). If I add capacitor C1 with a value >=300pF the disturbance disappears (circuit 2). I believe capacitor C1 composes a low-pass filter at about 2.1 Mhz but I do not understand why without it the visible spike in circuit 1 occurs.

I also cannot get down to 3.3V input with either a pulsed or continuous generator. I do not get the expected 5ma output from the regulator.

Can anyone help me with this?
Your simulation spike can be coming from a few things, some of which may be real issues and some of which may not.

You are using a voltage regulator in a way that it is not intended to be used. Voltage regulators are expected to take a reasonably steady input voltage and regulate it down to a very steady output voltage. They are intended to reject high frequency noise at the input. But you are essentially trying to power it with high frequency noise. You are turning it on or off every 3 ms. In doing so, you are constantly taking it below the input voltage at which it is designed to behave well and, in that region, it's behavior may be very erratic, unpredictable, and uncharacterized. Every time you power up the regulator, it is going to take some time for all of it's internal circuitry to power up and stabilize. The behavior during that period may not be modeled well (if at all) in the simulation model.

The next issue that your simulation has is that you are driving things with ideal voltage sources, which means extremely short rise and fall times and able to drive extremely large currents during those transitions. To get better simulations when you have changing inputs, make the inputs change at reasonably realistic speeds. Whether the simulation models can respond realistically to such unrealistic signals is questionable.
 
Top