Software apps and online services
Hand tools and fabrication machines
A couple of years ago, during some company team building activities I took part in some laser tag matches. I really loved it, but due to it's limited outdoor reliability, I got interested in airsoft. I love its idea of shooting real bullets/balls.
As I really love robotics and remote controlled things, I thought I'll build a custom airsoft turret that I can control with an RC transmitter and see it's results in my quadcopter's FPV headset. That's definitely not something that anyone would expect and it could mean a lot of fun, even outside airsoft matches.
Now you are reading the story of how I built the first version of it.The broad plans
For some reason the stl files that I uploaded under the attachment section does not render at all due to a "This sketchfab 3d model has not been published yet" error (I don't know what to do with that, reupload didn't help), but as far as I can see, you can still download the 3D models.
I have a 3D printer so it was an obvious choice to design it with CAD and print it out. Just getting an airsoft gun and using it for firing would be an obvious choice, but I wanted to experiment some, even if the end results might not be as effective as a store-bought airsoft gun. My firing mechanism is definitely a strange one and you can tell it by just looking at it. When I was testing it, people rarely knew what was happening and got concerned only when they heard the BLDC motor spinning up before firing.
I wanted it to spin around in 360° to cover all angles, move up and down and to have a way for me to see what it is firing at for better aiming. It means that it also needs a wireless camera that works reliably.
For this build I used numerous old drone parts, that were just lying around. Eachine sells not too expensive and very compact analog cameras that only requires a 5V power supply to operate. Camera, transmitter and antenna all in one. I used an Eachine TX03 as I already had one, unused.
They can be used with any FPV headsets, but you can also buy USB receivers for phones. The USB receiver will be recognized by your phone or PC as a general webcam. Image quality won't be the best, but it will be perfectly usable for this task.
It would be obvious to use an RC transmitter for controlling it, but they can be quite bulky, which is not a good thing in this case. For a first revision I thought I'll try something very compact. I had one of these 433MHz garage door opener style transmitters/receivers for years and never used it for anything:
They are very cheap and very easy to use. The receiver has 5 signal pins. When you push down any button on the transmitter, while pushing, the UT pin is High. The proper pin will also be High, but that also stays high until the next update.
I was sure that it will have limited capabilities, especially without analog sticks to control the turret, but I liked the small form factor, so I figured it worth experimenting with. It was lying in my "Arduino box" for years, unused.
For the brain of the turret I'll be using a BBC micro:bit. It is a very unique open source, ARM based microcontroller that is designed by BBC for computer educational purposes. This is one of the few parts of the turret that is actually new. It has a nice 5X5 LED matrix display and it is a nice and relatively cheap microcontroller. It also has accelerometer and BLE capability, but I won't be using those now. However the BLE based control can be an interesting way forward in the future. Usually people use Python to program the micro:bit, but I'll be using the Ada programming language this time!
For the firing mechanism I thought I try to build a baseball pitching machine style machine. It is a simple concept that can fire basically as fast as you can load BBs into it:
I specifically liked this version of it as it required only one motor to work with a very simple design:
As you'll see my firing mechanism is basically the same concept and design but with some adjustments for this specific use case. I used and old 920KV BLDC motor with an old ESC.
The 920KV BLDC motor that I used has a (now) funny story to it:
5 years ago, when I was building my first quadcopter with a custom, wifi based wireless communication method, I made some mistakes and I almost lost the quad. No fail safe is not a good idea and it almost went to infinity and beyond.
It was high up and also moving away from me. Before I lost connection, I could lower the throttle enough so it could land relatively safely about 4 neighbors away. I heard that it was still buzzing after it landed (crashed) and I just couldn't reconnect to it. When the neighbor came out and let me to get to it I realized that the drone was upside down, one motor (this motor) on muddy concrete and the others in mud, full of pig shit and all spinning. I managed to disconnect the battery, but the motor on the concrete literally sanded down almost 1 cm of aluminum of the motor's shaft and the whole propeller. It took hours to clean the drone and of course I had to buy new motors, propellers and an arm and it smelled like pig shit for weeks, but it still flies! No humans or pigs got hurt, but I learned that never fly UAV-s, especially unreliable ones in populated areas.
TL;DR this motor was perfect for the job as it can spin properly, bit I literally cannot use it for anything else without a threaded shaft.Building the turret
When it come to the designing part, naturally I created many iterations, before I ended up with the current one. Let's start with the most complex part: the head of the turret:
If you examine the model, you might notice that it is impossible to print without supports, and some of those supports need to be in the inside channels to which makes them almost impossible to remove without damaging the model.
As a workaround, I used a clever technique so I can print without generating impossible to remove supports: built-in supports and sacrificial walls. Here's the version where I added those:
These kinds of supports require a well tuned-in 3D printer, so you can print overhangs without issues. I used a quite low quality filament, so not even that is needed, but naturally useful. You still need to generate supports, but only where the model is touching the build plate. Overhangs are not possible where the nozzle would need to move in an angle (e.g. overhang corners, holes), so I added 1 one layer thick sacrificial walls at those places, so you can print it properly. After the printing is finished, you just need to remove those one layer walls. That way you can do a successful print, just like this one:
The white rubbery ring around the motor is from an old, cheap mouse's scroll wheel. Originally its diameter was much smaller, but I warmed it up in some hot water and it became much easier to work with. It stretched nicely and now it is a perfect fit and catches the airsoft BBs quite well.
Printing the other components are mostly straight forward. The trigger solenoid holder also has a sacrificial wall, but besides that, all 3D objects can be printed without any special care.
For now I used a simple gravity fed clip/magazine which is just a tube. I'm thinking about a better solution which can hold more BBs, can work in any angles and doesn't look like a long plastic antenna, but it is good for now.
The Eachine TX03 can become quite hot during operation if you use its 200mW mode. You should either use PETG (or something that can handle some heat without deforming) or you should use the TX03 in a power mode that produces less heat.
For the 360° horizontal movement, we need to modify a servo to have continuous rotation. I won't go into details about that. You can just follow this tutorial:
After that you just need to screw the parts together:
A smaller bearing would have also worked, but I was thinking about using a slip ring and put the electronics in the bottom. This bearing left that option open for me. The big hole on the bottom will help you attach the turret body to the bottom with screws.
The BBC micro:bit and its expansion board has a dedicated space at the back of the body. After the head and body part is complete, we can move on to the electronics.Wiring it up
The battery eliminator circuit (BEC) of the electronic speed controller (ESC) can provide 5V for the circuits of the turret, but I was worried that powering the micro:bit, the receiver, the camera and the servos might be too much for it, so I only used that for the logic and I created a separate voltage regulator circuit to create a separate 5V for the other things like servos, the solenoid or the camera.
The camera in the 200mW mode can draw a lot of power which means that it can heat up a lot. It also means that the 7805 IC will heat up, so I added a small heat sink to the voltage regulator just to help some. I didn't experience any issues with it, but I'd still avoid running it too hot. On the right side of the image you can see the TIP120 transistor that is used to switch on the solenoid.
For detailed circuit diagram please check the schematics section part of this project.
The radio receiver circuit operates at 5V, while the micro:bit operates at 3.3V. As far as I know, the micro:bit inputs are not 5V tolerant, so I had to do some logic level shifting. I used voltage dividers to do this. A bunch of 10k resistors did the job. I could have gone closer to the 3.3V, but by using R1 = 10K and R2 = 10K resistors, I could lover the 5V to 2.5V which is still a logic high for the micro:bit, so I went on with it.
The voltage divider formula:
Vout = Vin * R2 / (R1 + R2)
Using some insulating tape on these proto breadboards is a good idea to avoid possible damage and short circuits.
Connect the red and black wires to the battery. The 3 wire cable between them is 5V, GND and Signal. Connect the signal to the P0 pin of the micro:bit. Connecting the ESC to the BLDC motor is easy. Choose a random order to connect the wires together. When you get to the point with the project where you spin them up, check if the direction is good. If not, change 2 random wires of the motor and the direction should be good now.
Test the direction without BBs! If BBs get into the firing channel, they will stuck and melt in seconds. It will cause damage like this if you can disable it fast or worse if you can't:
Besides these, the circuit is simple. Just follow the diagram at the schematics section. Here's an image about the micro:bit that can help you find what pin is capable of what:
This was my first time that I used Ada. It approaches things quite differently from C-style languages, but after you spend some time with it, probably you'll realize that it is a very powerful language.
1. you need to setup your Ada Development Environment. Follow these steps to install GNAT on your computer.
2. If GNAT doesn't recognize your micro:bit, try these steps.
3. Clone my Airsoft Turret repo and open it in GNAT. The src/main.adb contains the main code
4. Build and flash the code to your micro:bit:
5. If everything went according to the plan, you should see this heart on the micro:bit's display. It means that it is ready in disarmed state.
GNAT provides a scroll text demo code when you create a new project, targeting micro:bit. You can also find some great examples for how to use different parts of the micro:bit with Ada. I recommend you checking it. I learned a lot from them.The software
The code runs in an infinite loop. I created this state machine on paper first, then I implemented it in Ada:
The update actuators part also contains the display update. Let's go over some cases in high level!
1. In the initial state everything is disabled, the turret is not armed, so you see the nice red heart on the display
2. If you push all 4 buttons together then the turret arms itself. If it was armed, it disarms itself. Firing and movement is not allowed in disarmed state. When it is armed, the BLDC motor spins up.
3. When you push Left (D) and Right (A) together in Armed state, the trigger will fire the BBs rapidly into the firing channel with the solenoid. The spinning motor will accelerate and shoot out the BB from the firing channel. When you are firing, you'll see a + symbol on the screen, flashing.
4. You can move horizontally and vertically at the same time. If you push up-down or left-right at the same time, no movement will happen.
5. When moving, you'll see simple arrows/lines on the display pointing to the proper direction on the vertical and horizontal axis.
Lets view how it moves! The firing part is disabled on this video, so you only see the + on the display indicating the firing.
Here you can hear the trigger firing:Problems
You might have noticed that I don't have a video about it actually firing BBs. Unfortunately I can't show you a video about how the BLDC motor is spinning and thus firing because it is very likely that somehow the ESC got damaged. Maybe wire damage (didn't find contact issues, but still that's my best guess), maybe something else from past experiments (it is a 5 or 6 years old cheap ESC that was my go to experimenting ESC for a couple of projects), but now its motor (or other motors) doesn't spin with it. I created a test code with the Ada micro:bit servo library that worked nicely, but unfortunately now the same code just causes the BLDC motor to shake violently and later even the shaking mostly stopped. On the Airsoft turret trigger solenoid firing video you can see what the BLDC motor does now when it should be spinning.
Earlier, while I was waiting for the micro:bit to arrive, I tested the turret with an Arduino and it worked perfectly. It resulted a couple of scared people and "WTF?" faces, so huge success. The firing power is not too high and the range is limited so it wasn't hurting people at all, unlike proper airsoft guns. The accuracy wasn't the best, but the high firing rate meant that I could always deliver hits in the range. Unfortunately I didn't think it would be genuine on an Ada contest to record that with an Arduino, so now I don't have any recordings about it properly firing. I commented out the ESC related code so I can prevent further damage of the ESC or any other components, but probably it would work. A similar code worked previously in an experimenting test project where I tested ESC control from the micro:bit. 2 new ESCs are on their way to me, but I didn't have a spare part or easy way to get one fast, so it's a bummer.
You might also noticed that the servos' movement is a little bit chunky sometimes. At first I thought it might be a software issue, but after doing some experiments, I realized that it is definitely caused by the servos. I concluded that the servos interfere with the receiver and the not uncommon servo jittering is also present here. Some ferrit rings will help with the jittering, but I have to get some first.
When the movement was chunky, I realized that the direction indicator leds on the display were also flashing. When I cut power from the servos, the same code worked fine, no flashing and the smoothness of the movement depended on the position of the turret. I believe noise generated from the servos interfere with the receiver module. Changing the battery in the transmitter helped somewhat, but moving the antenna higher and further from the servos is also on the todo list to improve the reliability.Camera
I did not write about the camera for a simple reason: it just works easily. This is the camera image that it can produce:
This is more than suitable for indoor usage, however different and better cameras can be used for different use cases. I made the turret head modular, so you can attach a different camera, trigger and clip mounts to it. I used this receiver to view the camera's image on my PC or on my old phone:
I'm thinking that with some machine learning, the turret can be automated to shoot unknown people. That would be a fun addition!Conclusion
I really enjoyed the process and learned a lot. Both on software side with Ada and hardware side with improving my 3D object designing capabilities. Ada is definitely an interesting programming language and it was great to work with it and I'm looking forward to see what others come up with it, so I can learn more.
I think the turret turned out to be a nice addition to my projects and while it needs some improvements (and repair at the moment), it is one of my most unique projects on hackster. It will reach its full potential, once I put it on an RC vehicle, but even in its current state, it is a very fun project that I can be proud of. The electronics are well protected, so it can survive some punishments and it is quite compact. Maybe it can even be made somewhat rainproof with some design improvements. After 1-2 revisions it can be a nice addition to any airsoft fights. I see numerous paths how I can iteratively move forward with this project.
Thank you for reading, have a nice day and here's a picture to commemorate my quadcopter crashing into a bunch of pig shit: