Introduction:
A gun turret is a mounting platform that provides protection, vision, and the ability to swivel and aim from which weapons can be launched. A contemporary gun turret is a rotating weapon mount that contains the crew or mechanism of a projectile-firing weapon while also allowing the weapon to be directed and fired at a certain degree and elevation. The tutorial demonstrates how to construct a turret that can be controlled using a PS4 controller.
Step1: Material List
Electronics:
- 1 x L293N Motor driver
- 1 x PCA9685 16 channel servo drivers
- 1 x Tower Pro MG995 metal gear servo
- 1 x 9g MG90s mini servo
- 1 x Turnigy-210 DMH servo
- 2 x DC Motor
- 1 x PDB board
- 1 x Laser diode 5v
- 1 x Pi 4 (any raspberry pi board will do the job)
- Jumper wires
- 12 v Battery
- And finally a DualShock PS4 Controller
Tools:
- Screwdriver kit
- Pliers
- Nylon tie or tap
- Adhesive
- Soldering iron
- Insert nut M3
Step 2: CAD Design and 3D Printed Components
The Turret is designed on Fusion 360 and by using a 3d printer it made my work mush easier because I suck at crafting. Print all Required parts using PLA material with infill of 25% and support for few parts. All the files are available in GitHub which given in the following page.
Step 3: Assembly
Building Yaw and Pitch mechanism
Note: Make sure all the servos are in 90 degree position.
Procedure:
1. Attach the Tower pro MG995 servo to the base plate to finish the yaw motion. 2. Screw the servo holder to the yaw servo before inserting the Turnigy-210DHM servo. 3. Attach the servo to the holder and the pitch bracket after that.
Step 4: Building the Roller Mechanism
Procedure:
1. Attach the DC motor to the Roller holder and tighten the screw to secure it. 2. Add the laser diode to the Roller Mechanism. 3. Attach roller mechanism to the Barrel. 4. Finish the barrel assembly by adding the 9g mini servo and rack and pinion mechanism.
Step 5: Completing the Turret assembly
Procedure:
1. Using the Interlock part, attach the barrel to the pitch mechanism and secure it with adhesive. 2. Using a servo tester or another method, verify that the servo is in the middle position.
Step 6: The Circuit Diagram
Follow this pinout which is given above and supply a clean power to Servo and Motor and make sure to give only 5v to Servo and 9v or 12 v to the motor and ground all the electronic component.
Step 6: Importing the Library and Program
Here is the main code to Control the Turret which is written in python 3!
- Connect to raspberry pi 4 using SSH connection, enable the interface such as GPIO, I2C from raspi-config > interface
- Follow this link from Adafruit to install Servo library. Link
- Make a directory and create a virtual python environment and install the library.
Command: sudo pip3 install adafruit-circuitpython-servokit
- Make sure your python is version 3 the code which I have written doesn’t support python2.
- Install DualShock PS4 Driver follow this tutorial. Link
Command: sudo pip3 install pyPS4Controller
- Turn on Bluetooth from Pi4 and pair it before installing the library because sometimes it shows unable to pair connection failure error.
- Import the func.py script from the repo. Link
Command: git clone https://github.com/rohitz123/Turret.git
- Run the main program:
Command: sudo python3 func.py
Step 7: Well, Done!
You have successfully completed this tutorial and you have your own Turret.
I hope you enjoy it and By the way the challenge is to shoot the dart into a container which I felt was little harder I can achieve 6/10 shoots with Manuel control.
If you any query on this project, feel free to contact me through Instagram:
Future Work
I'm now working on a cannon trajectory for more precise shots, and by adding a camera, we can utilize computer vision such as OpenCV. Not only are you creating a turret, but you're also learning python, computer vision, and the Raspberry Pi 4. As a result, you'll be more exposed and innovative, and who knows, you could even develop a next-generation Turret!
End of experiment
Result: Pass