Home > Projects > DIY Devices > PWM Signal Generator

DIY PWM Signal Generator
Main Menu
Home
Login
Cyber Circuits Cyber Circuits

Science LabScience Lab new

Surplus Items Surplus Items
Custom ElectronicsCustom Electronics & Software
Education Educational Resources
Other Services

 

 

 

 

Sponsored Links

Squarewave GeneratorA DIY Square Wave Signal Generator with Pulse Width Modulation

This circuit is very simple and has a fantastic range of potential uses. The two potentiometers (variable resistors) allow the frequency and pulse width to be varied independently and without affecting each other like in the super simple signal generator.

By incorporating a rotary switch, the value of the timing capacitor (C1) can be adjusted. This allows the frequency to be adjusted over the full range that the 555 timer can support.

A separate chip (LM393) is used to control the pulse width so that it will not effect the frequency. The LM393 is a 'Low Power Low Offset Voltage Dual Comparator' The pot (VR2) is used as part of a voltage divider so that the voltage on the inverting input of the comparator can be smoothly varied. This voltage determines the pulse width of the final output signal.

Pulse Width Modulated Signal Generator

IC1 LM555
IC2 LM393
R1 10k
R2 10k
R3 2.2k
R4 10k
VR1 1M
VR2 10k
C1 47nF
C2 4.7nF
C3 470pF
C4 47pF
SW1 4 Pole Rotary

Since the pulse width is relative to the input voltage on the this input, it is possible to use the circuit in conjunction with a multitude of robotic interface boards. The analog output of an interface board such as a Veleman K8000 or a USB experiment interface board can be used to control the pulse width. This signal can be used to drive a H-Bridge or power transistor which is ideal for varying the speed of a DC motor. We have some circuits based on this idea on the Cyber Circuits page. We also have a simple DIY version of this device here

Potential Uses Might Include:
DC Motor Speed Control Control
Boosting or Variable Dimming for LED's and Light Bulbs
Transformer or Ignition Coil Driver

This circuit was used in the Power Pulse Generator project as part of the Ignition Coil Driver

Science Menu

Research projects Research Projects

DIY ProjectsDIY Projects & Experiments
CyberneticsCybernetics & Virtual Worlds
High VoltageHigh Voltage
PropulsionPropulsion Systems
PhysicsPhysics & Formula

Info Box

Power Pulse ModulatorPower Pulse Modulator
Variable Frequency, Variable Pulse Width, 10A DC Pulse Control Circuit More....

We Ship Worldwide

 

 

 

 

Sponsored Links

Questions and Comments on the DIY Pulse Width Modulator with Variable Frequency

Some comments/questions are hidden. To include them below, click here
The information provided here can not be guaranteed as accurate or correct. Always check with an alternate source before following any suggestions made here.
HazmatThursday, 29th June 2006 8:56pm - No.87
Thanks for this circuit! It works soooo much better than any 555 circuit I've tried. I've tried all sorts of 555 circuits for PWM, inlcuding one that used 2 555's or a 556 chip.

This one wokred first time and provides exactly the frequency and duty cycle vairiability I needed for my motor speed controler.
 
timothyTuesday, 19th September 2006 1:13pm - No.300
Can you tell me what pins on the LM393 chip correspond to the inputs for IC2 on the schematic?
Thanks
 
RMCyberneticsTuesday, 19th September 2006 4:48pm - No.301
This is the pinout for the LM393. It contains 2 comparators, you just need to use one of them. Note that the + and - inputs are inverted in the circuit diagram.

You can download the datasheet for the LM393 here.
 
Santa ( no Bike for you )Monday, 25th September 2006 7:27am - No.325
Re :-timothy Tuesday, 19th September 2006 1:13pm
I think what Timothy wanted was the connection details. Same as you did for the LM555..
See Example.
EXAMPLE ONLY.. CHECK FOR THE CORRECT CONECTION..
 
SunnyboySunday, 8th October 2006 11:46pm - No.391
Wow, I really like this Circuit! Ive been fidgeting with Squarewave generators quite some time, but never came up with the idea of simply using a comparator for duty cycle adjustment virtually independent from the frequency. Ive packed this neat gadget in a little case with a 9V Battery and added some extra IC life savers by using optocuplers before the outputjacks. Comes in very handy when playing around with HV stuff like TC. Santas schematic seems correct to me, but in the worst case, there are two comps on the chip, so dont panic (exept u fry the supply section^^).
 
BDSDTuesday, 10th October 2006 4:21pm - No.404
I noticed in your design that there is no indication of where the output pin 3 would be connected, is this an oversight or is it because it's not necessary. Thanks for all your support.
 
RMCyberneticsTuesday, 10th October 2006 4:33pm - No.407
Nope its not neccesary. The signal going to the comparator is just from the charging and discharging capacitor.
 
CrispyWednesday, 22nd November 2006 3:25am - No.489
I'm kind-of new to electronics analysis, and am trying to build one of these to drive an ignition coil, and the circuit seems pretty simple, but I'm the type of person that won't use something unless they understand how it works. As I said, most of this seems relatively simple, but I can't figure out what the purpose of R3 is. If someone could give a quick explanation, I'd be very grateful. Thanks.
 
RMCyberneticsWednesday, 22nd November 2006 2:18pm - No.498
R3 is used as a 'pull-up' resistor. It is neccesary to get a good output signal voltage relative to ground.
If it is not used the output signal will be too flat.
 
AndrewTuesday, 5th December 2006 3:12am - No.566
I see a contradiction here: RMCybernetics said "Note that the + and - inputs are inverted in the circuit diagram," so shouldn't pins 2 and 3 be reversed in Santa's diagram???
 
RMCyberneticsTuesday, 5th December 2006 8:59am - No.567
No. Santas diagram is correct. It is just that the pinout diagram showing how it is arranged inside the DIL package shows the inverting input (-) above the non inverting one. Its just an easy thing to overlook because the symbol looks the same.
 
BrendonTuesday, 5th December 2006 7:16pm - No.573
I have built this crcuit last night....I listened to it through headphones and it seems to work. I don't get much of a range when the rotary switch is set to C4 though - is that expected? Also, can you confirm what the freq. range of the circuit is (i.e 20hz to 20 Khz?) And will the circuit drive a 12inch loudspeaker? I want to try emulate those experiemnts in the video with the water/cornstarch mixture. Thank you.
 
RMCyberneticsTuesday, 5th December 2006 8:49pm - No.576
C4 is probably overkill really. The range is about about 0Hz to 125kHz, but the signal may start getting a little distorted at the top end.
You cant drive a large speaker with this circuit, but adding a transistor like in the Pulse controller will work.
 
BrendonWednesday, 6th December 2006 9:21pm - No.581
Wow thats some range. Perhaps my circuit isn't working right then because even if I have VR1 (which should be the freq. right?) turned right down I get a fairly low freq. that sounds more like an outboard motor but I can't turn it right down to zero. And changing VR2 (the pulse width)just sort of makes the signal sound either more distroted or less distorted, so I just leave it mid way. Did you use LOG or LIN pots for this circuit? Its hard to know if its working right without hearing a working example of the circuit eh?
 
RMCyberneticsThursday, 7th December 2006 1:31am - No.582
Being given the wrong info makes it difficult too I guess :). Seems like yours is working fine. I used linear pots.

With the 47nF cap The low frequency end is 30Hz, You'll need capacitors in the uF range to get really low frequencies.

The circuit will even oscilate without a capacitor if there is enough parasitic capacitance elsewhere. I measured 222kHz, but the signal was quite small and not square.
 
BrendonThursday, 7th December 2006 3:47am - No.583
Thanks. So what effect should turning the pulse width Pot have on the sound?
 
RMCyberneticsThursday, 7th December 2006 9:58am - No.584
The effect would be just as you described. It would only slightly alter the percieved sound. The pulse width function is important for using it with power control for motors, lights etc.
 
AndrewThursday, 7th December 2006 11:32pm - No.585
Is it possible to add an LED to this circuit that blinks at the same frequency as the output? Would you be able to see it blink or would it be too fast? Also, when VR1 is set to zero is that the highest or lowest frequency, and when VR2 is set to zero is that the highest or lowest pulse width? Thanks for your help!
 
RMCyberneticsFriday, 8th December 2006 12:48am - No.586
Yes you can add an LED to the output. You can just about see it blinking at the very lowest frequencies 30Hz. At higher frequencies the brightness would vary proportional to the pulse width.
It depends which pins you use on your pots for the direction.
 
