Inverting the o/p of hardware PWM


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Brussels, Belgium
    Posts
    104

    Default Inverting the o/p of hardware PWM

    I'm working up a project to use 3 hardware PWM modules. Probably on a 16F777. The PWM signal goes into the signal pin of a LUXEON Buckpuck. The trouble is that that pin thinks 5V is "OFF" and 0V is "ON" for the led. So a 100% duty cycle would have the led off all the time and vice versa for a 0% duty cycle.

    I could just put a line in to subtract my desired duty cycle count from 1024 (if in 10bit mode) and invert it that way, but is there an easier way to just invert the output of the PWM module ?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Short answer ... NO.

    There isn't really a 10-bit mode. Depending on the frequency being used, there may only be 6-7 bits of resolution. Then instead of subtracting from 1024, you'd have to subtract from the maximum resolution.

    If you have PBP2.50 which allows all 3 HPWM's. You could subtract from 255, because the HPWM command always scales it to the available resolution.

    It could be done by modifying the Library, but you probably don't want to go there.

    There's always the 74HC04.
    <br>
    DT

  3. #3
    Join Date
    Feb 2006
    Location
    Brussels, Belgium
    Posts
    104


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel, it's only a couple of extra lines of code so not too difficult. 3 PWM modules - perhaps I wasn't being clear, I didn't mean three times HPWM, but using the three different embedded PWM modules in a PIC such as 16F777 and addressing them directly.

    Andrew

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by AndrewC
    perhaps I wasn't being clear, I didn't mean three times HPWM, but using the three different embedded PWM modules in a PIC such as 16F777 and addressing them directly
    Yikes,

    Then maybe my answer wasn't clear either, cause that's what I was talking about as well.

    I could be more specific, if you were too.

    What frequency are you running the PWM at?
    What OSC?
    Which version of PBP?
    PM or MPASM?
    <br>
    DT

  5. #5
    Join Date
    Feb 2006
    Location
    Brussels, Belgium
    Posts
    104


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    Basically following Bruce's example in this thread:

    http://www.picbasic.co.uk/forum/showthread.php?t=1770

    PBP: 2.46
    20MHz
    MPASM

    Hopefully I'm not missing something obvious - it has happened before and will doubtless happen again A 16F777 has 3 PWM modules and I'll control them directly.

    thanks, Andrew

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    AndrewC, Why not just use a transistor and a couple of resistors?

    Dave Purola,
    N8NTA

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by AndrewC View Post
    Hi Darrel,
    Basically following Bruce's example in this thread:
    http://www.picbasic.co.uk/forum/showthread.php?t=1770
    Oh,OK.
    According to that, it's running the PWM at the absolute minimum frequency, which gives exactly 10-bit resolution.

    From you're last post I see that it's not continuously changing the dutycycle. So I don't need to talk about "glitch-free" either.

    So it looks like your original idea from post #1 is the way to go, with 1 exception.
    Subtract from 1023 instead of 1024.
    <br>
    DT

Similar Threads

  1. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  2. Hardware PWM Question?
    By jhorsburgh in forum General
    Replies: 1
    Last Post: - 18th August 2008, 03:07
  3. PWM: Vernacular/Function (Newbee)
    By TerryN in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd July 2008, 16:58
  4. 3 Hardware PWM.
    By sirvo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th January 2008, 12:21
  5. pics with 3 hardware PWM ports
    By CBUK in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th August 2004, 00:14

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