Shop OBEX P1 Docs P2 Docs Learn Events
using counters to realise a "set and forget" variable dutycycle PWM-Signal — Parallax Forums

using counters to realise a "set and forget" variable dutycycle PWM-Signal

StefanL38StefanL38 Posts: 2,292
edited 2014-11-03 07:57 in Propeller 1
Hi, counter-experts,

recently I was looking for democode to create a pwm-signal with variable duty-cycle.
(I mean High/Low-Ratio 0,01 to 0,99)

I only found code that were using the counters but still needs spin or pasm to keep things going.

This counter has 32 different operationmodes and there are two counters in each cog
Is there a way to setup the counter registers that the counters can create the pwm-signal at a fixed frequency but with
variable duty-cycle? Yes there is (see above)

BUT! Is there a way that the two counters per cog work together to create that signal without any code that sets up counter-registers
periodically? I mean "set and forget"

I did dive not very deep into programming the counters. But I guess if two counters interact it should be possible to realise that?

or not?

best regards

Stefan

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2014-11-03 06:11
    IIRC http://obex.parallax.com/object/482 does exactly that (one of its examples that is).
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-11-03 06:26
    StefanL38 wrote: »
    Hi, counter-experts,

    recently I was looking for democode to create a pwm-signal with variable duty-cycle.
    (I mean High/Low-Ratio 0,01 to 0,99)

    I only found code that were using the counters but still needs spin or pasm to keep things going.

    This counter has 32 different operationmodes and there are two counters in each cog
    Is there a way to setup the counter registers that the counters can create the pwm-signal at a fixed frequency but with
    variable duty-cycle? Yes there is (see above)

    BUT! Is there a way that the two counters per cog work together to create that signal without any code that sets up counter-registers
    periodically? I mean "set and forget"

    I did dive not very deep into programming the counters. But I guess if two counters interact it should be possible to realise that?

    or not?

    best regards

    Stefan

    The two interacting counter method does require an external gate but why aren't you considering using a cog for this, I mean the Prop has eight cogs for this very reason, so that they can become peripherals. No point in having them run idel.
    I have an 8-bit PWM that runs up to 7.6kHz and up to 32 channels from the one cog. If you are not using all the cogs then surely this is the logical course.
  • StefanL38StefanL38 Posts: 2,292
    edited 2014-11-03 07:57
    Hi Marko,
    Hi Peter,

    thank you very much for your quick answer.

    Peter: the object kuroneko posted has a variant that "does exactly that " using a cog.

    best regards
    Stefan


Sign In or Register to comment.