AndrewFriday, 8th December 2006 2:32am - No.587
What I meant was if the pots were set to zero resistance. When VR1 is set to zero resistance is that the highest or lowest frequency, and when VR2 is set to zero resistance is that the highest or lowest pulse width? And would the LED go in line with the output or from the output to ground?
 
RMCyberneticsFriday, 8th December 2006 9:55am - No.588
With VR1 set to 0 the frequency will be max.
VR2 can be set to 0 resistance at either end of its turns, but ot will always be 10k between 2 of its terminals. It's wired as a potential divider. If you turn it so that there is 0 resistance between R4 and the inverting input, pulse width will be maximum.
 
ThomasWednesday, 10th January 2007 11:00pm - No.692
Hi RM. I made the Pulse width modulator and it seems to work fine... but I can't make sense of the frequency measurements I get. I did set the freq. at 1000 Hz (using a scope). When I check this with a DMM (red on output, black on ground of the pulse modulator), I get 20KHz. If I only have one lead (red/positive) on the "output" I get the right signal - why this?? Many thanks - Thomas
 
RMCyberneticsThursday, 11th January 2007 12:29am - No.693
The frequency measurment of many DMM's requires a reasonably high voltage input (>10V). Its interesting that it works with no ground reference. I just tried with a DMM I have with a frequency setting and the result is the same as you describe.

The scope will be the reliable reading, I guess your DMM isn't meant to be used for frequency in this way.
 
ThomasThursday, 11th January 2007 8:00pm - No.697
Very strange indeed... the DMM manual says 1.0v rms minimum for the frequency counter, but from the scope I think I have 8v peak to peak - I use a 9v battery as source.
 
ThomasSaturday, 20th January 2007 3:47pm - No.709
Is there a way to make is run around 600KHz? On the 47pF capacitor setting (or without a capacitor -parasitic capacitance I suspect, as you mention above-) I go up to 200KHz . I'd like to use it to find the resonance of primary and secondary of my tesla coil, which resonance is around 600KHz... any ideas of how to achieve this? Many thanks
 
ThomasSaturday, 20th January 2007 5:24pm - No.710
Hello... Am using the circuit as a source to find the resonance frequency of primary and secondary of my Tesla Coil. At the 47pF setting (and also without any capacitor - must be parasitic capacitance) I get about 200kHz. Ideally I would need a range around 600kHz (calculated resonance frequency of my primary). Any ideas of how to modify your circuit to get that? A smaller capacitor (e.g. 4.7 pF at C4) still gives around 200kHz. Many thanks
 
RMCyberneticsSaturday, 20th January 2007 6:52pm - No.713
Reducing the value of R1 may help. Try swapping it for a variable resistor, or just add one in parralel to it.

You could also try the Tesla Coil Tuner circuit. This goes up to around 450kHz.
 
ThomasSaturday, 20th January 2007 7:24pm - No.714
Added a potentiometer in // to R1. At combined values of 190 ohm I get about 340 kHz signal - then the signal just vanishes from the scope screen.
 
ThomasSaturday, 20th January 2007 8:29pm - No.715
Made the Tesla coil tester - but even by lowering C3 to 0.1 nF I get to a ceiling of about 500kHz!
 
CarlFriday, 9th February 2007 5:05am - No.754
Hi there. I'm planning to build your power pulse controller to run a dual ignition coil HV supply for an electric fence. There seems to be a problem though, you have forgotten to connect pin 4 of the 555 to Vcc in order for it to operate in Astable mode. I've simulated the circuit on Multisim 9 and it works very nicely. Thanx.
 
RMCyberneticsFriday, 9th February 2007 10:13am - No.755
Not forgotten. There is no need to connect pin 4 for this circuit to oscillate
 
ProblematicSaturday, 17th February 2007 12:10pm - No.782
Looking at the image I posted. Which pins should I connect to 1, 2, 3, 4 and 5 on the schematics view. I have looked through the data sheets online, but I still don’t know which is which? Thank you BTW :D
 
RMCyberneticsSaturday, 17th February 2007 12:41pm - No.784
You only need to use pins 1 2 3 4 and 8. See the post by Santa dated Monday, 25th September 2006 7:27am for the pinout.
 
ol'johnTuesday, 20th February 2007 3:01pm - No.803
before i go and try{?} building this circuit (or buying a complete one from you) i have a question on frequency: is it possible to get into the M or G frequencies with this device? judging from the posts i see here it does not appear so....
thank you
 
RMCyberneticsTuesday, 20th February 2007 6:12pm - No.804
No. This circuit will only work at low frequencies (i.e. audio frequencies). It will not work for RF.
 
hunter20Sunday, 18th March 2007 3:33pm - No.913
if you had a lower copasitor and then instead of the rotary you could use a dip and then you would be able to go through the entire frequency range. i think this is right but tell me if i am right.
 
RMCyberneticsSunday, 18th March 2007 3:38pm - No.914
You can use any method you like for adjusting the timing capacitance.
 
RobFriday, 20th July 2007 8:33am - No.1483
Hey everyone,

First off, great website. Second, im in the process of building this now, and i just put in LEDs between the dial and each capacitor. Will this have any negative effect on my circuit? Its really just for aesthetics, so when you turn the dial, the LED assigned to that certain capacitor lights up.
 
RMCyberneticsFriday, 20th July 2007 10:37am - No.1484
Yes it will effect the performance. The LED will provide a path for current to flow between the capacitor terminals. It could prevent the capacitor from charging and discharging correctly which is essential for oscillation to occur.
 
RobFriday, 20th July 2007 9:05pm - No.1485
Thanks for the advice, ill stick to the original circuit. Once again, thanks for the great website, and for dealing with all us electronics newbies :)
 
joeMonday, 23rd July 2007 3:59am - No.1492
hi i nead somthing that i can control the frequancy betwen 10khz and 30khz will this do that
 
RMCyberneticsMonday, 23rd July 2007 10:06am - No.1493
Yes. It will go from 0 Hz to about 125 kHz. This circuit will also provide that range of frequencies.
 
THE NAMEThursday, 9th August 2007 10:21pm - No.1559
Can you tell me how high is the voltage and current from output? Can I use OPAmp 741 instead LM393 ?
Many thanks!!!
 
RMCyberneticsThursday, 9th August 2007 10:28pm - No.1560
The output should go almost as high as the supply voltage (9V in this case). A 741 is not suitable for a direct replacement. This is because the 741 is designed for a dual supply voltage (+v, -v, and GND). The 393 is used here because it will operate from a single supply and is able to swing its output almost fully between the rails.
 
bonkersFriday, 10th August 2007 10:41pm - No.1570
could you please tell me where the wiper on VR1 is suppose to go. it doesn't look connected, also can I use an lm339, can't find any 339's, what I'de like to do is have seperate inputs and outputs so I can overlap different frequencies if that makes since.
P.S. Love the site!
 
RMCyberneticsSaturday, 11th August 2007 3:56pm - No.1574
VR1 represents a variable resistance. If you use a POT you would use an outer pin and the middle pin. The other pin would remain unconnected.
LM339 should work ok.
 
Albert ComoMonday, 1st October 2007 6:01pm - No.1788
The performance (the frequency and stuff) is not affected by the supply voltage, right? I can run this off of 12 volts, correct?
 
Albert ComoTuesday, 2nd October 2007 1:15am - No.1794
Very interesting thing with this circuit. If I touch or touch any terminal of 10k pot, while headphones are hooked up, I hear people speaking in spanish. I'm not joking. This thing is a radio or something.
 
RMCyberneticsTuesday, 2nd October 2007 1:50pm - No.1795
Yes you can run from any voltage within the component manufacturers specified tolerances.

lol! That's a pretty interesting result. Part of the circuit must be coincidentally tuned to match the broadcast frequency of those Spanish people!
 
Tom FerkoFriday, 5th October 2007 12:04am - No.1836
Can you get back with me on this. I am wondering if I can use this simple circuit to power a water splitting device whereas water is broken down into hydrogen and oxygen.

Get back with me at: 65t@commcast.net

Thanks, Tom
 
RMCyberneticsFriday, 5th October 2007 1:14pm - No.1842
The power pulse controller or a PWM-OC10A would be better.
 
