-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Set PWM frequency and duty cycle in microseconds #85
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
Comments
Frequency already is covered in #13 . Handling microseconds is a good point and I'll leave this open for that. |
After implementing |
While it's for Servos you should be able to use this for ESCs as well: https://github.com/adafruit/Adafruit_CircuitPython_Motor/blob/master/adafruit_motor/servo.py |
Thank you sir, I'm already using this library. But which method would you suggest? |
The current
nativeio.PWMOut
is pretty nice for things like controlling LED dimming or motor speed. However it's hopelessly inadequate for controlling hobby servos or BLDC ESCs.For controlling hobby servos I need to be able to specify the frequency (for instance, most analog servos expect 50Hz, digital servos and ESCs may go up to 300Hz or maybe even higher).
Setting the duty cycle as percentage of the total period (converted to 0-255) is also fine for LEDs, but for servos, which typically expect duty cycles between 1000µs and 2000µs with period of 20000µs that gives very poor resolution, makes it harder to calculate the right value, and gives an opportunity for rounding errors. It would be much nicer to be able to set the duty cycle in terms of absolute time units, like microseconds.
The text was updated successfully, but these errors were encountered: