This Article is a placeholder for work in progress and I will log my success as I go forward.
ArchLINUX has proven to be the lightest of all the distros that I have installed yet on Beaglebone Black. I have already got all the basics up and running and now I am setting up my perl stack and I2C and PWM interfaces. Make sure you have followed my previous instructions for ArchLINUX here.
Install base devel and include all the sub packages. This is needed for installing XS modules and its roughly equivalent to build-essential package on Ubuntu
$ pacman -S base-devel
$ pacman -S i2c-tools
Now we can go ahead and install Device::SMBus. This is the interface that I released to CPAN for connecting to I2C devices, in the last release Device::SMBus 1.05 I removed some dependencies on board and distribution specific differences in i2c-dev installations, so it works without issues on both Raspberry Pi and BeagleBone Black , ubuntu,armstrong and archlinux installations.
$ cpan Device::SMBus
I use the LSM303DLHC for my work with LSM303DLHC Altimeter and Magnetometer
$ cpan Device::LSM303DLHC
Installing module for using LPS331AP Altimeter Barometer
$ cpan Device::LPS331AP
Installing module for using L3GD20 Gyroscope
$ cpan Device::L3GD20
My two ways of controlling PWM on Beagelbone Black:
External I2C PWM Generator like PCA9685:
I have already implemented this method before on Raspberry Pi, Since we have already setup I2C on ArchLINUX above, using PCA9685 is quiet simple, and while I have not lokked into the fact if the BeagleBone Black has a seperate microcontroller with a clock for controlling PWM or it generate a “software PWM”, if its the latter, there are obvious benefits to using a external PWM generator like PCA9685. Since I already bought this PWM microcontroller when I was building a quad on the Raspberry Pi, I might go ahead and use it again with BeagleBone Black if it proves to be a better option for performance.
TO use PCA9685 with perl simply install Device::PCA9685 on your BB and connect your PCA9685 to the I2C Pins like I do. There are other ways to do it without using perl but I won’t go into that unless I need it. To look into syntax details of how to use Device::PCA9685 look up the documentation for Device::PCA9685 on metacpan
$ cpan Device::PCA9685
Onboard PWM Pins on Beaglebone Black:
BeagleBone black uses a internal clock in its arm335x CPU to generate a PWM on its 8 or so PWM pins. The way to use this is to set the internal registers in the CPU using /dev/mem to trigger the high and low in the PWM signal at the correct moment as required. I will probably write a perl library to maipulate these registers directly from perl for using OMAP335x CPU to achieve the desired PWM signal.
Stay Tuned . . .
UPDATE: All PWMs are not created equal
I have done my research and I realised that all PWM outputs are not created equal when it comes to the Beaglebone Black. Essentially the black has
- Two independent PWM outputs with dual-edge symmetric operation
- Two independent PWM outputs with single-edge operation
- One independent PWM output with dual-edge asymmetric operation
So no two similar PWM output which makes me edgy, because having rotors running on different clocks is a bit dodgy especially if I hope to have finer tuned control on my quad so I have dropped the idea to write the perl driver for BBB CPU controlled PWM.
I haven’t gone into details of different types of PWM but from a brief read up on the web, a dual edge symmetric PWM provides better quality signal for running Brushless DC motor, in a X config quad that I have, I am not sure I want to have different quality signals running the four motors.