Introduction: Electronics Projects: Constant Current Power Supply Using Pulse Width Modulation

Picture of Electronics Projects: Constant Current Power Supply Using Pulse Width Modulation

Light an LED, Power a motor, this simple - ish circuit will accommodate all you constant current needs using NE555 chips! This is a great way to learn about electronics and although not as efficient as using a pre made buckpuck, this is more fun, cheaper and hopefully you'll learn something too!

Step 1: Intro

Picture of Intro

To build on breadboard a circuit which will control the current across a load by using pulse width modulation for maximum power efficiency.
To operate the circuit the user will plug the circuit into a power supply; this will keep the load at a constant predetermined current.

Spec (don't worry about these bits yet, i will explain what these numbers mean later)
Power supply voltage: 15V,0V,-15V
Astable Frequency: 60KHz
Astable Space Period: 16µs
Astable Mark Period: 0.7µs
Monostable Period: 8µs (half the period of the astable)
Reference Voltage: 2mV
Output current: 2mA

1. Astable oscillates when circuit is connected to power supply.
2. Falling edge of the astable will trigger the monostable.
3. Monostable will stay high for a variable period; this period is modulated by the difference amplifier.
4. Mosfet switches and allows current to flow.
5. Current Set circuit uses LC to smooth out the voltage into a DC flow.
6. Output is high, LED comes on.
7. Current in load gets too high.
8. Difference amplifier attempts to make this the same as the reference by changing its output.
9. Output of difference amplifier drops.
10. Period of monostable decreases.
11. Monostable on for less time per astable oscillation.
12. Mosfet switches on for less time.
13. After smoothing the voltage is less.
14. Less current across the load.
15. Difference amplifier output rises.
16. Monostable period increases.

Block Diagram:
Here is a diagram where i have split the project down into 'manageable' chunks, i will explain each chunk individually to help with the build.

Step 2: Stage 1: Astable

Picture of Stage 1: Astable

Chip(s): NE555
Inputs: none, this is turned on when the circuit is connected to the power rails
Outputs: Pin 3 (output) goes to the trigger of the Monostable

'Circuit Diagram
(see image)

Build and Test
Once built test the output pin (pin3) with an oscilloscope and alter the variable resistor to get the pulse width to around 16 micro seconds. If you do not have an oscilloscope, simply set the potentiometer to the middle of its resistance using a multimeter which should work almost as well!

When the system is on, pin 3 of the astable will oscillate between 0V and +5V. The mark and space of this astable has been set to a small space but a large mark. Having the output low for a short time enables the circuit to trigger the monostable accurately, and, if the monostable’s period is set to be very short it won’t get triggered twice in one period of the astable.
The output of this circuit goes to the trigger of the Ne555 Monostable. Every time the astable gives a falling edge the monostable will trigger for a set period of time dependant on its pulse width modulation.
I have set the frequency of the astable to 60 KHz, this should be a fast enough sampling rate for the current to stay constant at all times, and however, it is not so fast that the monostable is triggered incorrectly, or the Mosfet being unable to switch on quick enough.
F = 60 KHz
C = 1nF
R1 = 50KΩ Potentiometer
R2 = 1KΩ
R1= 1.44/FC-2R2
R1= 1.44/((60x〖10〗3 )(1x〖10〗(-9)))-2000

R1 = 22KΩ, this value is within the reach of the potentiometer I have, this means it will be easy to trim the circuit to get an accurate result.

The Space (T2) will be set very short, this will make sure that, if the monostable has a short period, it is not triggered twice in one oscillation of the astable.
The Mark (T1) will be longer to accommodate the rest of the period.
This means, to get a short T1 (short low pulse) I will need a small R2. This works out with my equations for the resistors based on the whole period, as, I have set R2 very small. With these values I get:
T2=0.7((1x〖10〗3 ) )(1x〖10〗(-9)) = 0.7µs, this is a very short period compared to the period for the whole oscillation:
p= 1/f= 1/60000=16.7µs.
It will be short enough that even the most Pulse Width Modulated Pulses will not be short enough to fit inside the pulse.
T1=0.7((1x〖10〗3 )+(22x〖10〗3 ) )(1x〖10〗(-9)) = 16µs

Step 3: Stage 2: Monostable

Picture of Stage 2: Monostable

Chip(s): NE555
Inputs: Input pulse from astable triggers monostable, and Pin 5 (pulse width modulation) input from the difference amplifier.
Outputs: Outputs pulses to mosfet to turn it on and off and allow current to flow for varying amounts of time.

'Circuit Diagram
(see image)

Build and Test
Once built test the output pin (pin3) with an oscilloscope and alter the variable resistor to get the pulse width to around 8 micro seconds. If you do not have an oscilloscope, simply set the potentiometer to approx 1/5th of its resistance using a multimeter which should work almost as well!
Your test should look something like image 3, test shows the astable output in blue, the red shows the monostable.

The monostable will be triggered when pin 2 has a falling edge; this means that every time the astable has a low pulse the monostable will trigger. When the monostable is triggered the output will stay high for a set period of time.
The period of the monostable will be set to half the period of the astable. (16µs)/2=8µs
This means that the pin 5 will be able to vary the pulse width either way by the same amount. Pin 5 on the Ne555 can be used to vary pulse width. I will be using this pin to achieve pulse width modulation which will keep the output current of my circuit at a steady value. The voltage at Pin 5 is allowed to vary between 0.45 Vsupply and 0.9 Vsupply, the higher the voltage, the longer the pulse width.
To get the correct value for the pulse width, without modulation, I will use the following components:
p=1.1 x R x C
R=p/(1.1 x C)
C = 1nF
P = 8µs

R=(8x〖10〗(-6))/(1.1 x 1x〖10〗(-9) ) = 7272Ω = 7.2KΩ
Again I will be using a potentiometer as a variable resistor (R) in order to get the correct period.

Step 4: Stage3: Mosfet

Picture of Stage3: Mosfet

Chip(s): 2N7000
Inputs: Monostable
Outputs: Current Set circuit

When the monostable output is high the monostable will conduct between V supply and 0V. The longer the period of the monostable the longer the Mosfet will conduct for.

Step 5: Stage 4: Current Set Circuit

Picture of Stage 4: Current Set Circuit

Chip(s): no chips are used in this subsystem
Inputs: Mosfet
Outputs: Load, Difference Amplifier

Build and Test
Build but don't test yet, you will blow the LED (or whatever load device your using)

The current set circuit will take the ‘pulses’ of voltage from the monostable and smooth them out into a smooth voltage that can be used by the LED. Once the voltage has been smoothed by the inductor and capacitor, the Load (an LED in my circuit) will have a voltage across it, and, therefore a voltage across the small resistor (1Ω) it is in series with it will also rise. As I have set a low resistance very little power will be lost across it. The resistor has a known resistance so in my circuit I will use this to get the reference voltage for the difference amplifier, if the current through the LED gets higher, the voltage across the resistor will increase.
The 1N5817 is a fast switch diode; because of the high frequencies used it will have to deal with very fast speeds otherwise the circuit may not work.
LED current Calculation:
The resistor in series with the LED is there to give a reference voltage to the comparator. By using a fixed resistance I can calculate the voltage across the resistor when a certain current is flowing through it. In this case I will be using 1mA as the current. I have selected a small value for the resistor 1Ω, this way very little power is lost across the resistor, and this is what helps to make the circuit an efficient constant current source.
When the current through the LED rises to 1mA the voltage across the resistor will be:
V=1 x (1x〖10〗(-3) )=1mV

Step 6: Stage 5: Difference Amplifier

Picture of Stage 5: Difference Amplifier

Chip(s): NE555
Inputs: Reference Voltage from potential divider, Voltage from current set circuit.
Outputs: Output goes to pin 5 (pulse width modulation) input on the Ne555 monostable.

Build and Test
See next step

The job of the difference amplifier is to compare the two inputs and output the amplified difference. In my circuit this is used to compare the voltage across the LED with the voltage reference (preset current constant), it then will amplify this difference and output the voltage to the pulse width modulation pin of the monostable.
If the current in the LED is too high, the voltage across the resistor will be greater than the reference voltage, this will output will be low, this output will be clamped by the diode so that it cannot go below 0V, this should stop any damage happening to the monostable.
If the current in the LED is too low, the voltage across the resistor will be less than the reference voltage; the difference amplifier will output a high voltage to increase the pulse width of the monostable thereby increasing the current through the LED.
The input for the reference voltage comes from a potential divider. As my circuit is designed to work at different power supply voltages, the Vin to the potential divider network must be constant and not follow the power supply rail. To achieve this I have used a voltage regulator in my circuit. This will give out a constant +5V as long as the supply rail is above +5V, this means change in supply voltage will not affect the reference voltage, this will mean the current will remain constant.
To get an accurate 1mV from my potential divider I have used a potentiometer to be able to trim the voltage to an exact value. By changing this potentiometer the user can also change what the current limit is set to.
Calculation for Potential Divider:
Vin = 5V
Vout ~ 1mV
Use a 20KΩ Potentiometer for R2 to give an accurate voltage output when the tested and trimmed. The middle of the Pot will have the most adjustability either side so I will use 10KΩ in my calculation
Vout=Vin x R2/(R1+R2)
Vout/Vin ~ (10x〖10〗3)/R1
R1= R2/Vout xVin= (10x〖10〗3)/(1x〖10〗(-3) ) x5=50MΩ ~ 4.7MΩ

Calculation for Difference Amplifier:
The difference amplifier controls the voltage at pin 5 of the monostable. The Ne555 specification sheet states that this pin will vary between 0.45Vin and 0.9Vin; this means I must calculate to achieve a gain, large enough to give the difference amplifier a value in this range.
0.45x5=2.25 0.9x5=4.5
The middle of this range is what I want the difference amplifiers output voltage to be set to when the current is the correct value:
Vout=Rf/Rin x(Va-Vb)
Assume Vref ~ 2mV
Vin = 1mV
Rin = 1KΩ

(Vout x Rin)/((Va-Vb))=Rf= (3.375 x (1x〖10〗3))/((2x〖10〗(-3) )- 1x〖10〗(-3)))=3.375MΩ

