Beruflich Dokumente
Kultur Dokumente
T.Jashua danie
A.Mahender yadav
B.Raghuvardhan Reddy
G.Ravikiran
Bachelor of Technology
in
Electronics and Communication Engineering
by
Certificate
This is to certify that this project report entitled Design and implementation of Robot
Vehicle control with Wireless Joystick by T.Jashua danie (Roll No. 09241A0476), A.Mahender
yadav (Roll No. 09241A0480) , B.Raghuvardhan Reddy(Roll No. 09241A0491)and G.Ravikiran
(Roll No.09241A0496), submitted in partial fulfillment of the requirements for the degree of
Bachelor of Technology in Electronics and Communication Engineering of the Jawaharlal Nehru
Technological University, Hyderabad, during the academic year 2012-2013, is a bonafide record
of work carried out under our guidance and supervision.
The results embodied in this report have not been submitted to any other University or
Institution for the award of any degree or diploma.
(Guide)
K. Jamal
Assistant Professor
(External Examiner)
(i)
(Head of Department)
Ravi Billa
ACKNOWLEDGMENT
[To Project Guides(s)] It is a pleasure to express thanks to Mr. K.Jamal for the
encouragement and guidance throughout the course of this project.
[To all others (if any), such as individuals and organizations who were instrumental in
the completion of our project]
T.Jashua danie
___________________________
A.Mahender yadav
___________________________
B.Raghuvardhan Reddy
____________________________
G.Ravikiran
_____________________________
(ii)
Abstract
This paper presents the design and implementation of Robot Vehicle Control
with Wireless Joystick . Wireless communications play an important role in
mobile robotics and are able to address real world applications. Radio signals
sent from distant computer or smartphone or joystick can be used to control the
movements of robot. The main idea of this project is to control the robot vehicle wirelessly with joystick .A microcontroller attached with the robot gets the
incoming message from the transmitter and controls the movement of the robot
accordingly.
The paper provides information on the two main components of the project
One component is a transmitter which sends signals from the joystick to the
receiver using zigbee interface. The second component is the receiver which
takes incoming messages from transmitter and sends to the microcontroller
using zigbee interface. Pieces of software had to be written for both receiver and
transmitter.
CONTENTS
Abstract
List of Figures
ii
List of Tables
iii
1 Introduction
1.1 Background
1.2 Aim of this Project
1.3 Methodology
1.4 Significance of this work
1.5 Outline
1
1
1
2
2
4
5
5
8
10
15
17
20
20
21
21
21
22
6 Flow Chart
6.1 Transmitter flowchart
6.2 Receiver flowchart
23
24
7. Tools
7.1 X-CTU (configuring the XBees)
7.2 Arduino IDE
25
32
8. Arduino code
8.1 Arduino code for transmitter
8.2 Arduino code for receiver
37
41
Chapter 1
INTRODUCTION
1.1 Background
Technological advancement in the field of science has paved the way to the invention
of sophisticated machines, which could assist us and simplify our work. One such valuable
invention of humankind is robots. By flipping through the pages of history, it is studied that
people in the ancient Greece and Egypt started using the raw form of robots, for
accomplishing various kinds of works. With the passing time, robotics saw further
developments. The design of robots became more and more sophisticated, with the increase
in the capacity of the machines to do work. In The present time, Robots emerged as machines
that could follow along with a human by holding hands. Today, with the advancement of
science and technology, the researchers are coming up with innovative ideas to create robots
that could simplify the sophisticated tasks, which are otherwise done with intense hard work,
with work force. Robotics is a developing science.
1.3 Methodology
There are two sections in this project 1.Transmitter 2.Receiver
1.TRANSMITTER
In this section ,the transmitter consists of joystick ,microcontroller and xbee
module .The data is taken from Joystick ,The joystick gives the analog data and this data is
given to microcontroller and microcontroller process the data according to the software
written in it and sends the commands to the xbee module .Where xbee module transmits the
commands to the receiver
2. RECEIVER
In this section ,the receiver consists of xbee module ,microcontroller, and motor
driver .The xbee module takes the commands from the transmitter and sends to
microcontroller and microcontroller will process the commands according to the software
written in it and gives the signals to motor driver to drive the motors.
Secure
1.6 Conclusion
The aim of the project and methodology used ,significance of the project ,Outline of the
Project can be known from this chapter
Chapter 2
BLOCK DIAGRAM AND HARDWARE
2.1 Block diagram
Transmitter
A(0)
JOYSTICK
A(1)
A
R
D
U
I
N
O
U
N
O
xbee
TX
Receiver
MOTOR
1
MOTOR
DRIVER
MOTOR
2
A
R
D
U
I
N
O
U
N
O
RX
xbee
2.2 Hardware
The main components used in this Project are
Joystick shield
Arduino uno
Motor Driver shield
Xbee module
Working of Joystick:
The basic idea of a joystick is to translate the movement of a plastic
stick into electronic information a computer can process. In order to communicate a full
range of motion to the computer, a joystick needs to measure the stick's position on two
axes -- the X-axis (left to right) and the Y-axis (up and down). Just as in basic geometry, the
X-Y coordinates pinpoint the stick's position exactly
In the standard joystick design, the handle moves a narrow rod that sits in two
rotatable, slotted shafts. Tilting the stick forward and backward pivots the Y-axis shaft
from side to side. Tilting it left to right pivots the X-axis shaft. When you move the
stick diagonally, it pivots both shafts. Several springs center the stick when you let go
of it
To determine the location of the stick, the joystick control system simply monitors the position of
each shaft. The conventional analog joystick design does this with two potentiometers, or variable
resistors. The diagram below shows a typical arrangement
.
Each potentiometer consists of a resistor, in the form of a curved track, and a movable contact arm.
The computer power supply conducts electricity to the input terminal, through the curved resistor,
through the contact arm and back to the joystick port on the computer.
By moving the contact arm along the track, you can increase or decrease the resistance acting on the
current flowing through this circuit. If the contact arm is on the opposite end of the path from the
input connection terminal, electricity will have to flow through a long length of resistor, so it will face
maximum resistance. If the contact arm is near the input terminal, the potentiometer will have
minimal resistance.
Each potentiometer is connected to one of the joystick shafts so that pivoting the shaft rotates the
contact arm. In other words, if you push the stick all the way forward, it will turn the potentiometer
contact arm to one end of the track, and if you pull it back toward you, it will turn the contact arm
the other way.
Varying the resistance of the potentiometer alters the electrical current in the connected circuit. In
this way, the potentiometer translates the stick's physical position into an electrical signal, which it
passes on to the joystick port on the computer.
This electrical signal is totally analog -- it's a varying wave of information, like a radio signal. In order
to make the information usable, the computer needs to translate it into a digital signal -- a strict
numerical value.
Features:
Specifications:
Power supply
Indicators
Communication Protocol
7-15v
PWR, Motor direction
Xbee,UART
EnA
0
In1
X
In2
X
1
1
1
1
0
0
1
In2
EnB
0
In3
X
In4
X
1
1
1
1
0
0
1
In2
In1
In1
Description
Free running motor
stop
Forward
Reverse
Fast Motor Stop
Description
Free running motor
stop
Forward
Reverse
Fast Motor Stop
Port A is used to control the motor that connect with OUT1 and OUT2, Port B is used to
control the motor that connect with OUT3 and OUT4.
The EnA, EnB, ln1, ln2, ln3, ln4 can be used to drive the 4-wire stepping motor which
connects with OUT1, OUT2, OUT3 and OUT4.
Chapter 3
ARDUINO UNO AND ITS PROGRAMMING
Arduino is a tool for making computers that can sense and control more of the physical world
than your desktop computer. It's an open-source physical computing platform based on a
simple microcontroller board, and a development environment for writing software for the
board.
Arduino can be used to develop interactive objects, taking inputs from a variety of switches
or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino
projects can be stand-alone, or they can be communicate with software running on your
computer (e.g. Flash, Processing, MaxMSP.) The boards can be assembled by hand or
purchased preassembled; the open-source IDE can be downloaded for free.
The Arduino programming language is an implementation of Wiring, a similar physical
computing platform, which is based on the Processing multimedia programming environment
10
Overview
The Arduino Uno is a microcontroller board based on the ATmega328 . 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 version R2) programmed
as a USB-to-serial converter.
Summary
Microcontroller
ATmega328
Operating Voltage
5V
6-20V
40 mA
50 mA
Flash Memory
SRAM
2 KB (ATmega328)
EEPROM
1 KB (ATmega328)
Clock Speed
16 MHz
11
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.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw
is 50 mA.
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 bootloader). It also has 2 KB of
SRAM and 1 KB of EEPROM .
12
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial
data. These pins are connected to the corresponding pins of the ATmega8U2 USB-toTTL Serial chip .
LED: 13. 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.
The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground to 5 volts,
though is it possible to change the upper end of their range using the AREF pin and
the analog Reference() function. Additionally, some pins have specialized functionality:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a
reset button to shields which block the one on the board.
13
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 SoftwareSerial 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; see the documentation for details. For
SPI communication, use the SPI library.
Programming
The Arduino Uno can be programmed with the Arduino software . Select
"Arduino Uno from the Tools > Board menu (according to the microcontroller
on your board)..
The ATmega328 on the Arduino Uno comes preburned with a bootloader that
allows you to upload new code to it without the use of an external hardware
programmer. It communicates using the original STK500 protocol ( C header
files)
14
Chapter 4
AT MEGA 328
4.1
Features
15
CaptureMode
16
4.2
Pin diagram:
4.3
Pin Descriptions
VCC
Digital supply voltage.
GND
Ground.
Port B (PB7:0) XTAL1/XTAL2/TOSC1/TOSC2
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.Depending on the clock selection
17
fuse settings, PB6 can be used as input to the inverting Oscillator amplifier and input
to the internal clock operating circuit.Depending on the clock selection fuse settings, PB7 can
be used as output from the invertingOscillator amplifier.
If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as
TOSC2..1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set. The
various special features of Port B are elaborated in Alternate
Port C (PC5:0)
Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The PC5..0 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.
PC6/RESET
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the
electrical characteristics of PC6 differ from those of the other pins of Port C.
If the RSTDISBL Fuse is unprogrammed, PC6 is used as a 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. The various special features of Port C
are elaborated in Alternate Functions of
Port D (PD7:0)
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.
AVCC
AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6. 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. Note that PC6..4 use digital supply voltage,
VCC.
18
AREF
AREF is the analog reference pin for the A/D Converter.
ADC7:6 (TQFP and QFN/MLF Package Only)
In the TQFP and QFN/MLF package, ADC7:6 serve as analog inputs to the A/D
converter. These pins are powered from the analog supply and serve as 10-bit ADC channels.
4.4
19
Chapter 5
XBEE MODULE
For applications where robust mesh networking topologies are preferred, XBee
ZigBee/mesh OEM RF modules provide developers with both ZigBee mesh and the soon-tobe-released proprietary DigiMesh topologies. These networks allow devices to harness the
entire network of RF modules to effectively extend range beyond that of a single module, and
create a more stable and reliable network. Employing dynamic self-healing, self-discovery
functionality for reliable communications, XBee ZigBee/mesh OEM RF modules make mesh
networking simple and easy to deploy.
5.1 Performance
RF Data Rate
Indoor/Urban Range
Outdoor/RF Line-of-Sight Range
Transmit Power
Receiver Sensitivity
250kbps
133ft(40m)
400ft (120m)
1.25mW
-97dBm
5.2 Features
128-bit AES
Retries/Acknowledgements
PAN ID,64-bit IEEE MAC,16 Channels
Supply Voltage
2.1 -3.6VDC
Transmit Current
35mA/45mA
Receiver Current
38mA/40mA
<1 uA @ 25 C
Serial data
Data enters the module UART through the DI pin (pin 3) as an asynchronous serial signal.
The signal should idle high when no data is being transmitted. Each data byte consists of a
start bit (low), 8 data bits (least significant bit first) and a stop bit(high).
Serial communications depend on the two UARTs (the microcontroller's and the RF
module's) to be configured with compatible settings (baud rate, parity, start bits, stop bits,
data bits).
21
Data is buffered in the DI buffer until one of the following causes the data to be
packetized and transmitted:
No serial characters are received for the amount of time determined by the RO
(Packetization Timeout) parameter. If RO = 0, packetization begins when a character
is received.
2. The maximum number of characters that will fit in an RF packet (100) is received.
22
Chapter 6
FLOWCHART
6.1 Transmitter
START
Initialize Pins
8,9,10,11,12,13 as
Output Pins
SERIAL.BEGIN
Is
Serial data
available?
Case
f
Assign Pins
8,10,11,12 (HIGH)
13,9 (LOW)
F
F
Assign Pins
9,10,11,13 (HIGH)
8,12 (LOW)
Case
b
F
Case
r
Assign pins
11,12(HIGH)
10,13(LOW)
F
T
Case
l
Assign Pins
8,10(HIGH)
9,11(LOW)
F
T
Assign Pins
10,11 (LOW)
Case
s
STOP
6.2 Receiver
START
SERIAL.BEGIN
Is data
received
from analog
Read(0) pin
Data
from A(0)
pin > 517
Send f
Is data
received
from analog
Read(0) pin
Data
from A(0)
pin > 517
Send b
Send s
Data
from A(0)
pin > 517
Send r
F
STOP
Data
from A(0)
pin > 517
Send l
Send s
Chapter 7
TOOLS
The tools used in this project x-ctu software for configuring xbee and Arduino software for
writing code for arduino uno r3
Following steps are involved in configuring xbee
1.Open the X-CTU configuration tool and select the COM as shown below
25
2.You can test you can connect to your XBEE by pressing the TEST/Query button and it let
you know its current firmware as shown below
3. If X-CTU cannot find your XBee, you will see this pop-up as shown below
26
4. Now we are ready to program our XBee. The first XBee is going to be our Coordinator
module, basically the boss of the private area network (PAN) we are going to create. To
program an XBee we need to upload new firmware to it. To do this, navigate to the Modem
Configuration tab in X-CTU and choose the following configuration. Click Write and XCTU will attempt to program you XBee, this should take 30 seconds or so, you may be asked
to press the RESET button on your USB Dongle as shown in below figure
27
5. When your XBee has been successfully programmed, press the Read button to retrieve the
configuration of the device. All the details about the configuration will be downloaded and
shown as below:
28
6. We are going to use all this information as there are many ways of setting up complex
XBee configurations to suit specific applications. We are only going to set up a simple pointto-point network. This XBee will be the Coordinator node, and so all the 'end points' (Router
nodes) will need to know the address of this node to communicate. Very simply, this means
we want to get the Serial Number of this device to program into our Router.
Write down the SH - Source Address High and SL - Source Address Low for us to use in
the next step. The Coordinator node is now complete! Take this XBee (you may want to mark
this XBee so you know it is the Coordinator) out of your XBee USB Dongle (carefully, make
sure not to bend any of the pins on the module) and insert the next XBee we are going to
program.
Follow the same procedure as last time, make sure you can connect to the XBee and then go
to the Modem Configuration tab. This time instead of programming the node as a
Coordinator, we are going to program it as a Router. Select the same configuration as below
and press Write, this will take another 30 seconds.
29
7. Once this XBee is programmed, press Read to get the configuration. To tell this XBee
which Coordinator to connect to, we need to give it the address. We do that by setting the DH
- Destination Address High and DL - Destination Address Low with the serial number we
took from the Coordinator. Put this information in and then press Write to write this new
configuration to the XBee.
30
31
7.2 Arduino IDE is used to write the program and dump into the Arduino board
Following are the steps involved :
1. Open Arduino IDE as shown below
32
33
34
35
36
Chapter 8
ARDUINO CODE
/* the analog Read pin reads value from 0 to 1023 we will take a threshold value and based
on that we will assume the joystick moved left or right The assumed threshold value are
for x axis low thershold value =505;
high threshold value =515;
for y axis low thershold value =500;
high threshold value =510;
*/
int x_position;
int y_position;
int x_direction;
int y_direction;
void setup()
{
Serial.begin(9600);
}
void loop()
{
x_direction =0;
y_direction =0;
37
Serial.write ("l");
}
38
}
if(x_direction ==1)
{
if(y_direction ==0)
{
Serial.write("r");
}
}
if(y_direction ==1)
{
if(x_direction ==0)
{
Serial.write("f");
}
}
if(y_direction == -1)
{
if(x_direction ==0)
{
Serial.write("b");
}
}
if(x_direction ==0)
{
39
if(y_direction==0)
{
Serial.write("s");
}
}
}
40
void setup()
{
Serial.begin(9600); // initialize serial communication:
pinMode(10,OUTPUT); // initialize for motor A
pinMode(11,OUTPUT); // initialize for motor B
pinMode(8,OUTPUT); // IN1
pinMode(9,OUTPUT); // IN2
pinMode(12,OUTPUT); // IN3
pinMode(13,OUTPUT); // IN4
}
void loop()
{
if(Serial.available()>0)
{
int data =Serial.read();
switch(data)
{
case 'f' :analogWrite(11,255); //enable for channel B
digitalWrite(12,HIGH); //in3
digitalWrite(13,LOW); //in 4 forward (12-13)
digitalWrite(8,HIGH); // in 1
digitalWrite(9,LOW); // in 2 forward (8,9)
analogWrite(10,255); // enable for channel A
break;
41
42
References
1. Arduino Cookbook, 2nd Edition by Michael Margolis.
2.Building Wireless sensor networks by Robert Faludi.