MarkWednesday, 10th October 2007 2:03pm - No.1894
Great Website. I have built this circuit and it works brilliantly. I use a 9V supply and I have notice the output voltage is between 8 and 9V, is it possible to bring the output voltage down to about 4.5V - 5V (oscilloscope reading) without effecting the PWM. I do have some success in doing this with a 78L05 Regulator on the output, which gives about 4.2V. I would prefer a better way as I don't think this is quite right. Thanks Mark.
 
RMCyberneticsWednesday, 10th October 2007 2:19pm - No.1895
This pwm circuit is almost identical to this except it drives a big transistor for switching larger loads. You can use a different MOSFET or smaller transistor if the IRF740 is overkill.
To make it switch a different voltage you would disconnect the load from V+, connect V+ to the input of your regulator, then connect the output of your regulator to the loads +ve termial.
 
MarkThursday, 11th October 2007 10:51am - No.1915
Thanks RM for the info. Any idea which low power/smaller MOSFET I could use. Cheers.
 
RMCyberneticsThursday, 11th October 2007 10:55am - No.1916
That is totally up to you. Decide how much current and voltage you need to switch then look in a cataloge/shop for devices that will handle your requirements.
 
der stromMonday, 15th October 2007 4:17pm - No.1959
what does the end above R3 and the end way down at the bottom connect to in this circuit?
 
RMCyberneticsMonday, 15th October 2007 4:40pm - No.1960
These are the 'power rails' The top line is connected to +ve, the bottom line is -ve. It does not matter which end.
 
JohnSaturday, 27th October 2007 10:45am - No.2059
u da man, I need what Stan Meyer made, 555 with frequency and width pots thanks runs off 12v dc 5 amp
 
PumeeWednesday, 31st October 2007 9:22am - No.2091
Hi! I havent built this yet, becouse I have some questions. Is it possible to use it with 5V DC? Becouse I need TTL signals to drive an OEM laser device. And i also would like to use an optocoupler, at the output, ill have to use a resitor there do I? I mean a resitor which makes te good DC depending on the optcoupler(I decided to use 4N25)And after that i should use two Shmitt triggers?(becous it inverts). Id be really happy if you could help me, I need it for testing at our Lab. Thanks. Pumee from Hungary.
 
RMCyberneticsWednesday, 31st October 2007 2:02pm - No.2096
Yes it should run from 5V. You would just need a small resistor between output and your optocoupler to limit the current.
 
PumeeWednesday, 31st October 2007 2:36pm - No.2098
Thank you very much, for your quick reply!!
 