Step 7: Stage 6: Finishing UP!

Picture of Stage 6: Finishing UP!

Ok guys, we're nearly done here. Firstly check that your circuit looks like the circuit diagram below, check all wires go to the same places or your circuit will not work. Then, plug your supply rails in, and turn on, hopefully the LED will turn on and not blow! Adjust the potentiometer mostly the 12nd and 3rd ones) to get the desired current output (this is checked my measuring using an ammeter between the led and ground). Then...Your done!



AishwaryaNE (author)2016-09-14

what is the use of zener here ?& why are we using pwm method when we can obtain constant current source using bjt?

PerryM3 (author)2015-10-22

Hi im trying to run a 12v dc motor with a transformer from a wall socket but i am getting pulses of power rather than smooth current and was told i need to pulse width modulate it would i be able to use this set up or does this have to have ac power put through it or could i put dc through it ?

russ_hensel (author)2014-01-12

One of the nicest breadboard layouts on instructables., Congrads.

omer057 (author)2013-09-25

@drummer ian
i am working on my final project of constant current switch mode power supply.. i am wee bit worried as i didn't find any information related it's circuit diagram and working. i read your article but need more help. i am using a buck-boost converter & MOSFET for high frequency switching & PWM in feed back circuitry . do you have any circuit diagram and it's working please do share it with me i need your help badly.
my email is
waiting for your reply

