PWM with CTRA, variable on time, off time?
T Chap
Posts: 4,223
I need to control something with PWM, and will need to experiment with the on time and off time.
I have been testing the CTRA but can only find methods to adjust the duty using 001100, making variable on and off times not possible. Maybe I have missed something.
The PWM.spin object does the job, but requires a cog.
Is there any solution for making a counter accomplish this goal without the assembly object and additional cog?
Thanks
I have been testing the CTRA but can only find methods to adjust the duty using 001100, making variable on and off times not possible. Maybe I have missed something.
The PWM.spin object does the job, but requires a cog.
Is there any solution for making a counter accomplish this goal without the assembly object and additional cog?
Thanks
Comments
No, not really. For a counter to generate true PWM on its own, it needs either to reload PHSx from two different sources or reload from one source and trigger a second counter for the alternate phase. The Propeller counters don't have either capability. Consequently, unless DUTY mode is adequate, PWM needs to be mediated in software. For even moderate PWM rates, this entails assembly code.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Originator) : 9/25/2008 5:43:44 PM GMT
-Phil
Addendum: The tricky part will be setting the relative phases in Spin. It can probably be done by doing a WAITCNT, clearing PHSA, then doing another WAITCNT before clearing PHSB. The latencies between the WAITCNTs and the clearing of PHSx should be equal. The relative phases will depend on the programmed delay of the second WAITCNT.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Post Edited (Phil Pilgrim (PhiPi)) : 9/25/2008 6:05:40 PM GMT
Originator, with an external XOR gate and two propeller pins, it could do the whole 0-100% range.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thanks TJ