3D printed robot arm, controlled with a Raspberry Pi Pico.
The docker container that the code is compiled in was created by lukestep, for more instructions view his repo.
Run the following command in the repos root directory
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD},target=/home/dev lukstep/raspberry-pi-pico-sdk:latest
I have forked the lukestep's repository and added some more tools. To use that instead clone the repo and the build it.
git clone https://github.com/Anton-Augustsson/raspberry-pi-pico-docker-sdk.git
cd raspberry-pi-pico-docker-sdk
docker build . --tag pico-sdk
Cd into robot-arm-controller
and run.
docker run -d -it --name pico-sdk-aa --mount type=bind,source=${PWD},target=/home/dev pico-sdk:latest
You have two options: either you run with the pico library or you use the simulation flag. So that you may run without hardware. You are thus able to change the environment through software.
To run with hardware run:
rm -r build && mkdir build && cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. # or cmake ..
make -j4 # or make
Then you have to move the .uf2 file to the pico when it is in boot mode so it can be mounted.
To run with simulation run:
rm -r build && mkdir build && cd build
cmake -DSIMULATION=ON ..
make
./sample
Controlling the motors on the robot arm is done my sending a pwm signal to the motors on the robot arm.
Motor | PWM function | Header Pin | Broadcom pin name |
---|---|---|---|
MG996R | PWM | 4 | GP2 |
MG996R | PWM | 5 | GP3 |
MG996R | PWM | 6 | GP4 |
There are two models of motors used for the robot arm.
Model | PWM Period | Voltage |
---|---|---|
SG90 | 50Hz | 5V |
MG996R | 50Hz | 5V |
Framework is a separate program to experiment the general program structure of a microcontroller. SPI will be used to communicate with a bare metal controller and a node.
- SCLK: Serial clock
- MOSI: Master Out Slave In; SDI: Serial data in
- MISO: Master In Slave Out; SDO: Serial data out
- CE0: Chip enable 0
- CE1: Chip enable 0
SPI function | Header Pin | Broadcom pin name | Broadcom pin function |
---|---|---|---|
MISO | 25 | GP19 | SPI0 TX |
SCLK | 24 | GP18 | SPI0 SCK |
CE0 | 22 | GP17 | SPI0 CSn |
MOSI | 21 | GP16 | SPI0 RX |
From Communicating as master and slave via SPI | |||
![]() |
SPI function | Header Pin | Broadcom pin name | Broadcom pin function |
---|---|---|---|
MOSI | 19 | GPIO10 | SPI0_MOSI |
MISO | 21 | GPIO09 | SPI0_MISO |
SCLK | 23 | GPIO11 | SPI0_SCLK |
CE0 | 24 | GPIO08 | SPI0_CE0_N |
CE1 | 26 | GPIO07 | SPI0_CE1_N |
From link. | |||
![]() |
|||
From link. |
For src you need to install (nlohmann/json)[https://github.com/nlohmann/json/tree/develop?tab=readme-ov-file#integration], which you can do with vcpkg.