victi_vicimus (author)2008-03-17

This is interesting, but I get a lot of gibberish where more unusual characters are not rendered by Foxfire, Internet Explorer or Apple Safari. Can you help?

GASSYPOOTS (author)victi_vicimus2012-03-20

use chrome :D

ahh sorry,didn't realise this problem! haha i will fix it as soon as i can

I still get the gibberish

jmcol (author)2008-11-09

I am sorry but 8 months after your answer to victi_vicimus, I still get a lot of gibberish like this on step 2:
"T1=0.7((1xã�–10ã�—3 )+(22xã�–10ã�—3 ) )(1xã�–10ã�—(-9)) = 16�µs"

It's a pitty because your article seems quite interesting and serious.

Jimmy Proton (author)jmcol2011-09-22

Its instructables fault...

PeterMacGonagan (author)jmcol2008-12-17

Me too. Could you solve this problem, please?

drummer ian (author)jmcol2008-11-09

sorry about that, i will fix it soon i hope, i haven't been on in a while (uni seems to bog me down abit) thanks!

mbk.2k3 (author)2009-02-19

can you please re-upload this without all these random characters in between? makes for a very confusion read in some sections :)

marcia09 (author)2008-11-21

Hello, I´m new to this and am trying (hard) to make a display sign with leds; I have bought lots of leds I have soldered in parallel with 330 ohm resistors to make the sign. I also bought a breadboard, and a 555 IC and a 4017 IC, because I would like the first word (four letters) to flash as a whole, and the second word (8 letters) to flash sequentially. I succeeded in making my circuit on the breadboard, with one led representing the first word, and 8 leds representing the 8 letters of the second word, but now I have the problem to find a suitable transistor to amplify the power. The first led, coming out the 555 represents about eighty 20 mAmp leds (thus about 1.6Amp, right?) and the other 8 leds represents about 20 leds letters (so 500 mAmp should do). I have tried connecting a 2n2222 transistor on the breadboard with a flash lamp rated 500 mAmps instead of one of the 8 led (I do not want to make the tests with my mounted leds so as not to risk losing hours of soldering work) but it does not light up, not even a little. Then, I connected an led (5 mm) after the transistor and it blinks normally !! You seem like the expert on this, Can you help me ? Thank you in advance

