Introduction: Programmed Robot Arm

Picture of Programmed Robot Arm

The purpose of this instructable is to develop step by step a project for controlling and programming of a Robot Arm, simulating the basic functions of an industrial robot.

Step 1: SPECIFICATIONS

Picture of SPECIFICATIONS

The robot has two basic functions:

  • Program : Record arm positions in three dimensions (each record is a "step")
  • Run : Perform in sequence the positions recorded in the "Program". The robot will run the program until the command "ABORT" is used.

Main characteristics:

  • The project can be used to control robots with 3 or 4 DOF ( "Degrees of Freedom").
  • The robot can be controlled in "LOCAL" and "REMOTE" modes (the last one via an Android device)
  • During the program phase, user can change the control mode from "LOCAL" to "REMOTE" and vice and versa.
  • Information to user will be provided thru colored LEDs, a 2 lines LED display and sound (a buzzer).
  • The sound alarm can also be triggered remotely.

Step 2: ​THE PROJECT

Picture of ​THE PROJECT

The block diagram on the previous step shows the "Bill of Material" which will be used in this project.

I opted by the Arduino MEGA in order not to worry about the number of available Arduino ports (I/Os). The UNO for example, would work without problems but a port expansion method should be used. There are several options that can be easily found on the internet, as a 74138 decoder for example.

Here, the First prototype being programmed in "local mode"

For the Bluetooth network, the HC-06 will be used.

The Android app used for "remote mode", was developed using the tool MIT Appinventor2 , which is a powerful single platform for this kind of app based on Android devices. The app is available to be downloaded free of charge at Google store: MJRoBot Arduino Robot Arm Control.

Bellow the video can give you an idea of what should be the final project with remote programing:

Step 3: Project Development

Picture of Project Development

Robotic Arms can be classified according to the number of "joints" or "Degrees Of Freedom" (DOF) they have.

  • The "Base", or "Waist", usually can turn the arm 180o or 360o, depending of the Servo type used (here in this project, a 180o Servo was used)
  • The "Shoulder", is the responsible for "raising or lowering" the arm vertically
  • The "Elbow" will make the arm "go forward or backward".
  • The "Claw" or "Gripper" works by opening or closing to "grab things."

Step 4: ​THE CIRCUIT

Picture of ​THE CIRCUIT

Servo motors will be used to drive the joints, connected directly to the Arduino. Note that is not uncommon see "Stepper Motors" used at the base for greater torque and precision. The proper choice of servos are very important (there are cheap Chinese servos who are very poorly constructed such as MG995, which unfortunately are the ones that came with my SanSmart 3DOF AARM). But for the propose of this project worked fine.

The DC power for the servos should be separated from the Arduino and other components. An external power supply of 5 or 6V should work without problems (check the DataSheet of your servors to verify the proper voltage range). A common practice is also using 470uF capacitors between VCC and GND to minimize the noise generated by the DC motors inside the servors. Be sure to connect all the "Grounds" (external Power Source with the Arduino GND pin).

If the servos have problems and vibrate a lot, make adjustments at the "delays" of your code. It is important that the servos have time to get to a certain point before receiving a new command. Also worth checking out if the servos are digital or analog, as though they are mechanically similar, the digital works with a frequency of 300Hz while the analog, 50Hz. The standard Arduino library "Servo.h" was developed for analog servos and can be modified if necessary, for a better functioning with digital servos.

The above drawing shows the complete circuit

Step 5: ​THE CODE

The project is not complicated, but it has many variables. The most prudent is to clearly define them and let his remarks on a unique file:

ArmDefine.h

This file also should set the minimum, maximum and initial servo's angles. The code included in this tutorial, has two sets of parameters for the robotic arms that I tested in my project (of course only a group of constants should be used):

// MeArm 4-DOF
#define minGrip 15 
#define minBase 0 
#define minShou 60 
#define minElbw 60 

#define maxGrip 45 
#define maxBase 170
#define maxShou 180 
#define maxElbw 150 

#define midGrip 30
#define midBase 87
#define midShou 138
#define midElbw 100

/* SS 3-DOF
#define minGrip 75 
#define minBase 5 
#define minShou 5 
#define minElbw 0 

#define maxGrip 125 
#define maxBase 150
#define maxShou 155 
#define maxElbw 0 

#define midGrip 100
#define midBase 90
#define midShou 90
#define midElbw 0 
*/

Each type of arm has a different set of parameters and it is important that you find the right for yours. What I suggest is that initially the potentiometers (pots) remain at its midpoint and the Mapping of the PWM outputs are set to the default values: Max = 255, Min = 0 and Mid = 126 ( "#defines" above). Them, start varying the pots (one by one) and follow in the Serial Monitor (or LCD) what should be the minimum and maximum values where the arm works properly. Those will be the final values to be used for the settings (change my original values at ArmDefine.h.

For ”recording" the sets of coordinates (or steps) that the robot should play, I will use data arrays:

int gripPosition[100];
int basePosition[100];
int shouPosition[100];
int elbwPosition[100];

int positionIndex = 0;   // Index to be used at position array used for recorded tasks

Note that I'm not keeping the "stored" position and at the end of the "robot" program, the index is back to zero and the robot will wait for the recording of a new sequence (the program is lost). Alternatively, you could keep these data arrays in the Arduino EEPROM, for example. Doing that, the program would be executed again or even you could have more than one stored program.

Step 6: ​The Program Logic

The main block ( "Loop") is really quite simple:

  1. First, checks for messages arriving at the serial buffer, from the Android device.
  2. Next, verifies if the control mode is "Local" or "Remote" (the default is Local).
  3. Check if a command to execute the "program" (sequence of steps) was used.
    • If so, run it.
    • Otherwise, the "program" is not complete and still must write new steps.
    • If a “new position” is defined, add it to the program
  4. Back to the beginning and perform step 1 again.
void loop ()
{
  checkBTcmd ();
  defineLocalRemote () ;
  execTaskCmd = digitalRead (execTaskPin);
  if (execTaskCmd == || HIGH command == "runon")
  {
    RunProgram () ;
  }
  else recArmPosition () ;
  command = "";
}

The function checkBTcmd() assembles a string using the individuals characters that arrives from the BT module. This string is passed to the variable "command".

The function defineLocalRemote() considers the variable "command" checking whether one command to change the mode to remote is received or vice versa. The alarm command is also analyzed here. For the program logic, if the "Alarm" is triggered in the Android device, the arm must necessarily go to the Remote mode.

The function RunProgram() performs the preparations, turning LEDs on / off, etc and especially invoking the function: ExecuteTask(). The latter is the function that contains the execution’s logic of the sequence of steps. The function increases the "positionIndex" sending the position data to arm one by one using the tool: armPosition(grip, base, shoulder, elbow) .

Finally, the function that really command the servos and writes the "steps" is the recArmPosition(). Depending on receiving the Android command, this function will define the positioning of the servos that can be through the pots, or through the "sliders" of Android app. With each position’s change, this function sends the coordinates to the servos using the armPosition function ( grip, base, shoulder, elbow). The reading of the real position of the pots or sliders and the corresponding activation of servos occurs by the time the command "SAVE" or "PROGRAM" is triggered. At that moment, the arrays’position index is incremented and the step stored.

To simplify the understanding, all the code was based on its specific functions. The "Setup", "Loop" and the functions described above are virtually all in the file:

MJRoBot_Arm_Robot_Task_Prgm.ino

The more general functions such as read BT command: void checkBTcmd() ; sound generator: void beep (int pin, int freq, long ms) and debouncing: boolean debounce (int pin) ; are on file:

General_Functions.ino

An important fact. As the Arduino executes instructions based on a clock of 16Mhz, it is expected that the control buttons are read hundreds or even thousands of times per second, hence it is important to make a "debouncing" button that sets the recording step.

The fourth and final file is:

Arm_Ctrl_and_Display.ino

In this file are the potentiometer's reading functions: bool readPotenciometers() ; reading of Android sliders: bool readSliders() ; placement of servos: void armPosition (int gripp, int basee, int shoulder, elbow int) . The other functions included in the file are for data display on the LCD, Serial Monitor, alarms, etc.

The video shows the robotic arm 4DOF "meArm" being programmed remotely through the the Android app.

The complete source code for the project can be found at GITHUB:

https://github.com/Mjrovai/MJRoBot-Programmed-Arm

or here:

Step 7: Conclusion

Picture of Conclusion

As always, I hope this project can help others find their way in the exciting world of Electronics, Robotics and IoT!
For more projects, please visit my blog:

MJRoBot.org

Saludos from the south of the world!

See you at my next instructable!

Thank you

Marcelo

Comments

Robot55 (author)2016-10-21

Please, could you answer me? I need this information very quick. Thank you

mjrovai made it! (author)Robot552016-10-21

1. The Arm can be found at:

https://www.amazon.com/SainSmart-Control-Palletizi...

2. Yes, you can use the 20Kohms potentiometer without problem

3. The display is 16 x 2 lines

4. the only circuit that I have is the one that I published. I am sending it again in case you can find it better.

Robot55 (author)2016-10-16

Hello. l was wondering if you can send the schematics from fritzing or another program like that to me please? lt is a little hard from the circuit.? And can you tell me if a 20k potensiometer is all right for the job, and how big the screen is. And my last question is where do you find the robot arm's body from? l couldn't find it anywhere. And even if i did, how would l know if the holes in it are right??☺?

Thanks a lot.

NahomG made it! (author)2016-08-26

simple project that will teach you many basic things you need to know about electronics and Arduino. Thanks MJrovai!!

mjrovai (author)NahomG2016-08-27

My pleasure. Happy that you liked! I pretend to revisit this project in the future adding colour selection capability to the Robot. Also, I should replace the display with a simple I2C connection where only 4 wires is used. Much easer and simple!

Thanks a lot for your comment and support.

Marcelo

kimosubby made it! (author)2016-05-19

At last, have ironed out my problems and with mjrovai's help got the sketch into the MEGA via the Codebenders website. A minor bug found, the schematic in the pdf has an error, the signal lead for the base goes to pin 3 and DB4 from the LCD goes to PIN 2 which is correct in the sketch data.

mjrovai (author)kimosubby2016-05-19

Really great!!!!!!!!! ;-)

kimosubby (author)2016-04-24

Well I'e made it, but not quite getting the code correct on upload as I get errors when verifying the sketch, like LCD type not defined etc. Need some help i think.

mjrovai (author)kimosubby2016-04-26

Hi Kimosubby, let me know how I can help you. Please give me more details about your project. Thanks

DanM5 (author)2016-03-15

Very nice project. Great way to get students into robotics. Thank you for sharing.

kimosubby (author)2016-03-13

I have the MeArm and was working it with r/c, wondering where to start with Arduino control - which you've done and in such a well thought out and explained way. Thank you from a beginner (and I'm a pensioner too) but catching up....

mjrovai (author)kimosubby2016-03-14

Great. If I can help you, will be a pleasure. Regards

kimosubby (author)mjrovai2016-03-14

OK right now going through the download and checking I have all the gear to re-create your circuit - have an Ard Mega in the box too...

Eric.Hyungki.Jung (author)2016-03-03

Great!

Thanks

BrooklineLocksmith (author)2016-03-02

NICE DAY !

Thanks

JoseA124 (author)2016-03-13

Great job. Thank you for sharing.

mjrovai (author)JoseA1242016-03-14

Thanks a lot! My pleasure.

Edugarcia11 (author)2016-03-13

É muito legal ver brasileiros criando coisas assim, bom trabalho

mjrovai (author)Edugarcia112016-03-14

Muito obrigado pela força, Edu.

phenoptix (author)2016-03-14

Great job! Fantastic instructable!

diy_bloke (author)2016-03-01

nifty, but thats a lot of phone clicks for putting a chess piece in a box ;-)
next project: automatic recognition of chess pieces and sorting them by color in their box.
All jokes aside, well done!!

mjrovai (author)diy_bloke2016-03-01

Thanks and good point anyway! I have a plan to build a robot with vision recognition (probably with a RPi), but I could "merge" the projects in the future!

diy_bloke (author)mjrovai2016-03-01

visual recognition would make it really great.
Was wondering, have you ever seen the Big Bang Theory sequel in which Howard was showing off his robot hand during dinner?

diy_bloke (author)2016-03-01

I woud think that if an I2C LCD is used, a UNO could do this task as well :-)

mjrovai (author)diy_bloke2016-03-01

Sure, you are completely right! Only I did not have one on hand!!!! ;-)

diy_bloke (author)mjrovai2016-03-01

didnt want to criticize, made the remark just in case someone would want to make it on a UNO.
Really great project :-)

maxwellmoojw (author)2016-03-01

well done

About This Instructable

26,837views

416favorites

License:

Bio: Engineer, writer and forever student. Passionate to share knowledge of electronics with focus on IoT and robotics.
More by mjrovai:ESP32 and OLED Display: Internet Clock - DHT22 IOT Made Simple: Playing With the ESP32 on Arduino IDEIoT Made Simple: Monitoring Multiple Sensors
Add instructable to: