Shop OBEX P1 Docs P2 Docs Learn Events
Need pwm! — Parallax Forums

Need pwm!

RobofreakRobofreak Posts: 93
edited 2007-12-24 23:24 in Propeller 1
Hello all!
I just need someone to give me a link or something for a SPIN program/technique to·generate PWM. I'm relatively new to the Propeller (I built my programming board at the end of November) and I don't know of any function to generate PWM signals.

MERRY CHRISTMAS!

Thanks!
Austin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Austin Bowen,

Robo-freak.com

"One must watch out for mechanics. They start out with a sewing machine, and end up with the atomic bomb" - A quote from someone that I saw on Addall.com

Post Edited (Robofreak) : 12/24/2007 3:06:25 PM GMT

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-12-24 15:23
    No, not again!
    ---
    Austin, you can't be serious! Among the last 100 postings 20 had to do with PWM, giving explanations, links, etc. etc..

    Post Edited (deSilva) : 12/24/2007 3:28:25 PM GMT
  • RobofreakRobofreak Posts: 93
    edited 2007-12-24 16:32
    ... Wow... Okay, I'll go try to find a link somewhere.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Austin Bowen,

    Robo-freak.com

    "One must watch out for mechanics. They start out with a sewing machine, and end up with the atomic bomb" - A quote from someone that I saw on Addall.com
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-24 16:38
    I know how you feel I was new here once too and the search function on the forum isn't the best.

    Try here:

    http://forums.parallax.com/showthread.php?p=685997

    Also there are a couple of objects in the object exchange that might help.


    Post Edited (DynamoBen) : 12/24/2007 5:06:31 PM GMT
  • AleAle Posts: 2,363
    edited 2007-12-24 17:39
    deSilva. how about suggesting to make a sticky post about PWM ?, with your threads of course smile.gif

    Frohe Festtage.

    In the front page there are at least 2 threads about PWM:

    http://forums.parallax.com/showthread.php?p=696627
    http://forums.parallax.com/showthread.php?p=696682
    http://forums.parallax.com/showthread.php?p=667521
    http://forums.parallax.com/showthread.php?p=696702


    There are more [noparse]:)[/noparse]

    Post Edited (Ale) : 12/24/2007 5:45:27 PM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-24 17:52
    I have thought of the WIKI... It is quite extraordinary what a few of our comrades have accomplished here in such short a time.
  • RobofreakRobofreak Posts: 93
    edited 2007-12-24 18:12
    Thanks for all the links!

    Perhaps I'm wrong, but isn't PWM the action of simply bringing high, then bringing low, in this case, a pin, repeatedly (or vice versa)?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Austin Bowen,

    Robo-freak.com

    "One must watch out for mechanics. They start out with a sewing machine, and end up with the atomic bomb" - A quote from someone that I saw on Addall.com
  • AleAle Posts: 2,363
    edited 2007-12-24 18:13
    yes, with different widths...
  • RobofreakRobofreak Posts: 93
    edited 2007-12-24 18:15
    Okay, well, I designed a simple program to toggle pin 22 on and off, trying to get it to dim an LED, but there was no visable dimming to me... Is there something else I need to get it to dim and not just blink on and off rapidly? A capacitor perhaps?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Austin Bowen,

    Robo-freak.com

    "One must watch out for mechanics. They start out with a sewing machine, and end up with the atomic bomb" - A quote from someone that I saw on Addall.com
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-24 18:57
    *sigh* I started the wiki page - finally propeller.wikispaces.com/PWM
  • AleAle Posts: 2,363
    edited 2007-12-24 19:22
    Robofreak: Try with smaller duty cycles (with ratio) for the high pulse. If you integrate the signal for -inf to +inf will give you the resulting slice of "on time", well that was simple smile.gif
    The page at wikipedia en.wikipedia.org/wiki/Pulse-width_Modulation has a nice explanation smile.gif
  • BEEPBEEP Posts: 58
    edited 2007-12-24 23:24
    CON                                                       
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      
    PUB DimLed | duty, on, off
    
      duty := 50 ' set duty cycle, 1-99
      
      on   := 8_000 * duty  
      off  := 800_000 - on
    
      dira[noparse][[/noparse] 22 ] := 1 
      
      repeat
        outa[noparse][[/noparse] 22 ] := 1
        waitcnt(on+cnt)
        outa[noparse][[/noparse] 22 ] := 0
        waitcnt(off+cnt)
        
    
    




    CON                                                       
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      
    PUB DimLed | duty, on, off
    
      dira[noparse][[/noparse] 22 ] := 1 
    
      repeat
        repeat duty from 1 to 99
          on   := 8_000 * duty  
          off  := 800_000 - on
          outa[noparse][[/noparse] 22 ] := 1
          waitcnt(on+cnt)
          outa[noparse][[/noparse] 22 ] := 0
          waitcnt(off+cnt)
        repeat duty from 99 to 1
          on   := 8_000 * duty  
          off  := 800_000 - on   
          outa[noparse][[/noparse] 22 ] := 1
          waitcnt(on+cnt)
          outa[noparse][[/noparse] 22 ] := 0
          waitcnt(off+cnt)
            
    
    



    Wikipedia - PWM
    Wikipedia - Duty cycle

    Post Edited (BEEP) : 12/25/2007 4:03:43 AM GMT
Sign In or Register to comment.