Thanks to Gianluca Filippini from EBV for creating the original tutorial.
A slightly more complete version of this project is also available HERE
These are the step-by-step instructions on how to set up a MaaXBoard to drive multiple servos with an accurate PWM external add-on card. The goal is to be able to control these motors with Python. We will reuse code originally written for RaspberryPi by Adafruit's Tony DiCola. Only few modifications are required to get everything working on the MaaXBoard.
Go through the MaaXBoard headless setup here first.
Beside the board itself, we will need a few external parts:
PCA9685 servo driver
The external control will use the PCA9685 chip which allows the control up to 16 independent channels (i.e. 16 servo) leveraging a single I2C bus. There are multiple shields with PCA9685 made for Raspberry Pi. We can use the shield from Adafruit, or as an alternative, the shield from WaveShare.
GPIO adaptor (optional)
Since the heatsink on the MaaxBoard is quite high, if you use the shield from WaveShare you may also need an adapter to mount it. We can use a GPIO riser or a right-angle GPIO adapter for raspberry pi. This will allow to mount any external shield “vertically” which is even more convenient in case you have a fan mounted on your MaaxBoard heatsink.
Image courtesy of Kattni Rembor https://learn.adafruit.com/assets/69564
Once you have connected the shield we need to make sure that the hardware is recognized. For this reason we need to install i2ctools package. Connect to your board over SSH and install the package
sudo apt-get install i2c-tools
sudo touch /etc/udev/rules.d/50-i2c.rules
sudo nano /etc/udev/rules.d/50-i2c.rules
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
sudo adduser ebv i2c sudo chmod g+rw /dev/i2c-* sudo reboot
sudo i2cdetect -y 1
sudo apt-get install git build-essential python-dev
cd ~/ mkdir example cd example
sudo apt-get install tree
cd ~/ cd example mkdir test cd test
ln -s ../Adafruit_Python_GPIO/Adafruit_GPIO/ .
ln -s ../Adafruit_Python_PureIO/Adafruit_PureIO/ .
ln -s ../Adafruit_Python_PCA9685/Adafruit_PCA9685/ .
cd Adafruit_GPIO nano I2C.py
cd example cp Adafruit_Python_PCA9685/examples/simpletest.py test
cd example/test python ./simpletest.py
Now you can control multiple servo motors for your mechanical assembly like pan-tilt-zoom or animatronics or industrial prototypes. Always make sure to control servo type and maximum current rating when you plan to use more than one servo on the external shield, eventually adding a specific power supply dedicated only to the servo shield.