Warning message

The Propeller Object Exchange system is decommissioned and replaced with a GitHub repository to house the same existing and future Propeller objects. As of 12/5/2019, this site is read-only. You can continue to browse and download objects from here for a limited time; however, please begin using the Parallax Propeller repository for future reference.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Request group membership
By: created: 2013-04-12 | updated: 2015-11-10

Updated 10-November-2015.  Revision allows higher frequency operation, better control of the offset phase, accounting for delay in starting the two counters.

This object generates standard PWM, selectable frequency and high/low ratio, using the cog counters. Once running, no program intervention by spin or pasm is required until the frequency or period need to be changed. This requires two cog counters in NCO mode, and the PWM is achieved by addressing them both to the same pin and running them both at the same frequency with offset phases. A third cog counter is used as a dumb inverter to provide a comlimentary output over the full 0% to 100% range.   There are two separate objects here. 

"PWM_3ctrx_spin_demo" starts the PWM using spin only.   Demo asks for pin, frequency (Hz) and percent high width.  The complimentary outputs appear on pin and pin+1

"PWM_3ctrx_pasm_demo" starts a pasm cog which sets up and starts the counters in that cog.   Demo asks for pin, frequency (Hz) and width as proportion 0 to 256.  The complimentary outputs appear on pin and pin+1


Original File Upload
Binary Data PWM_3ctrx_spin_demo.spin6.64 KB
Binary Data PWM_3ctrx_pasm_demo.spin6.55 KB