Portal 2 Turret Gun

7,293

153

18

Portal Turret gun from Portal 2- UPDATED

"Defective Turret" is a fun variant, using Defective Turret sounds and some tweaking of code.

Updated with larger eye! More like original character now. Use v3 body and Lens. All other components are the same.

NEW: V4 is revision of body and wings to reduce front "bump" in body. See printed components section for more info.

Also working on V5 (no new body components though). One revised internal printed part, along with another chip and more features!! Stay tuned...

This Christmas, I decided to design and build a working Portal turret gun from the game Portal 2. For me, this was an exercise of properly modelling the entire assembly in Fusion 360 first, before building anything. This design uses an Arduino Nano, an MP3 player chip, distance sensor, servos, LEDs and 3D printed parts.

The goal here was to make it move in 3 "axes", with spoken sound from the game and LED's to simulate firing.

- Open the "wings" if it senses someone in front. Use a crank mechanism with sliders, just because.

- If the person is still there after opening, fire until they drop. LED's and machine gun sound.

- If the person is no longer there, run a little scanning search routine.

- Close up and go to sleep until someone else comes along.

- Use Portal turret sounds and voices from the game.

I took some liberties in the design, trying to make it appreciably the same as the one seen in the game, but functional and printable. With some basic sketches found online, I started modelling and planning...

The sounds are stored on a microSD card, which is accessible from the back side so that sounds may be updated or changed later. It is inline with the black infill strip, making it essentially invisible once installed. 18 individual expressions and sounds used in this go-round.

The lidar sensor (time-of-flight) is on a chip with a rectangular profile. This sensor is nearly invisible from the front once assembled.

Step 1: Fusion 360 Modelling

The design started from sketches found online. Using these images as canvases, I started sketching the outlines of the 3 views. Then it was a matter of extruding them into 3D, then shelling the general shape and making cuts. All electronics were built in Fusion as components that were inserted and placed where I thought it would make sense. Driving parameters were:

  • Arduino Nano had to have connector accessible for updating once fully assembled
  • MicroSD card had to be accessible in the same manner, and ideally invisible once installed
  • Time-of-flight sensor should be invisible as well
  • A 2.1mm electrical connector for power at the back
  • Printed parts to be as large as possible (not a lot of little pieces)
  • Print with no supports

After components (Nano, other chips, servos) were added to the basic shape, they were moved around and positioned as required, and the supporting structures were built to support them inside the shell.

The wing opening mechanism was a crank and slide mechanism. Why? Because I wanted to use a crank mechanism, that's why! This added some complications, but it also had a benefit; once the geometry was determined, operational repeatability would be ensured and the min and max limits were pretty much guaranteed.

Once the entire model was built and I was confident that it would work, and could be built (printed) and assembled, I went ahead and printed out the parts and built a prototype. Once that worked out, I went back to the model and made some tweaks to improve appearance and assemblability (is that a word?). This model is what came of those changes.

This was pretty taxing, as there really aren't many boxy shapes in this thing, and it closes up pretty tightly, with no real access for tweaking once put together. I learned quite a bit on this project, such as using embedded components within other components. This made manipulating and keeping sub-assemblies linked for quick access. In the end, it was worth the effort!

As for videos guides on Fusion 360, I'd recommend Lars Christensen's YouTube channel.

https://www.youtube.com/results?search_query=lars+...

I found Lars' channel along with other videos to be very helpful in coming up with new ideas and using features effectively in Fusion.

Step 2: 3D Printed Parts

V3 parts now replace v2 parts for body and Lens. Bigger eye and some other refinements. Print the Lens with no infill and with as few layers as you can get away with! I've gone with 2 layers and the red glow is consistent through the lens.

V4 parts (body and wings shown in RED) have been revised to reduce the bridge size in the body when printing and have virtually eliminated the "bump" on the front face, over the eye. This required modifying the wings to fit in the revised shell, and also required a revised pitch frame. I've also updated the infill strips to be consistently thin, and reduced the width by a hair. This makes putting it together much easier. I've also included a revised rear leg which is stretched a bit, allowing more room for the plug connector at the back.

Note that I haven't fully assembled V4 yet, but based on the model and the previous physical versions, it should all work out. Also, for me on my print setup, using a 2mm brim made a difference in part consistency - no spaghetti and no partial pulling up of thin wing sections, making the fit better with no gaps straight off the print bed!

These were printed on a Prusa Mk2, using PLA for all parts. The print orientation should be pretty evident. The body was printed in the vertical position, with no supports. There is the large gap in the sides that has to be bridged, but I really had no big issues with pretty standard settings, other than the bump. The bump on the front and rear can be virtually eliminated with good filament and some good print settings. I found that 0.2mm worked well in the slicer and produced a decent result. Any larger and openings started appearing in the body near the infill strip.

The design of channels and protrusions were done with 45 degree chamfers, so "hanging in space" elements will be minimal.

I had little cleanup to do to put the assembly together. The infill strips that slide into the channels are now pretty straightforward, with reduced width and consistent thickness. I think that one could use a thin, black material cut into strips instead of using these printed pieces (printed on edge).

The one area that does require finesse is the slider pins in the pitch frame. Straight pins (nails) in the bore holes that are chased with a 1/8" drill bit and some lube will go a long way.

Step 3: Components

V4 (Red turret) has smaller bridging, requiring v4 wings and Pitch frame.

Once the model was complete, and I was happy with my prototype, I printed rev 2 with the plastic components as shown. Everything here is PLA, with Black and design colour (Blue in this case), and a tiny bit of translucent PLA for the central "Lens" or laser eye.

This photo pretty well captures the components, with the exception of the wiring.

Step 4: Electronics

The build uses the following components:

  • Arduino Nano (1)
  • DFPlayer Mini MP3 player (or MP3-TF-16P) (1)
  • VL53L0X Time-of-Flight Ranging Sensor (1)
  • Generic SG90 micro servos (3)
  • 5mm red LEDs (5)
  • 220 Ohm resistors for LEDs (5)
  • 1kOhm resistor (1)
  • 4cm speaker, 4Ohm, 3 Watt (1)
  • 2.1mm power connector (1)
  • 3" long framing nails (4)
  • M2 x 6 screws (8)
  • M2.5 x 8 screws (2)
  • M3 x 8 screws (4)
  • M3 x 12 screws (4)
  • M3 x 16 screws (2)
  • shrink wrap
  • small tie wraps

All components are readily available from Amazon or Banggood and other sources.

The screws were sourced from an assortment kit. It's a pain in the butt to get them otherwise...

Step 5: Mechanical Assembly

Most of the mechanically assembly is reasonable. The printed parts are printed with the holes tapped where necessary, so a quick chase with a screw before final assembly will be helpful and made assembly of the screwed components pretty easy.

The Arduino and the MP3 chip snap into the cradle without hardware. The VL53LOX will slip into the front shell without fasteners. Trial fit first, then remove and install once wired up.

The slider assembly uses 4 framing nails as slider rails. They are about 1/8" in diameter, with the heads clipped. These were taken from a strip of DeWalt framing nails used with their electric framing nailer. Needless to say, smooth nails are a must.

The servos mount as shown. Orientation is important. The pitch and the pivot servos are "centred" when installing into their pieces. The crank is installed such that, when in the open position, it will close by rotating counter-clockwise direction, when viewing from the front. Open position is rods and crank straight in line, with another 10 degrees rotation till lock.

The leg assembly is the easiest part. 2-2.5mm screws, with the leg caps snapping over the elbows of each leg. Use fasteners than don't protrude above the top of the leg plate. That way, the pivoting body won't bind if you tweak the rotation range.

All servo connections to printed parts are made using the short white crank that comes with the servos. These cranks just press into the printed parts. I tried printing the splined bore in the parts that connected to each servo, but had limited, repeatable success. Much easier using the cranks that come with the servos.

The crank assembly uses the longer 2.5mm screws. The crank rods should not be squeezed between the crank halves. In fact, you could try using shorter screws without the Crank2 part. That should work as well (hopefully no appreciable torque here if the wings slide freely).

The speaker is captured by a servo mount (2 pieces) which capture the speaker. Speaker between these "legs", and held in position by securing them to the pitch servo. This servo then connected to the pitch (slider) assembly, followed by the crank assembly with rods. All of this is assembled before being installed in the LHS body with 4 small screws.

Once the main guts are installed, with the Arduino and MP3 player temporarily located, then the fun begins - wiring!

Step 6: Wiring

V5 - Radio option (Red turret photos). This includes an nRF24L01 radio chip. Completely changes the Arduino pin wiring to accommodate all the connections. Details to come...

The final packaging is tight, so spending some time here figuring out wire lengths is well worth it. Most interconnecting wires I ended up with were between 3" - 4".

The LEDs are wired with the 220 Ohm resistors directly, followed by some shrink wrap, and some wiring twisting, then put aside, after they have been tested. I used light gauge wiring here as I had some lying around (CAT5 type communication wiring) and didn't want the visible wiring to be obtrusive.

The mechanical bits are mock fit in the shell, then wire routing is figured out, then cutting and prepping the wires is next.

I built the servo connectors so that I could plug in and replace servos if I ever messed something up and stripped the gears. This was definitely helpful after messing up during my first prototype.

Once happy with the bulk of the wiring, the LEDs were soldered up at the end. Then it's time to carefully stuff the wired assembly into one half of the shell. The last step is to solder the power connector to the power wires once it is all inside.

At this point, all wiring is done, but before final assembly, it is important to upload the code to the Nano and power it up to make sure the LEDs, servos and MP3 player all worked as designed. After that, it's time to put the rest of the mechanical bits together.

Step 7: Arduino Code

Updated code! Cleaned it up and made some tweaks.

The attached file is what I came up with to drive the unit as shown in the videos. I will keep tweaking to change the Turret's character and the way it behaves. Lots of options here.

I structured the code using subroutines that I call as needed. It keeps the main body clean and was pretty helpful when I was playing around with different characteristics. It helped me manipulate the code for different behaviours.

I also used lots of variables up front which helped me tweak and adjust parking positions and min and max ranges, for example.

I used the DFMiniMP3 library in my code. I tried other libraries, like the DFRobot one, but had issues, so went back to this one. It meant that I had to keep the 'static void' pieces to keep it functional. These aren't necessary for the operation, but hey, I'm no master coder. I would love to hear of another library that is similarly as simple and neat as the VL53LOX library. Let me know if you find a better way to do this!

As for sounds, the implementation is done in a simple way, by having a folder named "mp3" on the SD card, with the files names 0001.mp3, 0002.mp3, etc. The first four digits must be in this format, but you can add any suffix after that to help identify the particular sounds. See https://www.dfrobot.com/blog-277.html for an example. I've included a pic of my file names as used on the folder. The numbers correspond to the call-outs in the code.

The sound files I pulled from the Wikipedia page on Portal Turret sounds. The code pics a random sound file (1 of 2, or 3 sounds) to keep things from getting stale.

Would love to hear or see cool implementations of other code. One idea I think I might try is to interconnect 2 or 3 of them wirelessly, such that triggering one turret will make them all wake up! Maybe adding a simple RF chip to the assembly? There's still some room in there... :)

Step 8: Final Body Assembly

This part is a bit tricky because of the black infill strips. The scale of the final assembly is small enough such that the strips and receiving grooves are tiny. This necessitated chasing the channel with a pointer or other small scraping implement to make sure the strips would fit with little resistance before trying to put the other side on.

Tying the wires together neatly and tie-wrapping as required will make this far easier.

I have put a couple of these together now and find it easier to put the two halves together first, then insert the infill strips. Insert one side into the half with the "shelf" that prevents the infill strip from falling in, then lightly pry open and gently press in. Not too bad now.

This was one of the trickier parts. Maybe one day, I'll rethink this assembly, but I do like the way it looks when done, and it is pretty robust.

Step 9: Wing Assemblies

Now that the body is together, with the wing LEDs sticking out, it is time to prep the wings and assemble.

It is imperative that the slider holes are chased with a 1/8" drill bit, then cleaned out. Clip the heads off the nails using bolt cutters, vise-grips, hacksaw or favorite nail-cutting tool. The slider pins (clipped nails) are installed into the wings by press fitting them into each wing piece. Straight, de-burred and smoothed nails are the key to making this work. The wing sliders and holes should be lubricated and tested before connecting the crank rods and running. Dry graphite, or other PLA suitable lubricant is recommended. I find that a small tube of personal lubricant works really well, and is cheap. It's really slick. It also requires for some 'splainin' when your partner or parent comes in and asks what exactly you need that for at the workbench!!

Start by figuring out which wing part goes where, and trial sliding that part first. Then fit the top and bottom halves together once the pins are installed, apply some lubricant (a q-tip works well for this) and make sure the wings slide well. This can be tricky, but without making sure the wings slide effortlessly, without binding, you'll be in for a frustrating time. Trust me...

Once the wings are good to go, it's just a matter of sliding them into place, locating the connecting rod over the hole in the wing and assembling with a single screw. Then, the LEDs are inserted into the gun holes, wires are tucked against the wing and you're ready to go! You can also use some hot glue to lock them into place once everything is tested.

Step 10: Scare and Shock Your Friends!!

The last little caveat on this design is that an angled plug is a great idea, since it doesn't interfere with the back leg when pivoting. The revised rear leg (v3) has been stretched to give a little more room.

Once built and plugged in (5V or suitable for Nano), it will sit quietly until someone is detected within the programmed distance, then spring to life and slay anyone who enters its domain!!

Let me know if you build one (or more) and if you come up with new features or concepts!

Toys Contest

Grand Prize in the
Toys Contest

Share

    Recommendations

    • Paper Contest

      Paper Contest
    • Organization Contest

      Organization Contest
    • Remix Contest

      Remix Contest

    18 Discussions

    0
    None
    AlF2

    21 days ago

    I just discover it and it is amazing, you did a very great job with 3D modeling and get all component very nicely integrated. I like it too much :)
    Do you think it is feasable to have a target folowing? May be with gesture sensor or lidar?
    Thanks and big thumb up

    1 reply
    0
    None
    ChrisN219AlF2

    Reply 20 days ago

    Target following: yes. One could do it optically with a camera, but couldn't do that with microcontroller like Nano. Would have to go to Raspberry Pi Zero or other microprocessor. It's been done in a Portal turret already!! https://www.instructables.com/id/Building-a-moving-and-tracking-Portal-Turret/
    I would love to try having multiple turrets in a room that act in a hive-like manner, that communicate with one another and follow a target. Would be cool and creepy!

    0
    None
    dbiesiada

    25 days ago

    Hi there it looks great! If you had to guess how much do you think all the components/materials cost you?

    2 replies
    0
    None
    ChrisN219dbiesiada

    Reply 24 days ago

    As for the components, the Lidar sensor the most expensive component at ~$8 (CDN). Arduino and sound chip as low as $3 ea. Servos <$2 ea. LEDs and resistors <$1. Hard components $20 (~$15 US). ~24hrs of printing all parts if you're all set up for it, so maybe $10-$20 there? + some wiring and soldering and hardware. Less than $50 total for sure.

    0
    None
    ChrisN219Philipd35

    Reply 24 days ago

    I thought about that, but decided against it. I knew it would garner some attention from friends and family and I didn't like the idea of a child staring into the laser... A bright LED gives the effect, and a super-bright LED would be effective too. Besides, if laser used, next step is bullets....

    0
    None
    Philipd35ChrisN219

    Reply 24 days ago

    I will test if the laser is too bright of course. And bullets..thought of that too, It would be great if it could shoot airsoft pellets, and then put it on a desk in front of ignorant colleagues :-). Just kidding, I could add a gyro and detect if the turret is put on its side, it could react to that with its usual behavior to that.

    0
    None
    Robot Boy

    25 days ago

    Very nice design! Is there any chance of getting the F360 files. I would be interested in making the"eye" a bit larger if possible. Also, the thin strips could be laser-cut if they were laid flat and a dxf file made.

    1 reply
    0
    None
    ChrisN219Robot Boy

    Reply 24 days ago

    The eye is too small and I was working on a quick update to the lens to make it bigger. I will look into the F360 file sharing. Haven't ever done that before.

    0
    None
    NathanE16

    24 days ago

    "I'm making a note here, huge success."

    0
    None
    Alastra

    25 days ago

    Nice ! Very nice job :D

    0
    None
    thirdjohn13

    25 days ago

    It looks like a droidika from star wars

    1
    None
    JohnSmith-Workshop

    4 weeks ago

    Brilliant work. It really blow my mind and I can't express myself how much I'm amazed.

    0
    None
    ChrisN219

    4 weeks ago

    Ok, post is now complete with Arduino file and STL files. Good luck and happy fabbing!

    0
    None
    sonoru

    Question 4 weeks ago on Step 10

    Hi! You did an amazing job!
    Where I can find the models for 3D print?

    1 answer
    0
    None
    ChrisN219sonoru

    Answer 4 weeks ago

    Thanks! I will be posting the parts and code in the next day or so. Need to clear up some time and tidy them up a bit.