Shop OBEX P1 Docs P2 Docs Learn Events
Using PWM or psuedo PWM on SX28, all pins — Parallax Forums

Using PWM or psuedo PWM on SX28, all pins

T ChapT Chap Posts: 4,223
edited 2009-06-02 18:49 in General Discussion
I built a board for a friend a few years back with an SX28, so that each output controls a transistor switching on and off LEDs, using simple on>pause>off>pause for each output.

He asked me how it could be done that any or all pins could actually fade the LEDs on for his product. I don't know the chip at all, and can't think of a solution.

Is there any way to do such a thing where any or all pins can emulate or use PWM so that the On time increments towards full on?

Post Edited (TChapman) : 6/1/2009 8:36:25 PM GMT

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-01 21:26
    The program I've attached should help. Make sure you have the latest version of SX/B.

    [noparse][[/noparse]Edit] Updated for 4MHz internal osc.

    Post Edited (JonnyMac) : 6/1/2009 10:33:32 PM GMT
  • T ChapT Chap Posts: 4,223
    edited 2009-06-01 21:36
    Thanks! I'll check it out.

    Oh, using internal osc, would I just change the speed and it still works ok?
  • PJMontyPJMonty Posts: 983
    edited 2009-06-01 22:25
    TChapman,

    Try Jonny's program using the SX-Key to generate the clock at 20 MHz. Verify it's working for you. Then, try changing the clock speed (the SX-Key can change output a wide range of clock freqs) and see if it works or not. If it's not working, try and figure out why it's not working. In other words, do some experimenting, have some fun, and learn something new in the process.

    If there are problems trying to get it to work at lower freqs (such as 4 MHz), post a question explaining what you did, the results you got, and see who can help. I think you'll find you learn a lot more by trying some experiments first and asking questions when you get stuck.

    Thanks,
    PeterM
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-01 22:30
    Nope, the ISR will have a problem running at that rate with a 4MHz clock -- I've updated the program above.

    [noparse][[/noparse]Edit] Whoops... I should check to see if others have answered before posting, especially when posting fixes.

    Post Edited (JonnyMac) : 6/1/2009 10:35:48 PM GMT
  • T ChapT Chap Posts: 4,223
    edited 2009-06-01 22:34
    Thanks Johnny.
  • PJMontyPJMonty Posts: 983
    edited 2009-06-01 22:40
    TChapman,

    Bummer. Now you know nothing more than you did before. Oh well, perhaps next time you'll dig in and try some experimenting first. I guarantee you'll be more knowledgeable for the effort.

    This is an old saying, but it's quite true:

    “Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime”

    Thanks,
    PeterM
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-01 22:54
    You're welcome, TChahpman, but Peter's right: you really should experiment for yourself as that's the best way to learn. He's very good and I'm pretty good because we experiment all the time.
  • T ChapT Chap Posts: 4,223
    edited 2009-06-01 23:39
    I really wanted to know if the chip would do what the guy wanted it to do. I have absolutely no interest in, or time to learn the SX, I would simply hire it done if it would work, but I know where you are coming from and appreciate the suggestion.

    PJ, not to be disrespectful at all, as you are clearly an asset to the forums, but you have to understand that I don't want to understand the SX, I am extremely busy with much bigger things things that learning a chip I'll never use, so the idea of me getting anything from it is a non issue. Quite honestly, I already was prepared to pay the code to get written for the guy, if it was capable of the task. Nowhere in my post does it suggest that anyone here write the code or show an example of it. It was a question of whether it was possible. So I find the lecture a bit over the top.

    For that matter, should Johhny want to be compensated for his efforts within reason, I'll get that handled as well no problem

    Post Edited (TChapman) : 6/1/2009 11:49:21 PM GMT
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-02 01:07
    Nobody posting in these forums expects compensation -- if you want to hire me for more detailed work I'm available.
  • PJMontyPJMonty Posts: 983
    edited 2009-06-02 18:49
    TChapman,

    I know you're an extremely busy person with much bigger things to do, so I'll keep it short. I promise to never go over the top and try to help you be a more knowledgeable person again. Mea culpa.

    Thanks,
    PeterM
Sign In or Register to comment.