PWM enhancements in 5.07.06 (undocumented)
| Author | Message | ||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11635 |
The 5.07.06 release notes and manual document the ability to optionally invert the PWM channels but that was actually part of a much more powerful change to PWM that is included in 5.07.06 (get the very latest download from Geoff's site). This change is difficult to document and late breaking hence the omission in the current manual. The PWM command is modified as follows: PWM channel, frequency, [dutyA] [,dutyB] [,deferredstart] The new parameter "deferredstart" when set to 1 prepares the PWM channels as before but does not start the output running. This is to avoid any undesirable startup artefacts There is a new sub command PWM SYNC [channel0offset] [,channel1offset] .......[channel7offset] This initiates the PWM on channels where a deferred start was defined or just syncs exisitng running channels. However, the power comes in the ability to offset the channels one to another (defined as a percentage of the time period as per the duty cycle - can be a float) In this thread a method is described to create two signals with one starting after the other and ending before it. With the new functionality this is easy without pokes or changing frequency. setpin GP0,PWM setpin GP2,PWM PWM 0,10000,50,,1 PWM 1,10000,40,,1 PWM SYNC 0,5 ![]() The same method can create a quadrature clock setpin GP0,PWM setpin GP2,PWM setpin GP4,PWM setpin GP6,PWM PWM 0,10000,25,,1 PWM 1,10000,25,,1 PWM 2,10000,25,,1 PWM 3,10000,25,,1 PWM SYNC 0,25,50,75 Unfortunately I don't have a 4 channel scope ![]() The SYNC command can also be used when the channels are already running e.g. setpin GP0,PWM setpin GP2,PWM PWM 0,10000,50 PWM 1,10000,50 do for i=0 to 99 PWM SYNC 0,i pause 50 next loop Edited 2023-01-09 18:46 by matherp |
||||