This is a Python library for controlling DFRobot's Dynamixel motors using SPI communication.
- Raspberry Pi 4B or 5B
- Python 3.7 or higher
- DFROBOT Digital Servo Shield for Dynamixel AX
- Dynamixel AX-12A
- 12V power supply
Pin Type | DFROBOT servo driver | Raspberry Pi 4 or 5B |
---|---|---|
VCC (POWER) | VCC | N/A |
GND (POWER) | GND | N/A |
5V | 5V | 5V |
GND | GND | GND |
SCK | GPIO13 | GPIO11 |
MISO | GPIO12 | GPIO9 |
MOSI | GPIO11 | GPIO10 |
CS | GPIO10 | GPIO8 |
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
source venv/bin/activate
-
Activate I2C, SPI, Serial and Camera interfaces:
sudo raspi-config nonint do_i2c 0 sudo raspi-config nonint do_spi 0 sudo raspi-config nonint do_serial_hw 0 sudo raspi-config nonint do_ssh 0 sudo raspi-config nonint do_camera 0 sudo raspi-config nonint disable_raspi_config_at_boot 0
-
Enable dtoverlay for spi0-0cs
sudo nano /boot/firmware/config.txt
Add the following line at the end of the file:
dtoverlay=spi0-0cs
-
Reboot the Raspberry Pi:
sudo reboot
-
Activate the virtual environment again:
source venv/bin/activate
-
Install Adafruit Blinka:
sudo apt-get install -y i2c-tools libgpiod-dev python3-libgpiod pip install --upgrade pip pip install --upgrade RPi.GPIO pip install --upgrade adafruit-blinka
-
(Optional for RPI5) Delete rpi.gpio and install rpi-lpgpio:
sudo apt remove -y python3-rpi.gpio pip uninstall -y RPi.GPIO pip install --upgrade rpi-lgpio
-
Execute
servo_test.py
to test the servo:python3 servo_test.py