Quantcast
Viewing all articles
Browse latest Browse all 5288

Troubleshooting • Re: Raspberry Pi 5 PWM control method inquiry

Hardware PWM is available on GPIO12, GPIO13, GPIO18 and GPIO19, though it's a little fraught with footguns (particularly locating the correct /sys/class/pwmchip* and ensuring the correct alt modes are set on the pins). I just fought against these and slapped up a gist to remind future me of these pitfalls, see: https://gist.github.com/Gadgetoid/b92ad ... bf0e09d569

It's my intention to write a new Python library for interfacing with Linux PWM since:

1. I expect PWM GPIO will eventually be merged, allowing arbitrary PWM on any pin in a cross-compatible manner (see: viewtopic.php?p=2195130)
2. I expect (or hope?) RP1 PIO PWM will also allow arbitrary "hardware" PWM on any pin
3. I kinda need PWM back for hardware products Image may be NSFW.
Clik here to view.
:cry:


Sweeping a servo jitter-free should be trivial for this. You'd want a period of 20,000,000 (20ms) and a duty_cycle of 1,000,000 to 2,000,000 (1-2ms) since Linux PWM expects a period in nanoseconds, and also a duty cycle (from 0 to period) in nanoseconds.

Software PWM outside of the official Linux kernel module is a fool's errand. The kernel PWM GPIO module significantly outperforms userspace on jitter and accuracy, and even more significantly resists userspace load, which can turn a soft PWM signal to useless mush otherwise.

Statistics: Posted by gadgetoid — Wed Mar 06, 2024 2:33 pm



Viewing all articles
Browse latest Browse all 5288

Trending Articles