arduino embedded systems and advanced robotics

33
ARDUINO EMBEDDED SYSTEMS AND ADVANCED ROBOTICS A Project Report for the Award of the Degree of B.Tech In Electronics and Instrumentation Engineering At ACADEMY OF TECHNOLOGY By Anirvan Misra Roll: 16900513005 Nilesh Tripathi Roll: 16900513022 Shubham Bhattacharya Roll: 16900513043

Upload: shubham-bhattacharya

Post on 13-Apr-2017

123 views

Category:

Automotive


7 download

TRANSCRIPT

Page 1: Arduino embedded systems and advanced robotics

ARDUINO EMBEDDED SYSTEMS AND ADVANCED

ROBOTICSA Project Report for the Award of the Degree of B.Tech

In

Electronics and Instrumentation Engineering

At

ACADEMY OF TECHNOLOGY

By

Anirvan Misra Roll: 16900513005

Nilesh Tripathi Roll: 16900513022

Shubham Bhattacharya Roll: 16900513043

Siddhartha Mishra Roll: 16900513044

Training Provided by

Tech Learning Solutions pvt. Ltd.

Technical Support given by

Skubotics

In Association with

MYWBUT (www.mywbut.com)

Page 2: Arduino embedded systems and advanced robotics

ACKNOWLEDGEMENTWe take this opportunity to express our deep gratitude and sincerest thank to our project mentor, Tunir Saha for giving most valuable solution helpful guidance and encouragement in the execution of this project work. We will like to give a special mention to our colleagues. Last but not the least to all the faculty member of Tech learning solution pvt. Ltd. for the support.

Page 3: Arduino embedded systems and advanced robotics

CONTENTSACKNOWLEDGEMENT

INTRODUCTION

Introduction to Embedded Systems Introduction to Arduino Anatomy of Arduino UNO ATmega-328p Arduino IDE

INTERFACING WITH ARDUINO UNO

Interfacing LED Interfacing IR Sensors Interfacing LDR Sensors Interfacing Temperature Sensor Interfacing a DC Motor

AUTONOMOUS ROBOTICS USING ARDUINO

Introduction to Autonomous Robotics Line Follower Robot

o Circuit Explanationo Working Principleo Codeo Project Snapshot

CONCLUSION

Page 4: Arduino embedded systems and advanced robotics

INTRODUCTION

Introduction to Embedded System:

An embedded system is a computer system with a dedicated function within a larger mechanical or electrical system, often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. Embedded systems control many devices in common use today. Ninety-eight percent of all microprocessors are manufactured as components of embedded systems.

Embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, and largely complex systems like hybrid vehicles, MRI, and avionics. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure.

The uses of embedded systems are virtually limitless, because every day new products are introduced to the market that utilize embedded computers in novel ways.

In recent years, hardware such as microprocessors, microcontrollers, and FPGA chips have become much cheaper.

Some examples of embedded systems include ATMs, cell phones, printers, thermostats, calculators, and videogame consoles. Handheld computers or PDAs are also considered embedded devices because of the nature of their hardware design, even though they are more expandable in software terms.

Page 5: Arduino embedded systems and advanced robotics

Introduction to Arduino:Arduino is a computer hardware and software company, project, and user community that designs and manufactures microcontroller kits for building digital devices and interactive objects that can sense and control objects in the physical world. The project's products are distributed as open-source hardware and software, which are licensed under the GNU Lesser General Public License (LGPL) or the GNU General Public License (GPL), permitting the manufacture of Arduino boards and software distribution by anyone. Arduino boards are available commercially in preassembled form, or as do-it-yourself kits.

Anatomy of Arduino UNO:Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button.

It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started.

Page 6: Arduino embedded systems and advanced robotics

ATmega328p:The Atmega328p is a very popular microcontroller chip produced by Atmel. It is an 8-bit microcontroller that has 32K of flash memory, 1K of EEPROM, and 2K of internal SRAM.

