-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use two PWM channels at the same time #84
Comments
Yes, because right now the clock that generates the pwm is being killed every time a new pwm is started, see here (I was more interested in building something to easily generate patterns than in the vanilla pwm, so a few basic thing were never implemented). If the frequency/ns parameter is kept the same (the duty cycle doesn't matter) this should not be needed, so it could be either removed, or better performed only the first time startPWM is called checking a flag. This was discussed with Kaiede some time ago in #73, and in the end in his improved fork he cleaned up the implementation reducing the number of moving parts and removing the need for the clock reset. |
Cool. Swapped in Kaiede's version and it works fine. I used an online calculator to convert my desired frequency from 20Khz to 50000 nanoseconds but I wanted to confirm with you that that is the correct nanosecond value for that frequency. |
Yep, correct, 1Hz=1/1sec, so 1/20000Hz gives you 50 microseconds or 50000 nanoseconds. Btw, since this could be a common annoyance for a lot of people I plan to fix this (and a few other things) and make a new release. |
I'll watch for the new release! Thanks! |
I was wondering if this improvement was eventually made to SwiftyGPIO. I've run into the same problem using SwiftyGPIO so I'm assuming not, but wanted to confirm before I switch over to SingleBoard. |
Board Type
RaspberryPi3
Operating System
Ubuntu Mate 16.04
Swift Version
4.1.3, pre-built
Description
Attempting to drive a motor controller (https://www.pololu.com/product/3754) using PWM. I have one channel each for the right and left sides of my robot vehicle. When I
startPWM
to one channel, the other channel stops. This occurs even if the period and duty are the same with eachstartPWM
call. Any way to overcome this behavior?The text was updated successfully, but these errors were encountered: