LINEAR CONTROL SYSTEMS
EEN-412
COMPLEX ENGINEERING PROBLEM
SUBMITTED TO: ENGR. MARYAM IQBAL
GROUP MEMBERS:
MASTER:
NAME: ENROLLMENT
HAIDER SULTAN 01-133212-066
MUHAMMAD HAMZA 01-133212-049
ABDUL AHAD ABBASI 01-133212-001
DEPARTMENT OF ELECTRICAL ENGINEERING
BAHRIA UNIVERSITY ISLAMABAD CAMPUS
Contents
PROJECT TITLE: ..................................................................................................................................... 2
INTRODUCTION: ..................................................................................................................................... 3
PROBLEM STATEMENT: ....................................................................................................................... 3
ABSTRACT: ............................................................................................................................................... 3
BACKGROUND: ........................................................................................................................................ 3
OBJECTIVES: .................................................................................................................................................. 3
ALGORITHM: ................................................................................................................................................. 3
CODING: ........................................................................................................................................................ 4
CIRCUIT DIAGRAM:....................................................................................................................................... 8
HARDWARE: ................................................................................................................................................. 8
CONCLUSION: ........................................................................................................................................ 10
PROJECT TITLE:
Master- Slave Robot
INTRODUCTION:
The objective of this project is to design a master-slave/swarm robot system capable of facilitating
real-time control by a human operator via a master robot while ensuring autonomous operation
with minimal human intervention. The system is engineered to execute complex tasks such as
inspection, exploration, and manipulation in hazardous and challenging environments where
human intervention is impractical.
PROBLEM STATEMENT:
Design a master-slave/swarm robot system that enables a human operator to control one or more
slave robots in real-time using a master robot. Design the system such that it should be able to
operate autonomously with minimal human intervention. Devise a plan where the system can
perform complex tasks such as inspection, exploration, and manipulation in a hazardous and
challenging environment where human intervention is not feasible.
ABSTRACT:
This project report delineates the design and execution of a master-slave robot system. The system
comprises two robots: a master robot, subject to human operator control, and a slave robot, which
mirrors the movements of the master robot. Utilizing an array of electronic components, including
Arduino microcontrollers, servo motors, and sensors, the system was implemented and evaluated.
The findings affirm its capability to effectively replicate the actions of the master robot.
BACKGROUND:
Master-slave robot configurations have enjoyed extensive application across various domains over
numerous years. Among the earliest instances is the teleoperator , pioneered in the early 1960s for
deployment in nuclear power facilities. Teleoperators enable operators to manipulate robots from
a secure distance, particularly crucial in hazardous environments. In manufacturing, master-slave
robots tackle tasks deemed perilous or challenging for humans, such as welding in confined spaces
or painting moving objects. Similarly, in surgery, these robots undertake intricate procedures that
may surpass human capacity.
OBJECTIVES:
This project aims to conceive, implement, and assess a master-slave robot system. Simplicity, user-
friendliness, and cost-effectiveness were key design considerations, alongside modularity to
facilitate system scalability and customization.
ALGORITHM:
The following algorithm was used to control the master-slave robot system:
1. The master robot is controlled by a human operator.
2. The movements of the master robot are sensed by sensors.
3. The sensor data is processed by the Arduino microcontroller.
4. The Arduino microcontroller sends commands to the servo motors.
5. The servo motors move the slave robot
CODING:
#include <SoftwareSerial.h>
#define enA 10 // Enable1 L298 Pin enA
#define in1 9 // Motor1 L298 Pin in1
#define in2 8 // Motor1 L298 Pin in1
#define in3 7 // Motor2 L298 Pin in1
#define in4 6 // Motor2 L298 Pin in1
#define enB 5 // Enable2 L298 Pin enB
#define L_S A0 // IR sensor Left
#define R_S A1 // IR sensor Right
#define echo A2 // Echo pin
#define trigger A3 // Trigger pin
#define servo A5
#define BT_STATE 4 // Bluetooth state pin
int Set = 15;
int distance_L, distance_F, distance_R;
SoftwareSerial BTSerial(2, 3); // RX, TX for Bluetooth
void setup() {
Serial.begin(9600); // Start serial communication at 9600bps
BTSerial.begin(9600); // Start Bluetooth communication at 9600bps
pinMode(R_S, INPUT); // Declare IR sensor as input
pinMode(L_S, INPUT); // Declare IR sensor as input
pinMode(echo, INPUT); // Declare ultrasonic sensor Echo pin as input
pinMode(trigger, OUTPUT); // Declare ultrasonic sensor Trigger pin as Output
pinMode(enA, OUTPUT); // Declare as output for L298 Pin enA
pinMode(in1, OUTPUT); // Declare as output for L298 Pin in1
pinMode(in2, OUTPUT); // Declare as output for L298 Pin in2
pinMode(in3, OUTPUT); // Declare as output for L298 Pin in3
pinMode(in4, OUTPUT); // Declare as output for L298 Pin in4
pinMode(enB, OUTPUT); // Declare as output for L298 Pin enB
pinMode(servo, OUTPUT); // Declare servo pin as output
pinMode(BT_STATE, INPUT); // Declare Bluetooth state pin as input
analogWrite(enA, 200); // Write the duty cycle 0 to 255 Enable Pin A for Motor1 Speed
analogWrite(enB, 200); // Write the duty cycle 0 to 255 Enable Pin B for Motor2 Speed
for (int angle = 70; angle <= 140; angle += 5) {
servoPulse(servo, angle);
}
for (int angle = 140; angle >= 0; angle -= 5) {
servoPulse(servo, angle);
}
for (int angle = 0; angle <= 70; angle += 5) {
servoPulse(servo, angle);
}
distance_F = Ultrasonic_read();
delay(500);
}
void loop() {
distance_F = Ultrasonic_read();
Serial.print("D F=");
Serial.println(distance_F);
// Send distance to slave via Bluetooth if connected
if (digitalRead(BT_STATE) == HIGH) {
BTSerial.print("DF=");
BTSerial.println(distance_F);
}
if ((digitalRead(R_S) == 0) && (digitalRead(L_S) == 0)) {
if (distance_F > Set) {
forword();
} else {
Check_side();
}
} else if ((digitalRead(R_S) == 1) && (digitalRead(L_S) == 0)) {
turnRight();
} else if ((digitalRead(R_S) == 0) && (digitalRead(L_S) == 1)) {
turnLeft();
}
delay(10);
}
void servoPulse(int pin, int angle) {
int pwm = (angle * 11) + 500; // Convert angle to microseconds
digitalWrite(pin, HIGH);
delayMicroseconds(pwm);
digitalWrite(pin, LOW);
delay(50); // Refresh cycle of servo
}
long Ultrasonic_read() {
digitalWrite(trigger, LOW);
delayMicroseconds(2);
digitalWrite(trigger, HIGH);
delayMicroseconds(10);
long time = pulseIn(echo, HIGH);
return time / 29 / 2;
}
void compareDistance() {
if (distance_L > distance_R) {
turnLeft();
delay(500);
forword();
delay(600);
turnRight();
delay(500);
forword();
delay(600);
turnRight();
delay(400);
} else {
turnRight();
delay(500);
forword();
delay(600);
turnLeft();
delay(500);
forword();
delay(600);
turnLeft();
delay(400);
}
}
void Check_side() {
Stop();
delay(100);
for (int angle = 70; angle <= 140; angle += 5) {
servoPulse(servo, angle);
}
delay(300);
distance_R = Ultrasonic_read();
Serial.print("D R=");
Serial.println(distance_R);
if (digitalRead(BT_STATE) == HIGH) {
BTSerial.print("DR=");
BTSerial.println(distance_R);
}
delay(100);
for (int angle = 140; angle >= 0; angle -= 5) {
servoPulse(servo, angle);
}
delay(500);
distance_L = Ultrasonic_read();
Serial.print("D L=");
Serial.println(distance_L);
if (digitalRead(BT_STATE) == HIGH) {
BTSerial.print("DL=");
BTSerial.println(distance_L);
}
delay(100);
for (int angle = 0; angle <= 70; angle += 5) {
servoPulse(servo, angle);
}
delay(300);
compareDistance();
}
void forword() {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
void backword() {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
void turnRight() {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
void turnLeft() {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
void Stop() {
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
CIRCUIT DIAGRAM:
HARDWARE:
Matlab/Simulink:
CONCLUSION:
The master-slave robot system developed within this project demonstrated remarkable proficiency
in accurately emulating the movements of the master robot. Characterized by its simplicity, user-
friendly interface, and cost-effectiveness, the system stands as a testament to its practicality and
accessibility. Moreover, its modular design facilitates seamless scalability and adaptability,
empowering users to easily extend or modify its functionalities as per evolving requirements. The
system's versatility renders it well-suited for diverse applications, spanning manufacturing,
surgical procedures, and hazardous environments alike. Its inherent capability to operate within
these varied contexts underscores its potential to revolutionize traditional methodologies and
enhance operational efficiency across industries. While the system remains in its developmental
phase, ongoing advancements and refinements hold the promise of further augmenting its utility
and efficacy. As it continues to evolve, it is poised to emerge as an invaluable asset, serving as a
versatile tool for a multitude of tasks across different domains.
References:
MrElectroUino, "Arduino Obstacle Avoidance Line Follower Robot Projects," [Online]. Available:
https://www.instructables.com/Arduino-Obstacle-Avoidance-Line-Follower-Robot-Pro/.
Mrelectrouino, "Autodesk Instructables," [Online]. Available: https://www.instructables.com/Arduino-
Obstacle-Avoidance-Line-Follower-Robot-Pro/.
J. Zafar, "Line Follower Obstacle Avoiding Robot Using Arduino And L298 Motor Driver," marobotic,
[Online]. Available: https://marobotic.com/2023/10/22/line-follower-obstacle-avoiding-robot-using-
arduino-and-l298-motor-driver/.
___________________________________________________________