CONSTRUCTION GUIDE Robotic Arm Robobox Level II
Robotic Arm This month s robot is a robotic arm with two degrees of freedom that will teach you how to use motors. You will then be able to move the arm more precisely using the pushbuttons. 1X Support Base 2X Plug-in Arms Pièces 2X Servo Motors 2X Push Buttons 2X 10KΩ Resistors 6X Male Male cables Instructions We suggest that you follow these instructions step by step. Additional details are available on your member space on Robobox.io. Please don t hesitate to ask any question, we will answer them promptly. Good luck!
Step 3 Step 1 Step 2 Robot Arm _0_ 1NTR0DUCT10N Go to www.robobox.io/members and enter the username and password you received by email. Next go to General to download the drivers for your card if you haven t already done so. Open and execute the file. In the same folder, download the Arduino software version corresponding to your operating system. Once installed, launch it and plug in your card. Let s now check your Robobox UNO : - Go to Tools, then ports and choose your card (ex: COM4) - Be sure that in Tools/Card, Arduino Uno is selected - Now go to: File/Examples/Basics/Blink In the window that just opened click on upload. Step 4 Wait until Done Uploading shows at the bottom of the window. You should now see the LED close to the pin 13 blink. Now unplug the card and check the content of your box
Step 7 Step 6 Step 5 Robot Arm _1_ BUILD Take a cross-shaped servo horn and insert it in the support base. The two sides of the crossshaped horn are not of the same size : «S» is the Short one and «L» is the long one. Insert a second cross-shaped horn into an arm and the servos into the grippers. Finally plug the motor in the horn. You can also screw the horns into the servos to solidify the arm. You can now connect the whole arm into the base. Remove the duct tape from the bottom of the base to increase the arm s stability.
Step 10 Step 9 Step 8 Robot Arm _1_ BUILD Please note that the colors used for the connections below are arbitrary and will not impact your circuit.. You can use your own color code depending on your available wires. Signal 5V Terre Let s now connect the two servos to the breadboard. Each motor has 3 wires : a brown one, a red one and a yellow one. The brown one is connected to Ground, the red one to the current source (5V) and the yellow one drives the signal. You can use male-male wires into the servo s female pins. Now connect the servo s brown wires (GND) to the breadboard. Both wires should be on the same breadboard strip. Do the same for the red (5V) wires on a separate strip. 5V GND You can then attach a male-male wire from the breadboard ground strip into the UNO s GND pin. Connect another cable from the breaboard current strip into the UNO s 5V pin. Finally, join two male-male wires from the servo s signal cables (yellow) onto the UNO #2 and #4 pins.
Step 11 Robot Arm _2_ COD3 We will now go through the software instruction, that is to say the code that will be sent to our circuit. This code will enable us to get any behavior we want from our circuit. In order to write this code we will need to launch Arduino. You will then need to type the program in the big white window at the center of the screen. You can copy / paste the lines below but we advise you to read and understand the explanations. Have fun! #include <Servo.h> Servo myservo1; // Creates a Servo object called myservo1 Servo myservo2; // Creates a Servo object called myservo2 int servoangle = 0; // Defines a position to set our servos First, let s define the global variables that we will be using throughout our code and then let s introduce libraries. With libraries we will add another piece of code in our code. This first program has been built by other programmers and is name Servo.h. This libraries includes a set of functions that will allow us to interface easily with our Servos. In a C/C++ program, we add a library with the following code at the top of our program : #include <library.h> where library.h is our library. These files end with.h so that we now they re libraries, but they are programs nonetheless.
Robot Arm _2_ COD3 With this code we can now create servo objects. In programming, an object is a type of big variable just like the int and float we saw earlier except we can give them additional functions that we call methods. We call an object s methods with the dot :.. It cat were an object, we could use the purr method like this : cat.purr(). New objects are instantiated just like regular variables, by writing the type and giving the new instance a name. Thus, Servo myservo1 means : instantiate a Servo object that will be called myservo1. In the previous code we create two of them. Finally, we generate and additional integer called servoangle that we will use to communicate the position we want the servo to be in.
Step 12 Robot Arm _2_ COD3 void setup() { myservo1.attach(2); myservo2.attach(4); } We tell the program that a servo is attached on pin #2 and a second one on pin #4 In an Arduino program we always start by a setup() function. It is used to set the general parameters. Here we will use a method of the servo objects we created previously. This method is called attach(n) and it is used to inform our program that a servo is plugged on pin N. You see that unlike previous programs, we don t set the pins in input or output mode (pinmode(2,output);). This is already done as part of the attach() method. Methods always end with parenthesis () because we sometimes want to insert additional parameters to personalize how the method () should be executed. Here we inserted 2 and 4 but we can add a lot more.
Step 13 Robot Arm _2_ COD3 void loop() { for(servoangle = 0; servoangle <= 90; servoangle += 1) { myservo1.write(servoangle); myservo2.write(servoangle); delay(15); } for(servoangle = 90; servoangle>=0; servoangle-=1) { myservo1.write(servoangle); myservo2.write(servoangle); delay(15); } } Let s now have a look at the heart of our program : the infinite loop that will send instructions to the robotic arm. Inside this loop(){} we have two additional for loops for : for( x=0 ; x<90; x = x+1){}. These loops are constructed thusly : for( start ; end ; step ){code} By starting at x = 0 and while x < 90 we will run the program in the brackets and add 1 to x in each loop. The initial variable (x=0) will then increase by 1 every 15 milliseconds, until in reaches 90. no x = 0 Is x less than 90? yes Runs the program in the brackets x = x+1 Next step
Robot Arm _2_ COD3 Once x = 90 is reached, the conditions set in the loop (servoangle <=90) are not true anymore. We therefore jump out of the loop and enter the second one, which will run from x = 90 to x = 0. Within these loops, we will use a method from the servos :.write(n). This method tells the servo to go to position N, where N represents an angle from 0 to 90 degrees. The servomotors can be positioned from 0 to 180 degrees. We chose 90 in our code but you can change this value if needed. Congrats! You ve made it to the end! You may see that some additional elements are still unused, you will need them for the challenges below! So, we made a robot that is able to constantly move its arm, but we can t really precisely change the robot arm s position. Let s now try to use buttons to control it! The goal of this challenge is to use two buttons, one controlling each motor, to place it in the required position. You will need to define a couple of pins as inputs (pinmode(n,input); and use and if statement to condition the movement. Show your solutions to this challenge on Robobox.io/members or on twitter @Robobox_io for a chance to win a prize!
Robot Arm To start on a good note, here is a quick presentation on how to use a push button. _2_ COD3 Signal The button constantly receives a 5V signal but only transmits it through the signal when the button is pushed. When the button is not pushed, current goes directly to the GND. To avoid a short circuit (5V directly to GND), we put a 10k resistor in the circuit.. GND 1K Ohm Resistor 5V...COMPLETED
Robot Arm _3_ ELECTRONIC_CONCEPTS This is a quick introduction to motors and servo motors in our circuits : How a motor works A motor is a device that transforms electrical energy into mechanical energy. This process is made possible by electric current and electromagnetic fields. A motor is composed of a stator and a rotor. The stator is the fixed part of the motor on which two poles: North and South, are installed by means of coils of wires or magnets. The rotor is the central rotating part which will be supplied with direct current and which will be responsible for the movement of the motor. The coils a and b here have a magnetic field S and N, thus pushing the coil into an equilibrium point of the second diagram. But the brushes connected to the motor shaft are connected in such a way that when the rotor is in this position the current which passes through the poles reverses. The engine then ends up in an unstable position and moves! The movement is thus perpetuated as long as the motor is powered by current. Mechanical energy now results from this operation. Your engine can either go fast but have fairly little rotating force, or have a lot of rotating force but be quite slow. This 'rotation force' has a name, it is the couple and is measured in Newton-Meter. N a S N b S a N N S b S Step 1 Step 3 N a S b N S N S a N b S Step 2 Step 4
Robot Arm _3_ ELECTRONIC_CONCEPTS Torque and speed The relationship between torque and velocity is inversely proportional and it is possible to choose between the two thanks to the gearbox. The gearbox, by means of a set of wheels, allows to swap speed for torque, it is the same principle as a bicycle drivetrain. For a given number of rotations around its axis, a small gear will perform more turns than a large gear to which it is connected. Now, since the forces are preserved, the loss of this velocity is compensated by a greater force, a greater torque. The servomotor During your various circuit, you have probably worked with servomotors. The servos are small motors with an integrated gearbox able to rotate an axis to 180. This actuator is composed of 3 pins, two for the current and one for the signal. 180 2ms 90 1,5ms 0 1ms In most actuators, the signal sent corresponds to a pulse of between 1 and 2 ms every 20 ms. The duration of the signal corresponds to an angle between 0 and 180. Thus 1 ms will correspond to an angle of 0, 1.5 ms to 90 and 2 ms to 180. 20ms 20ms 20ms 0 1ms 90 1,5ms 180 2ms This operation can be seen in the definition of the 'servo' library of Arduino: