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!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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

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

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

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

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!

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!



Participated in the



    • Indoor Lighting Contest

      Indoor Lighting Contest
    • Metal Contest

      Metal Contest
    • Make It Fly Challenge

      Make It Fly Challenge

    36 Discussions


    Question 1 year ago

    What is 178400 here in difference amplifier???what is it's use??


    2 years ago

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


    3 years ago

    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 ?


    5 years ago on Introduction

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


    5 years ago on Introduction

    @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 itsannonymous@rocketmail.com.
    waiting for your reply


    11 years ago on Introduction

    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?

    3 replies

    10 years ago on Introduction

    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.

    3 replies
    drummer ianjmcol

    Reply 10 years ago on Introduction

    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!


    10 years ago on Step 2

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


    10 years ago on Step 7

    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


    11 years ago on Introduction

    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.

    3 replies

    Reply 11 years ago on Introduction

    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%


    11 years ago on Introduction

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