1. Welcome to our site! Electro Tech is an online community (with over 100,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PWM Signal to LM317 to adjust Voltage Output

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by Suraj143, Feb 2, 2012.

  1. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    Guys can somebody help me to control voltage of the regulator from a PIC pwm frequency?

    Most people say generate a PWM signal feed to a low pass filter & feed into an gained opamp & drive a transistor.is this ok?

    Required range
    *Low end can be 1v or 1.25V & high end will be 30V with a resolution 0.5V.

    I have rail to rail opamps in my hand & LM317.

    Those are my questions.

    *What frequency to drive?
    *Low pass filter values?
    *Whats the gain?

    This is a problem for me from a long time----> I still cannot understand what will be happen if I feed a PWM signal to a low pass filter??
    Last edited: Feb 2, 2012
  2. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    4,277
    Likes:
    342
    Location:
    Cleveland, OH, USA
    Look at the low-pass filter like an integrator.

    As for other ways, remember the usual way is used because it works.

    John
  3. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    4,449
    Likes:
    448
    Location:
    Loveland, CO USA
    ONLINE
    A low pass filter removes the AC part of the signal and outputs the average, and gives you DC. From the PIC it probably will give a DC voltage of 0 to 5 volts. (if the VCC=5V)
  4. ronv

    ronv Well-Known Member Most Helpful Member

    Joined:
    May 30, 2010
    Messages:
    4,384
    Likes:
    452
    Location:
    Tucson, AZ. USA
    ONLINE
    If you know the frequency of your pwm from the PIC we can help you calculate the low pass filter.
  5. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    You are on track :)

    Let say I drive 1Khz pulse with a 50% duty cycle.
  6. ronv

    ronv Well-Known Member Most Helpful Member

    Joined:
    May 30, 2010
    Messages:
    4,384
    Likes:
    452
    Location:
    Tucson, AZ. USA
    ONLINE

    Here is a neat calculator that you can use. Adjust R & C untill you get the ripple voltage low enough for your needs, then make sure you can live with the response time for a change. Go down the page until you see the PWM calculator.

    http://sim.okawa-denshi.jp/en/PWMtool.php
  7. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    Hi ronv this is the first time doing such an experiment.That's a nice calculator.

    I did some calculations.from the blow values.

    PWM Frequency = 1Khz
    R=3.3K,C=0.1uF

    Whats your ideas on this?Does it have too much ripple?

    My main task is to generate voltage by PWM.
  8. ronv

    ronv Well-Known Member Most Helpful Member

    Joined:
    May 30, 2010
    Messages:
    4,384
    Likes:
    452
    Location:
    Tucson, AZ. USA
    ONLINE
    I think I would use something like 10K and 10 Ufd. That way only about 12 mv of ripple.
  9. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    Hi ron your values are superb.I calculated the vout from uC from the values you given.

    PWM Freq 1Khz
    R=10K
    C=10uF
    Ripple (PP)= 12mV ripple

    DC (1-100%) Vs V Out


    10% = 0.5V
    20% = 1V
    30% = 1.5V
    40% = 2V
    50% = 2.5V
    60& = 3V
    70% = 3.5V
    80% = 4V
    90% = 4.5V
    100%= 5V

    If I give this Vout to a gained opamp let say the gain is set to 2 & the minimum value will show as 1V.& maximum val will be 10V.

    I think this range is not enough.Atleast it must have 1V - 20V range.
    Last edited: Feb 3, 2012
  10. ronv

    ronv Well-Known Member Most Helpful Member

    Joined:
    May 30, 2010
    Messages:
    4,384
    Likes:
    452
    Location:
    Tucson, AZ. USA
    ONLINE
    317

    You need a gain of about 5.75.

    It won't be exact because the output of the 317 is 1.25 volts above the adjust pin. So.... You will have to make this adjustment in your micro program I think.
  11. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    9,238
    Likes:
    270
    Location:
    L.A., USA
    ONLINE
    R1 serves no purpose in your circuit. The voltage is determined by the op amp, low impedance output
  12. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    Ok ronv thanks for your help.

    I'm just wondering why I need a LM317 to make a digital power supply?

    Why can't I do it from an op-amp?

    PIC PWM --->Low Pass--->Gain Op-Amp--->Output

    Why cant I do like that?So no need any LM317 stuff!!

    Guys whats your idea on my way?
  13. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,370
    Likes:
    214
    Location:
    OKLAHOMA USA
    Are you going to drive something specific with this power supply or is it general purpose? It makes a difference in what you need.
  14. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    I want to build a general purpose power supply with digitally control voltage.

    It must build with commonly available components without using any digital potentiometers :)
  15. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,370
    Likes:
    214
    Location:
    OKLAHOMA USA
    If no one has mentioned it http://www.eevblog.com/episodes/
    has an very good series of videos on designing a lab/bench supply. He walks you through the logic as he refines the design.

    Watch them and be amazed.

    Not only is it good information but it is an interesting look into the logic and motivation.
  16. ronv

    ronv Well-Known Member Most Helpful Member

    Joined:
    May 30, 2010
    Messages:
    4,384
    Likes:
    452
    Location:
    Tucson, AZ. USA
    ONLINE
    If you don't need much current you could just use the output of the op amp or you could use a higher power op amp. All depends on your needs. R1 provides a minimum load so the 317 will regulate even with very low or no external load.
  17. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    Hi ron I simulated your circuit in Proteus,it worked nicely.

    Giving PWM voltage from 50mV to 4.5V will give the output to 1.5V - 24V range that's great.

    Of course for every gained voltage it must add 1.25V value.

    Now I just modifying the PWM part.What about adding an unity gain buffer to the input to the op-amp?In other words I'm going to add low pass filter to the unity gain buffer & its output will connect to the gained op-amp!!
  18. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    9,238
    Likes:
    270
    Location:
    L.A., USA
    ONLINE
    You could make the op amp into a second-order active filter for better suppression of the ripple.
  19. ronv

    ronv Well-Known Member Most Helpful Member

    Joined:
    May 30, 2010
    Messages:
    4,384
    Likes:
    452
    Location:
    Tucson, AZ. USA
    ONLINE
  20. Suraj143

    Suraj143 Active Member

    Joined:
    Jan 11, 2007
    Messages:
    1,415
    Likes:
    1
    Location:
    South Mald Isld
    Hi fellows from the 1st order filter 10K & 10uF I get a 12mV ripple.If I add 2nd order to this is it ok if I add another 10K with 1uF?

    Looks likes its harder to calculate those stuff.

    http://sim.okawa-denshi.jp/en/CRCRtool.php

Share This Page

___...__