The Atmega328 is one of the microcontroller chips that are used with the popular Arduino Duemilanove boards. The Arduino Duemilanove board comes with either 1 of 2 microcontroller chips, the Atmega168 or the Atmega328. Of these 2, the Atmega328 is the upgraded, more advanced chip. Unlike the Atmega168 which has 16K of flash program memory and 512 bytes of internal SRAM, the Atmega328 has 32K of flash program memory and 2K of Internal SRAM.

The Atmega328 has 28 pins.

It has 14 digital I/O pins, of which 6 can be used as PWM outputs and 6 analog input pins. These I/O pins account for 20 of the pins.

Pin configuration

Page 7: Arduino embedded systems and advanced robotics

Arduino IDE:The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux.

The environment is written in Java and based on Processing and other open-source software. This software can be used with any Arduino board. Programs written using Arduino Software (IDE) are called sketches. These sketches are written in the text editor and are saved with the file extension .ino. The editor has features for cutting/pasting and for searching/replacing text. First, the Arduino compiler/IDE accepts C and C++ as-is. In fact many of the libraries are written in C++. Much of the underlying system is not object oriented, but it could be. Thus, "The arduino language" is C++ or C.

Page 8: Arduino embedded systems and advanced robotics

INTERFACING WITH ARDUINO UNO

LED interfacing with Arduino:To light an external LED, we to build this circuit, where we connect one end of the resistor to the digital pin correspondent to the LED_BUILTIN constant. Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED (the negative leg, called the cathode) to the GND. In the diagram below we show an UNO board that has D13 as the LED_BUILTIN value.The value of the resistor in series with the LED may be of a different value than 220 ohm; the LED will lit up also with values up to 1K ohm.

Schematic:

Page 9: Arduino embedded systems and advanced robotics

Code:// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin LED_BUILTIN as an output.

pinMode(LED_BUILTIN, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second

}

Page 10: Arduino embedded systems and advanced robotics

Interfacing Infrared sensor:Principle of working

The principle of an IR sensor working as an Object Detection Sensor can be explained using the following figure. An IR sensor consists of an IR LED and an IR Photodiode; together they are called as Photo – Coupler or Opto – Coupler.

When the IR transmitter emits radiation, it reaches the object and some of the radiation reflects back to the IR receiver. Based on the intensity of the reception by the IR receiver, the output of the sensor is defined.It consists of an IR LED, a photodiode, a potentiometer, an IC Operational amplifier and an LED.IR LED emits infrared light. The Photodiode detects the infrared light. An IC Op – Amp is used as a voltage comparator. The potentiometer is used to calibrate the output of the sensor according to the requirement.When the light emitted by the IR LED is incident on the photodiode after hitting an object, the resistance of the photodiode falls down from a huge value. One of the input of the op – amp is at threshold value set by the potentiometer. The other input to the op-amp is from the photodiode’s series resistor. When the incident radiation is more on the photodiode, the voltage drop across the series resistor will be high. In the IC, both the threshold voltage and the voltage across the series resistor are compared. If the voltage across the resistor series to photodiode is greater than that of the threshold voltage, the output of the IC Op – Amp is high. As the output of the IC is connected to an LED, it lightens up. The threshold voltage can be adjusted by adjusting the potentiometer depending on the environmental conditions.

It is universal that black color absorbs the entire radiation incident on it and white color reflects the entire radiation incident on it. Based on this principle, the second positioning of the sensor couple can be made. The IR LED and the photodiode are placed side by side. When the IR transmitter emits infrared radiation, since there is no direct line of contact between the transmitter and receiver, the emitted radiation must reflect back to the photodiode after hitting any object.

Page 11: Arduino embedded systems and advanced robotics

The surface of the object can be divided into two types: reflective surface and non-reflective surface. If the surface of the object is reflective in nature i.e. it is white or other light color, most of the radiation incident on it will get reflected back and reaches the photodiode. Depending on the intensity of the radiation reflected back, current flows in the photodiode.

If the surface of the object is non-reflective in nature i.e. it is black or other dark color, it absorbs almost all the radiation incident on it. As there is no reflected radiation, there is no radiation incident on the photodiode and the resistance of the photodiode remains higher allowing no current to flow. This situation is similar to there being no object at all.

Schematic:

Page 12: Arduino embedded systems and advanced robotics

Code://define pins

#define irLedPin 4 // IR Led on this pin

#define irSensorPin 5 // IR sensor on this pin

int irRead(int readPin, int triggerPin); //function prototype

void setup()

{

pinMode(irSensorPin, INPUT);

pinMode(irLedPin, OUTPUT);

Serial.begin(9600);

// prints title with ending line break

Serial.println("Program Starting");

// wait for the long string to be sent

delay(100);

}

void loop()

{

Serial.println(irRead(irSensorPin, irLedPin)); //display the results

delay(10); //wait for the string to be sent

}

Page 13: Arduino embedded systems and advanced robotics

Interfacing Light Detecting Resistor:A Light Dependent Resistor (LDR) or a photo resistor is a device whose resistivity is a function of the incident electromagnetic radiation. Hence, they are light sensitive devices.

They are also called as photo conductors, photo conductive cells or simply photocells. They are made up of semiconductor materials having high resistance.

Schematic:

Code:int sensorPin = A0; // select the input pin for ldr

int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {

Serial.begin(9600); //sets serial port for communication

}

void loop() {

sensorValue = analogRead(sensorPin); // read the value from the sensor

Serial.println(sensorValue); //prints the values coming from the sensor on the screen

delay(100);

}

Page 14: Arduino embedded systems and advanced robotics

Interfacing Temperature Sensor:Temperature sensor is a device which senses variations in temperature across it. LM35 is a basic temperature sensor that can be used for experimental purpose. It give the readings in centigrade (degree Celsius) since its output voltage is linearly proportional to temperature.

Schematic:

Code:float tempC;

int tempPin = 0;

void setup()

{

Serial.begin(9600); //opens serial port, sets data rate to 9600 bps

}

void loop()

{

tempC = analogRead(tempPin); //read the value from the sensor

tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature

Serial.print((byte)tempC); //send the data to the computer

delay(1000); //wait one second before sending new data

}

Page 15: Arduino embedded systems and advanced robotics

Interfacing DC motor:There are three input pins for each motor, Input1 (IN1), Input2 (IN2), and Enable1 (EN1) for Motor1 and Input3, Input4, and Enable2 for Motor2.

Since we will be controlling only one motor in this example, we will connect the Arduino to IN1 (pin 5), IN2 (pin 7), and Enable1 (pin 6) of the L298 IC. Pins 5 and 7 are digital, i.e. ON or OFF inputs, while pin 6 needs a pulse-width modulated (PWM) signal to control the motor speed.

The following table shows which direction the motor will turn based on the digital values of IN1 and IN2.

IN1 IN2 Motor Behavior

0 0 BRAKE

1 0 FORWARD

0 1 BACKWARD

1 1 BRAKE

Pin IN1 of the IC L298 is connected to pin 8 of Arduino while IN2 is connected to pin 9. These two digital pins of Arduino control the direction of the motor. The EN A pin of IC is connected to the PWM pin 2 of Arduino. This will control the speed of the motor.

To set the values of Arduino pins 8 and 9, we have used the digitalWrite() function, and to set the value of pin 2, we have to use the analogWrite() function.

Schematic:

Page 16: Arduino embedded systems and advanced robotics

Code:const int pwm = 2 ; //initializing pin 2 as pwm

const int in_1 = 8 ;

const int in_2 = 9 ;

//For providing logic to L298 IC to choose the direction of the DC motor

void setup()

{

pinMode(pwm,OUTPUT) ; //we have to set PWM pin as output

pinMode(in_1,OUTPUT) ; //Logic pins are also set as output

pinMode(in_2,OUTPUT) ;

}

void loop()

{

//For Clock wise motion , in_1 = High , in_2 = Low

digitalWrite(in_1,HIGH) ;

digitalWrite(in_2,LOW) ;

analogWrite(pwm,255) ;

/*setting pwm of the motor to 255

we can change the speed of rotaion

by chaning pwm input but we are only

using arduino so we are using higest

value to driver the motor */

delay(3000) ;

//For brake

digitalWrite(in_1,HIGH) ;

digitalWrite(in_2,HIGH) ;

delay(1000) ;

Page 17: Arduino embedded systems and advanced robotics

//For Anti Clock-wise motion - IN_1 = LOW , IN_2 = HIGH

digitalWrite(in_1,LOW) ;

digitalWrite(in_2,HIGH) ;

delay(3000) ;

//For brake

digitalWrite(in_1,HIGH) ;

digitalWrite(in_2,HIGH) ;

delay(1000) ;

}

Page 18: Arduino embedded systems and advanced robotics

AUTONOMOUS ROBOTICS USING ARDUINO

Introduction to Autonomous Robotics:An autonomous robot is a robot that performs behaviors or tasks with a high degree of autonomy, which is particularly desirable in fields such as spaceflight, household maintenance (such as cleaning), waste water treatment and delivering goods and services.

Some modern factory robots are "autonomous" within the strict confines of their direct environment. It may not be that every degree of freedom exists in their surrounding environment, but the factory robot's workplace is challenging and can often contain chaotic, unpredicted variables. The exact orientation and position of the next object of work and (in the more advanced factories) even the type of object and the required task must be determined. This can vary unpredictably (at least from the robot's point of view).

One important area of robotics research is to enable the robot to cope with its environment whether this be on land, underwater, in the air, underground, or in space.

A fully autonomous robot can:

Gain information about the environment Work for an extended period without human intervention Move either all or part of itself throughout its operating environment without human

assistance Avoid situations that are harmful to people, property, or itself unless those are part of its

design specifications

An autonomous robot may also learn or gain new knowledge like adjusting for new methods of accomplishing its tasks or adapting to changing surroundings.

Like other machines, autonomous robots still require regular maintenance.

Page 19: Arduino embedded systems and advanced robotics

Line Follower Robot:Line follower Robot is a machine which follows a line, either a black line or white line. Basically there are two types of line follower robots: one is black line follower which follows black line and second is white line follower which follows white line. Line follower actually senses the line and run over it.

Concepts of Line Follower:Concept of working of line follower is related to light. We use here the behavior of light at black and white surface. When light fall on a white surface it is almost full reflected and in case of black surface light is completely absorbed. This behavior of light is used in building a line follower robot.

Page 20: Arduino embedded systems and advanced robotics

In this arduino based line follower robot we have used IR Transmitters and IR receivers also called photo diodes.

They are used for sending and receiving light. IR transmits infrared lights. When infrared rays falls on white surface, it’s reflected back and catched by photodiodes which generates some voltage changes. When IR light falls on a black surface, light is absorb by the black surface and no rays are reflected back, thus photo diode does not receive any light or rays.

Here in this line follower robot when sensor senses white surface then arduino gets 1 as input and when senses black line arduino gets 0 as input.

Circuit Explanation:The whole line follower robot can be divided into 3 sections: sensor section, control section and driver section.

Sensor section:

This section contains IR diodes, potentiometer, Comparator (Op-Amp) and LED’s. Potentiometer is used for setting reference voltage at comparator’s one terminal and IR sensors are used to sense the line and provide a change in voltage at comparator’s second terminal. Then comparator compares both voltages and generates a digital signal at output. Here in this line follower circuit we have used two comparator for two sensors. LM 358 is used as comparator. LM358 has inbuilt two low noise Op-amps.

Control Section:

Arduino Uno is used for controlling whole the process of line follower robot. The outputs of comparators are connected to digital pin number 2 and 3 of arduino. Arduino read these signals and send commands to driver circuit to drive line follower.

Driver section:

Driver section consists motor driver and two DC motors. Motor driver is used for driving motors because arduino does not supply enough voltage and current to motor. So we add a motor driver circuit to get enough voltage and current for motor. Arduino sends commands to this motor driver and then it drive motors.

Page 21: Arduino embedded systems and advanced robotics

Working Principle:Working of line follower is very interesting. Line follower robot senses black line by using sensor and then sends the signal to arduino. Then arduino drives the motor according to sensors' output.

Here in this project we are using two IR sensor modules namely left sensor and right sensor. When both left and right sensor senses white then robot move forward.

Page 22: Arduino embedded systems and advanced robotics

If left sensor comes on black line then robot turn left side.

If right sensor sense black line then robot turn right side until both sensor comes at white surface. When white surface comes robot starts moving on forward again.

Page 23: Arduino embedded systems and advanced robotics

If both sensors comes on black line, robot stops.

Sensor Response:

Page 24: Arduino embedded systems and advanced robotics

There are four conditions in this line following robot that we read by using arduino. We have used two sensor namely left sensor and right sensor.

Robot Response Table:

Input Output MovementOf Robot

Left Sensor Right Sensor Left Motor

Right Motor

LS RS LM1 LM2 RM1 RM2

0 0 0 0 0 0 Stop

0 1 1 0 0 0 Turn Right

1 0 0 0 1 0 Turn Left

1 1 1 0 1 0 Forward

Code:int k1=300;

int k2=300;

int lm1=5;

int lm2=6;

int lspeed=9;

int rm1=7;

int rm2=8;

int rspeed=10;

/*int left=A2;

int right=A5;*/

void setup()

{

Serial.begin(9600);

pinMode(9,OUTPUT);

pinMode(5,OUTPUT);

pinMode(6,OUTPUT);

Page 25: Arduino embedded systems and advanced robotics

pinMode(7,OUTPUT);

pinMode(8,OUTPUT);

pinMode(10,OUTPUT);

digitalWrite(lspeed,1);

digitalWrite(rspeed,1);

}

void right()

{

digitalWrite(lm1,1);

digitalWrite(lm2,0);

digitalWrite(rm1,0);

digitalWrite(rm2,0);

}

void left()

{

digitalWrite(lm1,0);

digitalWrite(lm2,0);

digitalWrite(rm1,1);

digitalWrite(rm2,0);

}

void forward()

{

digitalWrite(lm1,1);

digitalWrite(lm2,0);

digitalWrite(rm1,1);

digitalWrite(rm2,0);

}

void backward()

{

digitalWrite(lm1,0);

digitalWrite(lm2,1);

Page 26: Arduino embedded systems and advanced robotics

digitalWrite(rm1,0);

digitalWrite(rm2,1);

}

void loop()

{

int a=analogRead(A2);

int b=analogRead(A5);

Serial.print(a);

Serial.print('\t');

Serial.println(b);

if(a>k1)

left();

else if (b>k2)

right();

else if((a<k1 && b<k2)||(a>k1 && b>k2))

forward();

}

Snapshot of the project

Conclusion

Page 27: Arduino embedded systems and advanced robotics

In this project we have studied and implemented a Line Following Robot using Arduino Uno. The programming and interface of microcontroller has been mastered during the implementation.

The Track Follower robot is one of the outcomes of implementation of with microcontroller on single board. This robot can be autonomous if it is run by 4 AA batteries.

There are certain advantages of this robot. They are as:

Increased productivity, safety, efficiency, quality of products Can work in hazardous environments, no need for support Need no environmental comforts Have repeatable precision at all times Can be more accurate than humans Have many capabilities beyond those of humans Can process multiple stimuli/tasks simultaneously .A robot can work without sleep. So it can work 24/7/365 Apart from advantages there are some disadvantages too.

Robots take the place of many humans in places like factories. So the people have to find new jobs or be retrained. So a MAJOR disadvantage is that the robots take the place of humans in several situations.

Another disadvantage is that there is quite a high initial cost for the robot and the software and equipment that you need to use with the robot

Reference

Page 28: Arduino embedded systems and advanced robotics

http://circuitdigest.com/microcontroller-projects/line-follower-robot-using-arduino

https://www.arduino.cc/en/Main/ArduinoBoardUnoSMD http://en.wikipedia.org/wiki/Arduino