SynK (author)2008-04-23

Umm, unless I am wrong, there is no way to get a constant current with PWM. It works by timing pulses of electricity with certain durations giving the illusion of varying voltage and amperage, while actually putting through the same current in "short spurts." If I am wrong about this, please e-mail me with a better explanation.

carlitoscr (author)SynK2008-08-06

You are right, that is how PWM works BUT you can still get constant current and/or voltage after you add the propper filtering network. These networks are normally RC circuits for linear power supplies or LC networks for switching supplies like this one. Non filtered PWM output swings from 0% to 100% of the output voltage. Propperly filtered outputs can have a ripple voltage less than 0.1% which renders the outupt constant in 99.9%

SynK (author)carlitoscr2008-08-06

Thanks for straightening me out.

carlitoscr (author)SynK2008-08-06

It's been a pleasure!

hdh (author)2008-06-02

I want to run electroluminescent wire not LED’s will this type of power supply work?

carlitoscr (author)hdh2008-08-06

For an EL wire you need relatively high voltage and frequency. As an example: 90Vac running at 2kHZ. You can check or for more information.

cobrasniper555 (author)2008-03-20

Maybe a suggestion, but can you make a similiar device that outputs much more current and less voltage? Would this be possible on a similiar scale and funding? Also (it seems like this is a good place to ask), is there a way to up output of say an alarm clock? Like when the charge is send to the buzzer, can it be modified to a higher current by use of capacitors or what not? Thanks!

to answer your first question this circuit seems good up to about 20mA, which was the extent of my testing, it may handle more i don't know, i do know that the mosfet i used will be good up to around 350mA. Secondly, yes i believe it would be possible, i think what you would need is a transistor, a transistor amplifies current (perhaps some one with knowledge on this will chime in to confirm)

rayfalcon (author)2008-03-18

ok first off what type of capacitors and resistors and what uF and V and how many mF how much sensitivity and by u saying power source you mean a 120 vac wall plug? i need it fairly simply i had a seizure and lost all of my logical memory. also what size if any pot switches and is there any dip switches? if no dip switches can a person add dipp switches at the gateway and transverse or revers the flow into a diff direction or higher current and or a lower current? email me any detailed pics and or instructions please

drummer ian (author)rayfalcon2008-03-19

all the values your looking for are on the full circuit diagram at the end of the instructable

computerwiz_222 (author)2008-03-18

I have one quesion. How do you get the wires so tight on your bread board. I love to proto my projects out on my bread board, but it almost always turns out to be a big mess of wires.

well, firstly thanks for the compliment :p, secondly, it's fairly simply to make them neat and takes very little time. Heres my method for making wires: 1. Check the length of wire you'll need 2. cut your wire from the reel a bit longer than this length 3. Strip one end of this wire (take about 0.8cm off) 4. fold this stripped bit over 90 degrees with pliars (this is i think the key step) 5. insert this into one of the holes on the board 6. check where wire needs to go to, mark the wire with your thumb nail to get the correct length 7. now take the wire off the board again 8. strip the wire up to the marked place 9. cut the stripped bit to 0.8cm 10. bend with pliars 11. insert into the board

thanks so much! Its funny, i learned to solder, make boards, read schematics etc. but i never learned how to properly bread board a circuit.

no problems m8, ask for any other advice, im far from an expert but i find laying out the breadboard neatly (although initially takes more time) dramatically reduces the time you sped fault finding

Ahmedqatar (author)2008-03-18

GREAT !!! Faved !!!

drummer ian (author)Ahmedqatar2008-03-18


the.russkey (author)2008-03-17

why not use something like a wilson current mirror (wikipedia article instead?

drummer ian (author)the.russkey2008-03-18

this is also a possibility, however, heat is lost across the transistors (making it altogether less efficient)

LinuxH4x0r (author)2008-03-16

Cool! I needed this. Hopefully my parts come from ti on monday.

drummer ian (author)LinuxH4x0r2008-03-16

wicked! keep me informed on how it goes and feel free to ask for any help!

LinuxH4x0r (author)drummer ian2008-03-16

Actually that was worded badly- The parts are mostly audio related.

About This Instructable




More by drummer ian:Electronics Projects: Constant Current Power Supply using Pulse Width ModulationK'nex XBow
Add instructable to: