This is a training task for making an bow-like turret with Arduino Uno and 3 servo
in 2.0-2.5 hours, make a turret that will be controlled using 2 large servos and 1 small one. The model must be original. A typical code may be the connection code for Arduino uno servos. The model should move horizontally and vertically, and a small servo is used to "release the shutter." You also need to make a projectile. The finished product should not look too collective.
the repository will be divided into 2 blocks - programming and the build itself. since the part related to programming and the assembly of the modules themselves is the same
Add added g-code/3mf with final v2 models for FF a5m (pro)
Arduino Uno R3 Arduino Expansion Board
Servo MG995 (2 pc)
Servo SG90 (1 pc)
breadboard Wires The potentiometer (2 pc) Button Stationery elastic band
first, I need to connect the Arduino to the expansion board. In order to do this correctly, I found a diagram on the Internet.
in this diagram, I see a signed pinout, because I have an expansion board in my hands, where there are no labels.
here you can see what the connection of the modules will look like.
and here's what the result of connecting an Arduino to an expansion board should look like.
ready
The activation code and and also the connection diagram was found by me on the [Arduino website].(https://docs.arduino.cc/learn/electronics/servo-motors/).
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
then I connected the servos and potentiometers as shown in the diagram above
then I entered the code into the Arduino IDE program and started editing it, since in the example from the Arduino website, only one motor could be used.
the code to copy with descriptions
#include <Servo.h> // activate the library for working with servos (it is available by default, you do not need to download it)
Servo myservo1; // create servo object to control a servo1, there is a difference from examples code - we need to mark our servo by servo1 and servo2
Servo myservo2;
int potpin1 = 0; // analog pin used to connect the potentiometer, we need to mark it like in example with servo
int potpin2 = 1; // use correct analogue pin number from my connection
int val1; // variable to read the value from the analog pin, need to mark it also
int val2;
void setup() {
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo1.attach(10); // need to use correct pin number from my connection and also mark it
}
void loop() {
val1 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val1 = map(val1, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val1); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
val2 = analogRead(potpin2); // write command for 2 servo and also mark all
val2 = map(val2, 0, 1023, 0, 180);
myservo2.write(val2);
delay(15);
}
result
IMG_3386.MOV
everything is working. now we need to connect the third SG90 servo by analogy.
final corrected code from sg90
#include <Servo.h>
#define SERVO_PIN1 3
#define SERVO_PIN2 9
#define SERVO_PIN3 10
#define POT_PIN1 A0
#define POT_PIN2 A1
#define BUTTON_PIN 2
Servo myservo1;
Servo myservo2;
Servo myservo3;
int val1, val2;
int servo3Position = 90;
int buttonState = 0;
void setup() {
myservo1.attach(SERVO_PIN1);
myservo2.attach(SERVO_PIN2);
myservo3.attach(SERVO_PIN3);
pinMode(BUTTON_PIN, INPUT);
}
void loop() {
val1 = map(analogRead(POT_PIN1), 0, 1023, 0, 180);
myservo1.write(val1);
val2 = map(analogRead(POT_PIN2), 0, 1023, 0, 180);
myservo2.write(val2);
buttonState = digitalRead(BUTTON_PIN);
if (buttonState == HIGH) {
if (servo3Position < 180) {
servo3Position += 5;
}
delay(1);
} else {
if (servo3Position > 0) {
servo3Position -= 5;
}
delay(1);
}
myservo3.write(servo3Position);
delay(15);
}
In this part, I will describe my attempt to make a turret in the allotted time right during classes in FabLab.
To meet the deadline, I need to plan my work properly. While my classmates were busy connecting the motor to the board, I decided to focus on making the turret itself. It seemed to me that the modeling and manufacturing process would take too much time.
At first, I decided to search the Internet for models similar to a crossbow to see how other people implemented this idea.
I chose the right one in my opinion.
Now that I saw the example in front of my eyes, it was easier for me to model my crossbow.
first, it was necessary to determine the size. The size range will dictate the degree of tension of the elastic band, at which its force will be enough to release the projectile. I know from orthodontics that elastics gain the most strength if they are stretched 2-2,5-3 times. I'm not holding a special elastic in my hands, but just a stationery elastic band. Experimentally, I realized that it is better to stretch it no more than 3 times, since then it bursts. I stretched it with my hands about 2 times, applied a ruler, and it turned out to be about 100 mm. I decided to proceed from this figure. if there is not enough tension, I will be able to adjust the tension force using a trigger, the role of which will be performed by a small SG90 servo.
To create the model, I used RhinoCeros 7, with which I wanted to create a .dxf format drawing for cutting on a laser engraver made of plywood, since the task time is limited and this will make the model faster than printing on a 3D printer.
to begin with, I created a square with sides of 100*100 mm, so that I would have a guideline for modeling a crossbow of the right size.
then I started modeling the part where the elastic band should be stretched.
The blueprint was almost ready.
The two holes on the model are modeled in order to better attach the base of the crossbow to the bowstring itself.
the drawing was uploaded in the format.DXF in order to produce 3mm plywood on a laser machine.
laser cut in action
IMG_3378.1.MOV
got it
I decided to glue the parts together using a hot glue gun.
at that moment, I folded the model and thought about how to implement vertical and horizontal movement. for some reason, the option of putting one servo on top of another did not occur to me, and I decided to implement vertical movement using the "living hinge". I have modeled a (not the most successful) option in RHinoceros. The idea was that the servo, which controls vertical movement, would be connected by an elastic band to a live loop, so I could move the turret vertically. This solution does not look efficient and reliable enough, but it is copyrighted and it could have been tried to be implemented before the deadline.
the first version was absolutely terrible
the second one looked more acceptable (I positioned the hinges more tightly to increase strength) and sent it to CorelDRAW to prepare for laser cutting on 3mm plywood.
I also added the same fasteners that are used to fix the elastic band tightening mechanism - I thought it would be useful for better fixation.
Laser cut in action
IMG_3383.MOV
Got it
The photo shows that when trying to extract the living hinge from the laser cutter, it broke in half. After holding it in my hands, I decided that it might be worth gluing 2 pieces together to increase strength.
there will be no photos of the process of gluing parts together using a hot glue gun, as my hands are stuck to the glue, everything is stuck to the glue, even the glue is stuck to the glue. the most unpleasant sensation was getting a finger burn from hot glue, which I couldn't remove from my finger because it was too fluid. Since it was too far to the sink, I had to train my acceptance.
Result
IMG_3392.MOV
well, it was a good instructive moment, thanks to which I realized not only the disadvantages of this approach, but also that a hot-glue gun can create an elastic cushion for gluing plywood. Unfortunately, in my case it looks like a toy picked up in the trash.
IMG_3394.MOV
Still, I had to check if it could handle the elastic band tension function.
IMG_3393.MOV
in order to model the mounts, I need ready-made files with motors. I don't see the point in modeling them from scratch, since I can handle this task and I don't see the point in wasting time on it. other people have already done this. the meaning of my task is different
I took the model files from [this site].(https://grabcad.com/library/tag/mg995)
[MG995 Servo].(https://grabcad.com/library/mg995-servo-3)
[mounting on the "asterisk" motor].(https://grabcad.com/library/mg995-star-horn-gear-1)
The first iteration will be with the simplest way to place the motors: one on top of the other. in fact, I will need to model the fasteners for them and make a platform so that the structure does not tip over.
First, let's start by importing the engines themselves. I imported a file format from various files in the archive into RhinoCeros 8.IGS
I use a motor mount in the same format. after importing into Rhino, I turned the motor so that the rotating part was pointing upwards, and the mount coincided with this part.
the approximate location is ready. to do this, I combined and copied the motor with the mount and positioned it so that vertical movement was possible.
at that moment, it became clear to me that vertical movement would be implemented in a slightly different way. to do this, I asked google a question and this is what it answered me.:
I found an [interesting article on habr].(https://habr.com/ru/articles/200516/) that explained to me how movement along different axes would occur.
at that moment, I thought about the fact that the cannon would have to be shifted to the side even more than I thought. but for now, I'm not going to think about how to position it vertically, as my head is already boiling.
it is also better to imagine the movement of the cannon, I was helped by such a drawing from the same google query.
now I know that such a mechanism is called a "swivel cannon".
Now it's time to add the [SG90 servo model].(https://grabcad.com/library/4145-towerpro-sg90-mini-servo-sunrobotics_in-1) here.
The movement system is increasingly coming together. I imported the SG90 model in the format.STEP (this, of course, was worth doing with other models). I may still be moving the models between each other, but the general scheme is already clear. Now I need to think about how I'm going to connect the motors together.
Nevertheless, I decided to position the SG90 differently, since it should act as a trigger.
actually, at this stage it would be possible to look for special holders for servomotors, but I wanted to model them myself.
in real life, I started modeling the "advanced" version 2 at this stage, and returned to this one later.
Main part
Back part (it is possible without it)
Bow
Upeer model view
The first part of creating models is described in version 1.
There have been many corrections and alterations. So I will focus only on the main points.
this is the final result after several corrections.
I've taken a few points as a basis.:
- Since, due to the location of the engines I have chosen, the turret will have a clear shift in the center of gravity towards the cannon itself, I decided to create a large base that should give stability to the structure;
- also, for balance, I positioned the volumetric part in the opposite direction from the gun. initially, I wanted to make a support wheel there, which would provide another fulcrum, but I decided that I would have to make changes to the design, which would take too much time anyway, and abandoned this idea.;
- the motors will be fixed by matching the shape of the holders to the shape of the motors;
- The upper part of each of the motors will remain free. instead of screws, I will try to use specially modeled pins on the holders.;
- the big problem (which made me redo the holders) was that I underestimated the size of the wire. There should be plenty of room in the final version;
- I wanted to avoid angular shapes as much as possible in order to train myself to a different visual mindset during modeling, as well as to make the turret more stylish.;
- I use PLAY filament for printing, as it prints quickly and has a fairly low shrinkage;
- during the simulation, I did NOT provide for shrinkage compensation, nor did I adjust the geometry to make the landing of the motor more free. keep this in mind if you try to repeat the project.;
- I turned out to have too many components and to fix them with each other, I probably have to use an acrylate glue. I should have made the structure more monolithic;
- the weaknesses that are obvious to me at the moment, while the final sample is being printed, are the fixation of holders with nozzles on the motors and excessive load on the vertical servo;
now I will focus on a few points in more detail, since I am not sure that I have the strength to describe the modeling step by step.
this is what the model version looked like when I was still planning to make a wheel as an additional support for a vertical servo. there were flaws, for example, one layer at a time on the cutouts of the crossbow, an unfinished arrow, but at this stage I launched the printing platform, as well as horizontal and vertical holders for the servo. At that moment, the idea of "hiding the wires inside the structure" seemed attractive to me, but I did not approach it carefully enough.
The printer is FlashForge V5 Pro, the filament is Pla Geeetech, printing is carried out from a Reality Space Plus filament dryer, the filament was dried at 50 degrees, heating was about 1-1.5 hours before printing. Slicing in the OrcaSLicer 2.2 0.4 nozzle.
slicing
I had to redo the holder for the SG90 servo, as its rounded shape did not allow it to be adequately positioned on the printing table.
I either had to change the model from scratch or add a plane to it so that it could be adequately printed.
detail before adding the plane
a detail with an added plane, but not yet edited
despite the modification of the model, I had to use the support. this is my first experience of manually setting supports. I have drawn the areas where, in my opinion, it is necessary to put tree supports.
I also had to print the parts vertically to balance the center of gravity (because of their convex shape). I didn't want to change the form, so I also used the support
the result of the first print
the horizontal motor holder fits perfectly into the platform. but there were problems with attaching the motor to the nozzle, which is why I had to redo the part. the problem arose because I got confused in the large number of objects on the screen and missed what I had done with the "Boolean difference"
IMG_3585.MOV
The fit of the lower part of the motor seemed normal and tight enough to me, but I couldn't check it because I made a mistake with the size of the channel for the wires.
IMG_3586.MOV
the problem with the channel for the wires was that it was not large enough
IMG_3587.MOV
I tried to solve this problem by using dental micro-examination.
unfortunately, there were chips, which turned out to be quite difficult to remove. Perhaps the problem is partly related to the low melting point of PLA, and during processing at 30,000 rpm, it was locally heated and the chips were slightly fused. I was trying to use wire cutters and a wrench for the nuts from my 3d printer
finally, I decided to leave the platform, as it remained functional after the correction. The correction of the holders did not work out, so I decided to fix the errors on the 3d model itself and re-print it.
during the correction of 3D models, the "channels" for the wires became too large and the overhang area increased. I had to make the roof of the channel rounded to improve the print quality.
an example of a corrected channel
I uploaded the corrected models along with the models that I haven't printed yet to OrcaSlicer.
The printing process
IMG_3594.MOV
Ready
But there was some problems. again, I did not provide enough space for the wires, because I did not appreciate that I needed to provide ways to insert the motor into the holder. To fix this, I had to use a dental machine again to drill the models.
after the modification, the fixation of the motors in the holders became excellent. I also had to remove the internal bushings, since the motors are held by fixing the walls of the motors with a holder.
let's check the fixation of the horizontal motor holder in the platform
IMG_3625.MOV
the weak part of the project also becomes obvious - the idea of installing a holder in the nozzles for motors clearly failed.
IMG_3626.MOV
There is also a good fixation of the sg90 servo into its holder.
there was a problem with one of the parts for assembling the bow - I did not provide the tolerances and the beam got stuck inside the hemisphere. I didn't like the option of sawing it, since the walls are quite thin and I can permanently damage the model.
to install the beam in the hemisphere, it had to be literally hammered there.
IMG_3632.MOV
Fortunately, everything worked out.
I also did not provide for a good fixation of the adapter from the sg90 servo to the bow. this happened because I got confused about Boolean operations and didn't cut out everything. I also did not provide for the distance at which the nozzle on the sg90 is located from the servo housing itself.
since this problem became apparent already at school and there is no dental motor in FabLab, I tried using a screwdriver.
In order not to damage my hands during this process, I tried to fix the model using a special FabLab holder and pliers. I do not recommend repeating this experience because of the poor fixation of the model during drilling.
despite my efforts, the result was unsatisfactory. I didn't want to re-model the model and print it, but I guess I'll have to do this.
in order to remove the supports from the parts that are supposed to balance the structure, I used special pliers from a 3D printer.
the result was acceptable . my first experience with installing the supports manually on an FDM printer turned out to be successful
I re-modeled the adapter from the sg90 servo to the bow in Rhino, also made a new arrow model so that it was wider and better fixed on the bow plane, and also added 2 models of small supports for better fixation of the bow in the adapter to the sg90
slicing was done in OrcaSLicer by a teacher from FabLab
material - PLA from SolidFilament
3d printing on the FlashForge a5m printer
IMG_3651.MOV
Ready
The adapter for sg90 servos was a great fit. I was worried about fixing it with the motor, but it holds without additional accessories.
view of the assembled model. adapters for additional mounting are also visible here. I attached them with a hot glue gun. traces of glue are also visible in the photo. Unfortunately, they didn't work out the way they look in the simulation. It was probably worth making them bigger.
It is worth adding that the nozzles for the servo were also glued with a hot-glue gun to the holders themselves.
view of the landing pad with applied glue
ready-made view of the assembled cannon
at this stage, I double-checked the wiring connection again. in fact, it was at this stage that I changed the program code so that the sg90 servo would work (a reference to the programming point)
Let's check the mobility of the cannon
IMG_3662.MOV
an important point: I did not use the arrow that I originally printed for two reasons: I made it too narrow for the bow platform and it also turned out to be too light. so I used an arrow that I modeled based on the size of the landing pad. here we found out another nuance: the landing pad turned out to be too short in length, which is why the boom was outweighed by the leading edge. to fix this, I glued the failed parts to the tail of the boom to change the center of gravity. It's not much, but it has improved the situation a bit.
view of the cannon with the final version of the arrow with a weighting
I also had to connect the wires to each other to increase the distance to the microcontroller somewhat.
the task has already been completed. But let's check how the cannon fires.
IMG_3668.MOV
Of course, I wouldn't call it a powerful weapon, but the cannon works.
if I have time, I want to change the model. here are a few points that I want to fix: hide the wires inside the cannon body; change the fixation of the parts with each other so that glue is not required; change the shape of the bow and arrow to improve balance and range; make a housing for the microcontroller so that a beautiful and functional control panel comes out; change the design so as to reduce the number of elements, which the model consists of. These points will help me to work on mistakes, train my engineering thinking and take into account the difficult moments of modeling and assembly in the future.