Turret Gun

Introduction: Turret Gun

Like every mechanical engineer, at one point of our studies we were so tired/upset of everything not working or not going as intended that we wanted to shoot something.

What if we are able to make a project that converts all our frustration into something enjoyable and satisfying?

Here we present Billy, emperor of destruction, lord of the guns, ally of Nerf company.

The point of this project was to use our creativity to build a robot.

Shooting an object is a very challenging task. In previous project the idea consisted shooting a ball or a dart. We as a group think that we can do better then the average by using fly wheels hooked up to DC motors that can reach a no load of 26 000 rpm at 7,2 Volts.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: How It Works

The turret gun has been designed for being either a possible toy for children or a helpful balls shooter for old people and disabled people who want to play with their dogs. Hence, the gun has to be user friendly as much as possible. In order to do that we have implemented a bluetooth module to allow the user to control the gun directly from the phone. The balls chosen for this model are the Nerf soft balls with a diameter of 2.3 cm.

The gun is composed of three main elements: the "gun platform" where all the shooting and reloading mechanism is placed and the base, which is divided in in other two parts that are the main base structure and the lower base support. (see body design section).

The movements that the robot is able to performed are two:

  • The base can make a 360° horizontal rotation thanks to both the stepper motor and the lazy Susan bearing linked on the base (a better explanation of this mechanism is given in the chapter "BODY DESIGN".
  • 90° Vertical rotation made by the "gun plate" thanks to the servo motor linked on the base lateral plate and linked to a shaft which runs underneath the gun plate.

Once the turret gun is turn on, the servo motor sets the gun plate on the steady position that can be regulated by the user. By using the command "fire" the two DC motors attached to the gun plate start to run at the desired speed and by means of friction the flywheels directly linked on the motors' shaft start to rotate. Thanks to another servo motor the reloading mechanism starts to run and it can be set up for a single shoot or for multiple shoots. It is made of a crank-connecting rod-piston system which is very simple to assemble, control and very reliable. The crank makes a 180° rotation which allows the piston to move through the cylinder and push the balls through the rotating flywheels. The balls are loaded into the cylinder by means of an automatic "Nerf balls charger" that we got when we bought the Nerf balls.

Step 2: Components List

Electronics

2x Servo motors (LINK)

Stepper-motor (LINK)

2x DC motors (LINK)

Proximity sensor (FABLAB)

Arduino uno board (FABLAB)

Bluetooth module (LINK)

DC adapter (LINK)

H bridge (FABLAB)

Mechanical

2x Bearings (LINK)

Lazy-susan (LINK)

4x Side screw shaft lockers (FABLAB)

6mm shaft (FABLAB)

MDF 6mm plate (FABLAB)

MDF 4mm plate (FABLAB)

PLA for 3D prints (FABLAB)

Nerf balls (LINK)

Step 3: Body Design

In order to make both horizontal and vertical movements, it is crucial to design the body of the robot correctly. The first conceptual design made for this purpose is shown on the first image above.

There are 3 different holes that will fulfill this role. First the hole located in the horizontal plane. This is the place where the stepper motor is going to be placed in order to make the robot turn around its axis. One of the obligations that was given is to make sure that the robot can reach a target in a fully horizontal 360 degrees range.

The 2 other holes will be used to put a shaft inside in order to connect the structure containing the gun and other shooting mechanisms.

The space inside the box will be used as a place to connect all the cables and hardware (Arduino, PCB, ...).

The 2 parallel triangular planes were used to give stability to the structure. The first sketch that was made prior to this conceptual design was based on an U (see second image). This design was not good because the U shape can cause instability and oscillation during the shooting process. This is solved by putting triangular shaped plates on the sides.

Because we were not allowed to use glue, the design was slightly modified in order to build the body like a puzzle, and fix all the different pieces with screws and bolts (third picture). The holes at the bottom are used for the attachment of the stepper motor and for the lazy Susan.

Step 4: Support Design

The support shown in the third picture above is going to be placed under the body and above the table. This piece is crucial as its function is to have a support for the body, have contacts with the surface under it (generally a table) and most important being a reference for the rotation of the body.

In order to help the body rotation and to absorb the important load from the body and gun combined, a lazy Susan bearing (second image) will be placed between the support and the body. The holes that are on the support are for the lazy Susan bearing, and a shaft locker in order to fix the shaft of the stepper motor on the support. This will make sure that the shaft will hold its position and will have the same reference as the support, making the stator (and the body of the robot) turn around the axis of rotation.

The dimensions of the support and the legs are shown in the first picture. The holes that are not mentioned have a diameter of 4 mm.

Step 5: Gun Design

The upper part of the robot features the shooting and pitch mechanism

The side servo is held by an MDF plate which is in turn rigidly connected to the side panel of the base. Another MDF piece is used to transfer the torque from the servo motor to the aluminium piece that holds the shaft using a side screw. The same aluminium piece is used to connect the shooting platform to the shaft rigidly. In the final design the side panels were changed from having rails for position adjustment to a set hole which is positioned as close to the center of mass of the shooting platform as possible, this has been done in order to reduce the amount of torque the side servo motor has to deliver once the plane is not horizontal. Both side panels of the base contain a hole and a bearing in order to not transfer the weight of the shooting platform to the side servo motor.

The top servo motor that is mounted on the shooting platform is responsible for loading the balls in between the two flywheels by moving 180 ° back and forth.The three-way cylinder part holds the Nerf charger trough a clip mechanism, once the charger is put in, the balls are released because of a provided hole extrusion, the balls are forced down inside the Nerf charger because of an integrated spring so it’s not an issue if the platform is tilted at a very steep angle. There’s also has a hole on the side of the three-way cylinder to fit the light sensor to check if a ball is present or not. An adjustable flywheel cage is used to hold each motor from underneath, the flywheels themselves are connected to the shaft of the motors, during assembly the motor fixations are reinforced by adding MDF piece from underneath and fixating them with bolts. To have the robot shoot the balls in a predictable way a barrel was put right after the flywheels to correct the shooting direction of the balls.

Step 6: Manufacturing Choices

Creating a robot requires a lot of different components, especially during the prototype phase, being cost effective and trying to reduce material waste as much as possible led us to make choices about what kind of manufacturing process was better to use for each component.

Standard components as screws, bolts, shaft and so on have been taken directly from the FABLAB, whereas for motors, electronics and bearings we used the website RS COMPONENTS (see section COMPONENTS LIST).

For manufacturing both the base structure and the gun plate we used the laser cutting machine and 3/4 mm MDF panels as material. This process is very fast, furthermore if the pieces to produce are well designed, it is possible to reuse the wasted MDF panels from the previous productions to cut new pieces.

For the entire shooting mechanism it has been chosen to use the 3D printers (Ultimaker2 and Prusa mki3) available in the FABLAB. This process is way slower than the laser cutting but allowed us to design and produce complex shapes that wouldn't have been possible to produce with other manufacturing processes.

The DXF drawings and STL files for 3D printing can be found inside the .rar file in this section.

Laser cut parts (MDF 4mm):

  • Base structure
  • Electronics box
  • Lower base
  • Gun plate and mechanism support
  • Servo motor and DC motors supports
  • Light sensor holder
  • Board and Arduino spacers

3D printed parts:

  • Nerf balls charger holder (ivory white)
  • Cylinder (white)
  • Flywheels (black)
  • Flywheel supports (black)
  • Crank, connecting rod, piston

      Step 7: Electric Scheme

      the electric scheme can be found in the picture , this scheme contains 5 motors, 2 motor drivers and 2 sensor.

      Before we continue and talk about the components please note that in this scheme a 9V battery is used as a power supply, this is not the case in the final project. In the final design an external power supply is being used at 7V with a maximum current of 4A. Also the adruino is powered through the general power entry and not through the Vin pin and the ground.

      Drivers:

      To drive the DC motors and the stepper there are 2 drivers that are being used:
      -1 H bridge to control the movement of the DC motors.

      -1 Stepper driver module to control the stepper and the max current.

      Motors:

      2 of the motors are DC gearless motors that can reach up to 26 000 rpm no load at 7.2 volts, which is more than sufficient enough for the shooting of a small nerf ball. In fact it is so fast that we put both of the DC motors in series with a max voltage of 5V, so 2.5V each. This is done to avoid the powerful vibrations, heat generation and energy usage of the power supply. With all of these limitations we can still produce a very decent shot fast enough to be barely recorded by a smartphone camera.

      2 of the motors are servo motors, one is to control the vertical angle of the gun and the other is used to drive to piston. both of them contain a lot of power, do their jobs well and have metal gears to avoid slip.

      Lastly for the base rotation we use a stepper motor for horizontal rotation directly hooked to the base, without gears. This motor has no encoder attached to it and thus there is no feedback to check if the position requested has been reached. due to the gearless connection the stepper motor has the tendency to slip at fast rotations, so to counter this the base movement is limited in speed.

      Sensors:

      2 sensors have been installed:

      -A light sensor to check if there is a ball ready to fire.

      -A bluetooth module to control the turret.

      Step 8: Software Design

      With the coding of the arduino we had in mind that the arduino should be able to multitask multiple commands at the same time so that movement will look smooth in all directions. As can be seen on the flowchart.

      To do this we made sure that the arduino cycles through all the actuators and does a part of each operation before moving to the next one. This sounds really easy but it is hard to refine so that all combining movements look smooth. Also if multiple actuators are being used this means that all of them move slower because the loop gets longer.

      The code uploaded to the arduino works reasonably well, however delays in the code slow down the process of multi tasking. This can be avoided by using the internal clock of the arduino by making more use of the milis() function, how ever using this function correctly requires a lot of practice and can lead to multiple other complex issues, there for we only use the internal clock of the adruino once to speed up the DC motors.

      <p>#include<Servo.h>  //We're useing servomotors so we need this liberary</p><p>#include<SoftwareSerial.h> </p><p>const int ServoVert = 5;
      const int ServoPist = 6 ;
      const int StepperDir= 2;
      const int StepperStep=3;
      const int ENA=11;
      const int in1=10;
      const int in2=7;
      const int disable=4; //declare cnst ints for ports</p><p>Servo ServoV;
      Servo ServoP; //declare servomotors</p><p>int speedregulator=200; //starting speed for DC motors if wanting to fire
      int PosServoV=60;
      int PosServoP=0;//Servo position intigers
      int ReadValue=0;
      int PosStepper=0; // check this again when we have an encoder
      int incomingByte = 0; //bluethooth reader
      boolean ServoVertcheck= false;
      boolean ServoPistcheck= false;
      boolean StepperStepcheck= false;
      boolean PistonMovingup= true; 
      boolean rapidfire=false; //declare the booleans for the code</p><p>SoftwareSerial mySerial(13, 9); // RX, TX setup bluetooth module to pin 13 and 9.
      unsigned long deltatime;
      unsigned long timestamp; //Declare unsigned long to use the internal clock of the arduino</p><p>void setup() {
        Serial.begin(9600);
        mySerial.begin(9600);
        pinMode(StepperDir, OUTPUT);
        pinMode(StepperStep, OUTPUT);
        pinMode(disable, OUTPUT); //declare ports stepper driver
        ServoV.attach(ServoVert);
        ServoP.attach(ServoPist); //declare servos to ports
        ServoV.write(PosServoV);
        ServoP.write(PosServoP); //reset servos to start the loop
        digitalWrite(in1,HIGH);
        digitalWrite(in2,LOW); //set the direction of the DC motors to shoot the ball out of the gun instead of back in.
        
      }</p><p>void loop() {
      delay(5); // small delay to stabilize the loop
      unsigned long timetorumble=millis(); //declare the time at start loop
      int  PP=ServoP.read();
      int  PV=ServoV.read(); //read the servo position only once and use the intigers to simplyfy the actions in the code</p><p> if (mySerial.available() > 0) {
          </p><p> String incomingstring = mySerial.readStringUntil('/'); // Read the string until the '/' sign is found, cut the string there and analyse it further</p><p> char x= incomingstring.charAt(0); //x is the letter that signalizes which actuator is being used
       incomingstring.remove(0,1); //remove x from the list
       int ReadValue=incomingstring.toInt(); //the rest of the code are only intigers convert them</p><p>    
      switch (x) { //read the letter to know what action has to be taken
        case 'f': //rapidfire
          timestamp=timetorumble; //set the time of the commando</p><p>    ServoPistcheck=true; //initialize boolean to start piston movement
          rapidfire=true; //initialize booleans for rapidfire operation.
          break;
          
        case 'h': //hold all and reset to beginning position
          ServoPistcheck=false; //stop the movement of the piston
          PosServoP=0; 
          ServoP.write(PosServoP); //reset the piston
          ServoV.write(60); //set vertical piston to horizontal  
          break;
        case 's': //singlefire same as rapidfire, except for the boolean rapidfire is on false
          timestamp=timetorumble;
          ServoPistcheck=true; 
          rapidfire=false; //initialize booleans for single fire operation operation.
          break;
        case 'v': //vertival movement
          ServoVertcheck=true;
          if(ReadValue<25){ //fysical bounderies to servo, 25 is the max upward angle 90 is the max downward angle
          ServoVertcheck=false;   
          }else if(ReadValue>90){
          ServoVertcheck=false; 
            }else{
              PosServoV=ReadValue;
            }
            
            break;
         case 'b': //baserotation
          StepperStepcheck=true; // set base rotation on
          digitalWrite(disable,HIGH); //enable the stepper
         if (ReadValue>0){
          digitalWrite(StepperDir, HIGH); //the position of the stepper should be positive
         }else{
          digitalWrite(StepperDir, LOW); //the position of the stepper should be negative
      }
          PosStepper=abs((ReadValue*200.0)/360); //convert angle to 200stepts
         break;
         case 'r': //DC motor speed limited between 90 and 255
         if(ReadValue<90){
            speedregulator=0; 
          }else if(ReadValue>255){
            speedregulator=255;
            }else{
              speedregulator=ReadValue; //set intiger for speed of DC motors
            }
         break;
         default:
         break; 
      }
      }</p><p>if(PosStepper==0){ //read if the stepper should be on or not.
        StepperStepcheck=false; //put the stepper off if the position has been reached
        digitalWrite(disable,LOW);
      }</p><p>//////////HORIZONTAL MOVEMENT /////////
      //
      if(StepperStepcheck == true){
         digitalWrite(StepperStep,HIGH);
         delay(20); //big delay to avoid slipping of stepper
         digitalWrite(StepperStep, LOW);
         PosStepper=PosStepper-1;
      }</p><p>//
      ////////// VERTICAL MOVEMENT /////////
      if(PV-PosServoV>0) { // check the direction you need to turn.
        ServoV.write(PV-1); //update the position negative according to current position
      }else if (PV-PosServoV<0){
        ServoV.write(PV+1); //update the postion positive according to current position
      }</p><p>////////Fire/////////</p><p>if (analogRead(A0)>200){ // lightsensor to check if firing actually needs to happen
        ServoPistcheck=false;
        }
        
      if(ServoPistcheck == false){ //check if the piston needs to move
          analogWrite(ENA,0);
      }else{
        deltatime=timetorumble-timestamp; //check the time diffrence between the firing commando and the present
        delay(10);
        analogWrite(ENA,speedregulator); // fire up de dc motors
        if (deltatime >= 2000){ //if the time diffrence is larger than 2 seconds move the piston, this 2 second delay between the commando and start of the piston movement is to allow the DC motors to gain in speed, to avoid a puny shot
          if(PistonMovingup == true) {
            ServoP.write(PP+9); //move the piston forward, +9 has been determined with experiments
            if (PP>=180){ // if the maximum position has been reached move back
              PistonMovingup = false; 
            }   
          }else{
            ServoP.write(PP-9);
            if (PP<=1){ // if the minimum postion has been reached move forward
              PistonMovingup = true;
              if (rapidfire==false){ //if rapidfire is off then stop the loop afer one go. 
               ServoPistcheck=false;
              }
            }    
          }
        }
       }</p><p>}</p>

      Step 9: Things We Can Improve On

      Electric scheme:

      Redo the wiring because right now the wires are just a very big mess, if there is something wrong with the circuit or with the sensors it's really a hard time to find the mistake and this is due to all the wires that we don't know we have. With motor pins being close to each other we are having some electrical interference that we can't solve.

      Add capacitors over the motors to maintain a stable voltage level. With multiple movements going on at the same time the some of the motors don't function well due to voltage drops.

      3D design:

      Add an absolute encoder, during the design a mistake was made where a stepper was used with no back shaft, due to this an absolute encoder was really hard to install, in the end we decided not to use one since it would be really complex to add to the design afterwards. However an absolute encoder would be really useful since the stepper has the tendency to slip.

      A gearing between stepper and base, to lower the torque used by the stepper motor. As mentioned before the stepper motor has the tendency to slip due to high torques, to counteract this a gear could be added instead of directly connecting the stepper motor to the base, as it has been suggested to us.

      Step 10: Conclusion

      A fully functional nerf turret has been build in two and a half months time, with very good shooting component and a very solid 3D design. With a few minor changes to the circuit and software this will be truly a force to be reckoned with.

      Making this turret gun as a team was a very interesting experience for us that we will never forget. Our lives will from now on be without any frustrations thanks to the ability to shoot nerf balls at whom ever crosses our path, like for example our future bosses if they're not happy at our perfect results as a mechanical engineer.

      As a finisher we'd like to thank the following people helping us to achieve this project:

      Bram Vanderborght
      Albert De Beir
      Marco Rossini
      Lieven Standaert
      Robin Verbruggen
      Gwydion Kruglanski
      Cedric Colson
      Michiel Vrolix

      Be the First to Share

        Recommendations

        • Magnets Challenge

          Magnets Challenge
        • Raspberry Pi Contest 2020

          Raspberry Pi Contest 2020
        • Wearables Contest

          Wearables Contest

        Discussions