Portal Turret Build Guide
Table Of Contents
- About this guide
- Items Needed
- Tools Needed
- Source Code
- 3D Print Files
- Assembly Guide
- How to use
Ever since the release of Portal in 2007, the turrets featured in the game Portal are a true hit. The odd shaped white units lure you in with cute voicelines, but completely shoot you to pieces with one wrong move.
The reason I started this project was because now that I owned a 3D printer, I really wanted to create something cool that moved with servos and challenge myself in what I could achieve with Fusion 360.
I had a few goals I wanted to achieve:
- Try to keep the design small and compact. I'm using a Prusa Mini, so I wanted to keep the size of parts small. Also, I want it to fit on my desk.
- Get as much freedom of movement in there as physically possible
- It should respond like the turret in game, so I'd need sound, detection of people and movement detection.
- Make it look like you can't really tell it's 3D printed.
I managed to hit a lot of these goals. There were some sacrifices here and there, but concidering the physical size of the turret, this was something to be expected.
About this guide
This guide was written after the full assembly of the turret. Since there were quite some requests about releasing the print files, I decided to write down the steps to build one yourself. A lot of the problems I encountered during the design process are fixed, so the build should be rather straightforward. The most challenging part will probably be the wiring, and routing of these wires. Cut your wires long enough, you can always shorten them. Take your time to study the schematics and maybe even take a look at the source code before doing a full assembly. Doing it step by step will certainly help getting your turret up and running.
Putting together the design for this turret was quite a challenge. Writing this guide even more so. But I also believe other people should be able to enjoy building cool things like this. That's why I'm releasing all the files and guide for free. If you feel like this is a fun project and want to support me somehow, you can use the button below to buy me a coffee or something.
- 5V power supply with some decent amperage (2A should do fine). A USB charger will work.
- USB breakout board.
- 4 3mm LED holder
- 1 ADXL 345 Motion Sensor
- 4 3mm orange LEDs
- 1 5mm red LED
- 1 SK6812 5050 RGB 8 LED Ring
- 1 Regular g90 servo
- 1 Microswitch with lever
- 1 PCA9685 board, preferably without pre-soldered headers
- 1 PIR motion detector
- 1 4ohm speaker, 4cm wide, 2cm high.
- 1 Continuous g90 servo
- 1 YX5200 MP3 player
- 1 Wemos D1 Mini 3
- 4mm steel rods
- M3 threaded rod
- 4mm Allen Key
- Micro SD Card
- 1.5mm screws. I used 8mm and 12mm length.
- 3D printer
- Soldering iron
- Painting and sanding utilities
- Regular tools like screwdrivers, small saw, etc.
This schematics of the turret are relatively simple. All of the components run on the 5V lines. The ADXL345 and the PCA9685 both run on the I2C protocol. The YX5200 uses Serial communication. Then there's the PIR sensor and the LED ring both using just one pin for communication.
Some important notes:
- Once the Wemos is built in, it's quite hard to reach it. Make sure you upload the sketch beforehand. It provides you with OTA Update abilities so you don't have to connect it through USB every time.
- The PCA board has multiple channels. The defaults are:
- Center red LED: 0
- Right Gun: 13
- Left Gun: 12
- Rotation Servo: 8
- Wing Servo: 7
- Use a breadboard to make sure everything works. There's nothing worse than having to replace a part right after you're done with the final assembly.
- There's a 4.7kΩ resistor used to pull op the D0 pin used for the open/close detection switch. The reason I chose this pin is because the other remaining pins couldn't be pulled high on the Wemos without causing boot issues.
- I'm using the analog pin of the Wemos to check if the MP3 player is busy. That's a waste of the analog function as there are 2 digital pins left. However, the MP3 player will pull the pin high when it's Idle, so chances are the Wemos won't boot correctly using one of the remaining pins.
- The wemos runs on 3.3V, but the LED ring signal expects 5V. In my case I got it to work, but chances are you need to get a 3.3V to 5V logic converter if your LEDs are showing weird colors.
- For the ADXL345 to work in I2C mode, the CS pin needs to be pulled high. The logic level of this chip is 3.3V, but I tied this pin straight to the 5V line as a mistake. However, this seems to work fine so I'm keeping it in the schematic as this is how I've got it to work. You might be better of tying it to a 3.3V pin from the Wemos for example.
- The SD card should be formated to FAT32, otherwise it can cause issues with the sounds.
- Make sure to read the documentation of all the tiny boards. There's useful information in there that is not specifically mentioned in this guide!
These are just some of the things I bumped into when building the turret. Please read the technical specification of your chosen chips and boards before hooking them up!
The Wemos D1 Mini is the brain of the turret. This powerful little board has onboard WiFi and can be programmed like an Arduino. You'll need the Arduino IDE to install some libraries and program the board.
This page provides information about how to use the Filesystem of the Wemos to run the webpage. Make sure you use the LittleFS Data Upload tool mentioned lower on the page!
Keep in mind that most of this software was written to just get the turret to work, so it's not quite optimized for readability. All functionality is split over differnt files to keep it maintainable to some degree.
The code runs on some briliant libraries. Make sure to install:
- Adafruit ADXL345
- Adafruit Unified Sensor
- Arduino WebSockets
3D Print files
The turret consists of many parts. The combined parts can be found below. I suggest using a program like Slic3r or Prusa Slicer to split them into individual parts. Most parts can be printed with no or minimal support. Prusa Slicer provides tools to paint support where needed. Settings like temperature and the use of brims is really up to your printer and the used filament. The most difficult parts to print will probably be the wings. I used quite a bit of support material and a big brim to make sure it could print upright and keep it in one piece. To get the glossy finish, make sure to use something like 0.10mm as a layer height for the outer shells. The internal parts can be printed with slightly bigger layer height, but this will ofcourse show more visible layer lines.
Please note: The gun is only added once. You need to mirror it for the other side!
The turret plays a lot of voicelines from the game. Download this archive and put the contents on the SD card used in the YX5200.
I wish there was some sort of shortcut I could provide when it comes to painting the turret. But to get the shiny finish there's pretty much only one way to go about it:
- Use small layer height when printing.
- Sand the parts.
- Use a primer to smooth things out even more.
- Use a high gloss spray paint.
This part will require a lot of patience. Take your time, don't spray too much paint at once. The smoother the surface before painting, the better the result will be in the end. The time spent will be worth it.
Now that all the parts are printed and painted, it's time for the assembly. All these steps assume you know how the electronics should be hooked up.
To help with print orientation, the base of the mechanics is done in 3 prints. Use 6 smalls crews to attach the parts together.
The 3 gears should slide right in. I've used an old allen key for the center axel. It should go in relatively easy, but the gear should get stuck on there. If it's too loose, the axel might slide out. The other two axels are 4mm rods cut to length. Make sure the gears are oriented the right way!
Use 4 small screws to attach the rear plate to secure the gears in place.
Install the continuous servo and the microswitch. This switch helps the controller to detect if the wings are open or closed.
Insert the rack gears. Make sure they line up on both ends. They should go in both all the way.
Now you can install the large gear. This one also needs to have a snug fit to ensure not falling off. A drop of super glue surely will help.
Attach the top part with 3 small screws. This should complete the inner mechanics. The screws should not stick out of the top, as this will hinder movement of the part.
The center piece is printed flat to make sure it's easy to print and doesn't show any layer lines. However, the shape should be slightly indented. A tiny "mold" is added to the models to help with this. After printing, place the eye in some hot water. PLA gets soft at these temperatures, so you can push it on the mold to get the desired shape.
The LED ring should exactly fit in the holder. Same for the red LED. The white part is a 'diffuser' to make the red light more even across the eye. Looks way better than directly looking into the LEDs of the ring.
All the parts should fit together front to back and should slide over the extruded edges of the main body. The red LED should help keep everything in place.
There is a small mount to print used for the Wemos. Please note that at the time of writing, the Wemos V4 has launched with the mounting holes in a different position. Either try to get a V3, or do a small redesign of the mount. Use one small screw to keep the Wemos in place. Having it attached with just one screw makes it easy to access when soldering the components together.
Cut two pieces of M3 threaded rod to length and glue them in one side of the main body. Make sure the wires on your speaker are long enough, because it won't be easy to access it after this step.
Using some more glue, slide the second half of the shell in place.
The whole eye assembly should slide in place. Use superglue to attach the Wemos mount. This should also help with keeping the two shells alligned.
The bottom piece is part of the hinge that makes the wings turn. It also houses both the PCA9685 and the YX5200. Since there are no mounting holes on the YX5200, I decided to glue it to a custom small piece. The top layer of this piece is the same size as de Micro-SD card, providing a nice surface for the glue to do its work.
To save space, I'd recommend to remove the pin headers of the YX5200 by desoldering them. Use some clippers to cut the black plastic bits and use a soldering iron to remove the metal pins. Do them one by one, don't overheat the chip.
The PCA9685 is mounted with 4 smalls crews.
Once the YX5200 is glued to the 3D printed part, you can attach it with two small screws.
Slide the piece in the main body and secure it with 4 scews. This should greatly help stability of the whole build.
There are multiple ways to power the turret. You can use a USB breakout board, or simply route the power wires directly in the build. Both options should fit underneath the little clamp that gets attached with two small screws.
The acceleromter goes in next. There are two standoffs provided to secure it in place.
6 screws are used to attach this plate to the bottom. The PIR motion sensor can be clamped in the front and should just fit above the accelerometer. There's not much room, but with some tight cable management it should be possible.
The orientation of the ADXL345 is important. When mounted upside down the turret will constantly think it's tipped over and starts to panic and turn off. For me, this meant all the chips are on the top side of the board, facing the printed part.
Screw the small gear on the servo and attach it to the bottom plate.
Cut 2 4mm rods to length and run them through the bottom plate. They should stick out a few milimeters on each side.
Use a small piece of 4mm rod to create the hinge between the top and bottom part.
Most of the internal mechanics are now complete.
Slide the center mechanics in the hinge at the top. Slightly spread the outer shells at the bottom to slide them over the metal rods. If the shell doesn't keep the rods in place, concider some glue. However, this would fix things in place permanently, so only do this when you're sure everything works.
First up are the two guns. Insert the white LEDs in the metal holders. Insert a holder with LED in all of the muzzles. The LED holders should stay in place by itself.
The back of the guns provides a small path for wires. Use some hot glue to keep the LEDs and wires in place. Make sure the wires are long enough to reach the PCA9685. It's easier to cut some off than to resolder new wires later.
Cut some 4mm rods to length. I recommend smoothing them by inserting them into a drill and spin them in a piece of rough sandpaper. The smoother the better, but also keep in mind that they should fit as closely as possible to prevent the wings from wobbling too much. Roughen the outer tip a bit and use super glue to attach the rods to the wing. I suggest you insert the wings into the center mechanism to keep the rods in place while the glue dries. Make sure the wings don't touch the center mechanism though, as they could get stuck. Ask me how I know...
Attach the gun with 2 to 6 screws.
Cut some M3 threaded rod and use super glue to fix them in place in the wing. This will be the pin the rackgears will snap around so make sure they're tight.
When all the parts are glued and secure, you can slide in the wings and click the rack gears on the metal pins.
All legs consist of a piece of 4mm steel rod, 2 printed pieces and a small peg that can be cut from the M3 threaded rod. Use superglue to glue everything together. The peg should help with some strength.
Getting the metal parts in the correct shape can be quite tricky. Bending 4mm steel can be difficult. I suggest using something round of the approximate size to help with getting the right shape.
Now it's time to glue in the antenna and the 3 legs. And that concludes the assembly.
How to use
After assembly, the turret should be pretty much ready to go. When starting up, the Wemos will look for a WiFi network. If it can't find it, it will start a HotSpot to connect to. Use the provided portal to set up your WiFi credentials. After that, the turret should connect to your network and start its program.
You can look up the IP Address of the turret by accessing your router, or try http://portal.local on a device connected to the same network. This should give you the Portal themed webpage of the turret to go into manual mode and look at some of the sensors of the turret.