Now testing PWM with peripheral python library.
from periphery import PWM
# Open PWM chip 0, channel 10
pwm = PWM(0, 10)
# Set frequency to 1 kHz
pwm.frequency = 1e3
# Set duty cycle to 75%
pwm.duty_cycle = 0.75
pwm.enable()
# Change duty cycle to 50%
pwm.duty_cycle = 0.50
pwm.close()
This is in the /sys/class/pwm/
directory
(venv) pi@controller:~$ ls -l /sys/class/pwm/
total 0
lrwxrwxrwx 1 root root 0 Sep 9 10:44 pwmchip0 -> ../../devices/platform/ff180000.pwm/pwm/pwmchip0
lrwxrwxrwx 1 root root 0 Sep 9 10:44 pwmchip1 -> ../../devices/platform/ff180020.pwm/pwm/pwmchip1
lrwxrwxrwx 1 root root 0 Sep 9 10:44 pwmchip2 -> ../../devices/platform/ff180030.pwm/pwm/pwmchip2
@RadxaYuntian as per your statement
Newer Linux kernel no longer assign fixed number to pwm controller, instead in a first come first serve manner. Hardware initialization order is non deterministic, so there is no guarantee that even with the same overlay enabled you will get same numbering all the time
Does this mean that PIN 13 i.e PWM3 will not always correspond to /sys/class/pwmchip2
? It can be any of pwmchip0 / pwmchip1 / pwmchip 2 ?
So we have to pass chip and channel in the periphery library
If I want to set PWM on PIN13 i.e PWM3
what values of x and y should I pass in this?
# Open PWM chip x, channel y
pwm = PWM(x, y)