Welcome to Laser Pointer Forums - discuss green laser pointers, blue laser pointers, and all types of lasers

Buy Site Supporter Role (remove some ads) | LPF Donations

Links below open in new window

FrozenGate by Avery

Simple Linear MOSFET Dimming Circuit + PWM

Joined
Oct 26, 2007
Messages
5,438
Points
83
This is a mirror of an excellent tutorial on making a linear current regulator circuit using transistors. Though originally for LEDs, the circuit can be applied to lasers as well, and I have used it extensively for analog dimming. I've found this tutorial very helpful in understanding transistor circuits for lasers and LEDs.

Unfortunately, the original tutorial at the Candle Power Forums used images that were hosted on a now-down site. I recently located a copy of the circuit diagram used in the tutorial, and felt it would be good to mirror a complete copy of the original tutorial here to not lose it to Internet dilapidation. The original tutorial, like this mirror, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License. The tutorial is not modified in any way aside from formatting.


Super-Simple Power MOSFET Linear Current Regulator

The most important thing about feeding a power LED is the current flow through the LED. As such a good constant-current supply is a must.

But, building one is a pain.

The easiest known constant-current circuit making the DIY rounds is based on the LM317 voltage regulator. By connecting a resistor across the adjust and output pins and tying its adjust lead to the load, the LM317 becomes a linear current regulator instead of regulating voltage. Two parts and a heatsink and that's it.

The downside is that the LM317 needs at least 3 volts of overhead (the difference between load and supply voltages) to operate this way, and the extra will be converted to heat in the sense resistor and the LM317 itself. This can be exceptionally wasteful if you're working with a low-voltage supply such as batteries. The heat can also be problematic if you're limited on space or cannot provide much of a heatsink.

There is a better way. Presenting, the power MOSFET linear current regulator, inspired by and based on the Instructables post "Circuits for using High Power LED's" by Dan.

attachment.php


This circuit is about as simple as it gets. So simple, in fact, that adding PWM input support almost doubles the parts count!

Since PWM control is optional, let's ignore the shaded parts for a moment and discuss the actual regulator itself, which uses R1, R2, Q1, and Q2.

The design is elegantly simple. Q1 operates entirely in linear mode and acts as a variable resistor to control current through the load. R1 keeps the gate of Q1 pulled to positive voltage so that Q1 starts up turned on. As the current begins to flow through the load, Q1, and R2, the voltage drop across R2 increases. When the drop across R2 reaches the "knee" or state-transition voltage for the emitter-base junction of Q2, Q2 begins to switch on, and in so doing starts to pull the gate of Q1 to ground. This causes Q1 to increase its resistance, which decreases current flow through itself, the load, and R2, which decreases the drop across R2, which causes Q2 to let Q1's gate float back toward positive supply, which increases the current flow. Within a few milliseconds, the current flow stabilizes around a specific set point determined by the value of R2. Due to the design of the circuit, the required supply voltage overhead is only about 1.2 volts, less than half of what a LM317 regulator circuit requires.

As the value of R2 is based on the transition emitter-base voltage of Q2, calculating it is easy: all you need is Ohm's Law and an idea what voltage to use. Most conventional silicon general-purpose NPN transistors switch fully at around 0.7VDC and start to transition from off to on at 0.56-0.58VDC. Assuming a transition voltage of 0.58VDC and a target load current of 750mA, the math is as follows:

R = V / I

R = 0.58VDC / 0.750A

R = 0.773 Ohms​

Calculating the power dissipation for R2 under normal operation is then a matter of Watt's Law:

P = V * I

P = 0.58VDC * 0.750A

P = 0.435 Watt​

In this case a half-watt resistor will work but a one-watt would have a safety margin of double. The nearest standard value would be 0.75 ohm, which would give an actual limit of ~733mA in the above example. To achieve the same output current from a LM317 circuit you'd need a 1.6 ohm resistor rated for 2 watts, as the dissipation would be 0.9 watt - a loss of over double what we'll waste as heat here!

