Вы находитесь на странице: 1из 64

WIFI CONTROLLED MOBILE ROBOT

CHAPTER 1

INTRODUCTION

There are many types of Robots, from the simple ones like a Toy car to the

advanced ones like industrial Robots. a Wi-Fi Controlled Robot using Arduino . This

Arduino based Robot can be controlled wirelessly using any Wi-Fi enabled Android

smart phone. Circuit Diagram of Wi-Fi controlled robot is given below.

We mainly need a Arduino and ESP8266 Wi-Fi module. ESP8266’s Vcc and

GND pins are directly connected to 3.3V and GND of Arduino and CH_PD is also

connected with 3.3V. Tx and Rx pins of ESP8266 are directly connected to pin 2 and 3

of Arduino The robot can be controlled from an ordinary internet browser, using a

HTML designed interface. An Android smartphone might be used to broadcast video

and audio from the robot to the control interface.

An Arduino Uno was choosed because it's very accessible and easy to use for

everyone, and we wanted to design a simple shield for it. In our original project, who

also control some servos and LED matrices, and interfaces with the ESP. The

smartphone is actually replaced by a tablet, that runs other applications as well

Software Serial Library is used to allow serial communication on pin 2 and 3 of

Arduino. We have already covered the Interfacing of ESP8266 Wi-Fi module to

Arduino in detail.

A L293D Motor Driver IC is used for driving DC motors. Input pins of motor

driver IC is directly connected to pin 8, 9, 10 and 11 of Arduino. And DC motors are

connected at its output pins. Here we have used 9 Volt battery for driving the Circuit

and DC motors.An embedded system combines mechanical, electrical, and chemical

DEPT of ECE, ATRI Page 1


WIFI CONTROLLED MOBILE ROBOT

components along with a computer, hidden inside, to perform a single dedicated

purpose. There are more computers on this planet than there are people, and most of

these computers are single-chip microcontrollers that are the brains of an embedded

system.

Embedded systems are a ubiquitous component of our everyday lives. We

interact with hundreds of tiny computers every day that are embedded into our houses,

our cars, our bridges, our toys, and our work. As our world has become more complex,

so have the capabilities of the microcontrollers embedded into our devices. Therefore

the world needs a trained workforce to develop and manage products based on

embedded microcontrollers

DEPT of ECE, ATRI Page 2


WIFI CONTROLLED MOBILE ROBOT

CHAPTER 2

LITERATURE SURVEY

Various researches have been made by different researchers in developing this

project. However, they serve a different application and have different technologies

implemented. Some of those papers are mentioned below stating their technology and

application.

PAPER I

TITLE: AURDINO

Jorge Kazacos Winter has developed android controlled robot automation. Main

aim of his project was the transfer of information wirelessly between a smartphone and

the robot and developing the robot and its communication system underneath a low

price and open source philosophy. He has used Arduino micro-controller and Wi-Fi

technology in this robot.

AUTHOR: JORGE KAZACOS.

PAPER II

TITLE: WI-FI TECHNOLOGY

M.Selvam in his paper has projected design to develop a robotic system which

has a wireless camera attached to it for surveillance. Bluetooth was implemented in his

project for providing connection between robot and smartphone. The video which is

recorded by camera is then transmitted to TV unit through Radio Frequency

International Journal of Industrial Electronics and Electrical Engineering, ISSN(p):

2347-6982, ISSN(e): 2349-204X Volume-6, Issue-3, Mar.-2018, http://ijieee.org.in

AUTHOR:M.SELVAM.

DEPT of ECE, ATRI Page 3


WIFI CONTROLLED MOBILE ROBOT

CHAPTER 3

DESIGN IMPLIMENTATION
3.1 Block diagram:

Fig 3.1 block diagram

We mainly need a Arduino and ESP8266 Wi-Fi module. ESP8266’s Vcc and

GND pins are directly connected to 3.3V and GND of Arduino and CH_PD is also

connected with 3.3V. Tx and Rx pins of ESP8266 are directly connected to pin 2 and 3

of Arduino. Software Serial Library is used to allow serial communication on pin 2 and

3 of Arduino.

We have already covered the Interfacing of ESP8266 Wi-Fi module to Arduino

in detail.A L293D Motor Driver IC is used for driving DC motors. Input pins of motor

driver IC is directly connected to pin 8, 9, 10 and 11 of Arduino. And DC motors are

connected at its output pins. Here we have used 9 Volt battery for driving the Circuit

and DC motors.

DEPT of ECE, ATRI Page 4


WIFI CONTROLLED MOBILE ROBOT

3.2 Flow chart:

DEPT of ECE, ATRI Page 5


WIFI CONTROLLED MOBILE ROBOT

3.3 Internal circuit diagram:

We mainly need a Arduino and ESP8266 Wi-Fi module. ESP8266’s Vcc and

GND pins are directly connected to 3.3V and GND of Arduino and CH_PD is also

connected with 3.3V. Tx and Rx pins of ESP8266 are directly connected to pin 2 and 3

of Arduino. Software Serial Library is used to allow serial communication on pin 2 and

3 of Arduino.

We have already covered the Interfacing of ESP8266 Wi-Fi module to Arduino

in detail.A L293D Motor Driver IC is used for driving DC motors. Input pins of motor

driver IC is directly connected to pin 8, 9, 10 and 11 of Arduino. And DC motors are

connected at its output pins. Here we have used 9 Volt battery for driving the Circuit

and DC motors.

DEPT of ECE, ATRI Page 6


WIFI CONTROLLED MOBILE ROBOT

CHAPTER 4

HARDWARE DESCRIPTION
4.1 Arduino Microcontroller

The Arduino is a family of microcontroller boards to simplify electronic design,

prototyping and experimenting for artists, hackers, hobbyists, but also many

professionals.

People use it as brains for their robots, to build new digital music instruments,

or to build a system that lets your house plants tweet you when they’re dry. Arduinos

(we use the standard Arduino Uno) are built around an ATmega microcontroller —

essentially a complete computer with CPU, RAM, Flash memory, and input/output

pins, all on a single chip. Unlike, say, a Raspberry Pi, it’s designed to attach all kinds

of sensors, LEDs, small motors and speakers, servos, etc. directly to these pins, which

can read in or output digital or analog voltages between 0 and 5 volts.

The Arduino connects to your computer via USB, where you program it in a

simple language (C/C++, similar to Java) from inside the free Arduino IDE by

uploading your compiled code to the board. Once programmed, the Arduino can run

with the USB link back to your computer, or stand-alone without it — no keyboard or

screen needed, just power.

DEPT of ECE, ATRI Page 7


WIFI CONTROLLED MOBILE ROBOT

Figure 4.1 Structure of Arduino Board

Looking at the board from the top down, this is an outline of what you will see

(parts of the board you might interact with in the course of normal use are highlighted)

Figure 4.2 Arduino Board

DEPT of ECE, ATRI Page 8


WIFI CONTROLLED MOBILE ROBOT

Starting clockwise from the top center:

➢ Analog Reference pin (orange)

➢ Digital Ground (light green)

➢ Digital Pins 2-13 (green)

➢ Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used

for digital i/o (Digital Read and Digital Write) if you are also using serial

communication (e.g. Serial.begin).

➢ Reset Button - S1 (dark blue)

➢ In-circuit Serial Programmer (blue-green)

➢ Analog In Pins 0-5 (light blue)

➢ Power and Ground Pins (power: orange, grounds: light orange)

➢ External Power Supply In (9-12VDC) - X1 (pink)

➢ Toggles External Power and USB Power (place jumper on two pins closest to

desired supply) - SV1 (purple)

➢ USB (used for uploading sketches to the board and for serial communication

between the board and the computer; can be used to power the board) (yellow)

4.1.1 Digital Pins

In addition to the specific functions listed below, the digital pins on an Arduino

board can be used for general purpose input and output via the pin Mode(), Digital

Read(), and Digital Write() commands. Each pin has an internal pull-up resistor which

