# Dynamo current limiting circuit with LM317

I'm trying to lower current to about 20 mA, but even attaching a resistor of 50 Ω, I'm still not getting the regulated 20 mA or so current with the LM317.

• How come you put the circuit together like that? Commented Nov 1, 2023 at 20:08
• Why did you put a diode and does it work better without it? Commented Nov 1, 2023 at 20:26
• The diagram could easily have been MUCH better. Trinmming rubbish off top helps. There is an inbuilt schematic diagram editor that is amazingly easy to learn. Click circuyit symbol button at top of question page. || Label components. Even if there is only one diode and 1 resistor. Commented Nov 2, 2023 at 9:07
• What is the function of the diode? Commented Nov 2, 2023 at 16:30

The calculated resistor at 50 Ω is correct. But with the D1 you change the equation with the diodes voltage drop. Did you mean to use the diode to rectify the dynamos AC? Then put it in forward before the capacitors positive side. This is how I would remake your circuit:

• L:M317 dissipation is lowish at 20 mA x (18-1.25ish-1.25) x 20 mA ~~~~= 300 mW BUT if you want lower adding a series input resistor to drop most of Vin moves the heat off the regulator. [I know you know that :-) ]. Commented Nov 2, 2023 at 9:11
• You are wrong. Not the electronic part of course, but that I know :) I'm just a 1/1000th of what other here know. Anyway, wouldn't that resistor just move around the heat? Commented Nov 2, 2023 at 11:22
• Yes - you are correct. As noted "moves the heat off the regulator". In this case it's not important except perhaps if the OP used a TO92 or a small SMD and decided to up the LED current. But when you get to dissipating a few watts when dropping from eg 18V to LED, it's far easier to dissipate most of the heat in a cheap aircooled resistor than having to eg heatsink a low dissipation reguilator. An eg 10W aircooled ceramic resistor can be reliably run at about 5 Watts indefinitely. Commented Nov 2, 2023 at 11:36
• @RussellMcMahon With such a resistor you would not acheive the current at low dynamo RPMs.
– Jens
Commented Nov 2, 2023 at 17:36
• @Jens True. With variable input a compromise resistor would help to remove heat from the regulator with reasonably low L:ED impact. In this case it is not required. Commented Nov 3, 2023 at 3:33

It seems that all you want is a constant current source.

Instead of an LM317, why not use two transistors as shown below. It'll not be as accurate as LM317, but is cheaper, uses more available parts (if you can't get transistors, the world has ended), and still works pretty well. With a full diode bridge as shown, the dynamo can be an AC or DC dynamo - it won't matter. The diodes and transistors can be pretty much anything you can find cheaply for this application. They are not critical. You'll need to measure the current and try a couple different values for R1 and choose the one that gives output current closes to the 20mA you want.

simulate this circuit – Schematic created using CircuitLab

The relationship between the input voltage and output current is approximately:

That's quite reasonable regulation for a LED.

If you want it to work better at lower voltages, lower the value of R2. Conversely, for much higher voltages, R2 can be further increased. The current is set by R1.

If you want better regulation, and can find a Zener diode with voltage between 3-8V, here's how to do that:

simulate this circuit

As usual, adjust R1 for the current you want. The regulation is quite good:

Instead of a Zener diode, you can also use a transistor - but most Spice programs can't simulate it. It works fine in practice, though:

simulate this circuit

This circuit uses the reverse base-emitter breakdown voltage in Q2 as a voltage reference. The voltage will be somewhere between 5-8V in typical small signal transistors, so that works well.

With three transistors, we can get very solid regulation - an overkill for a simple LED driver. It takes more resistors though. And, as usual, adjust R1 for the current you desire.

simulate this circuit

Instead of Q2, you could use a Zener diode.

You don't have to, and in practice, you can't, "lower current" to x mA. What you need first is a voltage regulator. The dynamo has a variable voltage, and this voltage has to be regulated according to the device that you intend to power. If it's a 20mA LED, take the "typical voltage" of the LED. If it's another device, it's the same principle: The device will draw the required current as long as you provide the right voltage, without the need to control this current.

In the case of LED, it's always noted that current must be regulated exactly. This is true only if you want to keep the light at a precise, constant and predictable intensity. And for this, constant current regulators exists, and they basically correct the voltage so that x amount of mA are used. But first of all, you should know whether you really need it. In fact, you can power a LED with very slightly more or exactly the typical voltage of the LED with a resistor in series. If the voltage is properly regulated, there is no risk for LEDs or other devices.

• the lm317 can be used as a constant current source without any voltage regulation, see the datasheet for application examples. Commented Nov 1, 2023 at 22:55
• Remember LEDs regulate voltage, just like zeners. Open circuit voltage would be generator p2p, short circuit voltage would be ~0.01v. We can also know the output voltage of an LED CC'd@20ma; they show the i/v curve in datasheets, so we can precisely lookup V @20ma. KISS and minimize BOM. Commented Nov 2, 2023 at 1:59
• I agree It can work with a LED. Commented Nov 2, 2023 at 2:19
• In THIS case LM317 dissipation is around 300 mW. This can be further lowerd by using a series input resistor. || The LM317 starts up benignly. (If it didn't then using it as a voltage regulatror above it's internal Vref value would run an equal risk of excessive Vout.) Commented Nov 2, 2023 at 9:13
• Ruqayya Saleh Maybe you could put a complete, detailed schematic of the installation to be able to offer you the best advice. Commented Nov 2, 2023 at 19:35