PWM object not enough control
grasshopper
Posts: 438
Any one know of a way that i can modify the PWM object for better control? Instead of 0 - 100 I am looking for something that I can adjust from 0 - 10_00 or even better if possible.
Some things i thought of changing were below
Any ideas if this is the right aproach?
Some things i thought of changing were below
PUB SetDuty(counts) if (counts < 0) counts := 0 if (counts > 10_000) counts := 10_000 sDuty :=counts*sPeriod/10_000
Any ideas if this is the right aproach?
Comments
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Just a few PropSTICK Kit bare PCBs left!
Post Edited (TChapman) : 12/18/2008 8:45:25 PM GMT
Oddly enough, I was just working on that for a motor driver. I use the PWM to drive the base of a TIP120, and it gives a very nice ramp from about 10 Hz up to 200 Hz, apparently linear in duty cycle. This is taken from other files on the Parallax site, I claim no originality or cleverness in the modifications. It is here buzzing away beside me as I type!
Note that I changes the start method as well for my own style. I also added some parentheses in the driver to avoid overflows.
Cheers!
Thanks all. I think I got it working better now. Using the modified code works.