Neils,
I completely agree with your comments on there needing to be a C/C++
equivalent to the bonescript. With beaglebone 3.8.13, I am able to
successfully control a PWM actuator following Mark Yoder's example:
(http://elinux.org/EBC_Exercise_13_Pulse_Width_Modulation), almost exactly
the procedure Michael Vernier posted above. However, it will only work
after I run a bonescript analogWrite() on the PWM pin. It took some
digging to reverse engineer the
\bonescript-master\node_modules\bonescript\index.js::analogWrite() to
determine what it is doing that afterwards allows me to successfully use
the PWM device.
The analogWrite sets the PWM polarity to zero during the configuration of
the PWM: "fs.writeFileSync(pwm_test+'/polarity', 0);"
A similar operation from my C++ side resolved my issue and allowed me to
use the PWM device successfully: system("cd
/sys/devices/ocp.2/pwm_test_P9_21.14; echo 0 > polarity");
-Shaun
On Friday, May 3, 2013 4:27:20 PM UTC-5, [email protected] wrote:
>
> Thanks a lot. I was able to get an LED to blink using Angstrom with these
> steps. Notably the Debian Squeeze install I made with the instructions
> here: http://eewiki.net/display/linuxonarm/BeagleBone+Black only
> partially worked. The link for the PWM showed up but there were no "duty"
> and "period" files in the folder.
>
> I was going to investigate reverse engineering bonescript but it wasn't
> clear to me that PWM was supported there in the first place. I think
> ideally there ought to be an official C/C++ library to complement the
> bonescript API. When I first booted the board I really expected there to be
> a libbeaglebone or some such thing for me to link to. I see a number of
> such libraries cropped up for the last revision of beaglebone but they
> didn't seem really seem to be promoted by the beagleboard folks. I would
> really like to encourage them to make some effort to make C/C++ a first
> class citizen when it comes to IO. At the very least I think it's important
> that reverse engineering bonescript is not the best option for getting
> going in C/C++. A simple cheat sheet of instructions like Michael presented
> linked on the beaglebone.org website would be enough to feel like I was
> being supported.
>
> Thanks,
> Neils
>
> On Friday, May 3, 2013 12:11:43 PM UTC-7, Michael Vernier wrote:
>>
>> I got PWM working on my BBB from the command line the other day. Here's
>> what I did on Angstrom (4/13 image).
>>
>> Add the am33xx_pwm module to the bone_capemgr. You'll have to look at
>> your BBB for the # of the cape manager. Mine is bone_capemgr.8, but since
>> I've only tested on a single board, I'm not sure if the numbers are the
>> same across every board.
>> $ echo am33xx_pwm > /sys/devices/bone_capemgr.#/slots
>>
>> Add the individual PWM module to the bone_capemgr. For example, EHRPWM2B
>> is pin 13 on the P8 connector. To enable this pin for PWM, use the
>> following command
>> $ echo bone_pwm_P8_13 > /sys/devices/bone_capemgr.#/slots
>>
>> This creates a link in /sys/devices/ocp.#/pwm_test_P8_13.#. For my BBB,
>> I have /sys/devices/ocp.2/pwm_test_P8_13.12. The number in the pwm_test
>> has changed for me for a couple times that I've used it, so you'll have to
>> see what number it assigns for you.
>>
>> All the settings for the PWM configuration are found in that folder
>> similar to the old interface. To generate a 50 Hz signal with 50% duty
>> cycle, (the period and duty times are giving in nanoseconds)
>> $ echo 20000000 > /sys/devices/ocp.#/pwm_test_P8_13.#/period
>> $ echo 10000000 > /sys/devices/ocp.#/pwm_test_P8_13.#/duty
>>
>> I found all this from digging through the BoneScript source code found
>> here https://github.com/jadonk/bonescript.
>> bonescript/node_modules/bonescript/index.js has the core implementation of
>> the module.
>>
>> Hope this helps.
>>
>> On Friday, May 3, 2013 1:21:43 PM UTC-4, Jason Stapels wrote:
>>>
>>> If the goal is a tutorial, the SYSFS interface does provide the simplest
>>> way to ease someone into using PWM. I think that being able to simply
>>> access it from the command-line does make it very approachable from a
>>> beginner point of view. I agree that there is definitely more efficient
>>> means for working with the PWM, but realistically if you need that low
>>> level of interaction, you'll likely being using the /dev/mem device to
>>> direct access to the registers (or using a polished C library that does it
>>> for you).
>>>
>>> Also, as I understand it, the SYSFS interface is the only way to mux the
>>> pins you'd need from userspace.
>>>
>>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.