BeagleBoard logo
Blog Bone Buses
  • LEDs
  • I2C
  • SPI
  • UART
  • CAN
  • ADC
  • PWM
  • TIMER_PWM
  • eCAP
  • eMMC
  • LCD
  • eQEP
  • McASP
  • PRU
Journal About Status: Completed ✔️

© 2023. All rights reserved.

GSoC 2020 BeagleBoard.org

This website is created for keeping track of the Development of "Cape compatibility layer for BeagleBone Black and BeagleBone AI" project..

Testing servo cape on BBBWL/BBB

20 Jun 2020

BBORG servo cape uses PCA9685 PWM chip for it’s 16 servo outputs. You can control the servos by writing to 0x70 of /dev/i2c-2 But, here we well see how you can enable the pwm-pca9685 kernel driver using an overlay. We will also see how you can use a simple script that uses sysfs to control the servos.

Note: Links to overlay and test script files may change as this post is written as part of the development process!

The overlay

To install the overlay on your BBB execute these commands, $ and # before any command depicts normal user command and super user command respectively :)

Become super-user
$ su
OR
$ sudo su

Change to bb.org-overlays directory
# cd /opt/source/bb.org-overlays/src/arm

Download the DT overlay
# wget https://raw.githubusercontent.com/lorforlinux/bb.org-overlays/servo/src/arm/BBORG_SERVO-00A2.dts

Compile the overlay
# cd ../../
# make src/arm/BBORG_SERVO-00A2.dtbo

Install the overlay
# cp src/arm/BBORG_SERVO-00A2.dtbo /lib/firmware

Make sure you have not edited /boot/uEnv.txt to include any overlay at addr0!

Checking if it worked :)

shutdown your board using this command

# shutdown -h now

Insert your cape onto your BBB and start your board. First we check if the overlay is loaded perfectly.

Check if overlay loaded
$ cd /proc/device-tree/chosen/overlays/
$ ls

You should see the servo cape loaded here!

Now we check the driver is loaded fine, for doing that execute these commands,

This should not give any errors
$ cd /sys/class/i2c-adapter/i2c-2/2-0070/pwm

You sould see a pwmchip here
$ ls

Testing servo control

Before testing any servo make sure you have provided 5V input through terminal power block (Blue thing with screws)!

Now execute these commands to test the servo on S1 servo output of the cape :)

Go to HOME
$ cd ~

Download the script
$ wget https://raw.githubusercontent.com/lorforlinux/BeagleBone-Examples/master/ServoCape_test.sh

Make it executable
$ chmod +x ServoCape_test.sh

Run it
$ ./ServoCape_test.sh

You should see the servo moving!

Related posts

  • Using bone bus PWM on BBBWL/BBB/BBAI 22 Jul 2020

  • Using bone bus I2C on BBBWL/BBB/BBAI 19 Jul 2020

  • Installing compatibility layer on your BBBWL/BBB/BBAI 19 Jul 2020

{ Find me on social media }