can be turned on and off using digital Write() (w/ a value of HIGH or LOW,

respectively) when the pin is configured as an input. The maximum current per pin is

40mA.

DEPT of ECE, ATRI Page 9


WIFI CONTROLLED MOBILE ROBOT

➢ Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial

data. On the Arduino Diecimila, these pins are connected to the corresponding

pins of the FTDI USB-to-TTL Serial chip. On the Arduino BT, they are

connected to the corresponding pins of the WT11 Bluetooth module. On the

Arduino Mini and LilyPad Arduino, they are intended for use with an external

TTL serial module (e.g. the Mini-USB Adapter).

➢ External Interrupts: 2 and 3. These pins can be configured to trigger an

interrupt on a low value, a rising or falling edge, or a change in value. See the

attach Interrupt() function for details.

➢ PWM: 3, 5, 6, 9, 10, and 11 Provide 8-bit PWM output with the analog Write()

function. On boards with an ATmega8, PWM output is available only on pins

9, 10, and 11.

➢ BT Reset: 7. (Arduino BT-only) Connected to the reset line of the bluetooth

module.

➢ SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI

communication, which, although provided by the underlying hardware, is not

currently included in the Arduino language.

➢ LED: 13. On the Diecimila and LilyPad, there is a built-in LED connected to

digital pin 13. When the pin is HIGH value, the LED is on, when the pin is

LOW, it's off.

4.1.2 Analog Pins

In addition to the specific functions listed below, the analog input pins support

10-bit analog-to-digital conversion (ADC) using the analog Read() function. Most of

the analog inputs can also be used as digital pins: analog input 0 as digital pin 14

DEPT of ECE, ATRI Page 10


WIFI CONTROLLED MOBILE ROBOT

through analog input 5 as digital pin 19. Analog inputs 6 and 7 (present on the Mini and

BT) cannot be used as digital pins.

➢ I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire

library (documentation on the Wiring website).

4.1.3 Power Pins

➢ VIN (sometimes labeled "9V"): The input voltage to the Arduino board when

it's using an external power source (as opposed to 5 volts from the USB

connection or other regulated power source). You can supply voltage through

this pin, or, if supplying voltage via the power jack, access it through this pin.

Also note that the Lily Pad has no VIN pin and accepts only a regulated input.

➢ 5V: The regulated power supply used to power the microcontroller and other

components on the board. This can come either from VIN via an on-board

regulator, or be supplied by USB or another regulated 5V supply.

➢ 3V3 (Diecimila-only) : A 3.3 volt supply generated by the on-board FTDI chip.

➢ GND: Ground pins.

4.1.4 Other Pins

➢ AREF: Reference voltage for the analog inputs. Used with analog Reference().

➢ Reset: (Diecimila-only) Bring this line LOW to reset the microcontroller.

Typically used to add a reset button to shields which block the one on the board.

DEPT of ECE, ATRI Page 11


WIFI CONTROLLED MOBILE ROBOT

4.2 Atmega 328P

4.2.1 Pin diagram

Figure 4.3 Pin Configuration of Atmega328

Pin Description
VCC:
Digital supply voltage.
GND:

Ground.

Port A (PA7-PA0):

Port A serves as the analog inputs to the A/D Converter. Port A also serves as

an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins can provide

DEPT of ECE, ATRI Page 12


WIFI CONTROLLED MOBILE ROBOT

internal pull-up resistors (selected for each bit). The Port A output buffers have

symmetrical drive characteristics with both high sink and source capability. When pins

PA0 to PA7 are used as inputs and are externally pulled low, they will source current if

the internal pull-up resistors are activated.

The Port A pins are tri-stated when a reset condition becomes active, even if the

clock is not running.

Port B (PB7-PB0):

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected

for each bit). The Port B output buffers have symmetrical drive characteristics with

both high sink and source capability.

As inputs, Port B pins that are externally pulled low will source current if the

pull-up resistors are activated. The Port B pins are tri-stated when a reset condition

becomes active, even if the clock is not running. Port B also serves the functions of

various special features of the ATmega32.

Port C (PC7-PC0):

Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected

for each bit). The Port C output buffers have symmetrical drive characteristics with

both high sink and source capability.

As inputs, Port C pins that are externally pulled low will source current if the

pull-up resistors are activated. The Port C pins are tri-stated when a reset condition

becomes active, even if the clock is not running.

If the JTAG interface is enabled, the pull-up resistors on pins PC5(TDI),

PC3(TMS) and PC2(TCK) will be activated even if a reset occurs. The TD0 pin is tri-

stated unless TAP states that shift out data are entered. Port C also serves the functions

of the JTAG interface.

DEPT of ECE, ATRI Page 13


WIFI CONTROLLED MOBILE ROBOT

Port D (PD7-PD0):

Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected

for each bit). The Port D output buffers have symmetrical drive characteristics with

both high sink and source capability.

As inputs, Port D pins that are externally pulled low will source current if the

pull-up resistors are activated. The Port D pins are tri-stated when a reset condition

becomes active, even if the clock is not running.

Port D also serves the functions of various special features of the ATmega32.

Reset (Reset Input):

A low level on this pin for longer than the minimum pulse length will generate

a reset, even if the clock is not running. Shorter pulses are not guaranteed to generate a

reset.

XTAL1:

Input to the inverting Oscillator amplifier and input to the internal clock

operating circuit.

XTAL2:

Output from the inverting Oscillator amplifier.

AVCC:

AVCC is the supply voltage pin for Port A and the A/D Converter. It should be

externally connected to VCC, even if the ADC is not used. If the ADC is used, it should

be connected to VCC through a low-pass filter.

AREF:

AREF is the analog reference pin for the A/D Converter.

DEPT of ECE, ATRI Page 14


WIFI CONTROLLED MOBILE ROBOT

4.2.2 Features

➢ 1.8-5.5V operating range

➢ Up to 20MHz

➢ Part: ATMEGA328P-AU

➢ 32kB Flash program memory

➢ 1kB EEPROM

➢ 2kB Internal SRAM

➢ 2 8-bit Timer/Counters

➢ 16-bit Timer/Counter

➢ RTC with separate oscillator

➢ 6 PWM Channels

➢ 8 Channel 10-bit ADC

➢ Serial USART

➢ Master/Slave SPI interface

➢ 2-wire (I2C) interface

➢ Watchdog timer

➢ Analog comparator

➢ 23 IO lines

➢ Data retention: 20 years at 85C/ 100 years at 25C

➢ Digital I/O Pins are 14 (out of which 6 provide PWM output)

➢ Analog Input Pins are 6.

➢ DC Current per I/O is 40 mA

➢ DC Current for 3.3V Pin is 50mA

DEPT of ECE, ATRI Page 15


WIFI CONTROLLED MOBILE ROBOT

4.2.3. AVR CPU Core

The AVR core combines a rich instruction set with 32 general purpose working

registers. All the 32 registers are directly connected to the Arithmetic Logic Unit

(ALU), allowing two independent registers to be accessed in one single instruction

executed in one clock cycle. The resulting architecture is more code efficient while

achieving throughputs up to ten times faster than conventional CISC microcontrollers.

Figure 4.4AVR CPU Block Diagram

DEPT of ECE, ATRI Page 16


WIFI CONTROLLED MOBILE ROBOT

4.2.4 Status Register


The Status Register contains information about the result of the most recently

executed arithmetic instruction. This information can be used for altering program flow

in order to perform conditional operations. Note that the Status Register is updated after

all ALU operations, as specified in the Instruction Set Reference. This will in many

cases remove the need for using the dedicated compare instructions, resulting in faster

and more compact code. The Status Register is not automatically stored when entering

an interrupt routine and restored when returning from an interrupt. This must be handled

by software.

The AVR Status Register – SREG is defined as:

Figure 3.6 AVR status register

Bit 7 – I: Global Interrupt Enable

The Global Interrupt Enable bit must be set for the interrupts to be enabled. The

individual interrupt enable control The Global Interrupt Enable bit must be set for the

