Fab Academy 2019

Progress Documentation - Christian Schmidt

Final Project

A 3D printed gimbal

Here you can learn how to build a 3D printed three axis gimbal, using a Raspberry Pi with the corresponding PiCam as a camera. If you already own the pi and the camera, this project will cost around 70€. And probably a lot of time. With a few modifications, you can probably build it with stronger motors to use the gimbal with heavier cameras.

Here's a short video of all the steps I took to build the gimbal. If you want to know more about my struggles during development, check out my project development page. Since this page contains only the most essential information on how to build this project, you can also find more information about each step on the development page. In the description below, you will find links to the most relevant parts.


Initially, I wanted to design the gimbal in a more modular fashion, i.e. separate boards for each motor, the IMU, and the main controller; however, this proved to be too complex and I opted for a simpler design with just two boards. Nevertheless, I did keep the separation into motor control, IMU control, and main control chip, so the high-level overview of the electronics looks like this:

The IMU controller filters the sensor readings from the 9-axis orientation sensor, the motor controller provides PWM regulation to control the motor position, and the main controller runs the main PID control loop, coordinating the other chips. To see how it looks like when built, here's an overview of the components as laid out on the boards:

How to build it

This is not an easy project, mostly because the electronics are complex and I've tried to keep the boards as small as possible. Make sure you read the instructions beforehand. Soldering the boards is hard, and I recommend using a stencil and a hot air gun or SMD rework station to do it. In fact, some of the ICs have pads underneath that have to be soldered to ground, which is not possible with a soldering iron alone (at least I don't know of a way to produce reliable results).

For a list of all materials, have a look at the bill of materials. Additionally, you will need the following equipment to build this project:

  • A 3D printer
  • A laser cutter
  • A PCB mill which can reliably mill 6mil traces, on double sided boards. You will need a 0.1mm milling bit.
  • A soldering iron with a fine tip
  • A hot air gun and/or SMD rework station
  • Soldering paste
  • Thin wire for manually creating vias
  • Various screwdrivers

I also had a placing machine and a microscope available, which helped tremendously with placing and inspecting the many small components.

Make the boards

Export whatever format you need from the Eagle files I provided. You will need to make two boards: the main controller board and a pi hat containing the main IMU for orientation sensing. Both boards are double sided and contain a lot of vias.

If you cannot make them at your lab, you can order them cheaply online. I know that the academy wants us to make everything ourselves, but I feel like ordering the boards is a valid alternative, because they are hard to make, needing advanced equipment, skill, and a lot of time. Additionally, the quality is usually worse than the quality of ordered ones, and if I were to calculate time spent making boards versus the cost of ordering (including shipping!), I would quickly arrive at the conclusion that ordering is cheaper. Nevertheless, it certainly is possible to make them yourself.

For both boards, you will need a 0.1mm milling bit for the traces, a 0.4mm drill bit for the vias, 0.6mm drill bit for the micro USB connector, and a 1.0mm drill bit for the pin headers. Generate the CAM files from the Eagle files provided below and mill the boards. Export the layers "tpaste" and "bpaste" as SVGs (separately) to create stencils with your laser cutter or vinyl cutter. When using a laser cutter, you might have to experiment with the DRC settings to make the masks for solder paster smaller in order to accomodate the laser cutter kerf.

When you have the milled boards, apply solder paste with the stencils, carefully place the components, and use a hot air gun/SMD rework station to solder everything in place. Afterwards, use thin wire to create the vias: thread it through a couple of vias, then solder both sides of each via and remove the rest of the wire. Make sure to remove all the leftover wire, or you will get shortcuts! Test for shorts before turning it on. The board should work with voltages from 8V to 16V.

Your boards may look like this:

Cut the case

Cut all of the parts for the pi case out of 3mm Plexiglas (Other materials probably work fine too, but Plexiglas looks cool and provides enough stability), except for the back plate connected to the roll motor. Cut this one out of 2mm material.

Then assemble the pi, case, and camera. First, mount the camera to the extension board. Then, attach the hat to the pi, and the back plate to one of the motors. Finally, screw the back plate to the pi-board-camera combo. Make sure you have it the right way round; it should be well balanced and able to rotate freely around the motor axis.

Print and assemble the frame

I printed the frame on an Ultimaker 3+ out of PLA, with a layer height of 1.5mm and 20% infill, which worked very well. You will need to print the adapter twice, once for the yaw arm and once for the pitch arm. All parts are printer friendly if rotated correctly.

Attach the motors to the arms and the main housing with M3 screws. Beginning with the camera/roll motor, connect each part with the motor that rotates it, and use the adapters to make sure everything is well balanced. The adapters are designed for M2 screws. Finally, mount the main board into the housing at the top, connect the motors to the board, and the main board to the pi/extension board.

Prepare the pi

Install all the necessary software. You can use your favorite software stack to capture images with the pi, this is just an example. I installed pip, the python package manager, and a couple of modules needed to capture video streams with the picam and send them over the network:

$ sudo apt-get update
$ sudo apt-get install python3-pip

$ pip3 install picamera[array] opencv-contrib-python zmq imutils 

If you do this at home, make yourself a nice cup of tea (or coffee), because this will take some time.

Program the boards

I used the ST-Link integrated in a Nucleo-64 evaluation board to program the STM32 chips, together with the STM32Cube IDE, which worked flawlessly. Just remove the two jumpers on pins CN2 and connect the programming lines of the chip to the corresponding pins on connector CN4, as depicted on the images below (and per the manual, which you should have at your side anyways). There are three projects, one for each chip. Connect the programmer to the corresponding programming header and upload the correct firmware to each micro controller. Once all chips are programmed, reset all of them by removing and reattaching the power source.

Bill Of Materials

This turned out to be much longer than I anticipated. Unless otherwise noted, LEDs, capacitors, and resistors are SMD 0603.

Item Price Notes
BLDC motor 3x 11€
Raspberry Pi Zero W 15€
PiCam 20€
ICM20948 5.59€ 9-axis inertial measurement unit
STM32F103T8 2x 2.60€ 32-bit MCU
STM32F103RCT6 2.40€ 32-bit MCU
DRV8313 3x 1.07€ 3-phase BLDC driver
LD1117 0.40€ 5V LDO voltage regulator
TC1185, 3.3V 2x 0.33€ 3.3V voltage regulator
TC1185, 1.8V 0.33€ 1.8V voltage regulator
TXB1014 0.33€ 4-bit bidirectional level shifter
CP2102N 1.35€ USB-to-UART bridge
SMD Button 0.23€
Micro USB Connector 0.55€
LEDs 5x 0.05€
560Ω resistors 5x 0.02€ For LEDs; value not really relevant
10kΩ resistors 5x 0.02€ Pullup/pulldown
16MHz Crystal 3x 0.32€
22µF Elko Capacitor 0.20€
100µF Elko Capacitor 0.20€
12pF Capacitors 6x 0.02€ For the crystals
1µF Capacitors 9x 0.05€
100nF Capacitors 30x 0.05€
470pF Capacitors 3x 0.05€
40 Pin GPIO Header 1€
Pin Header 5x 0.20€
3mm Plexiglas ~5€
PLA ~5€ As much as you need to get a working print
- - -
Sum 104.20€ Around 70€ if you already own the pi and the camera