From time to time, i have use many circuits that generates PWM pulses. Most of them will translate a resistor value into duty cycle change. Although that is handy and easy, sometimes a voltage controlled PWM generator is needed. There are of course those micro-controllers that could make almost any kind of PWM signal translation, but i preferred to study and create a circuit without the use of such chips. I tried to keep it as easy as can be, but without this reflecting to the accuracy and integrity of the output pulses.
The following video demonstrates this circuit in operation:
The theory of this circuit
The operation is similar to the digital signal transmission using PWM signals. The DC input level voltage is compared to the current voltage of the triangular waveform. Every time those two levels have the same value, the output will change state. If the triangular waveform was on the rising edge, the output will go HIGH, otherwise the output will go LOW.
Look at those waveforms:
Figure 1
Figure 2
The green waveforms are the triangular signals. The brown line is the DC voltage level. Finally, the red pulses are the output PWM. You can see how these pulses changes the duty cycle as the DC input level changes.
The circuit
Following is the schematic of the Voltage controlled PWM generator:
You can find complete theory, details and drawing for the triangle wave oscillator in our relevant circuit. I have used the first circuit and i added the same transistor with a slightly changed resistors. My goal was to amplify the circuit but shift it a little bit, to help the circuit achieve duty cycles from 0 to 100%. You could as well use another circuit for generating a triangular waveform. The oscillation frequency in our circuit is around 1.5 KHz at the time, but this is not a critical value. You should keep in mind thought that the frequency of this triangle waveform will determine the PWM frequency.
To test the circuit, i needed a DC reference level. I used a simple 5K potentiometer implementing a voltage divider and i added a 1.5K resistor as shown in the schematic. This resistor will prevent the DC voltage to fall too much under the bottom edge of the shifted triangle waveform. Therefore, the whole range of the potentiometer will have active influence on the PWM duty cycle. That is the most important characteristic of this circuit.
You an use any kind of DC voltage level as input, as long as it remains equal or less than the power supply of this circuit. The circuit is tested from 3.3 to 12 volts, but i am sure that it an operate in much higher voltages. Actually, the transistor and the selected OP-AMP will put the final frontiers.
Oscilloscope results - from theory to reality
I'm always impressed from applied theory! I love to see the results. Following, i have include some photos of the oscilloscope monitor, while i am changing the DC level. Three waveforms are shown. The green is the triangular waveform and the blue is the DC voltage level. I have put them one over the other with common ground. The bottom yellow waveform is the result of the voltage comparison from the two above lines...
Minimum input voltage Max duty cycle output
The input voltage rises The duty cycle is decreased
At 22 July 2014, 23:48:48 user tim wrote: [reply @ tim]
555 timer?
At 7 September 2013, 8:32:42 user Tom wrote: [reply @ Tom]
Cool circuit. I have the idea to use this as part of a charge controller for a renewable power system. As the battery voltage rises,the duty cycle decreases with the zero part of the duty cycle used to switch in a dummy load.
Hi, i want to know how to build pulse voltage board with variable DC output from 1.5-24 volt that can open thyristor diode gate pls asist me i know you can.
Hi, I would Like to Build a PWM circuit with Variable DC Input from 0-60 volts. Hope you could be able to help me. The current capacity should be above 15 amps. Plz Email me
@Charalambos what you want is not easy. You will need a 4 wire fan with a sort of frequency to voltage converter to convert the feedback pulses into volts. Then you can feed this voltage back to the circuit as DC input. I only had this setup in theory in my mind. I never made one analog though, since i made it with PIC.
@Seán Certainly it can, as long a the mC has digital to analog output.
At 2 June 2012, 20:46:56 user Seán wrote: [reply @ Seán]
Hi, just wondering if the DCV here could be the output from a micro-controller? Or am I way off. I'm trying to send a string of numbers wirelessly with Pulse Width Modulation because Amplitude Key Shifting looks too complicated :D
Would be great if I could programme the micro-controller to have different widths representing numbers from 0-9.
@Glenfidich The problem is that LED brightness is proportional to the current and NOT the voltage. So even if the voltage to PWM is proportional, the voltage to current is logarithmic (refer to LED I-V characteristic). Therefore, the brightness can only be proportional if you make a constant current driver instead.
A simple solution would be driver from this page:
http://www.pcbheaven.com/userpages/LED_driving_and_controlling_methods/?topic=worklog&p=4
@Giorgos Lazaridis. Wouldn't you simply have to phase shift the triangle wave 90 degrees for the opposite effect? unless I don't understand this like I think I do it would be that easy to inverse the current voltage~brightness proportionality.
@Tony 1.the lm741 is rated at 10KHz max, so you certainly will need a faster one. I have not a great experience with op-amps, so i cannot suggest you one that fits best. I suppose you need a fast one, maybe faster than 150Khz.
2. The first op-amp works as a comparator to generate the clock pulses, similar as a relaxation oscillator. The shaping is done with the 2nd op-amp (integrator).
3. That is one very good idea. I suppose that this would work, but i have not test it though. If you try it please let me know.
At 10 September 2011, 22:20:13 user Tony wrote: [reply @ Tony]
Hi Kammenos,
I am building a 100kHz full bridge PWM with the above triangle wave method. The separated positive and negative range of the output will provide the separated pulse trains for the 2x H-Brigde PWM channels.
I've built simple model in simulator with a triangle wave generator, a pre-amplifier and 2x diodes for the separating the signal. I haven't built it in reality yet as not all the parts are available at this point of time.
I would have a couple of questions:
1. I would like to replace the U1 and U2 with something more common, however as for the simulation at this frequency the signal distorts. I tried a more available AD811 and the signal was jittery. Is that serious I would need such an advanced OPAMP as LMH6702MA rated for 1.7GHz? I know the simulator is not always accurate but I still find that wierd. Do you have any suggestion what common OPAMP should I use?
2. I don't fully understand the role of the first OPAMP. Is that a clock source-only or it also plays a role in shaping the signal?
3. Would that be possible to replace the first with a more stable oscillator? (e.g. crystal)
the only difference between your and my circuit is the voltage.
I use 12,5V.
Could this be the cause of the voltage build up taking too long so that this non vertical line appears?
I cannot think of anything else although I can hardly imagine that the voltage difference is the cause.
I have this effect at both squares, so at the pwm signal and at the square of the first opamp in the triangle circuit.
@Diaa that is correct, it will not. If you want to scale the voltage to the levels you want, you need to add a transistor and a capacitor and then scale to the amplitude you need. Take an example from the triangle wave oscillator i made. I have a capacitor and a transistor at the output to scale it to 0-5 volts.
At 9 August 2011, 11:33:43 user Diaa wrote: [reply @ Diaa]
Hello
I just constructed the circuit and it gave me an amplified triangular wave at the collector pin of the transistor, however, when applying the DC voltage level at the inverting input the peak-to-peak value doesnt exceed 3.3-3.6 volt.
I tried different types of OP-Amps but in vain. The maximum voltage doesnt exceed 3.3-3.6 volt.
Any1 can help me write a program using P16F88 and make uses of PWM module.
1. control air-cond fan using analogue voltage ranging 0 to 5V.
2. 5V for faster speed and 0 V at the lowest speed.
3. output voltage control air-cond fan from PortB bit3.
write a fully commented 16F88 microcode that show can output an analogue voltage ranging from 0 tp 5V at PortB bit0 of the microcontroller in 16 voltage levels based on the input from 4 dip-switches that tied to PortB, bit 1 ( LSB) to bit4 (MSB).
At 18 November 2010, 19:32:32 user Guus wrote: [reply @ Guus]
Hello!
I want to link the PWM to a H bridge and control a motor with a joystick.
I'm gona replace te 5k potentiometer with the joystick.
It is a joystick from a playstation controller (http://www.produktinfo.conrad.com/datenblaetter/425000-449999/425609-da-01-en-3D_JOYSTICK_F_POTENTIOMETER_O_SCHALTER.pdf)
As you can see on the datasheet the joystick has no conduction wen in neutral position. When you start moving it is starts with 2k and full "speed" is 70 ohm (the resistance is different than the datasheet). There a 2 separate tracks. Is it possible to use 2 transistors and 2 diodes to control the H bridge?
This is the plan: offer the 5 volt to the 2nd connection. When you move the joystick forward you activate
1: the transistor that allows pwm signal to flow to the forward mode of the H bridge.
2: use the joystick to control the PWM with the pwm generator
when in reverse you saturate the other transistor that allows the PWM signal to the reverse mode.
You can blok the signal to prevent it saturating both transistors with 2 diodes.
Both transistors are between the PWM modulator & the H bridge. By moving the joystick you active one of the 2 and activate the forward ore backward motion
Is the explanation clear or should I make a drawing of it?
would this be a good solution? I'm quite curios at your opinion / solution to the problem.
Thanks!
Guus
Netherlands
At 16 November 2010, 10:06:28 user amira wrote: [reply @ amira]
Can you design Duty cycle using traingular generator with adjustable DC level and comparator
The reason why i broke down the circuit in two (other for the triangle wave oscillator and other for the PWM) is exactly this. You can use one triangle wave oscillator for many PWM generators. One is enough.
At 2 November 2010, 14:55:50 user Guus wrote: [reply @ Guus]
Hello!
I'm making this pwm for a engine speed project (with H bridge) and I want to control 2 engines.
Can I use 1 triangle wave oscillator for both pwm controllers or do I have to make 2 seperate triangle wave oscillators?
One would be compacter so thats my prefferance.
Greetings
Guus
Netherlands
At 20 April 2010, 14:43:30 user jared wrote: [reply @ jared]
Thanks for that info never though about using the fan controller simple yet overlooked. I can use a voltage divider on my 0-10 input and just keep the 0-5 unless see that I need to modify the code.
Your site has been fun to look through and will look forward to seeing what else you come up with for projects.
I have already make a PWM controller controlled with DC voltage. I used it to control a fan, you can replace the fan woth LEDs. Check it out:
http://pcbheaven.com/circuitpages/PWM_3_Wires_Fan_Controller_with_RPM_feedback/
The 12 first lines in the \\\"MainLoop\\\" subroutine is what you are looking for. these lines will read the 0-5 volt input from the potentiometer and will convert it to PWM duty cycle. Put a \\\"goto Mainloop\\\" instruction right under the \\\"movwf ccpr1l\\\" and it will be a DC controlled PWM controller. Ignore from the schematic everything that has to do with the LCD. Replace the fan with LEDs (under the appropriate voltage).
Right now i am working on a 4-channel AC light dimmer with 4 0-10V DC inputs. I hope i will have it prepared by the end of this week. Have in mind that PWM is for controlling DC loads. The AC dimmer works different.
At 19 April 2010, 22:11:13 user jared wrote: [reply @ jared]
Sorry already posted this on the \"Voltage Controlled AC Light Dimmer\" project but saw this one and think it might be more related?
Would you be able to make this circuit using a micro-controller for us to look at?
Reason I ask is there is a lot of lighting controllers out there that output 0-10vdc for the control but nothing really to describe how to convert that over to PWM for use with a HB LED driver to dim them.
At 10 February 2010, 7:25:34 user Rafmag wrote: [reply @ Rafmag]
Terry Deck, I think i have a solution for your problem, Email me if your interested
this circuit will fit you fine. For the DC voltage input level, yo will exchange the 1.5K resistor with the thermistor. If you use a PTC, the speed will decrease with the temp. use a NTC instead to increase the speed with the temperature. Use the following circuit for the triangle wave generator:
http://pcbheaven.com/circuitpages/Triangle_Wave_Generator/
At 23 January 2010, 1:12:52 user P-DR wrote: [reply @ P-DR]
congratulation for your site. I want to make a automatic PWM controller using a thermistor!...while the temperature gets increase...the rpm of the fan also gets increase immediatly.i want a simple circuit if this is posible.12V-DC.thnx a lot!
I have a variable voltage of 0-500 VDC. I want the controller to monitor the voltage and if the voltage gets to 300 volts I want it to bring on the mosfets to send power to a resistive load such as a heating element (we supply the load). By sending some power to the resistors we can maintain a voltage very close to 300 volts. If the voltage drops below 300 volts the controller is on stand-by. I also would like the controller to have an alarm output and trigger a set of dry contacts when the voltage increases over 350VDC. Also if the two voltages could be adjusted this would be greatly helpful.
If you have or are able to supply such an item please email me ASAP. We are currently looking for 6 of these controllers and may need many more in the future.
I would be willing to pay you or someone you know that was interested in building these for me.
If you use the triangle wave generator from our circuits, then it will work... If you make something else instead and works, please send it to us as well.
Nice, simple circuit! I'm half-tempted into believing I could duplicate it and make it work. I'd love to use it to control a cooling fan for my cpu cooler that is only a 3-wire fan.
Thank you!