interrupts to be enabled. The individual interrupt enable control is then performed in

separate control registers. If the Global Interrupt Enable Register is cleared, none of the

interrupts are enabled independent of the individual interrupt enable settings. The I-bit

is cleared by hardware after an interrupt has occurred, and is set by the RETI instruction

to enable subsequent interrupts. The I-bit can also be set and cleared by the application

with the SEI and CLI instructions, as described in the instruction set reference.

DEPT of ECE, ATRI Page 17


WIFI CONTROLLED MOBILE ROBOT

Bit 6 – T: Bit Copy Storage

The Bit Copy instructions BLD (Bit Load) and BST (Bit Store) use the T-bit as

source or destination for the operated bit. A bit from a register in the Register File can

be copied into T by the BST instruction, and a bit in T can be copied into a bit in a

register in the Register File by the BLD instruction.

Bit 5 – H: Half Carry Flag

The Half Carry Flag H indicates a Half Carry in some arithmetic operations The

Half Carry Flag H indicates a Half Carry in some arithmetic operations. Half Carry Is

useful in BCD arithmetic. See the “Instruction Set Description” for detailed

information.

Bit 4 – S: Sign Bit, S = N V

The S-bit is always an exclusive or between the Negative Flag N and the Two’s

Complement Overflow Flag V. See the “Instruction Set Description” for detailed

information.

Bit 3 – V: Two’s Complement Overflow Flag

The Two’s Complement Overflow Flag V supports two’s complement

arithmetic.

Bit 2 – N: Negative Flag

The Negative Flag N indicates a negative result in an arithmetic or logic

operation.

Bit 1 – Z: Zero Flag

The Zero Flag Z indicates a zero result in an arithmetic or logic operation.

Bit 0 – C: Carry Flag

The Carry Flag C indicates a carry in an arithmetic or logic operation.

DEPT of ECE, ATRI Page 18


WIFI CONTROLLED MOBILE ROBOT

4.2.5 General Purpose Register File

The Register File is optimized for the AVR Enhanced RISC instruction set. In

order to achieve the required performance and flexibility, the following input/output

schemes are supported by the Register File:

• One 8-bit output operand and one 8-bit result input

• Two 8-bit output operands and one 8-bit result input

• Two 8-bit output operands and one 16-bit result input

One 16-bit output operand and one 16-bit result input

Most of the instructions operating on the Register File have direct access to

all registers, and most of them are single cycle instructions. As shown in Figure 6-2,

each register is also assigned a data memory address, mapping them directly into the

first32 locations of the user data space. Although not being physically implemented as

SRAM locations, this memory organization provides great flexibility in access of the

registers, as the X-, Y-, and Z-pointer Registers can be set to index any register.

Figure 4.6 Structure of the 32 general purpose working registers in the CPU

X-, Y-, and Z-register

DEPT of ECE, ATRI Page 19


WIFI CONTROLLED MOBILE ROBOT

The registers R26:R31 have some added functions to their general purpose

usage. These registers are 16-bit address pointers for indirect addressing of the data

space. The three indirect address registers X, Y, and Z are defined as described in

Figure 4.7 X-, Y-, and Z-Registers

In the different addressing modes these address registers have functions as fixed

displacement, automatic increment, and automatic decrement.

4.2.6 Stack Pointer

The Stack is mainly used for storing temporary data, for storing local variables

and for storing return addresses after interrupts and subroutine calls. Note that the Stack

is implemented as growing from higher to lower memorylocations. The Stack Pointer

Register always points to the top of the Stack. The Stack Pointer points to the data

SRAM Stack area where the Subroutine and Interrupt Stacks are located. A Stack

PUSH command will decrease the Stack Pointer.

The Stack in the data SRAM must be defined by the program before any

subroutine calls are executed or interrupts are enabled. Initial Stack Pointer value equals

the last address of the internal SRAM and the Stack Pointer must be set to point above

start of the SRAM

DEPT of ECE, ATRI Page 20


WIFI CONTROLLED MOBILE ROBOT

Table 4.1 Stack Pointer instructions

The AVR ATmega128A Stack Pointer is implemented as two 8-bit registers in

the I/O space. The number of bits actually used is implementation dependent. Note that

the data space in some implementations of the AVR architecture is so small that only

SPL is needed. In this case, the SPH Register will not be present.SPH and SPL - Stack

Pointer High and Low Register.

4.2.7 AVR Memories

This section describes the different memories in the ATmega328. The AVR

architecture has two main memory spaces, the Data Memory and the Program Memory

space. In addition, theATmega328 features an EEPROM Memory for data storage. All

three memory spaces are linear and regular.

In-System Reprogrammable Flash Program Memory:

The ATmega328 contains 4/8/16/32Kbytes On-chip In-System

Reprogrammable Flash memory for program storage. Since all AVR instructions are

16 or 32 bits wide, the Flash is organized as 2/4/8/16K x 16. For software security, the

Flash Program memory space is divided into two sections, Boot Loader Section and

Application Program Section. The Flash memory has an endurance of at least 10,000

DEPT of ECE, ATRI Page 21


WIFI CONTROLLED MOBILE ROBOT

write/erase cycles. The ATmega328 Program Counter (PC) is 11/12/13/14 bits wide,

thus addressing the 2/4/8/16K program memory locations.

SRAM Data Memory:

ATmega328 is a complex microcontroller with more peripheral units than can

be supported within the 64 locations reserved in the Opcode for the IN and OUT

instructions. For the Extended I/O space from 0x60 - 0xFF in SRAM, only the

ST/STS/STD and LD/LDS/LDD instructions can be used.

The lower 768/1280/1280/2303 data memory locations address both the

Register File, the I/O memory, Extended I/O memory, and the internal data SRAM. The

first 32 locations address the Register File, the next 64 location the standard I/O

memory, then 160 locations of Extended I/O memory, and the next

512/1024/1024/2048 locations address the internal data SRAM. The five different

addressing modes for the data memory cover: Direct, Indirect with Displacement,

Indirect, Indirect with Pre-decrement, and Indirect with Post-increment. In The Register

File, Registers R26 to R31 Feature the indirect addressing pointer registers. The direct

addressing reaches the entire data space. The Indirect with Displacement mode reaches

63 address locations from the base address given by the Y- or Z register.

When using register indirect addressing modes with automatic pre-decrement

and post-increment, the address registers X, Y, and Z are decremented or incremented.

The 32 general purpose working registers, 64 I/O Registers, 160 Extended I/O

Registers, and the 512/1024/1024/2048 bytes of internal data SRAM in the ATmega328

are all accessible through all these addressing modes.

DEPT of ECE, ATRI Page 22


WIFI CONTROLLED MOBILE ROBOT

Figure 4.8 Data Memory Map

4.2.8 Interrupts
This section describes the specifics of the interrupt handling as performed in the

Atmega328. In Atmega328Each Interrupt Vector occupies two instruction words and

the Reset Vector is affected by the BOOTRST fuse, and the Interrupt Vector start

address is affected by the IVSEL bit in MCUCR.

Table 4.2 Reset and Interrupt Vectors in ATMEGA 328 and ATMEGA 328P
Vector Program Source Interrupt Definition
No. Address
1 0x0000 RESET External Pin, Power-on Reset,
Brown-out Reset and Watchdog
System Reset
2 0x0002 INT0 External Interrupt Request 0
3 0x0004 INT1 External Interrupt Request 0
4 0x0006 PCINTO Pin Change Interrupt Request 0
5 0x0008 PCINT1 Pin Change Interrupt Request 1
6 0x000A PCINT2 Pin Change Interrupt Request 2
7 0x000C WDT Watchdog Time-out Interrupt
8 0x000E TIMER2 COMPA Timer/Counter2 Compare Match A
9 0x0010 TIMER2 COMPB Timer/Counter2 Compare Match B
10 0x0012 TIMER2 OVF Timer/Counter 2 Overflow
11 0x0014 TIMER1 CAPT Timer/Counter 2 Capture Event
12 0x0016 TIMER1 COMPA Timer/Counter1 Compare Match A
13 0x0018 TIMER1 COMPB Timer/Counter1 Compare Match B
14 0x001A TIMER 1 OVF Timer/Counter1 Overflow
15 0x001C TIMER0 COMPA Timer/Counter0 Compare Match A
16 0x001E TIMER0 COMPB Timer/Counter0 Compare Match B
17 0x0020 TIME0 OVF Timer/Counter0 Overflow
18 0x0022 SPI, STC SPI Serial Transfer Complete
19 0x0024 USART, RX USART RX Complete

