AML-S905X-CC Le Potato has 5 available hardware PWM multiplex over 6 pins. The hardware PWMs are grouped in chip pairs accessible via pwm0 and pwm1.
AO_A AO_B on c8100550
A on c1108550
E F on c11086c0
You cannot enable overlapping overlays within the grouped pair. This means you can not individually enable pwm-e and pwm-f. You have to enable pwm-ef to have both running at the same time.
In terms of pin routing:
AO_A on Pin 11 controlled via c8100550 pwm0
AO_B on Pin 12 or 13 controlled via c8100550 pwm1
E on Pin 32 controlled via c11086c0 pwm0
A on Pin 33 controlled via c1108550 pwm0
F on Pin 35 controlled via c11086c0 pwm1
For AO_A on pin 11, you must move the jumper for 2J1 to the edge of the board from the stock jumper position to connect the GPIO to the 40 pin header pin 11.
sudo ldto enable pwm-{x} # replace x with one of the dtos in list above
ls -al /sys/class/pwm # see the pwmchip{n} to hardware mapping
echo {0,1} | sudo tee /sys/class/pwm/pwmchip{n}/export
echo 1000000 | sudo tee /sys/class/pwm/pwmchip{n}/pwm{n}/period
echo 500000 | sudo tee /sys/class/pwm/pwmchip{n}/pwm{n}/duty_cycle
echo 1 | sudo tee /sys/class/pwm/pwmchip{n}/pwm{n}/enable
I moved the jumper over one pin to the edge, updated my board, ran commands below and wasnt able to get anything from my servo. i am connected to gpio pin 11, power on pin 4, and ground on pin 6. i used multiple brand new servos to rule out defected hardware. any thoughts?
update: Just kidding i looked over the " AO_A on Pin 11 controlled via c8100550 pwm0" part. after echoing 0 instead of 1 to /sys/class/pwm/pwmchip0/export, that took care of the problem. Any thoughts on how to reverse the direction?
I try both solutions. And still, I wasn´t able to set enable on pins 32, 33 and 35. After rebooting the system I was able to write to pmw0/enable (for pin33 and 32). However, for some reason, I still cannot write (write error: Invalid argument) to pmw1/enable for pin35.
Aditional info
Like @technoryt, I was always able to set period and duty_cycle for all pins. I only had issues while setting enable (echo 1 > /sys/class/pwm/pwmchip{x}/pwm[n}/enable ) for pins 32, 33 and 35.
I only have one active DTO each time. And I’m using rasbian.
Actually, I rebooted after using ldto merge (so that I do not need to use ldto activate, I don’t think I changed anything else). Now I can successfully use all four PWM lines. I started from the Ubuntu 22.04 Desktop image.
@Samuel: did you manage to use the PWM lines from a non-root user? If I try to add my user to the gpio group as mentioned by @librecomputer, I have the error that the group does not exist. All the directories under /sys/class/pwm are all owned by root:root.
ubuntu@lepotato:~$ sudo adduser ubuntu gpio
[sudo] password for ubuntu:
adduser: The group `gpio' does not exist.
@librecomputer: Regarding your last post. All the files under sys/class/pwm/pwmchip{X} belong to the gpio group. Except for the pwmchip{X}, which are owned by root group. So, I tried to change the group of these directories (assuming that it should be gpio) but nothing changed:
inl@raspberrypi:~ $ sudo chgrp gpio /sys/class/pwm/pwmchip0
inl@raspberrypi:~ $ ls -l /sys/class/pwm/
total 0
lrwxrwxrwx 1 root root 0 Jan 18 16:43 pwmchip0 → …/…/devices/platform/soc/c1100000.bus/c11086c0.pwm/pwm/pwmchip0
By way, it is not very clear to me which group should own these directories. Should It be gpio?
For some reason, now I can control pin35, but cannot control pin33 anymore (refer to my previous post). Why could this be?
@technoryt: Regarding your question, I believe so, at least for pins 12 and 13. Relative to your comment, my user was already a member of gpio group.
Hello, I am new to this space and have no idea what do I do. So I tried enabling pin 32 and 33.
ls -al /sys/class/pwm # see the pwmchip{n} to hardware mapping
echo {0,1} | sudo tee /sys/class/pwm/pwmchip0/export
echo 1000000 | sudo tee /sys/class/pwm/pwmchip0/pwm0/period
echo 500000 | sudo tee /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 | sudo tee /sys/class/pwm/pwmchip0/pwm0/enable
Overlay pwm-ef: already exists
total 0
drwxr-xr-x 2 root root 0 Dec 31 1969 .
drwxr-xr-x 75 root root 0 Dec 31 1969 ..
lrwxrwxrwx 1 root root 0 Apr 8 13:48 pwmchip0 -> ../../devices/platform/soc/c1100000.bus/c11086c0.pwm/pwm/pwmchip0
lrwxrwxrwx 1 root root 0 Apr 8 13:52 pwmchip2 -> ../../devices/platform/soc/c1100000.bus/c1108550.pwm/pwm/pwmchip2
0 1
tee: /sys/class/pwm/pwmchip0/export: Invalid argument
tee: /sys/class/pwm/pwmchip0/pwm0/period: No such file or directory
1000000
tee: /sys/class/pwm/pwmchip0/pwm0/duty_cycle: No such file or directory
500000
tee: /sys/class/pwm/pwmchip0/pwm0/enable: No such file or directory
1
I am not sure what is wrong and why, or even the right way to do that. Also, what do I use for python to control PWM? Is periphery good? Also weird thing is that It says in spreadsheet that port 32 is controlled by chip 1 and not 0…
You have to echo 0 or 1 based on which PWM you want to export. {0,1} is an invalid entry. You have to replace all things in {} with the proper value as outlined in the OP.
Ok that worked. But how do I control it? When I try using periphery, it gives me
periphery.pwm.PWMError: [Errno 19] Exporting PWM channel: No such device
I do not understand channels and how do I find right one for pin 32.
Here is what I got from activating pin 32:
yasushiko@raspberrypi:~ $ sudo ldto enable pwm-e # replace x with one of the dtos in list above
ls -al /sys/class/pwm # see the pwmchip to hardware mapping
echo 0 | sudo tee /sys/class/pwm/pwmchip0/export
echo 1000000 | sudo tee /sys/class/pwm/pwmchip0/pwm0/period
echo 500000 | sudo tee /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 | sudo tee /sys/class/pwm/pwmchip0/pwm0/enable
Overlay pwm-e: applied
total 0
drwxr-xr-x 2 root root 0 Dec 31 1969 .
drwxr-xr-x 87 root root 0 Dec 31 1969 ..
lrwxrwxrwx 1 root root 0 Apr 8 19:28 pwmchip0 -> ../../devices/platform/soc/c1100000.bus/c11086c0.pwm/pwm/pwmchip0
0
1000000
500000
1
But if I want to control it through periphery, how do I do that? I want to control Victor SPX. Also, could I control two of them at the same time? What is chip, and what is channel when I set up periphery in the code down below?