Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

3 July 2009
Author: Giorgos Lazaridis
Voltage Controlled PWM Generator


The circuit in full operation

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


The duty cycle changes
according to the slope


Duty cycle can go
below 50% easily

Maximum input voltage
Zero duty cycle output




Relative pages
  • Learn how RC Servos work
  • PWM signal theory
  • The transistor theory of operation
  • Triangle wave generator
  • How to make a PWM fan controller / LED dimmer using a 555
  • Dr.Calculus: Op-Amp inverting amplifier calculator
  • Dr.Calculus: Voltage divider calculator
  • Op-Amp IC Pinouts
  • A 2-speed PWM temperature fan controller
  • An intelligent self-tunned fan PWM controller





  • Comments

      Name

      Email (shall not be published)

      Website

    Notify me of new posts via email


    Write your comments below:
    BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


          

  • At 1 December 2015, 9:35:52 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Eric Martel You need to work on a "zero cross" circuit instead of this. This will not work for you.


  • At 23 November 2015, 16:45:02 user Eric Martel wrote:   [reply @ Eric Martel]
    • Hello,

      I want to use that circuit and the sawtooth circuit with an optocoupler and TRIAC to make a phase dimmer.

      The load, a lamp, will be on a 120-240 Vac circuit, at 60HZ.

      Do I have to modulated my sawtooth signal to be a 60hz signal ?

      THX


  • At 23 July 2014, 19:11:17 user Giorgos wrote:   [reply @ Giorgos]
    • @tim LM741


  • 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.


  • At 29 July 2013, 8:01:29 user Anthony Okorie wrote:   [reply @ Anthony Okorie]
    • 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.


  • At 7 June 2013, 11:50:14 user Deepak wrote:   [reply @ Deepak]
    • 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


  • At 24 August 2012, 7:20:01 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @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.


  • At 22 August 2012, 9:46:50 user Charalambos wrote:   [reply @ Charalambos]
    • What modifications must take place in order to use this as a switchmode PWM power supply with feedback ?

      Suppose that PWM signal has to drive the power transistors or mosfet gate, and the DCV should be the feedback voltage from the load ?

      Is this possible to work with this method without the usage of a special IC from the market?


  • At 4 June 2012, 10:12:17 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @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.


  • At 31 May 2012, 12:48:18 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @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


  • At 29 May 2012, 17:36:08 user Glenfidich wrote:   [reply @ Glenfidich]
    • @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.


  • At 29 May 2012, 9:01:53 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Glenfidich actually the voltage goes up and the duty cycle is decreased. this is done linearly since the ramp is linear.


  • At 27 May 2012, 21:09:56 user Glenfidich wrote:   [reply @ Glenfidich]
    • How would I make the voltage proportional to the brighgtness? Right now the voltage goes up and the duty cycle goes down, right?


  • At 11 September 2011, 14:56:07 user Kammenos wrote:   [reply @ Kammenos]
    • @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.

      Schematic: http://i52.tinypic.com/2qvw3f5.png
      Scopeshot: http://i56.tinypic.com/29c0zf4.png

      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)

      Many thanks for the answers in advance.

      Kind Regards
      Tony


  • At 17 August 2011, 21:11:45 user Kammenos wrote:   [reply @ Kammenos]
    • @dieter this is a typical problem for the 741 if you run at high frequency. Anything above 10Khz is too high! What is the frequency?


  • At 17 August 2011, 15:48:01 user dieter wrote:   [reply @ dieter]
    • Hello kammenos,

      To continue the posting from the triangle circuit...
      I just bought a normal oscilloscope and everything looks much better, as it is supposed to be.

      My squares however look more trapezium like with an angle of approx 10 degr from the straight up line where yours have only a 1 or 2 degree slope.

      http://farm7.static.flickr.com/6202/6052714743_196a34e160.jpg

      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.

      What so you think it could be?


  • At 11 August 2011, 9:52:02 user Kammenos wrote:   [reply @ Kammenos]
    • @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.

      Thanks for help in advance


  • At 29 June 2011, 15:34:53 user Adrianc wrote:   [reply @ Adrianc]
    • Hello,

      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).

      Thanks.


  • At 18 November 2010, 20:26:25 user Kammenos wrote:   [reply @ Kammenos]
    • Guus better post a schematic in the forum


  • 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


  • At 2 November 2010, 16:10:37 user Kammenos wrote:   [reply @ Kammenos]
    • 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.

      Cheers
      Jared


  • At 20 April 2010, 4:35:58 user Kammenos wrote:   [reply @ Kammenos]
    • 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

      rafmagc@gmail.com


  • At 23 January 2010, 11:48:47 user Kammenos wrote:   [reply @ Kammenos]
    • Hi P-DR,

      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!


  • At 6 January 2010, 22:40:51 user Terry Deck wrote:   [reply @ Terry Deck]
    • Hi Giorgos Lazarids


      I am looking for a PWM controller

      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.


      Terry Deck
      Deck\'s Geo-Electrical Ltd.
      P.O. Box 1115
      Lumsden, SK. S0G 3C0
      PH 306-731-2366
      FAX 306-731-3044
      www.geoelectrical.ca


  • At 13 September 2009, 13:24:35 user Kammenos wrote:   [reply @ Kammenos]
    • 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.


  • At 8 September 2009, 2:51:35 user Tracy Mathews wrote:   [reply @ Tracy Mathews]
    • 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!


  • At 15 August 2009, 16:43:53 user Kammenos wrote:   [reply @ Kammenos]
    • Of course it works ;). Thanx


  • At 12 August 2009, 10:18:59 user Stefan wrote:   [reply @ Stefan]
    • Congratulations!!!!!!!!!!!!!!!!!!!!!

      It just WORKS



    delicious
    digg
    reddit this Reddit this
    Faves



     HOT in heaven!


    NEW in heaven!



    New Theory: AC electric motor working principle



     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy