Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views43 pages

Electronics Lab

The document presents a project report on a Hand Gesture Based Robotic Vehicle and Robotic Arm designed to pick and place objects, developed by a group of students from the University of Delhi. It details the components used, including Arduino boards, sensors, and motors, and discusses the practical applications of the robotic system in various fields such as defense, industry, and medicine. The project aims to assist physically challenged individuals and improve precision in object handling.

Uploaded by

Aashri Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views43 pages

Electronics Lab

The document presents a project report on a Hand Gesture Based Robotic Vehicle and Robotic Arm designed to pick and place objects, developed by a group of students from the University of Delhi. It details the components used, including Arduino boards, sensors, and motors, and discusses the practical applications of the robotic system in various fields such as defense, industry, and medicine. The project aims to assist physically challenged individuals and improve precision in object handling.

Uploaded by

Aashri Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

REPORT

Hand Gesture Based Robotic Vehicle & Robotic Arm

To Pick And Place Objects

From Vehicle

DEPARTMENT OF PHYSICS AND ASTROPHYSICS

UNIVERSITY OF DELHI

SUBMITTED BY:

 Aashri Bansal (1887197)


 Swati Goyal (1887185)
 Jatinder Pal Singh (
 Manish Kumar
 Kritika Sharma
 Manjeet
DECLARATION

We hereby declare that the project entitled “Hand Gesture based Robotic
Vehicle & Robotic Arm to pick and place the objects from vehicle” is based on
our work carried out during the course (January 2020 to May 2020) in Masters
in Physics submitted at the Department of Physics and Astrophysics, University
of Delhi. We assert that the conclusions drawn and work done are an outcome
of our work. The work has not been submitted to any other Institution for any
other degree/ certificate in this University or any other University.

Whenever we have used theoretical analysis and text from other sources, we
have given due credit to them and giving their details in the references.

Date:
ACKNOWLEDGEMENT

We would like to this opportunity to acknowledge the support of all those


without whom this project report would not have been possible.

In the accomplishment of our project we “THE ANONYMOUS” group


members would like to thank all the people who have been involved in this
project. We would like to thank all the people who have been concerned with
this project. We would like to express our special thanks of gratitude to our
teachers (Prof. Nivedita Deo, Prof. Vinay Gupta, Prof. Amitabha Mukherjee,
Prof. K Sreenivas) who have helped us to put into great ideas. Every time when
we reached the, with our difficulties they welcomed them, which helped us in
completing the project successfully.

We would also like to thank our lab assistants for their generous attitude and
friendly behaviour.

We would also like to thanks Solid lab attendant for giving access to various
instrumentation.

At last, we would thank each other as fellow lab-mates, for the stimulating
discussions for the completion of the project within limited time.
INTRODUCTION

Our objective for this project was to design Hand Gesture based Robotic
Vehicle & Robotic Arm to pick and place the objects from Vehicle.

Word robot was coined by a Czech novelist Karel Capek in 1920. Robot in
Czech is a word for worker or servant. In another words, it can be defined as
any automatically operated machine that replaces human effort.

Robots are widely used in such industries as automobile manufacture to perform


simple repetitive task, and in industries where work must be performed in
environments hazardous to humans.

Robotics is a current emerging technology in the field of science. A number of


researchers are working in this field. Robotics is the new emerging field, which
will be of great use to society in the coming years. These days many types of
wireless robots are being developed and are put to varied applications and uses.

Here, an effort has been made to developed a hand gesture based robotic car and
a robotic arm which will pick and place the objects from the car. The robotic car
is operated and controlled wirelessly with the help of hand gestures which
transmits signals to the car through an auto device which is fixed on the gloves
or can say that the user just needs to carry a gesture device which in our case is
transmitter section. The car moves and acts in the manner depending on the
gestures made by the fingers and hand from a distance. The car can move in
forward, backward direction according to our hand’s orientation. The robotic
arm which is mounted on the car, can pick the objects from ground and can
place it in the car, this signature is followed according to the movements of
fingers and hand. It is basically servo controlled robotics system.

Hand gesture based robotic vehicle mainly benefits in the condition where
disabled persons can’t derive the vehicle itself, in this condition they can move
the vehicle in the direction they want to go with the help of the hand gestures.
And the Robotic arm mainly benefits for places where there is a need to pick an
object and place it to some other place safely. If the object is being picked by
the human, there is a risk of damage to the object which is avoided by this
system.

This system includes mainly two sections:

Robotic Glove: It consists MPU 6050, Flex sensor, RF Module 433 MHz transmitter, Arduino Nano

Robotic Vehicle: It consists DC Motors, Servo Motors, RF Module 433 MHz receiver, Arduino Uno

These different components are defined later.

APPLICATIONS:

Practical Applications of Gesture controlled Vehicle:

 Hand gesture controlled vehicle can be used by physically challenged in


wheelchairs.

Practical Applications of Pick and Place Robot:

 Defence Applications: It can be used for surveillance and also to pick


up harmful objects like bombs and diffuse them safely.
 Industrial Applications: These robots are used in manufacturing, to pick
up the required parts and place it in correct position to complete the
machinery fixture. It can also be used to place objects on the conveyer
belt as well as pick up defective products from the conveyer belt.
 Medical Applications: These robots can be used in various surgical
Mechanical
operations like in joint replacement operations, orthopaedic and internal
surgery operations. It performs
Energy
the operations with more precision and accuracy.
DESCRPTION OF THE COMPONENTS USED:

 Arduino Uno
 Arduino Nano
 MPU6050 (Gyroscope + Accelerometer + Temperature) Sensor Module
 Flex Sensor
 Servo Motor
 RF Module 433 MHz Transmitter-Receiver pair
 DC motors

ARDUINO UNO

It is an open-source platform, means the boards and software are readily


available. The software for Arduino devices is called (Integrated Development
Environment) which is free to use and required some basic skills to learn it. It
can be programmed using C and C++ language.

 The Arduino Uno is a microcontroller board that is principally based on


the ATmega328 microcontroller’s series. Various sensors will forward
the environmental data as an input to the microcontroller which will
correspondingly send the attached peripherals.
 It has a total number of 28 pins; 14 digital I/O pins (six are pulse width
modulation (PWM) pins) and six pins are analogs used for interaction
with the electronic components like sensor, motors; 3 GND pins (for
grounding) and remaining pins for 3.3V, 5V, Vin, RESET and AREF
(Analogue Reference).
 Arduino contains a microcontroller with a 32KB storage memory, 2KB of
SRAM and 1KB of EEPROM.
 Only 5V is required to turn the board on, which can be achieved directly
using USB port.

Pins description:
Pin type Pin name Details
Power Vin, 3.3V, 5V,GND Vin: Input voltage to Arduino when
using an external power source.
5V: Regulated power supply used to
power microcontroller and other
components on the board.
3.3V: 3.3V supply generated by on-
board voltage regulator. Maximum
current drawn is 50mA.
GND: ground pins.
Reset Reset Resets the microcontroller
Analog pins A0-A5 Used to provide analog input in the
range of 0-5V.
Input/ Digital pins 0-13 Can be used as input or ouput pins.
Output pins
Serial 0(Rx), 1(Tx) Used to receive and transmit TTL
serial data.
External 2,3 To trigger an interrupt
Interrupts
PWM 3,5,6,9,11 Provides 8-bit PWM output.
SPI 10(SS), 11(MOSI), Used for SPI communication.
12(MISO) and
13(SCK)
Inbuilt LED 13 To turn on the inbuilt LED
TWI A4 (SDA), A5(SCA) Used for TWI communication.
AREF AREF To provide the reference voltage for
input voltage.

Following figure shows the Arduino Uno board:


ARDUINO NANO

The Arduino Nano is a small, complete, and breadboard-friendly board based


on the ATmega328 (Arduino Nano 3.x). It has more or less the same
functionality of the Arduino Uno. It lacks only a DC power jack, and works
with a Mini-B USB cable instead of a standard one.

 Arduino Nano has total 30 pins of which 14 are digital input and output
pins (6 are PWM), 8 analog pins, 2 GND pins, 2 RESET and remaining
pins for 5V, 3V, Vin and REF.

Following figure shows the pinout of the Arduino Nano board:


FLEX SENSOR

Flex is basically a strip of carbon material having metal pads inside it. It is a
sensor which measures the amount of bending or deflection. When the strip is
bend or deflect then the resistance of this flex sensor is changed therefore it is
also called bend sensor.

The following figure shows the image of flex sensor:

This resistance was calibrated and converted into angles and further used for
the grabbing purpose in the Robotic Arm.

Working Principle of Flex Sensor

This sensor works on the principle of bending. As the sensor is flexed, the
resistance across the sensor increases. It means when the strip is bend then its
resistance is changed which can be measured with the help of controller. This
change will depend upon the surface linearity or can say depend upon the
amount of bending done.

The following figure shows the change in resistance with respect to different
angles:

Flat (nominal resistance)

45⁰ Bend (increased resistance)

90⁰ Bend (resistance increased further)


So the resistance across the terminals rises linearly with bent angle. So in a
sense the flex sensor converts flex angle to RESISTANCE parameter.

Flex Sensor Pin Configuration:

Flex sensor is a two terminal device. The flex sensor does not have polarized
terminals like diode. So there is no positive and negative.

Pin Number Description


P1 Usually connected to positive of power source
P2 Usually connected to ground

How to interface Flex sensor with Arduino Board?

For measuring bend, flex sensor is used with type of controller such as
microcontroller or Arduino etc. Here we are discussing how we can interface it
with Arduino board. For interfacing with Arduino board this sensor is powered
up with Arduino board. When it is connected with Arduino board then its pin1
is connected to +5V Arduino board pin through 100K ohm resistor and pin 2 is
directly connected to Arduino ground pin. Similarly, a wire is connected
between the centre point of 100k ohm resistor and flex sensor to Arduino board
A0 pin. For check purposes, a led is connected to the PWM on Arduino board
as shown in figure
MPU6050 (GYROSCOPE + ACCELEROMETER + TEMPERATURE)
SENSOR MODULE

The MPU-6050 sensor holds a MEMS (Micro-Electro-Mechanical Systems)


accelerometer and a MEMS gyroscope only in the single chip.

 It contains 16-bits analogue to digital conversion hardware for each of the


channels and it captures the x, y and z channel at the same time.
 MPU-6050 interfaces with the Arduino microcontroller using I2C
protocol.
 It has total number of 8 pins.
 Operating voltage is 3V-5V.

Pin Name Pin Function


VCC For providing power
Ground For grounding of system
Serial Clock (SCL) SCL used for providing clock pulse for I2C
communication
Serial Data (SDA) SDA used for transferring data through I2C
communication
Auxiliary Serial Data (XDA) XDA is optional but can be used to interface
other I2C modules with MPU6050
Auxiliary Serial Clock (XCL) XCL is also optional but can be used to
interface other I2C modules with MPU6050
AD0 If more than one MPU6050 is used a single
MCU, then this pin can be used to vary the
address
Interrupt pin (INT) It indicated that data is available for MCU to
read

The following figure show the different pins of MPU-6050 Module:


RF MODULE 433 MHz TRANSMITTER-RECEIVER PAIR

RF modules are 433 MHz RF transmitter and receiver modules that are used to
transmit and receive the infrared waves.

 Its working voltage is between 3V-12V and consumes 12V power.


 RF transmitter can transmit up to 90m in open area.

RF Transmitter consists of three pins:

Pin Name Pin Function


ATAD Signal pin used to send data for the receiver
VCC For providing voltage
Ground Pin For grounding the module

 RF receiver working voltage is 5V.

RF Receiver consists of four pins:

Pin Name Pin Function


VCC For providing voltage
Two DATA pins To receive data from transmitter
Ground For grounding the module

The following image shows the RF transmitter- receiver pair:


SERVO MOTOR

A servo motor is an electrical device which can push or rotate an object. If we


want to rotate the object at some specific angles or distance, then we can use
servo motors.

 A servo motor consists of three wires- a black wire connected to the


ground
a white/yellow wire connected to
control unit
a red wire connected to the power
supply
 The function of the servo motor is to receive a control signal that
represents a desired output position of the servo shaft and apply power to
its DC motor until its shaft turns to that position.
 Servo motor generally requires a DC supply of 4.8-6V.
The image below given the description of the servo motor:

Working principle of Servo Motor

To understand its basic principle firstly we have to know about its internal
structure. It mainly contains a DC motor, a gear system, a position sensor and a
control circuit.

 The motor is attached by gears to the control wheel. DC motor gets


powered from a battery and run at high speed and low torque. The gear
and shaft assembly connected to the DC motors lower this speed into
sufficient speed and higher torque. The position sensor senses the
position of the shaft from its definite position and feeds the information to
the control circuit. Then the control circuit decoded the signals from the
position sensor and compares the actual position of the motor with the
desired position and accordingly controls the direction of rotation of the
DC motor to get the desired position.
 When the shaft of the motor is at desired position, power supplied to the
motor is stopped. The desired position is sent via electrical pulses through
the signal wire. The motor’s speed is proportional to the difference
between its actual position and desired position.

Controlling of Servo Motor

A servo motor is controlled by controlling its position using Pulse Width


Modulation technique. The width of the pulse applied to the motor is varied and
send for a fixed amount of time.

 The PWM determines the angular position of the servo motor.


 For example, a pulse width of 1ms causes an angular position of 0⁰,
whereas a pulse width of 2ms causes an angular width of 2ms causes an
angular width of 180⁰.

DC MOTORS

A DC motor is a class of rotary electrical motors that converts direct current


electrical energy into mechanical energy.

Image of the DC motor is shown below:


Construction:

1.Robotic vehicle:

Firstly , we took a electric switch-board to make the base of robotic


vehicle(approximately 24*16cm). Then we cut a length of 9 cm and width of 2
cm in both side of board in back side and in front side we make cut of same
length but width of 4.5cm , because we have to rotate our front wheels also.
Then we attach 2(two) DC motors in back wheels and front two wheels are
connected by rod . And a servo motor is connected to rod , which helps us to
move our vehicle in left and right direction( and it is verified by us also).

Hence, diagram of our vehicle will be like :

All these wires of motors and servo motor are connected to Arduino UNO with
RF receiver , which is placed in between space of front and back wheels.
2. Robotic Arm:

Now , to make space to put whole robotic arm(or the base of robotic arm) on
vehicle , we took same electric switch board of same dimension and to hold it
with the base of car, we use 4 long boults.

To move arm to left or right , we took small board which is connected by base
of robotic arm by heavy servo motor.

So to make arm, we use electric rectangular shape fitting pipes. Firstly we took
a piece of pipe and it is inclined with movable base with the help of nail and a
servo motor in its end to move our arm up and down (as shown in figure)

Now to make next part , we use same type of pipe whose one end is connected
to servo motor’s shaft.

And to pick and drop the objects we make a handle which is made up of hard-
cardboard which has two arms and each arm is connected with individual servo
motor and we will give same input to both servo motors so that both arms is in
synchronisation .

The picture of arm with handle is given below :


All these wires of servo motors are connected with Arduino UNO with RF
receiver .
Working :

1.THE ROBOTIC VEHICLE:

Firstly, we will start with working of robotic vehicle. The heart behind the
working of this vehicle is MPU6050.

As we discussed earlier,MPU6050 can be used as a GYROSCOPE,


ACCELEROMETER and TEMPERATURE sensor.

Here, we will use it as an accelerometer because gyroscope measure the


angular velocity along three axis , which is not used in this project. So,
accelerometer give us amount of force(i.e. acceleration) experienced by it in
X,Y,Z direction. For example, if there is an MPU6050 placed on your hand and
just hold your hand straight then it will give you z-component of acceleration
(i.e. AZ) , +1g where g is acceleration due to gravity and other components(i.e.
Ax,AY) to be zero. Now, if we tilt or move our hand in direction up-down or
right-left then it will give you component of acceleration in x,y direction also
and after using all these components ,we drive formulas of roll and pitch ,
which is given below :

Pitch = 180 × atan(Ax/sqrt(Ay*Ay + Az*Az))/π;


Roll = 180 ×atan (Ay/sqrt(Ax*Ax + Az*Az))/π;
DIAGRAM ILLUSTRATING THE HAND GESTURES TO CONTROLTHE
MOTION OF THE VEHICLE

Now, we got the different values of pitch and roll for different orientations of
our hand and our next task is to transmit these value to vehicle which is done
by RF module transmitter-receiver pair. The transmitting part is given below :
In receiver part , we use roll values as input to two dc motors which is
connected to backward wheels of vehicle and pitch value as an input to a servo
motor ,which is connected to front two wheels of vehicle so that we can rotate
our vehicle in left-right direction. Block diagram for receiver part is given
below :
NOTE : This is the original picture of the base of robotic vehicle which is
made by us.

As we can see that two dc


motors connected to back
wheels and a servo motor
which is connected to front
two wheels will move our
vehicle to right or left
depending upon our hand
orientation and it is verified
by us also.

2. THE ROBOTIC ARM:

Now, our next task is to operate robotic arm which is placed on our vehicle. We
will use our second hand to operate the robotic arm . This time we will use
MPU6050 which control the motion of our robotic arm , a flex sensor which is
used to close and open the grip of handle of robotic arm , RF module
transmitter-receiver pair to send data form hand to arm and of course, arduino
nano at both, transmitting and receiving part.
NOTE:
This is the original picture of our robotic
arm mounted on our robotic vehicle
which is constructed by us.
OUR ROBOTIC ARM

As we discussed above, from MPU6050(which is placed on our hand) readings,


we can convert those readings in pitch and roll values . And from flex
sensor(which is placed on one of our fingers), we can change the value of
resistance or voltage drop across resistor on flex sensor , by bending it .So, by
rotating our hand or bending our finger ,we will use robotic arm to pick and
drop the object, anywhere we want.
ZOOMED VIEW OF OUR GRIPPER

The transmitting part is given below :


NOTE : This is the picture of the second hand to control the robotic arm
which we will use to verify if time will permit us.

In receiver part , we used a heavy servo motor(Tower Pro MG995) ,on which
we put whole base of robotic arm so that our robotic arm can move in left or
right, one light servo motor(Tower Pro SG90 ,let’s say it servo 1) to move our
robotic arm up – down and 2 more light servo motor( same, Tower Pro SG90 ,
let’s say it servo 2 and servo 3) , to make a handle of robotic arm to pick and
drop the things.

So,we will give roll values to servo 1 and pitch values to heavy servo motor and
value from flex sensor , will uses for servo 2 and servo 3.

In the programming , we set only two values of flex sensor : one is to open the
handle and second one is to close it.
In normal position, it is in closed state.

Block diagram for receiver part is given below :


NOTE : Robotic arm shown in above picture is also made by us .
DESCRIPTION OF SOURCE CODE

With all the hardware connected together, it all comes down to coding with the
task to make sure all the hardware pieces are interfaced properly and work as a
unit to perform the task they are supposed to. As Arduino is the microcontroller
used in the project both at the transmitter and receiver section, it is the heart of
the whole project and the programming is thus written, executed and uploaded
to use in the project using the official Arduino Interactive Development
Environment (IDE).

THE VEHICLE

TRANSMITTER SECTION:

The transmitter section for both the vehicle and the robotic arm perform almost
in the same way. As both of them use the MPU6050 Accelerometer-Gyroscope
sensor along with the RF Transmitter to transmit data, one of the initial tasks at
hand is to make sure both these devices are connected properly to the Arduino
following all the correct protocols. Let’s analyse the code part by part:

//Transmitter
#include<Wire.h>
#include <RH_ASK.h>
#include <SPI.h>

The MPU6050 supports only I2C Communication and hence, it must be


connected only to the I2C Pins of the Arduino. The I2C pins of Arduino are
multiplexed with the analog input pins A4 and A5 i.e. A4 is SDA and A5 is
SCL. The Wire Library is used to obtain the data from the MPU6050
Accelerometer-Gyroscope. The Wire library facilitates I2C communication with
the MPU6050 using the SDA and SCL pins of the Arduino.
The RadioHead (RH_ASK) library provides a complete object-oriented library
for sending and receiving packetized messages via a variety of common data
radios and other transports on a range of embedded microprocessors. Thus, it
helps in the wireless transfer of data via the RF transmitter.

The Serial Peripheral Interface (SPI) Library, although not directly used in the
program, is essential for the synchronous serial data protocol used by
microcontrollers for communicating with one or more peripheral devices
quickly over short distances.

RH_ASK driver;
float roll,pitch;
const int MPU6050_addr=0x68;
int Angle[2];
float AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;

Now we move on to declaration of variables and objects at the global scale.


First, we declare an object of RH_ASK class named driver that will facilitate
the wireless transmission. Then we declare a constant with the address of the
MPU6050 sensor as the I2C protocol demands. The rest are variables which
will be used to store data from the sensor and transmit the data when the
program runs.

void setup()
{ Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}

In the setup() section, we initialise our transmission procedure. This is done first
by calling the begin()function from the Wire library. Then as per the defined
protocols we first feed the MPU6050’s address and then wake up the 0x6B
register, which is essential to start transmission.
The Wire.endTransmission(true)just makes sure that the transmission is started
from the beginning when the due protocols are done with. In the last line, the if
(!driver.init()) just make sure if the RF transmitter is working properly and
displays the message if it is not. With the communication setup and everything
working, it is time to collect and transmit data.

void loop()
{
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr,14,true);
float Acc[] = {0,0,0};

The code in the loop() part is executed over and over, and must contain the task
we want to perform. Once we feed the feed the MPU6050’s address, we begin
the data retrieval from the 0x3B register, which actually stores the acceleration
along the x direction. The MPU6050 Accelerometer-Gyroscope gives seven
values at a time. They are: Acceleration along the x, y, z axis, the temperature
and Angular velocity along the x, y, z axis, stored in the register in the same
order, with each value occupying 16 bits or 2 bytes. The
Wire.requestFrom(MPU6050_addr,14,true) function asks the MPU6050 sensor
to send data, beginning from the register mentioned earlier (0x3B) and stopping
after 2X7=14 bytes.

Acc[0]=Wire.read()<<8|Wire.read();
Acc[1]=Wire.read()<<8|Wire.read();
Acc[2]=Wire.read()<<8|Wire.read();
Temp=Wire.read()<<8|Wire.read();
GyroX=Wire.read()<<8|Wire.read();
GyroY=Wire.read()<<8|Wire.read();
GyroZ=Wire.read()<<8|Wire.read();

Once the transmission begins, we need to store the incoming data into variables.
The data is transferred to Arduino byte by byte but every value is of two byte
and we need to merge those incoming bytes to make sense of the data. This is
done using the lines of code above.
As soon as data is received by using Wire.read(), the operator <<8 shifts the
data by 8 bits on the left-hand side. After the function Wire.read() reads the next
8 bits and the | operator makes sure the two of them are merged to form the
required 16 bit data.

The array Acc stores the acceleration along the x, y and z direction. Other
values are also stored (just to check if the data transfer is working smoothly) but
are not used further in the program.

Acc[0]/=16383; Acc[1]/=16383; Acc[2]/=16383;


roll = atan(Acc[1] / sqrt(pow(Acc[0], 2) + pow(Acc[2], 2))) * 180 / PI;
pitch = atan(-1 * Acc[0] / sqrt(pow(Acc[1], 2) + pow(Acc[2], 2))) * 180/PI;
Serial.print("Roll="); Serial.print(roll);
Serial.print(" || Pitch="); Serial.println(pitch);

Angle[0]=int(round(roll));
Angle[1]=int(round(pitch));

The raw data that we receive is in the for of a number ranging from 0 to 16383
(216-1) as it is 16-bit data. But in order to covert that into angular tilt, we need to
convert it into the respective g (acceleration due to gravity) values, which varies
from 0 to 1 g in magnitude. So, we divide the data we receive by 16383 to do
so. Then, these values are substituted in the formula for roll and pitch as
discussed earlier. Finally, the roll and pitch are transferred to a new array called
Angle.

driver.send((uint8_t *)Angle, 4);


driver.waitPacketSent();
delay(500);
}

With the data ready, it is time to transmit it. The driver.send(() function sends
the data over the RF transmitter. uint8_t * makes sure that the data is of the
format as required by the transmitter. 2X2=4 is the size of the total data being
transmitted i.e. the Angle array.
The driver.waitPacketSent() makes sure the data packets are delivered properly
and a delay is introduced so all the processes run smoothly.
RECEIVER SECTION

Once the data is transmitted by the RF transmitter, the RF receiver catches it


and now the job is to decode those raw bytes into meaningful data and once that
is done, the servo motor and DC motors operate as described in the Working
section of the report.

//Receiver

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Servo.h>

Just like the Transmitter section, the RadioHead(RH_ASK) library is used is


facilitate wireless communication between the transmitter and receiver. The
Servo library is used to control the Servo motor by creating objects of the Servo
class.

RH_ASK driver;
int motor=5;
int spd=0;
int Angle[2];
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position

The RH_ASK objects helps in retrieving data from the receiver. The myservo
object of Servo class is for the movement of servo motor. The rest of the
variables store the data and the pins at which the motors are attached to.

void setup()
{
Serial.begin(9600); // Debugging only
myservo.attach(10); // attaches the servo on pin 9 to the servo object

if (!driver.init())
Serial.println("init failed");
}
The setup() section just checks if we are receiving data from the RF receiver
properly or not.

void loop()
{
uint8_t buf[4];
uint8_t buflen = sizeof(buf);
int j=0;
int rtdata[10];
int data[2];
if (driver.recv(buf, &buflen)) // Non-blocking

We define an array buf to initially store the incoming data. The driver.recv()
takes care of that But this data will be of the uint8_t format and needs to be
converted into int before proceeding.

memcpy(rtdata,buf,sizeof(buf));
for(byte i=0;i<2;i++)
data[j++]=rtdata[i];

The above lines of code take care of that. First, we copy the data from buf to an
array called rtdata. Then, in the loop we move from one byte of rtdata to the
next and store those in data array. This is effective because instead of moving
from one data location to next, we shift byte by byte by declaring the variable i
of type byte in the loop initialiser. The j index takes care of the data array. Now
we have our angles in the array data.

if(data[0]>60){
spd=255;
analogWrite(motor,spd);
}
else if(data[0]<-60){
spd=0;
analogWrite(motor,spd); }
The element data[0] contains the angle related to the upward/downward
motion of the hand i.e. the roll. They will control the speed of the DC motors.
Both the DC motors are connected to pin defined by the variable motor(=5).

The function helps control the speed of the motors by employing the use of
PWM present on the Arduino board. This is the reason pin 5 was used here as it
is one of the PWM pins. As per our predefined values, if the angle is over 60°,
the vehicle reaches top speed instantly. This is done by spd variable attaining its
maximum value which is 255. Similarly is the angle is below -60°, the vehicle
instantly comes to halt, i.e. it works as a break system for instantly stopping the
vehicle.

Now, the two extreme scenarios out of the way, we need to define how the
vehicle accelerates and slows down.

else if(data[0]>7)
{ if(spd>250)
spd=255;
else
spd+=int(data[0]/5);
analogWrite(motor,spd);
}

else if(data[0]<-7)
{ if(spd<5)
spd=0;
else
spd+=int(data[0]/5);
analogWrite(motor,spd);
}

If the angle is in the range of 7° to 60°, the vehicle accelerates by the rate that
depends on the value of the angle divided by a scale factor which on limited
testing, 5 was found to be the best fit. The line spd+=int(data[0]/5) takes care of
that. The same is true if the angle is between 7° and 60° downwards, here the
only difference is that the vehicle decelerates at that rate.
It is the job of the coder to keep into account every scenario that might happen
in the real world. There may be a case where while increasing the speed
gradually, the speed exceeds its top limit which is 255. The first conditional
block if(spd>250) takes care of that. Same is taken care if the speed is trying to
go below 0 that is meaningless.

else{
spd=0;
analogWrite(motor,spd);
}

The idea of keeping the angle range from 7° to 60° was to make sure the vehicle
doesn not move with very small movements of the hand. That will lead to
instability. So, the vehicle should stay at rest if none of the aforementioned
conditions are met. The last else block takes care of that. It makes sure that the
hand needs to be continuously tilted in the upward/downward direction to
accelerate/decelerate the vehicle. After controlling the speed of the vehicle, it is
time to discuss the turning.

if(data[1]>30)
myservo.write(180); // tell servo to go to position
//in variable 'pos'
else if(data[1]<-30)
myservo.write(0);
else
myservo.write(90);
}

The pitch or the left/right motion of the hand is stored in the element data[1].
Here, a singular motion will define the turning. As per the construction, the
default position of the servomotor is 90°. If the pitch is over 30°, the motor
instantly shifts to 180° turning the front wheels in the right direction. Something
similar happens if the angle is over 30° in the other direction, the result here is
the motor moving to 0° turning the vehicle left. If the hand is inbetween the two
positons, the motor stays at its default position and vehicle goes on in a straight
line.
THE ROBOTIC ARM

TRANSMITTER SECTION:

The transmitter section of the robotic arm is pretty similar to the vehicle, the
only difference here being the existence of an extra value in the form of the data
from the flex sensor which controls the robotic gripper.

//Transmitter
#include<Wire.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

So, just like the transmitter section for the vehicle, the transmitter for the robotic
arm also makes use of the RadioHead (RH_ASK) library for the wireless
transmission of data and the Wire Library is used to obtain the data from the
MPU6050 Accelerometer-Gyroscope. The only difference here being that
instead of using just the MPU6050 sensor to convert physical actions into
electronic signals, a combination of actions defined by an MPU6050 sensor and
flex sensors are used. The MPU6050 sensor works in the same fashion as in the
case of the vehicle but here it is used to control the movement of the Robotic
arm at the joints. The defined values for the MPU6050 variables will make sure
how and when the arm mover left-right or up-down, which is essential when it
comes to picking up/dropping objects. The picking/dropping action is achieved
by the gripper at the end of the arm, whose movement is controlled by the Flex
sensor.

RH_ASK driver;
float roll,pitch;
const int MPU6050_addr=0x68;
int Data[3];
float AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;
int flex=0;
int flexPin = A0;
As the code reflects, in order to accommodate the data from the felex sensor, an
extra element is added to the data array and the analog pin (A0) to which the
flex sensor is connectd is defined.

void setup()
{ Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}

void loop()
{

Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr,14,true);
float Acc[] = {0,0,0};
Acc[0]=Wire.read()<<8|Wire.read();
Acc[1]=Wire.read()<<8|Wire.read();
Acc[2]=Wire.read()<<8|Wire.read();
Temp=Wire.read()<<8|Wire.read();
GyroX=Wire.read()<<8|Wire.read();
GyroY=Wire.read()<<8|Wire.read();
GyroZ=Wire.read()<<8|Wire.read();

Acc[0]/=16384; Acc[1]/=16384; Acc[2]/=16384;


roll = atan(Acc[1] / sqrt(pow(Acc[0], 2) + pow(Acc[2], 2))) * 180 / PI;
pitch = atan(-1 * Acc[0] / sqrt(pow(Acc[1], 2) + pow(Acc[2], 2))) * 180 / PI;
Serial.print("Roll="); Serial.print(roll);
Serial.print(" || Pitch="); Serial.println(pitch);

As expected, the code and its working till the extraction of data from the
MPU6050 sensor is exactly the same as shown above. The only difference will
come when we get the data from the flex sensor.
flex=analogRead(flexPin);

This single line of code performs that function. As described in the Working
section, the flex sensor simply works as a voltage divider. Ideally, it can have a
value of 0-5 V depending on how much it’s being bent. The function
analogRead() reads this value and convert this into a number ranging from 0 to
1023(10 bit).

Data[0]=int(round(roll));
Data[1]=int(round(pitch));
Data[2]=flex;
driver.send((uint8_t *)Data, 6);
driver.waitPacketSent();
delay(2500);
}

The rest of the code just involves writing the roll, pitch and flex data to first,
second and third element of the array data respectively and then transmitting the
data over the transmitter just like the vehicle. (Note the use of 6 instead of 4 in
the driver.send() function because there are 3 elements to transmit instead of 2).

RECEIVER SECTION:

Once the variables for the movements are transmitted, they are received and
converted into their corresponding angular values that are fed to the servo
motors at the joints and the gripper. The rotations of the servo motors facilitate
the arm and gripper movement and can be employed as an efficient object
picker/dropper and when combined with the vehicle, it adds a new dimension to
the applicability of the arm making sure that it is not fixed at a single location
and can be used for mobile applications as well.

//Receiver

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Servo.h>

RH_ASK driver;
int Data[3];
Servo myservo1; // create servo objects to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
int pos1 = 0; // variables to store the servo position
int pos2 = 0;

The only difference from the vehicle here is the fact that we will be controlling
four servo motors with the data we receive which are described in the Working
section and in the figure below as well. We will call the four motors as 1,2,3
and 4 according to this figure. To handle that four objects of the class Servo are
declared.

void setup()
{
Serial.begin(9600); // Debugging only
myservo1.attach(5); // attaches the servo on pin 9 to the servo object
myservo2.attach(9);
myservo3.attach(10);
myservo4.attach(11);
if (!driver.init())
Serial.println("init failed");
}

The Servo motors are connected to four different PWM pins as described by the
attach() function in the setup().

void loop()
{
uint8_t buf[6];
uint8_t buflen = sizeof(buf);
int j=0;
int rtdata[10];
int data[3];
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
//Serial.println("Message:\n");
//for(j=0;j<buflen;j++)
//Serial.println(buf[j]);
}
Serial.println("Data:");
memcpy(rtdata,buf,sizeof(buf));
for(byte i=0;i<3;i++)
data[j++]=rtdata[i];

The process followed till the extraction of data from the receiver and its
conversion into meaningful form is exactly the same as that in the case of the
vehicle, only difference being here we have an extra value coming from the flex
sensor. The change will come in how we use the values we are receiving to
define the position of the motors and the movement of the arm and gripper.

if(data[0]>60){
pos2=180;
myservo2.write(pos2);
}
else if(data[0]<-60){
pos2=0;
myservo2.write(pos2);
}

else if(data[0]>7)
{ if(pos2>170)
pos2=180;
else
pos2+=int(data[0]/5);
myservo2.write(pos2);
}

else if(data[0]<-7)
{ if(pos2<5)
pos2=0;
else
pos2+=int(data[0]/5);
myservo2.write(pos2);
}

else{

myservo2.write(pos2);
}
First let’s discuss the way in which the movement of motor 2 is defined. It is
pretty similar to how we handled the speed in case of the vehicle. We will use
the roll i.e. the upward/downward motion of the hand to control this motor. The
extreme positions of the motor are 180° (straight up) and 0° (straight down) and
this will happen only when the hand controlling the arm is 60° in the upward or
downward direction. Again, if the angle is between 7° and 60° in either
direction, the motor and thus the joint of the arm will move in that direction by
a factor of the angle divided by the scale factor defined by the line. Finally, if
the hand is not in upward/downward motion, the joint will stay at its last
recorded position.

