Shop OBEX P1 Docs P2 Docs Learn Events
Multiple PWM outputs from one COG? — Parallax Forums

Multiple PWM outputs from one COG?

godzichgodzich Posts: 74
edited 2008-09-02 12:27 in Propeller 1
Hi,

I am completely new with the Propeller, so please bear with me.

I have the prototype kit and have not powered it yet, just learning about this interesting technology by doing some serious reading.

Before I go forward using the propeller chip -please enlighten me - is the following possible:

1. I need 24 PWM outputs with fixed frequency
2. The PWM frequency should be in the 600Hz...1200Hz range
3. The PWM resolution need to be at least 10 bits, preferrably 12-bits
4. The PWM outputs needs to be interleaved, so that the turn on is timely divided between the channels (no simultaneous turn on of the waveforms)
5. Can this functionality be placed in one COG, or how many are required?

I appreciate any comments, either based on experience or just wild guesses!

Thanks in advance for your help [noparse]:)[/noparse] I hope to become also a propellerhead some day [noparse];)[/noparse]

Christian



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The future does not exist - we must invent it!

Post Edited (godzich) : 9/1/2008 10:49:19 AM GMT

Comments

  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2008-09-01 14:19
    A good read to get started on PWM with the Prop Is Phil's post.:

    8-channel PWM output, one cog, 23KHz for 8-bit resolution (updated 17 Jul 08)

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

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Aka: CosmicBob
  • AribaAriba Posts: 2,687
    edited 2008-09-01 22:40
    In a fast Assembly loop, you can check every PWM On/off point against a timer:
    loop
            cmp   timer,pw1on  wz
      if_z  or    outa,pin1mask
            cmp   timer,pw1off  wz
      if_z  andn  outa,pin1mask
    
            cmp   timer,pw2on  wz
      if_z  or    outa,pin2mask
            cmp   timer,pw2off  wz
      if_z  andn  outa,pin2mask
    
      .... and so on for pwm 3..24
    
            add    timer,#1
            and    timer,MaxCycles
            djnz   count,#loop
    
    


    with that you can produce 24 interleaved PWMs. If you set MaxCycles to 1023 then you get 10bit resolution.
    The compares for every PWM needs 16 clocks * 24 PWMs + perhaps 16 for the loop = 400 clocks.
    Then the PWM frequency is 80MHz / 400 / 1024 = 195 Hz.
    In other words: it is not possible with 1 cog. You need 3 .. 4 cogs for 600Hz and 10Bit resolution.

    The code above is only for estimating the needed clock cycles and not a complete program. It also lacks the rdlongs for reading the PW parameters from HubMemory.

    Andy
  • godzichgodzich Posts: 74
    edited 2008-09-02 05:30
    Andy & Bob

    THX for your fast replies. This seems to be great forumn with nice and skilled people [noparse]:)[/noparse]

    I might be able to relax my frequency and channel requirement. With this assebly loop it should the be possible to produce 18 channels at 10 bit resolution at a PWM frequency at about 250 Hz. That could be still ok. The idea using the vide generator producing 8 pwm outputs is also very interesting. However, I would need then 3 COGs for 18 channels. In my application I probably need all the other GOGs for other control purposes, so the assembly approach using only one is probably the way I go. But there is still lots to learn before I'm that far [noparse]:)[/noparse]

    Just a little outside the topic:

    Are the Parallax software tools compatible with Vista x64?
    =====================================

    Yesterday evening I dowloaded the SW and the installation went fine. When I tried to lauch the application a blue screen flashed and my PC rebooted. What the heck? I was too tired to investigate, and continue today after my work... [noparse]:([/noparse]

    Thanks for all your kind help.

    Christian

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The future does not exist - we must invent it!
  • macrofusemacrofuse Posts: 3
    edited 2008-09-02 12:27
    You also have the option of "overclocking" the propeller, seems to accept 20% quite happily.
    Just swap the xtal from 5MHz to a 6MHz and get more "breathing room".

    Kaj

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If the propeller stops - the pilot starts sweating...
Sign In or Register to comment.