Upload
manojgpillai
View
220
Download
0
Embed Size (px)
Citation preview
8/8/2019 Path Following Robo Car
1/23
PATHFOLLOWING ROBOTIC CAR
ABSTRACT
The graphical user interface of the MATLAB
provides a way for the user to input the path that he
wants the robotic car to follow. MATLAB processes the
path by using the program written on MATLAB and
produces four signals for left, right ,forward and for
stopping the car. This is communicated to themicrocontroller on the vehicle part by using a serial
communication port and the microcontroller generates
the signal to drive the stepper motors and the robotic car
runs in the path drawn.
College of Engineering, Trivandrum
PATHFOLLOWING ROBOTIC CAR
8/8/2019 Path Following Robo Car
2/23
INTRODUCTION
In a world where everything robotic is trying to
become more human-like, there is a need for making a robotic car which
follows any path the user defines for it. It will be better to have the user
predefine the path instead of always having to monitor the path.
The RC car is designed to follow a path drawn by
the user. The Control signals are transmitted according to a user defined
path with the help of MATLAB and Microcontroller. The robotic car can be
controlled from the MATLAB environment. The MATLAB signals are
serially transmitted to the Microcontroller using a serial interfacing
wireless module. Control of the wheels is done by Microcontroller. Thus the
car follows the path drawn by the user.
MATLAB is a numerical computing environment and
programming language. Maintained by The Math Works, MATLAB allows
easy matrix manipulation, plotting of functions and data, implementation ofalgorithms, creation of user interfaces, and interfacing with programs in
other languages.
The MATLAB sent the signals to the microcontroller and
proper controlling of the car was done so that it followed the path that was
drawn. . There are 2 control signals from the microcontroller was
transmitted to the receiver and then given to the motor driving circuit.The
Web Camera placed in front of the vehicle instantly catches all the images
in front of it .The final result acquired was an RC car that follows the userdefined path.
College of Engineering, Trivandrum
8/8/2019 Path Following Robo Car
3/23
DESIGN APPROACH
The Project was executed in 4 stages:-
1) MATLAB: - The path drawn by the user is read using MATLAB and
programming is done to generate the signals accordingly. Path is drawn using a
drawing tool (GIMP, Paint) which is read by MATLAB using its inbuilt functionimread.
2) Serial Communication: - The signals generate by the MATLAB is serially
communicated to the Microcontroller using RS 232 cable. Output signals from
MATLAB is sent in 8 bit frame format and a baud rate of 9600 based on serial
communication protocol.
3) Microcontroller: - Microcontroller programming is done to generate the control
signals provided to the motor driving circuit. RS232 serial communication portand Microcontroller 18F452 is interfaced using a MAX 232 for logic
conversion from CMOS to TTL.
4) Driving Circuit: - The stepper motor in the motor driving circuit picks up the
control signals and drives the wheels. Microcontroller output is three controlling
signals that are taken up by the interfacing module made up of TIP 122 and sent to the
motor driving circuit for driving the wheels.
PATHFOLLOWING ROBOTIC CAR
8/8/2019 Path Following Robo Car
4/23
BLOCK DIAGRAM
TRANSMITTER PART
College of Engineering, Trivandrum
PATHFOLLOWING ROBOTIC CAR
PCSerial port
Communic-
ation
module
8/8/2019 Path Following Robo Car
5/23
MOBILE PART
College of Engineering, Trivandrum
8/8/2019 Path Following Robo Car
6/23
PATHFOLLOWING ROBOTIC CAR
CIRCUIT DIAGRAM
5 V
5 V
5 V
5 V
5 V
5 V
5 V
5 V
1
2
3
4
5
6
7
8
9
1 0
1 1
1 21 3
1 4
1 5
1 6
1 7
1 8
1 9
2 0
4 0
3 9
3 8
3 7
3 6
3 5
3 4
3 3
3 2
3 1
3 0
2 92 8
2 7
2 6
2 5
2 4
2 3
2 2
2 1
M C L R / V P P
R A 0 / A N 0
R A 1 / A N 1
R A 2 / A N 2 / V R E F
R A 3 / A N 3 / V R E F +
R A 4 / T 0 C K I
R A 5 / A N 4
R E 0 / R D / A N 5
R E 1 / W R / A N 6
R E 2 / C S / A N 7
V D D
V S S
O S C 1 / C L K I
O S C 2 / C L K O / R A 6
R C 0 / T 1 O S O
R C 1 / T 1 O S I / C C P 2
R C 2 / C C P 1
R C 3 / S C K / S C L
R D 0 / P S P 0
R D 1 / P S P 1
R B 7 / P G D
R B 6 / P G C
R B 5 / P G M
R B 4
R B 3 / C C P 2
R B 2 / I N T 2
R B 1 / I N T 1
R B 0 / I N T 0
V D D
V S S
R D 7 / P S P 7
R D 6 / P S P 6
R D 5 / P S P 5
R D 4 / P S P 4
R C 7 / R X / D T
R C 6 / T X / C K
R C 5 / S D O
R C 4 / S D I / S D A
R D 3 / P S P 3
R D 2 / P S P 2
R 1
T P 1 4
1
T P 1 01
T P 91
T P 21
T P 11
Q 1
T I P 1 2 21
2
3
T P 31
T P 41
Q 3
T I P 1 2 21
2
3
Q 4
T I P 1 2 21
2
3
Q 5
T I P 1 2 21
2
3
Q 6
T I P 1 2 21
2
3
T P 51
T P 61
D 1L E D
T P 71
T P 81
Q 8
T I P 1 2 21
2
3
M A X 2 3 2
1 3
8
1 1
1 0
1
3
4
5
2
6
1 2
9
1 4
7
1
6
1
5
R 1 I N
R 2 I N
T 1 I N
T 2 I N
C +
C 1 -
C 2 +
C 2 -
V +
V -
R 1 O U T
R 2 O U T
T 1 O U T
T 2 O U T
V
C
C
G
N
D
+ C 91 0 0 0 m F
C
1
23456789
R 1 1
Q 2
T I P 1 2 21
2
3
Q 7
T I P 1 2 21
2
3
+ C 5
1 0 0 0 m F
+
C 6
1 0 0 0 m F
U 3L M 7 8 0 5
1 3
2
I N O U T
G
N
D
T P 1 1
1
T P 1 2
1
Y 1
1 0 M H zC 1
3 3 p FC 2
3 3 p F
P 1
5
9
4
8
3
7
2
6
1
T P 1 3
1
1 m f
R X
1 m f
1 m f
1 m f
-
T X
1 8 F 4 5 2
R X
T X
T O
B L U E T O O T H
M O D U L E
B +
B -
6 V D C / 5
M O T O R
2 . 2 K
8 x 1 0 0 E
1 K
2 2 0 E
M O T O R S
9 V D C / 5 0 0 m A
M O T O R
B +
B -
R 2
R 3
R 4
R 5
R 6
R 7
R 8
R 9
R 1 0
C 4
C 8
C 7
C 3
U 2
U 1
College of Engineering, Trivandrum
8/8/2019 Path Following Robo Car
7/23
PATHFOLLOWING ROBOTIC CAR
Figure shows the block diagram of the
transmitter unit and mobile unit. In the Transmitter
unit consist of Pc, serial port and communication
module. In the mobile unit consists of Receiver part
of the communication module, Microcontroller and the
Interface unit. The block diagram also consists of web
camera and usb port.
This GUI file with the program to be
executed is opened by calling Pc used in the Transmitter
unit used for the creation of GUI file.the MATLAB file
car.m at the command prompt. Load loads the image on
the GUI window. Run command is used to execute the
program.The input at the GUI level is the filename The
graphical user interface of the MATLAB provides a way for
the user to input the path that he wants the robotic car to
follow of the path that the user has drawn. MATLAB
processes the path and produces four signals for left, right,forward and for stopping the car.The serial port interface forconnecting two devices is specified by the TIA/EIA-232C
Software serial port monitor, Com Rs232 sniffer with
8/8/2019 Path Following Robo Car
8/23
8/8/2019 Path Following Robo Car
9/23
transmitted.
For an asynchronous system, the number of bits
transmitted per second must be known by the receiver. Since
the clock signal is not transmitted, the receiver needs to know
what clock frequency the transmitter is using so that it can use
the same.
The receiver also needs to know how many bits per word
the transmitter is using (in most cases we deal with 8-bit
words, but we will see cases where nine bits are transmitted
per word). And the receiver needs to know where the data
begins and where the data stops.Bluetooth wirelesstechnology is a short-range communications technology
intended to replace the cable connecting portable and/or fixed
devices while maintaining high levels of security.
The mobile unit consists of Receiver part of the
communication module and the it is followed by
microcontroller part. The Microcontroller part will gives signals
to the motor driving circuit. And it is also followed by the web
camera and then the signals from the camera will transmit to the
Pc for showing the pathe that the robotic car gone.
8/8/2019 Path Following Robo Car
10/23
Microcontroller programming is done to generate the control
signals provided to the motor driving circuit. RS232 serial
communication port and Microcontroller 18F452 is interfaced
using a MAX 232 for logic conversion from CMOS to TTL
The stepper motor in the motor driving circuit picks up the
control signals and drives the wheels. Microcontroller output is
three controlling signals that are taken up by the interfacing
module made up of TIP 122 and sent to the motor driving circuit for
driving the wheels. The Web camera placed infront of the
moving part takes up instantaneous images &the user can check
the images instantaneously. If any obstacle comes in the
designed path he can see the image and can redraw a new path
for the destination
The Circuit diagram of mobile part will be shown in
figure. It will consists of Voltage Regulated Ic LM7805 is used
for voltage for the power supply. 10MHz crystal oscillator will
be used for the frequency generation for the microcontroller Ic.
RS232 is used for transmission and reception of the signals.
The collector of TIP122 is connected to the coils of the motor
for giving signals to the transmitter.
College of engineering,Trivandrum
PATHFOLLOWING ROBOTIC CAR
8/8/2019 Path Following Robo Car
11/23
PIC MICROCONTROLLERS
PIC is a family of Harvard architecture microcontrollers
made by Microchip Technology, derived from the PIC1640
originally developed by General InstrumentsMicroelectronics division. The name PIC initially referred to
Programmable Interface Controller, but shortly thereafter
was renamed Programmable Intelligent Computer.
PICs are popular with developers and hobbyists alike dueto their low cost, wide availability, large user base, extensive
collection of application notes, availability of low cost or free
development tools, and serial programming (and re-
programming with flash memory) capability.
Core Architecture
The PIC architecture is distinctively minimalist. It is
characterized by the following features:
Separate code and data spaces (Harvard architecture)
A small number of fixed length instructions
8/8/2019 Path Following Robo Car
12/23
Most instructions are single cycle execution (4 clock cycles),
with single delay cycles upon branches and skips
A single accumulator (w), the use of which (as source
operand) is implied (ie is not encoded in the opcode)
All RAM locations function as registers as both source and/or
destination of math and other functions.
A hardware stack for storing return addresses
A fairly small amount of addressable data space (typically 256
bytes), extended through banking
Data space mapped CPU, port, and peripheral registers
The program counter is also mapped into the data space and
writable (this is used to implement indirect jumps)
Unlike most other CPUs, there is no distinction between
memory and register space because the RAM serves the
job of both memory and registers, and the RAM is usually just
referred to as the register file or simply as the registers.
Data Space (RAM)
PIC have a set of registers that function as general
purpose RAM. Special purpose control registers for on-chip
hardware resources are also mapped into the data space. The
8/8/2019 Path Following Robo Car
13/23
addressability of memory varies depending on device series,
and all PIC devices have some banking mechanism to extend
the addressing to additional memory. Later series of devices
feature move instructions which can cover the whole
addressable space, independent of the selected bank. In earlier
devices (i.e., the baseline and mid-range cores), any register
move has to be achieved via the accumulator.
To implement indirect addressing, a file select register (FSR)
and indirect register (INDF) are used: A register number is
written to the FSR, after which reads from or writes to INDF will
actually be to or from the register pointed to by FSR. Later
devices extended this concept with post-and pre-
increment/decrement for greater efficiency in accessing
sequentially stored data. This also allows FSR to be treated
almost like a stack pointer.
External data memory is not directly addressable except in some
high pin count PIC18 devices.
8/8/2019 Path Following Robo Car
14/23
Code Space
All PICs feature Hardvard architecture, so the code space and
the data space are separate. PIC code space is generally
implemented as EPROM,ROM, or flash ROM.
In general, external code memory is not directly addressable due
to the lack of an external memory interface. The exceptions are
PIC17 and select high pin count PIC18 devices.
Word Size
The Word size of PICs can be a source of confusion. All PICs
handle (and address) data in 8-bit chunks, so they should be
called 8-bit microcontrollers. However, the unit of addressability
of the code space is nit generally the same as the data space. For
example, PICs in the baseline and mid-range families have
program memory addressable in the same wordsize as the
instruction width, ie. 12 or 14 bits respectively. In contrast, in the
PIC18 series, the program memory is addressed in 8-bit
8/8/2019 Path Following Robo Car
15/23
increments (bytes), which differs from the instruction width of 16
bits.
In order to be clear, the program memory capacity is usually
stated in number of (single word) instructions, rather than in
bytes.
Stacks
PICs have a hardware call stack, which is used to save return
addresses. The hardware stack is not software accessible on
earlier devices, but this cganged with the 18 series devices.
Hardware support for a general purpose parameter stack was
lacking in early series, but this greatly improved in the 18 series,
making the 18 series architecture more friendly to high level
language compilers.
Instruction Set
A PICs instructions vary in number from about 35 instructions
for the low-end PICs to over 80 instructions for the high-end
PICs. The instruction set includes instructions to perform a
8/8/2019 Path Following Robo Car
16/23
variety of operations on registers directly, the accumulator and a
literal constant or the accumulator and a register, as well as for
conditional execution, and program branching.
Some operations, such as bit setting and testing, can be
performed on any numbered register, but bi-operand arithmetic
operations always involve W; writing the result back to either W
or the other operand register. To load a constant, it is necessary
to load it into W before it can be moved into another register. On
the older cores, all register moves needed to pass through W, but
this changed on the high end cores.
PIC cores have skip instructions which are used for conditional
execution and branching. The skip instructions are: skip if bit
set, and, skip if bit not set. Because cores before PIC18 had
only unconditional branch instructions, conditional jumps are
implemented by a conditional skip (with the opposite condition)
followed by an unconditional branch. Skips are also of utility for
conditional execution of any immediate single following
instruction.
The PIC architecture has no (or very meager) hardware support
for automatically saving processor state when servicing
8/8/2019 Path Following Robo Car
17/23
interrupts. The 18 series improved this situation by
implementing shadow registers which save several important
registers during an interrupt.
In general, PIC instructions fall into 5 classes:
1. Operation on W with 8-bit immediate (literal) operand. E.g.
movlw (move literal to W), andlw (And literal with W). One
instruction peculiar to the PIC is retlw, load immediate into W and
return, which is used with computed branches to produce lookup
tables.
2. Operation with W and indexed register. The result can be
written to either the W register (e.g. addwf reg, w). or the selected
register (e.g.addwf reg,w).
3. Bit operations. These take a register number and a bit
number, and perform one of 4 actions: set or clear a bit, and
test and skip on set/clear. The latter are used to perform
conditional branches. The usual ALU status flags are
available in a numbered register so operation
3. Control transfers. Other than the skip instructions
previously mentioned, there are only two: goto and call.
8/8/2019 Path Following Robo Car
18/23
4. A few miscellaneous zero-operand instructions, such as
return from subroutine, and sleep to enter low-power mode.
Limitations
The PIC architecture have several limitations:
Only a single accumulator
A small instruction set
Operations and registers are not orthogonal; some instructionscan address RAM and / or immediate constants, while others
can only use the accumulator
Memory must be directly referenced in arithmetic and logic
operations, although indirect addressing is available via 2
additional registers
Register-bank switching is required to access the entire RAM
of many devices, making position-independent code complex
and inefficient
Cnditional skip instructions are used of conditional branch
instructions used by most other architectures
The following limitations have been addressed in the PIC18,
but still apply to earlier cores:
8/8/2019 Path Following Robo Car
19/23
Indexed addressing mode is very rudimentary.
Stack:
The hardware call stack is so small that program structure
must often be flattened
The hardware call stack is not addressable, so pre-emptive
task switching cannot be implemented
Software-implemented stacks are not efficient, so it is
difficult to generate reentrant code and support local variables
Program memory is not directly addressable, and thus space-
inefficient and / or time-consuming to access. (Thus is true ofmost Harvard architecture microcontrollers.)
With paged program memory, there are two page sizes to
worry about: one for CALL and GOTO and another for
computed GOTO (typically used for table lookups). For
example, on PIC16, CALL and GOTO have 11 bits of
addressing, so the page size is 2KB. For computed GOTOs,
where you add to PCL, the page size is 256 bytes. In both
8/8/2019 Path Following Robo Car
20/23
cases, the upper address bits are provided by the PCLATH
register. This register must be changed every time control
transfers between pages. PCLATH must also be preserved by
any interrupt handler.
PIC18 High End Core Devices
Microchip introduced the PIC18 architecture in 2002.
Unlike the 17 series, it has proven to be very popular, with a
large number of device variants presently in manufacture. In
contrast to earlier devices, which were more often than not
programmed in assembly, C has become the predominant
development language.
The 18 series inherits most of the features and
instructions of the 17 series, while adding a number of
important new features:
Much deeper call stack (31 levels deep)
The call stack may be read and written
Conditional branch instructions
Indexed addressing mode (PLUSW)
8/8/2019 Path Following Robo Car
21/23
Extending the FSR registers to 12 bits, allowing them to
linearly address the entire data address space
The aqddition of another FSR register (bringing the number
up to 3)
The auto increment/decrement feature was improved by
removing the control bits and adding four new indirect
registers per FSR. Depending on which indirect file register
is being accessed it is possible to postdecrement,
postincrement, or preincrement FSR; or from the effective
address by adding W to FSR.
In more advanced PIC18 devices, an extended mode
is available which makes the addressing even more favorable
to compiled code:
A new offset addressing mode; some addresses which were
relative to the access bank are now interpreted relative to the
FSR2 register The addition of several new instructions,notable for
manipulating the FSR registers.
8/8/2019 Path Following Robo Car
22/23
These changes were primarily aimed at improving the
efficiency of a data stack implementation. If FSR2 is used
either as the stack popinter or frame pointer, stack items may
be easily indexedallowing more efficient re-entrant code.
Microchip C18 chooses to use FSR2 as a frame pointer.
Device Variants and Hardware Features
PIC devices generally feature:
Sleep mode (power saving).
Watchdig timer.
Various crystal or RC oscillator configurations, or an
external clock.
Variants
Within a series, there are still many device variants
depending on what hardware resources the chip features.
General purpose I/O pins.
Internal clock oscillators.
8/16 Bit Timers.
8/8/2019 Path Following Robo Car
23/23
Internal EEPROM Memory.
Synchronous/Asynchronous Serial Interface USART.
MSSP Peripheral for I2C and SPI Communications.
Capture/compare and PWM modules.
Analog-to-digital converters (up to 1.0 MHz).
USB, Ethernet, CAN interfacing support.
External memory interface.
Integrated analog RF front ends (PIC16F639, and rfPIC).
KEELOQ Rolling code encryption peripheral
(encode/decode)
Fig:D-subconnectors. Fig:Left: DE9M Right: DB25F