All these movements of motor 2 will make sure the joint of the arm will move
up and down and can help picking up or dropping objects from the ground or at
a height.

if(data[1]>60){

pos1=180;
myservo1.write(pos1);
}
else if(data[1]<-60){
pos1=0;
myservo1.write(pos1);
}

else if(data[1]>7)
{ if(pos1>170)
pos1=180;
else
pos1+=int(data[1]/5);
myservo1.write(pos1);
}

else if(data[1]<-7)
{ if(pos1<5)
pos1=0;
else
pos1+=int(data[1]/5);
myservo1.write(pos1);
}

else{
myservo1.write(pos1);
}

Motor 2 only takes care of making sure that the arm reaches Infront of the
vehicle, but what if we want to pick up/drop the objects on the sides of the
vehicle. Motor 1 takes care of that. It’s movement is defined by the pitch or the
left/right tilt of the hand. It works in exactly the same way as Motor 2, just the
upward downward motion of the arm at joint 2 is replaced by right and left
movement of the arm at joint 1. Also, a motor that produces more torque and
can handle larger weights is used at joint 1 as it is the base of the entire arm.

if(data[2]>700)
{myservo3.write(180);
myservo4.write(0);
}
else
{
myservo3.write(90);
myservo4.write(90);
}
}

The motors 3 and 4 work together to open and close the gripper so that the arm
can pick up or drop the object. Its movement completely depends on the
bending of the flex sensor. As the flex sensor is bent more, its resistance and
hence voltage drop across it increases. We define if the value is over 3.42 V
(5*700/1023), the gripper should close. To close the gripper, the motors should
move in the opposite direction according to our construction. Thus, one of them
(motor 3) moves to 180° and the other (motor 4) in the opposite direction to 0°.
It should be noted that the default position of both the motors when the gripper
is open is 90° and it will stay so if the voltage across flex sensor is below 3.42V.

Combining all these snippets of code and uploading them to the Arduinos
handling receiver and transmitter portions for the vehicle and robotic arm, they
have the capacity to work in harmony as an efficient wireless, low-cost, mobile
pick-up and drop machine.

(Note: All the codes above can be found in their entirety in the Appendix section
of the report)

You might also like