Guys please bear with me. I am new to linux and beagle embedded system.
I am trying to set PWM on beagle y AI. i followed all the possible info i could but failed to get the PWM signal.
what i have done?
I have got overlays for 4 PWM pins as follows.
boris@BeagleBone:~$
sudo beagle-version | grep UBOOT
UBOOT: Booted Device-Tree:[k3-am67a-beagley-ai.dts]
UBOOT: Loaded Overlay:[k3-am67a-beagley-ai-pwm-ecap1-gpio16.kernel]
UBOOT: Loaded Overlay:[k3-am67a-beagley-ai-pwm-ecap2-gpio18.kernel]
UBOOT: Loaded Overlay:[k3-am67a-beagley-ai-pwm-epwm0-gpio15.kernel]
UBOOT: Loaded Overlay:[k3-am67a-beagley-ai-pwm-epwm1-gpio20.kernel]
following was the test i performed.
boris@BeagleBone:~$ echo 0 > /sys/class/pwm/pwmchip0/export
boris@BeagleBone:~$ echo 100000 > /sys/class/pwm/pwmchip0/pwm0/period
boris@BeagleBone:~$ echo 5000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
boris@BeagleBone:~$ echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
but still no signle on any of the Pins.
any help in this regard will be much appriciated.
Use another board like the pico rp2040 that has hardware PWM, talk to it via UART. All you will do with some of this stuff is chase your tail. Use a 2 board solution and you will be working on your own project and not fiddling around with someones headaches. Use the beagley for your HMI and other edge connection needs, let the RP2040 handle deterministic aspects of the system. In the end you will have a solid and stable system.
Also, if your system is critical use a PLC that has an open ethernet bus and talk to it, again use the beagley as the HMI / GUI / connectivity hub and talk with a PLC over ethernet.
Thanks for your response. but i do want to use pwm channel from beagle y ai.
BTW if beagle cant handle two pwm channels then why would they have this module incorporated.
1 Like
I am having similar issues with the ai64 I’ll let you know if I make any progress.
1 Like
thank you. appreciated your kind words.
i have solved the issue. here are the steps i followed.
-
updated the beagle y ai kernel and debian to latest version.
-
added uboot overlays.
boris@BeagleBone:~/Desktop/TEST$ sudo beagle-version | grep UBOOT
UBOOT: Booted Device-Tree:[k3-am67a-beagley-ai.dts]
UBOOT: Loaded Overlay:[k3-am67a-beagley-ai-pwm-epwm0-gpio15-gpio14.kernel]
UBOOT: Loaded Overlay:[k3-am67a-beagley-ai-pwm-epwm1-gpio13.kernel]
-
And followed this pwm help. Pulse Width Modulation (PWM) — BeagleBoard Documentation
in previous kernel version i was not able to get this working.
and here is my servo test pwm code for python.
import os
import time
def write_pwm_sysfs(path, value):
os.system(f"echo {value} > {path}")
Full device path
pwm_path = “/dev/hat/pwm/GPIO13”
Set period (20ms = 50Hz)
write_pwm_sysfs(f"{pwm_path}/period", 20000000)
Set duty cycle for 90° (1.5ms pulse)
write_pwm_sysfs(f"{pwm_path}/duty_cycle", 1500000)
Enable PWM
write_pwm_sysfs(f"{pwm_path}/enable", 1)
print(“Moved to 90°”)
time.sleep(1)
Move to 0° (0.5ms)
write_pwm_sysfs(f"{pwm_path}/duty_cycle", 500000)
print(“Moved to 0°”)
time.sleep(1)
Move to 180° (2.5ms)
write_pwm_sysfs(f"{pwm_path}/duty_cycle", 2500000)
print(“Moved to 180°”)
time.sleep(1)
Back to 90°
write_pwm_sysfs(f"{pwm_path}/duty_cycle", 1500000)
print(“Back to 90°”)
time.sleep(1)
Turn off PWM
write_pwm_sysfs(f"{pwm_path}/enable", 0)
print(“PWM disabled”)
I hope this helps you .
1 Like