PWM to 0-5V


Closed Thread
Results 1 to 9 of 9

Thread: PWM to 0-5V

  1. #1
    Join Date
    Aug 2009
    Posts
    16

    Default PWM to 0-5V

    I am using the PWM command to create a 0-5V output that corresponds to 0-100% on my display. The Pic Pin has a RC filter 10K and 1uf cap into a rail to rail op amp. The op amp is powered off of the 5V supply that powers the PIC. I can only get about 4.5V out of the op amp when the cout is at 100. Is there a better way to do this or am i missing something?

    ' b1 varies from 0-100 which is converted to 0-255

    Normal:
    if sw1 = 1 then up
    if sw2 = 1 then dwn
    if sw3 = 1 then foff
    if sw4 = 1 then fon
    lx = b1
    d1 = ((b1*100)/39)
    pwm out,d1,100
    call display
    pause 250
    goto normal

    Thanks,

    Terry

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You will have to use two resistors to give the op amp a gain of greater than 1.
    A 1K resistor from the output to the (-) input and a 4.7K resistor from the (-) input to GND should do it.
    Charles Linquist

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Check output load

    My initial circuit did the same thing until I switched from a TI chip to a MIC7300YM5 TR. I think the output load was too much for it and could only source to 4.35V.
    My PWM filter is a 39K with a 0.1uF to GND and the op amp is just configured as a buffer to give me the full 0 to 5V swing.
    Louie

  4. #4
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default More info

    Oops! Took too long to edit. Wanted to include partial schematic for clarity.
    Don't recall actual PWM frequency but running PIC on IOSC set to 8MHz.
    Attached Images Attached Images  
    Louie

  5. #5
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LinkMTech View Post
    Oops! Took too long to edit. Wanted to include partial schematic for clarity.
    Don't recall actual PWM frequency but running PIC on IOSC set to 8MHz.
    This not really solution for your problem but why you have so big RC time constant for filter?
    PWM cycle time for 8MHz is ~2.5ms.
    39kOhm and 100nF:
    Name:  39k-100n-8MHz.jpg
Views: 76222
Size:  35.6 KB

    How about something like this or in that range?
    10kOhm and 10nF
    Name:  10k-10n-8MHz.jpg
Views: 76351
Size:  40.7 KB
    BR,
    -Gusse-
    Last edited by Gusse; - 29th April 2010 at 19:52. Reason: Some corrections

  6. #6
    Join Date
    Aug 2009
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    adding the 1k and 4.7K resistors to the op amp to give it some gain, did not seem to help. I only have one rail to rail op amp here it is a lmc 6482 form national.

    I'm using a PIC 16F716 @ 4mhz. I just used the RC filter that was used in the example on page 120 of the PBP book. That was what they were using for ther PWM Out Example.

    Thanks,

    Terry

  7. #7
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Good question

    Quote Originally Posted by Gusse View Post
    This not really solution for your problem but why you have so big RC time constant for filter?
    PWM cycle time for 8MHz is ~2.5ms.
    39kOhm and 100nF:
    Attachment 4358

    How about something like this or in that range?
    10kOhm and 10nF
    Attachment 4359
    BR,
    -Gusse-
    Hi Gusse,
    It was a choice between really fast response or a steady output to replace a resistor network and switch. This app. didn't need the speed but really good filtering.

    Terry,
    It looks like the LM6482 should work for you. Taken from data sheet:
    3.0 RAIL-TO-RAIL OUTPUT
    The approximated output resistance of the LMC6482 is
    180Ω sourcing and 130Ω sinking at VS = 3V and 110Ω
    sourcing and 80Ω sinking at Vs = 5V. Using the calculated
    output resistance, maximum output voltage swing can be
    estimated as a function of load.
    Unless... your output load is 1K then that would explain your 0.5V loss.
    Louie

  8. #8
    Join Date
    Aug 2009
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    I will keep working on it. The only load I have on it now is a volt meter. It is powered for the 5V Rail.

    Thanks,

    Terry

  9. #9
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default

    I understood wrong, so you want to create adjustable voltage output with buffer (OP-amp)?

    Even with your heavy filtering, you'll have a nasty ripple on PWM out (= OP amp input). If you add diode (cathode to OP amp) in front of RC-filter, the you'll get rid of pull-down effect of PWM. This will require additional pull-down resistor (after RC) to sink current when you want to reduce voltage (= decrease PWM duty cycle). Also d1 function will need some re-tuning.

    Can you measure what is input voltage to OP amp? If that PIC output is 5V then problem is in your OP amp.

    BR,
    -Gusse-

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts