FAB LAB Khairpur Sukkur IBA Sukkur IBA University
Merit, Quality, Excellence

WEEK-16

Machine Design

Lecture & Recitaton of a Week:

Lecture on 9th of May, 2018: Mechanical Design by Neil Gershenfeld

Recitation on 14th of May, 2018: Making things that matter by Felicity Mecha and Kamau Gachigi

Tasks for a Week

Robotic Arm with 7 Servos

List of components with components

Robotic arm with 7 Servos

List of components with components

Poster Describing the Workflow of the Assignment

The demonstration of working of Robotic arm is shown in the video below. It's the first time that we have completed our assignment before the deadline ;)

In this week and the upcoming week, we have to make a Machine.So, first we need to design the mechanical parts of our machine in this week.It is basically a group assignment, and every person is required to do a part of assignment and document their contribution.

Continue from Mechanical Design:

After assembling robot our mechanical week is completed and after that Wiring of Robot is done by Nadir (He also made leonardo clone for this project). So along with Leonardo (clone), wired Robotic hand and my colleague Rasheed Qazi we start to work with programming.

Programming the Robotic Hand

Before programming it is better to discuss the operation of Robot, so we discuss our recommendations with our Instructor Sir Sohail Ahmed and come to decision that we need to automate the robot so he perform specific task autonomous and second is to work as per instruction given to him using bluetooth.

Program for Autonomous:

The task is to collect an object from one place, move and drop it to another place.

First we need to find the initial position of robot and for this we need to find the exact angle of 7 motors. We write a code for this in which we check the position of each motor by giving instruction from bluetooth module(HM-10 BLE V 4.0) to set it with respect to our requirements

/* Robotic hand servo initial postion setting code by NARP (Noor Ahmed Raza Pirwani while doing FAB diploma from FABLAB Khairpur noorahmedpirwani@gmail.com)
The code is designed to connect a motor with Arduino board while setting pin of arduino in a_servo.attach
(write servo pwm pin here in code). The code is used to found the best position of robotic hand servo which
I used in my another code to set initial position of motor. The code has no right issues so feel free to use it.
*/
#include
char val; // variable to receive data from the serial port
Servo a_servo; // create servo object to control a servo
int pos_a = 30; // variable to store the servo position


void setup() {
a_servo.attach(11); // attaches the servo on pin 9 to the servo object
a_servo.write(pos_a);
Serial.begin(9600); // start serial communication at 9600bps
}


void loop() {

if( Serial.available() ) // if data is available to read
{

val = Serial.read(); // read it and store it in 'val'
}
if( val == 'A' ) { // if 'A' was received
if( pos_a < 170 ) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
pos_a =pos_a+10;
a_servo.write(pos_a); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'a' ) { // if 'A' was received
if( pos_a > 10 ) { // goes from 180 degrees to 0 degrees // in steps of 1 degree
pos_a =pos_a-10;
a_servo.write(pos_a); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

}

After setting up the initial positions of each week then we write the code using "hit and try" method it takes time to reach the goal to move an object from one place to another but it works

#include
#include

#define F_CPU 16000000UL ;
Servo a_servo; // create servo object to control a servo
Servo b_servo; // create servo object to control a servo
Servo c_servo; // create servo object to control a servo
Servo d_servo; // create servo object to control a servo
Servo e_servo; // create servo object to control a servo
Servo f_servo; // create servo object to control a servo
int pos_a = 90; // variable to store the servo position
int pos_b = 20; // variable to store the servo position
int pos_c = 20; // variable to store the servo position
int pos_d = 150; // variable to store the servo position
int pos_e = 60; // variable to store the servo position
int pos_f = 130; // variable to store the servo position
int pos = 0; // variable to store the servo position

void setup() {
a_servo.attach(3); // attaches the servo on pin 9 to the servo object
b_servo.attach(5); // attaches the servo on pin 9 to the servo object
c_servo.attach(13); // attaches the servo on pin 9 to the servo object
d_servo.attach(9); // attaches the servo on pin 9 to the servo object
e_servo.attach(6); // attaches the servo on pin 9 to the servo object
f_servo.attach(10); // attaches the servo on pin 9 to the servo object

}

int a = 0;

void loop() {


if (a == 0){
delay(2000);

e_servo.write(pos_e);
delay(2000);

d_servo.write(pos_d);
delay(2000);

c_servo.write(pos_c);
delay(2000);

f_servo.write(pos_f);
delay(2000);

b_servo.write(pos_b);
delay(2000);

a_servo.write(pos_a);
delay(2000);
pos_e = 75;
e_servo.write(pos_e);
delay(3000);
pos_a = 110;
a_servo.write(pos_a);
delay(3000);

pos_e = 60;
e_servo.write(pos_e);
delay(3000);
pos_f = 60;
f_servo.write(pos_f);
delay(3000);
pos_a = 90;
a_servo.write(pos_a);
delay(3000);
pos_e = 50;
e_servo.write(pos_e);
delay(3000);



a = 1;

}

}

Program to Control with Bluetooth Device:

The code to use in this program is the advance version of code we used to calibrate motors initial position, we just change to control all motors with different Alphabets using bluetoth serial application of android

/* Robotic hand 6 servos operation by NARP (Noor Ahmed Raza Pirwani while doing
FAB diploma from FABLAB Khairpur noorahmedpirwani@gmail.com)
This code is designed to run the Robotic hand which has 6 servos.
The code requires motor calbrating code by NARP to set intial positions of motors.
After setting initial positions, in void setup set the pins of motors.
The code is working when it gets instruction from serial (we are using bluetooth
device along to get instruction from serial). The code has no right issues so feel free to use it.
*/

#include

char val; // variable to receive data from the serial port
Servo a_servo; // create servo object to control a servo
Servo b_servo; // create servo object to control a servo
Servo c_servo; // create servo object to control a servo
Servo d_servo; // create servo object to control a servo
Servo e_servo; // create servo object to control a servo
Servo f_servo; // create servo object to control a servo
int pos_a = 10; // variable to store the servo position
int pos_b = 20; // variable to store the servo position
int pos_c = 20; // variable to store the servo position
int pos_d = 150; // variable to store the servo position
int pos_e = 80; // variable to store the servo position
int pos_f = 130; // variable to store the servo position


void setup() {
a_servo.attach(3); // attaches the servo on pin 9 to the servo object
a_servo.write(pos_a);
delay(100);
b_servo.attach(5); // attaches the servo on pin 9 to the servo object
b_servo.write(pos_b);
delay(100);
c_servo.attach(13); // attaches the servo on pin 9 to the servo object
c_servo.write(pos_c);
delay(100);
d_servo.attach(9); // attaches the servo on pin 9 to the servo object
d_servo.write(pos_d);
delay(100);
e_servo.attach(6); // attaches the servo on pin 9 to the servo object
e_servo.write(pos_e);
delay(100);
f_servo.attach(10); // attaches the servo on pin 9 to the servo object
f_servo.write(pos_f);
delay(100);
Serial1.begin(9600); // start serial communication at 9600bps
}


void loop() {

if( Serial1.available() ) // if data is available to read
{

val = Serial1.read(); // read it and store it in 'val'
}
if( val == 'A' ) { // if 'A' was received
if( pos_a < 170 ) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
pos_a =pos_a+10;
a_servo.write(pos_a); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'a' ) { // if 'a' was received
if( pos_a > 15 ) { // goes from 180 degrees to 0 degrees // in steps of 1 degree
pos_a =pos_a-5;
a_servo.write(pos_a); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'B' ) { // if 'B' was received
if( pos_b < 165 ) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
pos_b =pos_b+5;
b_servo.write(pos_b); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'b' ) { // if 'b' was received
if( pos_b > 15 ) { // goes from 180 degrees to 0 degrees // in steps of 1 degree
pos_b =pos_b-5;
b_servo.write(pos_b); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'C' ) { // if 'C' was received
if( pos_c < 165 ) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
pos_c =pos_c+5;
c_servo.write(pos_c); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'c' ) { // if 'c' was received
if( pos_c > 15 ) { // goes from 180 degrees to 0 degrees // in steps of 1 degree
pos_c =pos_c-5;
c_servo.write(pos_c); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'D' ) { // if 'D' was received
if( pos_d < 165 ) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
pos_d =pos_d+5;
d_servo.write(pos_d); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'd' ) { // if 'd' was received
if( pos_d > 15 ) { // goes from 180 degrees to 0 degrees // in steps of 1 degree
pos_d =pos_d-5;
d_servo.write(pos_d); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}


else if( val == 'E' ) { // if 'E' was received
if( pos_e < 180 ) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
pos_e =pos_e+5;
e_servo.write(pos_e); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'e' ) { // if 'e' was received
if( pos_e > 0 ) { // goes from 180 degrees to 0 degrees // in steps of 1 degree
pos_e =pos_e-5;
e_servo.write(pos_e); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}
else if( val == 'F' ) { // if 'F' was received
if( pos_f < 165 ) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
pos_f =pos_f+5;
f_servo.write(pos_f); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

else if( val == 'f' ) { // if 'f' was received
if( pos_f > 15 ) { // goes from 180 degrees to 0 degrees // in steps of 1 degree
pos_f =pos_f-5;
f_servo.write(pos_f); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
}

val='0';

}

Here is the end result video in which Robotic hand is working autonomous and controlled via bluetooth



"Click here"to download all files of this week

"Click here"to visit the complete documentations of mechanical design and machine design weeks

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License
.