DEPT of ECE, ATRI Page 23


WIFI CONTROLLED MOBILE ROBOT

20 0x0026 USART, UDRE USART, Data Register Empty


21 0x0028 USART, TX USART, TX Complete
22 0x002A ADC ADC Conversion Complete
23 0x002C EE READY EEPROM Ready
24 0x002E ANALOG COMP Analog Comparator
25 0x0030 TWI 2-wire Serial Interface
26 0x0032 SPM READY Store Program Memory Ready

4.3Arduino with ATmega328


The Arduino Uno is a microcontroller board based on the ATmega328

(datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs),

6 analog inputs, a 16 MHz ceramic resonator, 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 a AC-to-DC adapter

or battery to get started.

The Uno differs from all preceding boards in that it does not use the FTDI USB-

to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to versionR2)

programmed as a USB-to-serial converter.

➢ Pin out: Added SDA and SCL pins that are near to the AREF pin and two other

new pins placed near to the RESET pin, the IOREF that allow the shields to

adapt to the voltage provided from the board. In future, shields will be

compatible with both the board that uses the AVR, which operates with 5V and

with the Arduino. Due that operates with 3.3V. The second one is a not

connected pin that is reserved for future purposes.

➢ Stronger RESET circuit.

➢ Atmega 16U2 replace the 8U2.

"Uno" means one in Italian and is named to mark the upcoming release of

Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino,

moving forward. The Uno is the latest in a series of USB Arduino boards, and the

DEPT of ECE, ATRI Page 24


WIFI CONTROLLED MOBILE ROBOT

reference model for the Arduino platform; for a comparison with previous versions, see

the index of Arduino boards.

4.3.1 Arduino Characteristics Power


The Arduino Uno can be powered via the USB connection or with an external

power supply. The power source is selected automatically. External (non-USB) power

can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be

connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads

from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.

The board can operate on an external supply of 6 to 20 volts. If supplied with less than

7V, however, the 5V pin may supply less than five volts and the board may be unstable.

If using more than 12V, the voltage regulator may overheat and damage the board.

The recommended range is 7 to 12 volts.

The power pins are as follows:

➢ VIN: The input voltage to the Arduino board when it's using an external power

source (as opposed to 5 volts from the USB connection or other regulated power

source). You can supply voltage through this pin, or, if supplying voltage via

the power jack, access it through this pin.

➢ 5V: This pin outputs a regulated 5V from the regulator on the board. The board

can be supplied with power either from the DC power jack (7 - 12V), the USB

connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the

5V or 3.3V pins bypasses the regulator, and can damage your board. We don't

advise it.

➢ 3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current

draw is 50 mA.

➢ GND. Ground pins.

DEPT of ECE, ATRI Page 25


WIFI CONTROLLED MOBILE ROBOT

➢ IOREF. This pin on the Arduino board provides the voltage reference with

which the microcontroller operates. A properly configured shield can read the

IOREF pin voltage and select the appropriate power source or enable voltage

translators on the outputs for working with the 5V or 3.3V.

Memory:
The ATmega328 has 32 KB (with 0.5 KB used for the boot loader). It also has 2 KB of

SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM

library).

Serial Communication:
The Arduino Uno has a number of facilities for communicating with a

computer, another Arduino, or other microcontrollers. The ATmega328 provides

UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and

1 (TX). An ATmega16U2 on the board channels this serial communication over USB

and appears as a virtual com port to software on the computer.

The '16U2 firmware uses the standard USB COM drivers, and no external driver

is needed. However, on Windows, a .inf file is required. The Arduino software includes

a serial monitor which allows simple textual data to be sent to and from the Arduino

board. The RX and TX LEDs on the board will flash when data is being transmitted via

the USB-to-serial chip and USB connection to the computer (but not for serial

communication on pins 0 and 1).

A Software Serial library allows for serial communication on any of the Uno's

digital pins. The ATmega328 also supports I2C (TWI) and SPI communication. The

Arduino software includes a Wire library to simplify use of the I2C bus. For SPI

communication, use the SPI library.

DEPT of ECE, ATRI Page 26


WIFI CONTROLLED MOBILE ROBOT

4.3.2 Conclusion
In this chapter Arduino, ATmega328, and also about the Embedded system and

its application was dicussed.

4.4 L293D Motor Driver IC:

Figure 4.9block diagram of l293d

4.4.1 Description
L293D is a typical Motor driver or Motor Driver IC which allows DC motor to

drive on either direction. L293D is a 16-pin IC which can control a set of two DC motors

simultaneously in any direction. It means that you can control two DC motorwith a

single L293D IC. Dual H-bridge Motor Driver integrated circuit(IC).The l293d can

drive small and quiet big motors as well, check the Voltage Specification at the end of

this page for more info.

DEPT of ECE, ATRI Page 27


WIFI CONTROLLED MOBILE ROBOT

4.4.2Concept:

It works on the concept of H-bridge. H-bridge is a circuit which allows the

voltage to be flown in either direction. As you know voltage need to change its direction

for being able to rotate the motor in clockwise or anticlockwise direction, Hence H-

bridge IC are ideal for driving a DC motor.In a single l293d chip there two h-Bridge

circuit inside the IC which can rotate two dc motor independently. Due its size it is very

much used in robotic application for controlling DC motors. Given below is the pin

diagram of a L293D motor controller.

There are two Enable pins on l293d. Pin 1 and pin 9, for being able to drive the

motor, the pin 1 and 9 need to be high. For driving the motor with left H-bridge you

need to enable pin 1 to high. And for right H-Bridge you need to make the pin 9 to high.

If anyone of the either pin1 or pin9 goes low then the motor in the corresponding section

will suspend working. It’s like a switch

Figure 4.10 pin diagram of L293D

DEPT of ECE, ATRI Page 28


WIFI CONTROLLED MOBILE ROBOT

4.4.3 Working:
There are 4 input pins for l293d, pin 2,7 on the left and pin 15 ,10 on the right as shown

on the pin diagram. Left input pins will regulate the rotation of motor connected across

left side and right input for motor on the right hand side. The motors are rotated on the

basis of the inputs provided across the input pins as LOGIC 0 or LOGIC 1.

In simple you need to provide Logic 0 or 1 across the input pins for rotating the
motor.

4.4.4Voltage Specification:

VCC is the voltage that it needs for its own internal operation 5v; L293D will

not use this voltage for driving the motor. For driving the motors it has a separate

provision to provide motor supply VSS (V supply). L293d will use this to drive the

motor. It means if you want to operate a motor at 9V then you need to provide a Supply

of 9V across VSS Motor supply.

The maximum voltage for VSS motor supply is 36V. It can supply a max current

of 600mA per channel.Since it can drive motors Up to 36v hence you can drive pretty

big motors with this l293d.

VCC pin 16 is the voltage for its own internal Operation. The maximum voltage

ranges from 5v and upto

4.4.5 H-Bridge:
An H-bridge is an electronic circuit which enables DC electric motors to be run

forwards or backwards. These circuits are often used in robotics. H-bridges are

available as integrated circuits, or can be built from discrete components 36v.

DEPT of ECE, ATRI Page 29


WIFI CONTROLLED MOBILE ROBOT

The term "H-bridge" is derived from the typical graphical representation of such

a circuit. An H-bridge is built with four switches (solid-state or mechanical).

When the switches S1 and S4 (according to the first figure) are closed (and S2 and S3

are open) a positive voltage will be applied across the motor. By opening S1 and

S4 switches and closing S2 and S3 switches, this voltage is reversed, allowing

reverse operation of the motor. Using the nomenclature above, the switches S1 and S2

should never be closed at the same time, as this would cause a short circuit on the input

voltage source. The same applies to the switches S3 and S4. This condition is known

as shoot-through

4.4.6 Operation
The H-Bridge arrangement is generally used to reverse the polarity of the motor,

but can also be used to 'brake' the motor, where the motor comes to a sudden stop, as

the motors terminals are shorted, or to let the motor 'free run' to a stop, as the motor is

effectively disconnected from the circuit. The following table summarizes operation.

Table 4.3 H-Bridge operation

S1 S2 S3 S4 Result

1 0 0 1 Motor moves right

0 1 1 0 Motor moves left

0 0 0 0 Motor free runs

0 1 0 1 Motor brakes

DEPT of ECE, ATRI Page 30


WIFI CONTROLLED MOBILE ROBOT

4.4.7 H-Bridge Driver


The switching property of this H-Bridge can be replaced by a Transistor or a

Relay or a MOSFET or even by an IC. Here we are replacing this with an IC named

L293D as the driver whose description is as given below.

Features:

➢ 600mA output current capability

➢ Per channel

➢ 1.2a peak output current (non repetitive)

➢ Per channel

➢ Enable facility

➢ Over temperature protection

➢ Logical "0" input voltage up to 1.5 v

➢ (high noise immunity)

➢ Internal clamp diodes

4.4.8 Description

The Device is a monolithic integrated high voltage, high current four channel

driver designed to accept standard DTL or TTL logic levels and drive inductive loads

(such as relays solenoids, DC and stepping motors) and switching power transistors. To

simplify use as two bridges each pair of channels is equipped with an enable input. A

separate supply input is provided for the logic, allowing operation at a lower voltage

and internal clamp diodes are included.

DEPT of ECE, ATRI Page 31


WIFI CONTROLLED MOBILE ROBOT

Figure 4.10 Block Diagram of H bridge

This device is suitable for use in switching applications at frequencies up to 5

kHz. The L293D is assembled in a 16 lead plastic package which has 4 center pins

connected together and used for heat sinking The L293DD is assembled in a 20 lead

surface mount which has 8 center pins connected together and used for heat sinking.

4.5 DC Motors:

Here DC Motor is used to rotate the panel in the required direction. Let us study

in detail about the DC Motor.

4.5.1 Principles of Operation


In any electric motor, operation is based on simple electromagnetism. A current-

carrying conductor generates a magnetic field; when this is then placed in an external

magnetic field, it will experience a force proportional to the current in the conductor,

and to the strength of the external magnetic field. As you are well aware of from playing

with magnets as a kid, opposite (North and South) polarities attract, while like polarities

(North and North, South and South) repel. The internal configuration of a DC motor is

DEPT of ECE, ATRI Page 32


WIFI CONTROLLED MOBILE ROBOT

designed to harness the magnetic interaction between a current-carrying conductor and

an external magnetic field to generate rotational motion. Let's start by looking at a

simple 2-pole DC electric motor (here red represents a magnet or winding with a

"North" polarization, while green represents a magnet or winding with a "South"

polarization).

Figure 4.11 Internal structure DC motor


Every DC motor has six basic parts. They are axle, rotor (a.k.a., armature),

stator, commutator, field magnet(s), and brushes. In most common DC motors (and all

that BEAMERS will see), the external magnetic field is produced by high-strength

permanent magnets1. The stator is the stationary part of the motor -- this includes the

motor casing, as well as two or more

permanent magnet pole pieces. The rotor (together with the axle and attached

commutator) rotates with respect to the stator.

The rotor consists of windings (generally on a core), the windings being

electrically connected to the commutator. The above diagram shows a common motor

layout with the rotor inside the stator (field) magnets.

The geometry of the brushes, commutator contacts, and rotor windings are such

that when power is applied, the polarities of the energized winding and the stator

magnet(s) are misaligned, and the rotor will rotate until it is almost aligned with the

DEPT of ECE, ATRI Page 33


WIFI CONTROLLED MOBILE ROBOT

stator's field magnets. As the rotor reaches alignment, the brushes move to the next

commutator contacts, and energize the next winding. Given our example two-pole

motor, the rotation reverses the direction of current through the rotor winding, leading

to a "flip" of the rotor's magnetic field, driving it to continue rotating. In real life,

though, DC motors will always have more than two poles (three is a very common

number). In particular, this avoids "dead spots" in the commutator. You can imagine

how with our example two-pole motor, if the rotor is exactly at the middle of its rotation

(perfectly aligned with the field magnets), it will get "stuck" there. Meanwhile, with a

two-pole motor, there is a moment where the commutator shorts out the power supply

(i.e., both brushes touch both commutator contacts simultaneously). This would be bad

for the power supply, waste energy, and damage motor components as well. Yet another

disadvantage of such a simple motor is that it would exhibit a high amount of torque

"ripple" (the amount of torque it could produce is cyclic with the position of the rotor).

You'll notice a few things from this -- namely, one pole is fully energized at a time (but

two others are "partially" energized). As each brush transitions from one commutator

contact to the next, one coil's field will rapidly collapse, as the next coil's field will

rapidly charge up (this occurs within a few microsecond). We'll see more about the

effects of this later, but in the meantime you can see that this is a direct result of the coil

windings' series wiring:

The use of an iron core armature (as in the Mabuchi, above) is quite common,

and has a number of advantages2. First off, the iron core provides a strong, rigid support

for the windings -- a particularly important consideration for high-torque motors. The

core also conducts heat away from the rotor windings, allowing the motor to be driven

harder than might otherwise be the case. Iron core construction is also relatively

inexpensive compared with other construction types. But iron core construction also

DEPT of ECE, ATRI Page 34


WIFI CONTROLLED MOBILE ROBOT

has several disadvantages. The iron armature has a relatively high inertia which limits

motor acceleration. This construction also results in high winding inductances which

limits brush and commutates life. In small motors, an alternative design is often used

which features a 'coreless' armature winding. This design depends upon the coil wire

itself for structural integrity. As a result, the armature is hollow, and the permanent

magnet can be mounted inside the rotor coil. Coreless DC motors have much lower

armature inductance than iron-core motors of comparable size, extending brush and

commutator life. The coreless design also allows manufacturers to build smaller

motors; meanwhile, due to the lack of iron in their rotors, coreless motors are somewhat

prone to overheating. As a result, this design is generally used just in small, low-power

motors. BEAMers will most often see coreless DC motors in the form of pager motors.

Consider the g a DC motor. A DC motor will have two terminals. Let the terminals are

D1 and D2. If we give positive voltage to D1 and negative voltage to D2 (simply voltage

at D1 should be more positive than the voltage at D2) the rotor will rotate in forward

direction. Alternatively if the voltage at D1 is negative and D2 is positive (or in other

words voltage at D1 is more negative than D2) then the motor will rotate in reverse

direction.

4.5.2 Basics of Dc Motor


The speed of a DC motor is directly proportional to the supply voltage, so if we reduce

the supply voltage from 12 Volts to 6 Volts, the motor will run at half the speed. The

speed controller works by varying the average voltage sent to the motor. It could do

this by simply adjusting the voltage sent to the motor, but this is quite inefficient to do.

A better way is to switch the motor's supply on and off very quickly. If the switching is

fast enough, the motor doesn't notice it, it only notices the average effect. Now imagine

a light bulb with a switch. When we close the switch, the bulb goes on and is at full

DEPT of ECE, ATRI Page 35


WIFI CONTROLLED MOBILE ROBOT

brightness, say 100 Watts. When we open the switch it goes off (0 Watts). Now if you

close the switch for a fraction of a second, then open it for the same amount of time,

the filament won't have time to cool down and heat up, and you will just get an average

glow of 50 Watts. This is how lamp dimmers work, and the same principle is used by

speed controllers to drive a motor. When the switch is closed, the motor sees 12 Volts,

and when it is open it sees 0 Volts. If the switch is open for the same amount of time as

it is closed, the motor will see an average of 6 Volts, and will run more slowly

accordingly.

4.6 Wi-Fi Module (ESP8266):

4.6.1 Introduction

ESP8266 is Wi-Fi enabled system on chip (SoC) module developed by Espressif

system. It is mostly used for development of IoT (Internet of Things) embedded

applications.

Figure 4.12 Wi-Fi module

ESP8266 comes with capabilities of

• 2.4 GHz Wi-Fi (802.11 b/g/n, supporting WPA/WPA2),

• general-purpose input/output (16 GPIO),

• Inter-Integrated Circuit (I²C) serial communication protocol,

DEPT of ECE, ATRI Page 36


WIFI CONTROLLED MOBILE ROBOT

• analog-to-digital conversion (10-bit ADC)

• Serial Peripheral Interface (SPI) serial communication protocol,

• I²S (Inter-IC Sound) interfaces with DMA(Direct Memory Access) (sharing

pins with GPIO),

• UART (on dedicated pins, plus a transmit-only UART can be enabled on

GPIO2), and

• pulse-width modulation (PWM).

It employs a 32-bit RISC CPU based on the Tensilica Xtensa L106 running at 80 MHz

(or overclocked to 160 MHz). It has a 64 KB boot ROM, 64 KB instruction RAM and

96 KB data RAM. External flash memory can be accessed through SPI.

ESP8266 module is low cost standalone wireless transceiver that can be used for end-

point IoT developments.

To communicate with the ESP8266 module, microcontroller needs to use set of AT

commands. Microcontroller communicates with ESP8266-01 module using UART

having specified Baud rate.

There are many third-party manufacturers that produce different modules based on this

chip. So, the module comes with different pin availability options like,

• ESP-01 comes with 8 pins (2 GPIO pins) – PCB trace antenna. (shown in above

figure)

• ESP-02 comes with 8 pins, (3 GPIO pins) – U-FL antenna connector.

• ESP-03 comes with 14 pins, (7 GPIO pins) – Ceramic antenna.

• ESP-04 comes with 14 pins, (7 GPIO pins) – No ant. etc.

For example, below figure shows ESP-01 module pins

DEPT of ECE, ATRI Page 37


WIFI CONTROLLED MOBILE ROBOT

ESP8266-01 Module Pin Description

Figure 4.13 ESP8266-01 Module Pins


3V3: - 3.3 V Power Pin.

GND: - Ground Pin.

RST: - Active Low Reset Pin.

EN: - Active High Enable Pin.

TX: - Serial Transmit Pin of UART.

RX: - Serial Receive Pin of UART.

GPIO0 & GPIO2: - General Purpose I/O Pins. These pins decide what mode (boot or

normal) the module starts up in. It also decides whether the TX/RX pins are used for

Programming the module or for serial I/O purpose.

To program the module using UART, Connect GPIO0 to ground and GPIO2 to VCC

or leave it open. To use UART for normal Serial I/O leave both the pins open (neither

VCC nor Ground).

For more information refer http://esp8266.net/

Now, before we start with ESP8266 interfacing, we need to update its firmware.

DEPT of ECE, ATRI Page 38


WIFI CONTROLLED MOBILE ROBOT

Downloading Firmware’s

There are many software & hardware platforms, firmware’s and frameworks available,

that are specific to their applications such as,

Espressif AT Firmware

EspressifFreeRTOS Firmware

Espressif NON-OS SDK Firmware

NodeMCU (Lua Firmware)

etc.

ESP8266 Firmware has been provided in binary format files (.BIN) that can be

downloaded directly on the ESP8266 chip.

These binaries are generated using ESP8266 SDK (Software Development Kit), which

is an application development platform produced by Espressif. Linux OS is required to

compile the ESP8266 SDK. Windows user can use virtual machine.

For more information about ESP8266 SDK compilation refer -

ESP8266_Getting_Started_Guide or download below attached ESP8266 Getting

Started Guide

After compilation, download firmware directly on ESP8266 chip over serial port.

Let’s download Espressif NON-OS SDK Firmware in to the ESP8266 module.

First download ESP8266 FLASH DOWNLOAD TOOL which is the official firmware

download tool developed by Espressif.

Second download Espressif NON-OS SDK Firmware

DEPT of ECE, ATRI Page 39


WIFI CONTROLLED MOBILE ROBOT

Now select .bin files with their respective address as shown in below figure.

boot_v1.2.bin ------------------------------------------------> 0x00000

user1.1024.new.2.bin ------------------------------------------------> 0x01000

esp_init_data_default.bin ------------------------------------------------> 0xfc000

blank.bin ------------------------------------------------> 0x7e000

blank.bin ------------------------------------------------> 0xfe000

Note that, all binary (.BIN) files are available at ESP8266_NONOS_SDK-

master\bin directory except user1.1024.new.2.bin which we can generate from SDK

compilation and can be found in subfolder of ESP8266_NONOS_SDK-

master\bin directory.

DEPT of ECE, ATRI Page 40


WIFI CONTROLLED MOBILE ROBOT

Ensure that you have selected the correct COM port and BAUD rate (115200 default).

Note that, to put ESP8266 in flash mode, make connections as per above figure (in

between ESP8266 and USB to Serial converter) and then only connect it to PC/laptop.

Do not forget to connect GPIO0 pin to ground.

Then click on START tab in ESP8266 DOWNLOAD TOOL, and wait till it finishes.

After finishing flash process, disconnect ESP8266 module from PC/laptop and remove

ground connection at GPIO0 pin.

After successful downloading of firmware, we can use below AT commands for server

and client communication using ESP8266.

Note: This time do not connect GPIO0 and GPIO2 pins (leave the open/unconnected).

4.4ESP8266 AT Command Set

Function AT Commands Response


Working AT OK
OK

Restart AT+RST .......


Ready

<AT version info> information about


AT version
<SDK version info> information about
Firmware SDK version
AT+GMR
Version
<compile time> time of the bin was
compiled
OK

+CWLAP:<ecn>,<ssid>,<rssi>,<mac>
List
,<ch>,<freq offset>
Access AT+CWLAP
Point OK

DEPT of ECE, ATRI Page 41


WIFI CONTROLLED MOBILE ROBOT

Function AT Commands Response


Query +CWJAP:<ssid>,<bssid>,<channel>,<
Joined rssi>
AT+CWJAP?
Access
OK
Point
WIFI CONNECTED
Join
Access AT+CWJAP=”SSID”,”Password” WIFI GOT IP
Point OK

Quit OK
Access AT+CWQAP
WIFI DISCONNECTED
Point
+CIFSR:APIP,<IP address>
+CIFSR:APMAC,<mac address>
AT+CIFSR
Get IP +CIFSR:STAIP,<IP address>
Address (Assuming AT+CWMODE=3)
+CIFSR:STAMAC,<mac address>
OK

Query
WiFi AT+CWMODE? +CWMODE:<mode>
Mode
AT+CWMODE=<mode>
Mode: -
Set WiFi 1 = STA (station)
OK
Mode
2 = AP (Access Point)
3 = BOTH i.e. STA & AP

Query
TCP/UD
P AT+CIPMUX? +CIPMUX:<mode>
Connecti
on
AT+CIPMUX=<mode>
Set
TCP/UD Mode: -
P OK
0 = Single Connection
Connecti
on 1 = Multiple Connection

DEPT of ECE, ATRI Page 42


WIFI CONTROLLED MOBILE ROBOT

Function AT Commands Response


STATUS:<status>
Possible statuses are
TCP/IP
Connecti AT+CIPSTATUS 2: Got IP
on status 3: Connected
4: Disconnected

Query
TCP
AT+CIPMODE? +CIPMODE:<mode>
transmiss
ion mode
AT+CIPMODE=<mode>
Set TCP Mode: -
transmiss OK
0 = Normal mode
ion mode
1 = Transparent mode

(CIPMUX=0) AT+CIPSTART =
<type>,<addr>,<port>
Set up
(CIPMUX=1) AT+CIPSTART=
TCP/UD CONNECT
<id>,<type>,<addr>, <port>
P
OK
connectio Example (CIPMUX=0):
n
AT+CIPSTART="TCP","192.168.1
01.110",80

OK
>
(Note: write your data after > and enter
it to send it will return status like.)
(CIPMUX=0)
Recv<data length> bytes
AT+CIPSEND=<data length>
Send
SEND OK
Data (CIPMUX=1)
AT+CIPSEND=<id>,<data length> (after we receive response from server
if any for default auto receive mode)
(CIPMUX=0): + IPD, <length>: <data>
(CIPMUX=1): + IPD, <id>, <length>:
<data>

DEPT of ECE, ATRI Page 43


WIFI CONTROLLED MOBILE ROBOT

Function AT Commands Response


Close
TCP/UD CLOSED
P AT+CIPCLOSE
OK
Connecti
on

4.9 Power Supply:


Arduino board can be connected through an USB cable or we can use 12Vpower

supply battery

DEPT of ECE, ATRI Page 44


WIFI CONTROLLED MOBILE ROBOT

CHAPTER 5

SOFTWARE DESCRIPTION
4.1 Arduino IDE
The Arduino Integrated Development Environment - or Arduino Software (IDE) -

contains a text editor for writing code, a message area, a text console, a toolbar with

buttons for common functions and a series of menus. It connects to the Arduino and

Genuino hardware to upload programs and communicate with them.

4.2 programming in arduino:

STEP 1

Arduino microcontrollers come in a variety of types. The most common is the Arduino

UNO, but there are specialized variations. Before you begin building, do a little

research to figure out which version will be the most appropriate for your project.

DEPT of ECE, ATRI Page 45


WIFI CONTROLLED MOBILE ROBOT

STEP 2

Connect your Arduino to the USB port of your computer. This may require a specific

USB cable. Every Arduino has a different virtual serial-port address, so you 'll need to

reconfigure the port if you're using different Arduinos.

DEPT of ECE, ATRI Page 46


WIFI CONTROLLED MOBILE ROBOT

CHAPTER 6

EXPERIMENTAL RESULTS

DEPT of ECE, ATRI Page 47


WIFI CONTROLLED MOBILE ROBOT

CHAPTER 7

ADVANTAGES AND DISADVANTAGES

Advantages:
1. Consistency of performance.

2. 24/7 continuous working.

3. Reduced amount of operators.

4. Improved quality of product.

5. It can move from one location to another location.

6. Robotic workers never gets tired.

7. Do not need to be paid.

Disadvantages:
1. High standard of maintenance required.

2. Precise programming needed.

3. Complex and expensive.

DEPT of ECE, ATRI Page 48


WIFI CONTROLLED MOBILE ROBOT

CHAPTER 8

CONCLUSION AND FUTURESCOPE

Conclusion:
The project carried out by using the node mc and motor drive in the field of

mechatronics department. New things and new technology are being invented. As the

technology grows day by day, it can imagine about the future in which thing may

occupy every place. User friendly and less complex, which can readily be used in order

to perform. Several tedious and repetitive tasks. Though it is designed keeping in mind

about the need for industry, it can extended for other purposes such as commercial and

research application. The chassis of robot made by aluminium it give the efficiency and

more speed to robot. The command coding are entered in robot it is very easy to

understand. Though it is designed keeping in mind about the need for industry, it can

extended for other purposes such as commercial and research application.

Future scope:
Wi-Fi will be a key access technology for Internet of Things enablement due to

cost coverage and bandwidth, challenges with mobile cellular which can be

compromised through wifi. We can introduce a spy camera in this project and we can

use it in military purposes. Even we can develop it as a drone

DEPT of ECE, ATRI Page 49


WIFI CONTROLLED MOBILE ROBOT

REFERENCES

[1] Al- Sahib Nabeel.K& Azeez.Z Mohammed created “Internet Remote


Control Interface for a Multi-Purpose Mobile Robot”

[2] Andreasson.J, Gavert.M created “The Vehicle Dynamics Library


Overview and Applications Modelon”.

[3] Cuno Pfister created “Getting started with Internet of Things”.

[4]Joy deep Biswas created “Wifi Localization and Navigation for


Autonomous Indoor Mobile Robots”.

[5] Sudha Jamthe created”IoT Disruptions: The Internet of Things -


Innovations & Jobs “

[6] Tom nguyen ,josh slonaker created “Semi Autonomous wireless


control robot”.

[7] M.S.Sreejith, Steffy Joy created “Conceptual design of a wifi and gps
based robotic library using an intelligent system.

[8] C.W.Warren , S.G.Buckley created “Mobile robotic over wifi


network using arduino technology”.

[9] Harshit Gulati, Shriyannsh Vaishya created “Bluetooth and wifi


control rescue robot.

DEPT of ECE, ATRI Page 50


WIFI CONTROLLED MOBILE ROBOT

APPENDIX
SOURCE CODE
/*-----( Calling of Header File)-----*/

#include<SoftwareSerial.h>

#include <EEPROM.h>

#define IP "13.232.24.83" //Server IP that one may pi or Amazone, Here it


is Amazone IP

#define MotorL1 4

#define MotorL2 5

#define MotorR1 6

#define MotorR2 7

String URL_Link = "/2019_projects/college/ATRI_2019/Robot/Status.txt"; //


WEB page Link to send Data and control Device

String SSID_Name = "belkin.18f" ;

String SSID_PSWD = "ERF1234_0001";

String DATA="", MyIP;

String CMD, Response;

unsigned long Ptime_get = 0;

char Receive_Channel;

bool Left_Change = true, Right_Change = true;

SoftwareSerial ESP_Serial(8, 9);

void setup()

Serial.begin(9600);

DEPT of ECE, ATRI Page 51


WIFI CONTROLLED MOBILE ROBOT

ESP_Serial.begin(9600);

Robot_Int();

Serial.println(F("If u want to set ur SSID & PSWD"));

Serial.println(F("Then send ur SSID followed by ',' and ur Password"));

Ptime_get = millis();

ESP_Serial.listen();

while (millis() - Ptime_get < 10000)

if (Serial.available())

delay(1000);

while (Serial.available())

CMD += (char)Serial.read();

SSID_Collect();

break;

ESP_Setup();

Ptime_get = millis();

void loop()

if (millis() - Ptime_get >= 3000)

DEPT of ECE, ATRI Page 52


WIFI CONTROLLED MOBILE ROBOT

ESP_Serial.listen();

get_server();

if (CMD.length() > 1)

if (CMD.startsWith("Forward"))

Forward();

Right_Change = 1;

Left_Change = 1;

else if (CMD.startsWith("Back"))

Back();

Right_Change = 1;

Left_Change = 1;

else if (CMD.startsWith("Right"))

if(Right_Change){

Right_Change = false;

Right();

else if (CMD.startsWith("Left"))

if(Left_Change){

DEPT of ECE, ATRI Page 53


WIFI CONTROLLED MOBILE ROBOT

Left_Change = false;

Left();

else if (CMD.startsWith("Stop"))

Stop();

Right_Change = 1;

Left_Change = 1;

CMD = "";

Ptime_get = millis();

/*

This function set the ESP8266 Mode 3 And on Server

*/

void ESP_Setup()

ESP_Serial.println(F("AT+CWMODE=3"));

if (ESP_Receive("OK", 100))

Serial.println(F("Mode Set"));

ESP_Serial.println(F("ATE0"));

if (ESP_Receive("OK", 100))

Serial.println(F("Echo Stop"));

DEPT of ECE, ATRI Page 54


WIFI CONTROLLED MOBILE ROBOT

if (EEPROM.read(1023) == 255)

EEPROM.write(1023, 0);

ESP_Serial.println(F("AT+CWSAP=\"Pump1\",\"\",10,0"));

if (ESP_Receive("OK", 100))

ESP_Serial.println(F("AT+RST"));

delay(4000);

ESP_Serial.println(F("AT+CIPMUX=1"));

if (ESP_Receive("OK", 200))

Serial.println(F("CIP MUX SET"));

ESP_Serial.println(F("AT+CWJAP?"));

if (ESP_Receive(F("+CWJAP:"), 2000))

Serial.println(F("Connected to Wifi"));

ESP_Serial.println(F("AT+CIFSR"));

if (ESP_Receive("+CIFSR:STAIP", 200))

MyIP = Response.substring(14, 26);

Serial.print(F("My IP Is")); Serial.println( MyIP);

else

Serial.println(F("Wifi not Connect"));

DEPT of ECE, ATRI Page 55


WIFI CONTROLLED MOBILE ROBOT

Serial.println(F("Enter ur SSID and PSWD"));

ESP_Serial.println(F("AT+CIPSERVER=1,80"));

if (ESP_Receive(F("OK"), 100))

Serial.println(F("Server Started"));

ESP_Serial.println(F("AT+CIPMUX=1"));

if (ESP_Receive(F("OK"), 200))

Serial.println(F("CIP MUX SET"));

/*

This function Received the data from ESP_Module

In this Function we can pass the Argument to cross check starswith

If argument satisfied with startwith then it return 1 and store the string in "MSG"

*/

bool ESP_Receive(String Argument, int time_delay)

unsigned long Rx_Time = millis();

String Rx_MSG;

while (millis() - Rx_Time < time_delay) // it working fine with delay 520 milisec

if (ESP_Serial.available())

char Byte = ESP_Serial.read();

Rx_MSG += Byte;

if (Byte == '\n')

DEPT of ECE, ATRI Page 56


WIFI CONTROLLED MOBILE ROBOT

if (Rx_MSG.startsWith(F("check")))

Response += Rx_MSG;

else if (Rx_MSG.startsWith(Argument))

Response = Rx_MSG;

if (Argument == "Content-Type")

Byte = '\0'; Rx_MSG = "";

Rx_Time = millis();

while (millis() - Rx_Time < 1000)

if (ESP_Serial.available())

Byte = ESP_Serial.read();

Rx_MSG += Byte;

Serial.println(Rx_MSG);

unsigned char Count = 0;

for (int i = 0; Rx_MSG[i] != '\0'; i++)

if (Rx_MSG[i] == '\n')

Count++;

// Serial.println(i);

DEPT of ECE, ATRI Page 57


WIFI CONTROLLED MOBILE ROBOT

CMD = Rx_MSG.substring(2, Rx_MSG.indexOf(","));

Serial.println(CMD);

// Serial.println(Count);

return 1;

if (Argument == "<html>")

Serial.println(Rx_MSG);

Get_Control_CMD(Rx_MSG);

else if (Argument == "+IPD")

get_data(Rx_MSG);

return 1;

else

Rx_MSG = "";

} Rx_Time = millis();

return 0;

/*

DEPT of ECE, ATRI Page 58


WIFI CONTROLLED MOBILE ROBOT

This Below function will get the Control Comand from the Received String

This function we will call once we get return 1 from ESP_Receive()

*/

bool Get_Control_CMD(String MSG)

// String CMD_Byte;

CMD = "";

CMD = MSG.substring((MSG.indexOf("<html>") + 6), MSG.indexOf("</html>"));

// Serial.println(MSG);

// Serial.print(F("Command is: ")); Serial.println(CMD);

// MSG = "";

boolean get_data(String MSG)

CMD = "";

Receive_Channel = MSG[5];

CMD = MSG.substring(9, MSG.indexOf("\r\n"));

// Serial.print(F("Command is: ")); Serial.println(CMD);

// MSG = "";

void get_server()

// String dat=DATA;

ESP_Serial.listen();

unsigned char Try = 0;

DEPT of ECE, ATRI Page 59


WIFI CONTROLLED MOBILE ROBOT

String POST = "GET " + URL_Link + DATA + " HTTP/1.0\r\n" + "Host: " + IP +
"\r\n" +

"Accept: *" + "/" + "*\r\n" + "Content-Length: " + DATA.length() + "\r\n"


+

"Content-Type: application/x-www-form-urlencoded\r\n" + "\r\n" + "\r\n";

ESP_Serial.println(F("AT+CIPMUX=1"));

if (ESP_Receive(F("OK"), 200))

Serial.println(F("OK"));

StartServer:

// ESP_Serial.println(F("AT+CIPCLOSE=2"));

// if(ESP_Receive("2,CLOSED", 200))

// Serial.println(F("Chanel Close"));

// ESP_Serial.println(F("AT+CIPSTART=2,\"TCP\",\"13.232.24.83\",80"));

ESP_Serial.print(F("AT+CIPSTART=2,\"TCP\",\""));

ESP_Serial.print(IP);

ESP_Serial.println(F("\",80"));

if (ESP_Receive(F("OK"), 200))

Serial.println(F("OK"));

ESP_Serial.print(F("AT+CIPSEND=2,"));

ESP_Serial.println(POST.length());

if (ESP_Serial.find('>'))

delay(200); //with 250 milisec delay its working fine

Serial.println(F("OK in send"));

Serial.print(POST);

DEPT of ECE, ATRI Page 60


WIFI CONTROLLED MOBILE ROBOT

ESP_Serial.print(POST);

if (ESP_Receive("Content-Type", 1000));

else

Try++;

if (Try < 3)

ESP_Serial.println(F("AT+CIPSTATUS"));

delay(100);

goto StartServer;

void SSID_Collect()

unsigned char i;

SSID_PSWD = ""; SSID_Name = "";

for (i = 0; CMD[i] != ','; i++)

SSID_Name += CMD[i];

SSID_PSWD = CMD.substring(i + 1);

Serial.println(SSID_Name + SSID_PSWD);

ESP_Serial.print(F("AT+CWJAP=\""));

DEPT of ECE, ATRI Page 61


WIFI CONTROLLED MOBILE ROBOT

ESP_Serial.print(SSID_Name);

ESP_Serial.print(F("\",\""));

ESP_Serial.print(SSID_PSWD);

ESP_Serial.println("\"");

if (ESP_Receive("OK", 8000))

Serial.println(F("Connected to Wifi"));

else

Serial.println(F("Wifi not Connect try Again"));

delay(3000);

void Robot_Int()

pinMode(MotorL1,OUTPUT);

pinMode(MotorL2,OUTPUT);

pinMode(MotorR1,OUTPUT);

pinMode(MotorR2,OUTPUT);

void Forward()

digitalWrite(MotorR1,HIGH);

digitalWrite(MotorL1,HIGH);

digitalWrite(MotorR2,LOW);

DEPT of ECE, ATRI Page 62


WIFI CONTROLLED MOBILE ROBOT

digitalWrite(MotorL2,LOW);

void Back()

digitalWrite(MotorR2,HIGH);

digitalWrite(MotorL2,HIGH);

digitalWrite(MotorR1,LOW);

digitalWrite(MotorL1,LOW);

void Left()

digitalWrite(MotorR1,HIGH);

digitalWrite(MotorL1,LOW);

digitalWrite(MotorR2,LOW);

digitalWrite(MotorL2,LOW);

delay(1000);

Stop();

void Right()

digitalWrite(MotorL1,HIGH);

digitalWrite(MotorR1,LOW);

digitalWrite(MotorR2,LOW);

digitalWrite(MotorL2,LOW);

delay(1000);

DEPT of ECE, ATRI Page 63


WIFI CONTROLLED MOBILE ROBOT

Stop();

void Stop()

digitalWrite(MotorR1,LOW);

digitalWrite(MotorL1,LOW);

digitalWrite(MotorR2,LOW);

digitalWrite(MotorL2,LOW);

DEPT of ECE, ATRI Page 64

Вам также может понравиться