The circuit's only real disadvantage is that it doesn't fail gracefully - by design, it tries to push as much current through the load as it can as long as the voltage across R2 doesn't exceed what starts to turn Q2 on. So, for increased fault tolerance, the power rating for R2 could be selected based on the worst-case scenario of the maximum amount of available current flow in the event of a catastrophic failure: a short across both the load and Q1. For that, simply calculate dropping the supply power (voltage times current) across R1. It's generally cheaper to simply use a fuse rated for just above the desired current set point, though, as a power supply providing 1A @ 12VDC would require a 15-watt resistor for R2 and this would be far more costly than a simple fuse.

Dissipation through the MOSFET under operating conditions is calculated the same way, only the voltage used in the calculation should be the supply voltage so that the heatsink selection will account for the worst-case scenario of a dead-shorted load at the target current. In the above example, assuming a 12VDC supply and 750mA current limit, the math works out as follows:

P = V * I

P = 12VDC * 0.750A

P = 9 watts​

The IRF520 listed in the schematic is rated to handle 9.2A @ 100VDC, and can dissipate 60 watts, so this part will work perfectly well in this configuration with a modest heatsink.

And now the fault-tolerant approach - dissipation through Q1 with a shorted load. Again, simply calculate the maximum supply power that Q1 will see. If the supply is unregulated and capable of large current flows in short time spans (e.g., batteries), again a fuse would be wise as a last-ditch protective measure against catastrophic failures by blowing the circuit open so it cannot try to short the supply. If the set current is 750mA, a 1A-1.5A fuse in series with this circuit would be a wise, and relatively inexpensive, addition - all the more so for portable projects using lithium batteries, given how these like to catch fire (and for nonrechargeable lithium primaries, explode) when shorted.

The only limiting factors on load current and supply voltage relate to the components - using a suitable resistor for R2, this circuit can easily regulate up to a few amps of current in as little as one square inch of board space. The values shown in the schematic will regulate to ~700mA at any supply voltage from ~1.2VDC to about 40VDC, which is the limit for the 2N3904.


