PWM On Beaglebone black with Jessie

964 views
Skip to first unread message

Walter Schilling

unread,
Mar 14, 2016, 10:13:24 AM3/14/16
to BeagleBoard
Good evening.

I am currently using the latest beaglebone black debian image, and I am trying to get pwm to work on the board using the instructions in Molloy's Exploring the Beaglebone.  Unfortunately, shall we say, it doesn't seem to be working.  I am unable to see the bone_capemgr.9 directory to setup the SLOTS export.  I suspect this may be due to changes between Debian releases.  With that being the case, is there some location that has the current instructions for setting up the PWM module with the current image?

Walt

Chad Baker

unread,
Mar 14, 2016, 11:23:38 AM3/14/16
to beagl...@googlegroups.com
Walt,
Try using a "*" in place of the "9".
Chad
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Walter Schilling

unread,
Mar 14, 2016, 3:18:33 PM3/14/16
to BeagleBoard
I don't even see anything resembling bone_capemgr.  This is my /sys/devices directory:

root@beaglebone:/sys/devices# ls
armv7_cortex_a8  
platform  
software  
tracepoint
breakpoint  
soc0   
system    
virtual
root@beaglebone:/sys/devices# 

Robert Nelson

unread,
Mar 14, 2016, 3:31:48 PM3/14/16
to Beagle Board
On Mon, Mar 14, 2016 at 2:18 PM, Walter Schilling <schi...@msoe.edu> wrote:
> I don't even see anything resembling bone_capemgr. This is my /sys/devices
> directory:
>
> root@beaglebone:/sys/devices# ls
> armv7_cortex_a8
> platform
> software
> tracepoint
> breakpoint
> soc0
> system
> virtual
> root@beaglebone:/sys/devices#

With "4.1" it's

/sys/devices/platform/bone_capemgr/slots

see: https://github.com/beagleboard/bb.org-overlays/

If you want 3.8, to match Derek's book:

Use: Debian 7.9 from:

http://beagleboard.org/latest-images

Regards,


--
Robert Nelson
https://rcn-ee.com/

William Hermans

unread,
Mar 14, 2016, 6:22:49 PM3/14/16
to beagl...@googlegroups.com
If I were you Walter, I'd just learn how to adapt DR Molloy's instructions to 4.1.x. These newer kernels I've found to be noticeably more responsive . . .

Walter Schilling

unread,
Mar 15, 2016, 12:32:21 PM3/15/16
to BeagleBoard
Thanks.  That helps quite a bit.  I've still not quite got everything working, but I'm making headway.  Now to find the magic decoder ring of pwm chips to pins and ports.

WZ9V

unread,
Mar 15, 2016, 2:51:44 PM3/15/16
to BeagleBoard
You might want to contact DR Molloy via his website he may have adapted the samples and put them on his site.

William Hermans

unread,
Mar 15, 2016, 7:45:12 PM3/15/16
to beagl...@googlegroups.com
I could probably walk through how to setup an use PWM on Debian with a 4.1.x kernel. Problem is that I would have no real way of testing that what I'm doing is actually outputting what I'd expect.

Walter Schilling

unread,
Mar 17, 2016, 10:47:39 PM3/17/16
to BeagleBoard
OK, so here is where I am at:
#1 I wrote the following script, and, well it worked great...  Until I had to reboot my machine:

#!/bin/bash
# SE3910 Real Time Systems
# PWM Bash shell script.
# Author: W. Schilling
# This script will enable PWM on the beaglebone connected to ECAPPWM0.
# It will set the duty cycle to the value passed in, which is a value between 1 and 10000.

# Setup the pin as a PWM pin.
config-pin P9.42 pwm

# Export the control for the device, creating the directory structure that we w$
echo 0 > /sys/class/pwm/pwmchip0/export

# Setup the period for PWM to be 10000 to make things nice and easy to work wit$
echo  10000 > /sys/class/pwm/pwmchip0/pwm0/period

# Setup the duty cycle to the value passed in as $1
echo $1 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle

# Enable pwm
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

However, when I rebooted my machine, the pin failed to toggle.  I believe I inadvertently did something with capes that wasn't enabled when I first tried it.  I then tried this script on my home beaglebone, running Robert Nelson's image bone-debian-8.3-lxqt-4gb-armhf-2016-02-21-4gb.img.  This one, however, fails with the following:

root@beaglebone:~# ./pwm2.sh 1000
P9_42 pinmux file not found!
cape-universala overlay not found
run "config-pin overlay cape-universala" to load the cape
./pwm2.sh: line 12: echo: write error: Device or resource busy
./pwm2.sh: line 15: /sys/class/pwm/pwmchip0/pwm0/period: No such file or directory
./pwm2.sh: line 18: /sys/class/pwm/pwmchip0/pwm0/duty_cycle: No such file or directory
./pwm2.sh: line 21: /sys/class/pwm/pwmchip0/pwm0/enable: No such file or directory
root@beaglebone:~#

I've tried the following, which results in different errors but still errors:
root@beaglebone:~# config-pin overlay cape-universaln
Loading cape-universaln overlay
bash: line 0: echo: write error: File exists
Error loading device tree overlay file: cape-universaln
root@beaglebone:~# ./pwm2.sh 1000
P9_42 pinmux file not found!
cape-universala overlay not found
run "config-pin overlay cape-universala" to load the cape
./pwm2.sh: line 12: echo: write error: Device or resource busy
./pwm2.sh: line 15: /sys/class/pwm/pwmchip0/pwm0/period: No such file or directory
./pwm2.sh: line 18: /sys/class/pwm/pwmchip0/pwm0/duty_cycle: No such file or directory
./pwm2.sh: line 21: /sys/class/pwm/pwmchip0/pwm0/enable: No such file or directory
root@beaglebone:~#

Ideas to try next?

Walt

William Hermans

unread,
Mar 18, 2016, 4:46:59 AM3/18/16
to beagl...@googlegroups.com
Seems like you've not loaded the proper device tree file ( "cape" ) for the correct PWM - To start off with.

William Hermans

unread,
Mar 18, 2016, 4:47:46 AM3/18/16
to beagl...@googlegroups.com
You should always write down step by step what you're doing so you have no problems reproducing it in the future . . .

hoffm...@gmail.com

unread,
May 3, 2016, 2:05:31 PM5/3/16
to BeagleBoard
Have you solved the problem that you were having?  I am unsure why you are getting the error:

P9_42 pinmux file not found!
cape-universala overlay not found

I am currently trying to figure out how the PWM pins work in the 4.1+ Kernel and it appears that after each reboot the pwmchip* links in the /sys/class/pwm/ directory link to different directories in the ocp directory.  For P9.42, look for the pwmchip link that links to the /sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip? directory and then your code works for me.

Jon
Reply all
Reply to author
Forward
0 new messages