DannyThursday, 8th November 2007 3:35pm - No.2148
Excellent site you've got here!
How can I use a 555 noise maker kit from Maplin to drive an IRF740. The reason is to isolate the 555 circuit from the coil switching mosfet (and as a kit it's easy to build!).
I admit I am struggling with some fundamentals here but I assume the gate has to be grounded after it is pulsed in order to shut off the IRF740. How could this be done? I guess thats what the LM393 does but can I do it without?

Many thanks
 
RMCyberneticsFriday, 9th November 2007 2:47pm - No.2152
I'm not sure about the maplin kit as I don't have a schematic or any parameters for it.
Yes there needs to be a path to ground from the gate pin because it is effectively a capacitor and it needs to discharge to switch off the MOSFET. The 393 will do this to a limited extent, but it is common to just place a resistor between the gate and GND to drain off any remaining charge on the gate.
 
Awsome High VoltageWednesday, 21st November 2007 12:13am - No.2199
if you used this to power an ignition coil, could it power a tesla coil this size?
 
RMCyberneticsWednesday, 21st November 2007 9:25pm - No.2201
No. This is a signal generator only. It will not even power an ignition coil.
 
pikadude500Thursday, 22nd November 2007 5:41pm - No.2204
i have already built a 555 timer circuit using a MOV and ablocking diode in series with the coil on the + input the - input is from an audio amplifying transistor it was working seemingly well although te hv was some how getting to the 555 it wasnt heating up neither was the transistor,but it is not working anymore... con you tell me what went wrong
 
RMCyberneticsThursday, 22nd November 2007 6:02pm - No.2206
This is a signal generator only. it will not drive coils directly.
Look at the ignition coil driver page for a circuit to drive coils.
 
WardFriday, 23rd November 2007 10:59pm - No.2212
RM please help me understand why the LM393 (193) switches badly when saw tooth wave in from 555 is a slower frequency than say 65KHz? It only happens when input slope is too shallow. I would like to get down to 30KHz and still get clean PWM output.

If I try 100K R2, R4, and VR2 the effect is even worse. Any advice? The input saw tooth from 555 is clean. I zoomed in to limit file size. Thanks in advance.

Ward
 
RMCyberneticsFriday, 23rd November 2007 11:15pm - No.2213
The low frequency should not be a problem. The circuit on this page will work from DC to hundreds of kHz.
Is your circuit somehow different such as a series capacitor on the 193's input?
 
WardFriday, 23rd November 2007 11:29pm - No.2214
RM,

Circuit is same except R3 is 2K Vs 2.2K. It is on bread-board right now so I can play with it. I will try different components and report back if no ideas. Thanks.

Ward
 
JonFriday, 30th November 2007 4:05am - No.2276
Where do I get a Rotary Switch like the one in the picture, and what are the specs of the rotary switch?
 
OutThereSaturday, 8th December 2007 12:49am - No.2316
Is this a negative offset circuit being the pulsating output is negative current?
If so would reversing the polarity on the battery cause the output to be pulsating positive current?(positive offset)?
Thanks
 
nicnicFriday, 18th January 2008 6:41am - No.2452
yey, it worked! thanks a lot! :D
bravo!
 
sparkyWednesday, 16th April 2008 4:25am - No.2722
firstly, awesome awesome website. very knowledgeable info. i would like to know how to calculate the 4 different capacitor values (C1 to C4). i am currently designing a magnetic arc controller and i need a square wave generator with PWM connection to a mosfet driver leading to 2 different mosfets switching low and high. i basically need to control the inductive coil for position, frequency mark space ratio and amplitude. thank you soo much for all this info.
 
Your name hereThursday, 17th April 2008 1:05pm - No.2728
You can use this online 555 calculator here
 
ELsimfyWednesday, 4th June 2008 9:40pm - No.2798
Nice circuit & clever design. Thank you.
However a problem: In tuning the circuit I have found out that the frequency is not constant but is is varying, especially at low freq, i.e. at 20 Hz up to 10%. Already output freq. from 555 in not constant. All measured with DDM.
Any clue what's happening?
 
RMCyberneticsFriday, 6th June 2008 12:49am - No.2802
Maybe some interference. Try adding some capacitors over the power supply terminals to suppress noise.
 
ELsimfyMonday, 9th June 2008 8:35pm - No.2809
Thanks. My switch was on the wrong side (on GND instead as above).

1.Another thing, for adjusting min and max level of duty cycle on needs to adjust 10K resistors on 393 input... a little inconvenient. I have connected upper end of 10K variable resistor to the pin 5 (threshold), which properly selects upper voltage level (about 2/3 Ucc) of comparator or min. duty cycle. Max. duty cycle (min voltage level aout 1/3 Ucc) still manually adjusted.
Any comment on that?

2. I found LOG variable resistors for freq. more linearly adjustable, especially for high freq.
 
SamWednesday, 25th June 2008 12:25pm - No.2871
Hi, I haven't build this yet. As per my memory.. the O/P is the third pin (555 IC), but in here it left unconnected. Can you explain little bit?
 
RMCyberneticsThursday, 26th June 2008 2:28pm - No.2872
The 555 output is a square wave. It would be usless to put the squarewave into the 393. The signal is taken from the timing capacitor which is triangle wave. The 393 compares the voltage of this wave to the voltage from the 10k pot to determine if the outut should go high or low.
 
MetzenWednesday, 16th July 2008 7:39pm - No.2909
If you hook this to a 12v supply instead of 9v, will it work as expected or fry it?

If it will fry it, which components would need to be replaced to make it work with 12v? Likewise, which could be replaced to allow it to operate up to 20 or 30 amps?

Thanks!
 
RMCyberneticsThursday, 17th July 2008 10:59am - No.2912
12V will work fine.
If you want to switch large currents you need to use a large transistor on its output like in this circuit
 

Click the button to leave your comment or question

© 2007 All Rights Reserved

About Us | Terms of Use | Services