If you need precision, the easiest way to get it is to build a test circuit with a fixed supply (12VDC is a great value, but use the desired or intended supply voltage if there's a need to be precise), a dead short for a load, and a 100 ohm resistor for R2. This will set the current limit to about 6mA. Once the circuit is powered up, measure the drop across R2 to determine the exact transition voltage for Q2, and calculate a specific value for R2 for your current requirements based on the math described earlier.

Now, about that PWM stuff...

The extra parts for PWM support include Q3, R3, and R4 - these are blue shaded in the schematic. Since Q3 is a PNP transistor and R4 biases its base to ground, Q3 starts up turned on and pulls Q1's gate to ground regardless of what Q2 is doing, and this forces both Q1 and Q2 to turn off. R3 limits current draw to the PWM signal source. Provide a positive voltage greater than ~0.7VDC to Q3 through R3, and Q3 turns off, which allows the rest of the regulator to function as described above. In this manner a PWM signal can be used to vary the brightness of a load of power LEDs, or a simple on-off switch effect can be implemented by merely pulling Q3's base to positive supply with a few milliamperes of current. In this manner it would be possible to use the circuit as a self-current-limiting switch that only needs a tiny little low-current button as its actuator even though the load could be an amp or more.

So, how well does it work?

For LEDs, this circuit is the cat's meow in that it's very simple and wastes very little power if the source and load voltages are close enough to each other. Ideally this circuit works most efficiently with the supply being right at 1.5VDC above the ideal load voltage at the set current. Naturally it'll also be crucial to be able to provide at least the set amount of current.

There will be some ripple depending on the type of load being powered, especially during power-up, but decoupling capacitors could be used to compensate for this if it's a problem. The circuit is flexible enough in design that it can be driven directly from any logic circuit (even at 3.3VDC), so this can be a great front end for a microcontroller acting as a lighting controller.

The circuit is load-type-independent, meaning that it will happily drive resistive, inductive, capacitive, or mixed loads. Capacitive loads may well experience slower charge times, as the circuit will clamp the charge current. Inductive loads should be paralleled with a reverse-polarity diode (and in some cases, also a proper snubber capacitor) to suppress any back-EMF from the load when power is disconnected so that the voltage spike won't damage the MOSFET. (Most power MOSFETs include integrated protection diodes, but this should never be relied upon as the sole protection mechanism.)

Amusingly enough, with proper component selection it's possible to use this circuit as the driver stage for a single-ended (e.g., digital/class-D) audio power amplifier, which would make such an amp self-protected against a shorted voice coil or bad capacitor in a crossover network. This has not been tested as of this writing, though, so this implementation is not at all guaranteed. So, YMMV. (Your Mileage May Vary.)

LEDs are an interesting load to drive, in that they want variable voltage at a fixed amount of current, with the voltage being sought as the current reaches the desired amount. If the power supply cannot deliver enough voltage to drive the load at the proper current but does have adequate current capacity, it'll do what it can with what it has. For example, if four series-connected LEDs as a load wanting 350mA @ 11.7VDC total are used, and the supply is rated for 1A @ 12VDC, there's not enough overhead to accommodate the full desired load voltage but there's plenty of current capacity. In that case the circuit will produce a reduced voltage across the load (specifically, Vss - ~0.6VDC, or ~11.4VDC in this example) and the power through the load will seek equilibrium with the load's desired voltage and current; the circuit will seek to and center on the closest match to the set point that it can get the load to accept with the reduced load voltage.

If the power supply cannot deliver enough current to reach the set point, Q1 will go full-on and stay there, the circuit will fall out of regulation and just push as much current as it can get out of the supply. It's important to keep in mind that the circuit is not voltage-dependent, and the voltage through the load will climb almost to Vss (well, Vss minus the drop across R2, which will vary with available current that can be pulled from the power supply) if the load doesn't clamp it naturally. It's also important to be aware of supply voltage droop if the power supply is insufficient for the load's desired voltage and the circuit's set current - a decreasing Vss will further decrease the available load voltage. LED loads tend to auto-clamp the load voltage to their junction voltage totals at a given current level, so they tend to self-regulate the circuit's voltage in undercurrent situations.

And there you have it - a ridiculously simple, relatively efficient, inexpensive linear constant-current regulator that only requires four parts (or seven if you need switching/PWM).
 

Attachments

  • MOSFET_Current_Regulator_web.png
    MOSFET_Current_Regulator_web.png
    5.4 KB · Views: 71,882





A bit of a read.... but nicely done and detailed...
Thanks for sharing...


Jerry
 
Yeah, I thought it was a great tutorial, but it always sucked when I would refer people to it and that image was broken.
 
Great circuit! This has a very wide variety of applications. Thanks for sharing!
 
Well the thing with Q1 is that you're really using it as a voltage-controlled resistor, and the R_on value is really if you're in saturation (completely on). I was trying to find MOSFETs with low Ron, but it ended up making negligible difference. Find one that you can mount easily to cool down, as they can get hot.
 
Sourced some nice 8 pin SOIC FDS6676AS series MOSFETs on Greedbay, seems that folks use 'em for repairing motherboards with blown Vcore supplies.
Unfortunately my MB took out 4 of my expensive chips on test, so the other 5 are being reused for something else ie this.
For 19 UKP this isn't too bad considering they can take nearly 19A each with Rds of around 0.02 ohms.
This is close to what might be needed for a high power setup such as a 10W IR laser bar or 100W LED etc.

I am not giving up just yet as the rest of the board is OK just the Vcore is frazzled.
Plan to use two MC34063's in parallel to get the needed 1.28V Vcore and "fool" the MB into working despite the controller chip being
seriously damaged.
 
Last edited:
Sorry for digging up a dead thread. I'm going to build a 7 channel color changing project for my room, which will be powered by 3 CGR18650's and PWM-d by a PIC16F628A.

My question: Is R4 in the schematic really necessary if my PIC is referenced to the same ground?

Choosing the cumbersome 7 channel color mixing over the usual RGB, since it will capture more saturated colors like cyan, royal blue, deep purple, lime yellow, deep red etc. .
 
Last edited:
Well R4 is nice for dragging the input of the base of the transistor to ground if the port of your output is floating. That's good for ensuring that the output is not on when you start up. You don't necessarily need it though.

As for all 7 channels, remember that--assuming enough PWM resolution--you can produce almost all the colors of the rainbow with those three color channels (assuming it's large enough). Take a look at the CIE color diagram for more information about the colors you can produce.

Unlike regulating current for brightness with LEDs or lasers, PWM has linear brightness (in theory) because it is full-bright/full-off and the average brightness is a function of the PWM, not the I-V characteristics of the laser diode. Whether the system can react fast enough to truly achieve that color resolution is another matter.
 
Hi Bionic Badger,
Thanks for the quick response. Yeah I realize 7 channels might be an overkill. But while 3 channel system definitely covers most of the CIE color space, it misses some of the 'beautiful' colors (most prominent weakness being the inability to produce saturated cyan). For more color resolution, I can always step upto 16/32 bit MCUs.


UPDATE: I have done this using 150+rebel LEDs, 10 bit PWM (at 120Hz) from PIC24FJ128GA106 and StevesLEDs CAT4101 drivers, 4.8A 100W meanwell power supply. I'll post the pictures someday. Not being an EE, it was challenging to write the code and read the PIC datasheet, although the PCB design part was easy. Soldering LEDs and the wires was a pain.The whole thing took me 1 year! I'll say its worth it, but many issues still remain:

(i) Sadly even 10 bits are not enough when slowly fading from royal blue to red (there is some amount of stair stepping near the pink end:(). I like very slow fading speed (the whole rainbow has a period of 1 minute) so that doesn't help either.

(ii) I wanted to keep the brightness constant, but CIE brightness data didn't do a good job for my eyes. So I had to match the apparent brightness (set the max current for each channel) by trial/error. This is very difficult since some colors (red and royal blue) are more saturated than yellow/green. The saturation somehow adds to the brightness(?) and confuses my brain.

I also had to apply nonlinear fading curves to keep the apparent hue change rate constant. These required hours of fiddling and I'm still not fully satisfied. I used some JND curve data available on the net as a baseline. (however no data is there for nonspectral purple/pink colors). The cone cells adapt quickly and mess up the calculations. (This has been discussed here many times, 488nm looks blue next to a 520nm laser beam, but looks green next to a 445nm laser beam)

(iii) When royal blue faded into red, I felt the peripheral vision suddenly got brighter towards the red end. Maybe this is because we've less blue cones in periphery of the retina(?)

(iv) Pink/Purple color were so strongly saturated that I found them distracting/harsh on my eyes.


(v) Brightness additivity didn't work out well for me. To me, 50%red+50%royal blue mixture was brighter than both 100% royal blue and 100% red.
 
Last edited:
You could also just modulate the LEDs with an LED driver like the TLC5940, which is 12-bit. That's a nice and easy way to go and you can still use it as an input to the MOSFET driver above.
 
Calculating the power dissipation for R2 under normal operation is then a matter of Watt's Law:

P = V * I

P = 0.58VDC * 0.750A

P = 0.435 Watt​

errr....
Thermal Dissipation of Resistors reflects Joule's first law
P = RI^2

P= VI
(Energy dissipated per unit time) = (Energy dissipated per charge through resistor) × (Charge passing through resistor per unit time)

V = RI [restatement of Ohms Law], P = I(RI) = RI^2

so your resistor should reflect 326mW as opposed to 435mW, but its better to go for the bigger value, more safer, more stable.
 
I wanted to keep it on tab, because I'm currently using the application. I know, its a two year old thread.
Some of us still reference old threads like these for circuits, obviously if there was a technical discrepancy it should be evaluated for accuracy. Old thread may it be, but the age of it should not be the overbearing factor over every other criterion.
 
Last edited:
errr....
Thermal Dissipation of Resistors reflects Joule's first law
P = RI^2

P= VI
(Energy dissipated per unit time) = (Energy dissipated per charge through resistor) × (Charge passing through resistor per unit time)

V = RI [restatement of Ohms Law], P = I(RI) = RI^2

so your resistor should reflect 326mW as opposed to 435mW, but its better to go for the bigger value, more safer, more stable.

Eh

If the resistor is dropping 0.58 Volts at 0.750mA the formula P = I*V works fine , so it will dissipate 435mW

And if you do R*I^2 you get , 0.773 ohms * 0.750^2 = 434mW ...
 
Last edited:
True as it may be, im not sure how important the information in this thread is to the original posters anymore, is what i should have said.
 





Back
Top