Shop OBEX P1 Docs P2 Docs Learn Events
Sx28 dip, pwm — Parallax Forums

Sx28 dip, pwm

dmaruskadmaruska Posts: 13
edited 2009-08-12 12:24 in General Discussion
Hi,· I would like to use my SX28 to generate 3· - 4 PWM signals at the same time, and be independent of each other(other than base freq).· I would like to know if this can be done, and can I control the % up / down with a button push for each pwm output, 10 pushes up and 10 down?· Thanks for the guidance.· If I need to upgrade chip, I will need to purchase the next developers set for this as I have the SX28 developer PWB.

Regards,

Dave M.

Comments

  • RS_JimRS_Jim Posts: 1,771
    edited 2009-07-31 13:51
    Dave,
    Check out the sticky thread for Best of Threads, There are an number of threads on multiple PWM signals.
    RS_JIM
  • dmaruskadmaruska Posts: 13
    edited 2009-07-31 14:07
    OK, but how do I get there?· Not well versed in the forum navigation
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2009-07-31 14:26
    If you only needed one you might be able to use the built-in hardware timer. The SX28 has a single 8-bit timer and the SX48 has two 16-bit timers. Those work well for generating PWM.

    For your application the best method is probably putting the PWM routines in an ISR (Interrupt routine). You can setup the Interrupt internal as something that will work for all your PWM and just use it to update counters for each one of your PWM signals and toggle the output as needed for each counter.

    You can find some examples:

    http://forums.parallax.com/forums/default.aspx?f=7&m=310134&g=310158#m310158

    http://forums.parallax.com/forums/default.aspx?f=21&p=1&m=73867
  • natpienatpie Posts: 35
    edited 2009-07-31 15:38
    Here is a little test program I wrote a while ago to control a RGB led by a variable duty cycle. It should give you an idea of how to do multiply PWM from an interrupt. Its pretty easy. You have a counter for your your entire duty cycle. You compare this counter to variables of the time for your individual PWMs. if it is equal shut that output off. When your duty cycle counter rests turn all of your PWMs back on and start over. Then in your main program you just edit the variables to change the PWMs and you never have to think about it.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-07-31 17:01
    A friend of mine works for Disneyland and is creating a new element for one of their shows that uses the SX to modulate a bunch of LEDs. I took the program I wrote for him and gutted it of everything except the PWM stuff. This will handle up to eight PWM channels.
  • dmaruskadmaruska Posts: 13
    edited 2009-07-31 19:40
    Wow, thanks to all that have answered. It is all welcome.
  • dmaruskadmaruska Posts: 13
    edited 2009-07-31 19:45
    One more question,· Is there any port better than any other port to run the PWM on? A, B, C



    Regards,

    Dave M.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-08-01 00:19
    Neither port is any better than the others. If you know you're going to be limited to four bits you can use RA, otherwise your RB or RC.
  • PJMontyPJMonty Posts: 983
    edited 2009-08-01 19:48
    Dave,

    Since you seemed unclear earlier on how to find the sticky threads, I thought I'd help out. First, do you know what a "sticky" is? If you do, then you should be able to find them. Because of this, I'll assume you have no idea what a sticky is. It's simply a message that stays permanently at the top of the list of new messages in a forum.

    When you log onto the Parallax forums, you are presented with all the sub-forums. You (since you are posting here) then click on the "SX Microcontroller" sub-forum. Okay, when you arrive at this forum next time, take a look at the handful of messages that are always at the top of the list and have a blue BG. They are the stickies. Look for the one that says "Best SX Threads" and give it a read. Excellent stuff in there.

    Thanks,
    PeterM
  • dmaruskadmaruska Posts: 13
    edited 2009-08-02 20:41
    Thanks for the help...
  • dkemppaidkemppai Posts: 315
    edited 2009-08-12 12:24
    dmaruska said...

    One more question,· Is there any port better than any other port to run the PWM on? A, B, C



    Regards,

    Dave M.

    Yes, Port A is supposed to have symmetrical drive capability (pull up and pull down are the same), at least according to the data sheet. Depending on what you are doing with the PWM, this may be good to know...



    -Dan



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    "A saint-like quantity of patience is a help, if this is unavailable, a salty vocabulary works nearly as well." - A. S. Weaver
Sign In or Register to comment.