A REAL TIME VIDEO TRACKING AND WIRELESS SPEED CONTROL FOR
MILITARY APPLICATION
SIBAWAIHI MACCIDO
A project report submitted in partial fulfillment of the
requirements for the award of degree of Bachelor of Engineering
(Hons) in Electrical & Electronics Engineering (Control)
UNIVERSITY OF EAST LONDONDECEMBER 2011
xi
DECLARATION
I hereby declare that this project entitled A Real Time Video
Tracking and Wireless Speed Control for Military Application has
been done by me and no portion of the work contained in the report
has been submitted in support of any application for any other
degree or qualification of this or any other university or
institute of higher learning.
Name: ______________________Signature:____________________UEL
ID:_____________________Date:________________________
Supervisors Signature:_____________________Supervisors
Name:________________________Date:____________________________________
DEDICATION
To my late brother Abdul-Satar Maccido
ACKNOWLEDGEMENTS
Thanks be to Allah (S.W.A) verily,when He intends a
thing,Hiscommand is, "be", and it is!I would be very remised if I
did not thank the many people who helped me survive the birthing of
my project.My parents have been my rock; I dont know how anyone
does this without a Dads good advice and a Moms shoulder to cry
on.My supervisor, Mdm. Sreeja continues to guide my career with
genius and finesse. It is very comforting to know that I am in such
good hands.I wont forget Bashir Ibrahim Zwall and Sharavanan my
course mates extraordinaire, they made all the difference to my
sanity both on and off the road. I am eternally grateful.Thanks to
Ms Mary Alvean, first for your unwavering faith in my work, and
second for polishing that work until it shines.Thanks to Mr Ery the
programming lecturer for being so in tune with my project and
helping me find the best ways to express it.Most of all, thank you
to all my classmates I firmly believe that you are the most
hardworking, intelligent and dedicated mates in the whole
world.
ABSTRACT
The aim of this project is to design a real time video tracking,
wireless speed and position control system based on PWM control
logic using microcontroller for Military application. The project
is strictly concerned with; wireless communication and remote
control, real time video tracking, speed and position control, and
lastly a closed loop model on the receiver section. In order to
achieve wireless communication and remote control, RF transmitter
and receiver module was designed using microcontroller based
technology. To implement a real time video tracking, wireless
camera and Bluetooth serial link is used. More also, to achieve
closed loop position and speed control of dc motor, PIC
microcontroller is used based on its built-in PWM circuitry that
generates square wave of different duty cycle. To accomplish a
closed loop model, optical disc mounted on the motor shaft is fed
back to the microcontroller. To achieve speed measurement, optical
encoder is used based on back e.m.f. . The microcontroller is
interfaced with Liquid Crystal Display (LCD) for speed display
purposes. A laser gun has been installed on the robot so that it
can fire an enemy remotely when required. This is not possible
until a wireless camera is installed. Wireless camera sends a real
time video which could be seen on a remote monitor and action can
be taken accordingly. The motor driver (H-bridge) is used to
control the direction of the motor. Visual Basic 6.0 is used as a
tool to design the Graphical User Interface (GUI) on the PC. At the
end of this project, a closed loop speed control is obtained on the
receiver section. The speed of the robot is controlled at 10rpm,
8rpm and 5rpm for fast, average and slow respectively. The position
of the laser gun is controlled at 15 degrees, 25 degrees and 45
degrees for point down, point medium and point up respectively. A
real time video tracking is performed up to 328.083 ft away. Hence,
the project has met its main objective.
Table of
ContentsDECLARATIONiiDEDICATIONiiiACKNOWLEDGEMENTSivABSTRACTvLIST
OF ABBREVIATIONSxvCHAPTER 1: INTRODUCTION11.1 Overview of the
Project11.2 Background Study of the Project11.3 Problem
statement21.4 Aim of the project21.5 Objectives of the project21.6
Scope of the project31.7 Organization of the report3CHAPTER 2:
THEORETICAL BACKGROUND AND LITERATURE REVIEW52.1 Theoretical
background52.1.1 Principle of operation of a Direct-Current
motor52.1.2 Significance of back Electromotive Force52.1.3 Speed
control of Direct-Current Motor62.1.4 Speed control by using
tachometer62.1.5 Speed control by using optical encoder72.2
Literature Review92.2.1 Reviews on video tracking and wireless
speed control robotics from 1966 to 20089CHAPTER 3: SYSTEM
DESIGN143.1 Overview of the design process as block diagram143.1.1
Wireless transmitter and receiver section block diagram and
description153.1.1.1 Wireless transmitter section block diagram and
description153.1.1.2 Wireless receiver section block diagram and
description163.2 Hardware design details183.2.1
Microcontroller183.2.1.1 Choice of microcontroller183.2.1.2 PIC
microcontroller for transmitter and receiver193.2.2 Power supply
circuit203.2.2.1 Transformer and regulator IC choice203.2.2.2 Power
supply simulation and discussion213.2.2.2.1 Decoupling Capacitors
and bridge rectifier213.2.2.2.2 Desired output parameters213.2.2.2
Power supply design calculations233.2.2.3 Parameters selection and
circuit design calculations263.2.2.3.1 MC oscillator design
calculations and simulation263.2.2.3.2 Frequency
selection263.2.2.3.3 Justification of results using Multisim
10.0273.2.2.4 Choice of resistors between MC and encoder303.2.2.4.1
Calculated results303.2.2.4.2 Simulated results for pull up
resistor313.2.3 DC MOTOR313.2.3.1 DC MOTOR DRIVER
CIRCUIT323.2.3.1.1 Motor driver L293D INPUT CIRCUIT323.2.3.1.1.1
Transistor used as an electronic switch323.2.3.1.1.2 Analysis of a
transistor switching circuit for cutoff and
saturation333.2.3.1.1.2.1 Conditions in cutoff333.2.3.1.1.2.2
Conditions in saturation333.2.3.1.1.3 Design calculations of the
L293D driver input circuit343.2.3.1.1.3.1 Condition 1 (transistor
in cutoff)343.2.3.1.1.3.1.1 Verification of transistor results in
cutoff region by voltage divider rule353.2.3.1.1.3.1.2 Using ohms
law to determine the Base Current 353.2.3.1.1.3.1.2 Condition 2
(transistor in saturation)363.2.3.1.1.3.1.2.1 Verification of
transistor results in saturation region by Voltage Divider
Rule373.2.3.1.1.3.1.2.2 Using Ohms to determine the Base Current
373.2.3.1.1.4 Transistor circuit simulation using ISIS 7
professional software383.2.3.1.1.4.1 Simulation of transistor in
cutoff region using Proteus383.2.3.1.1.4.2 Simulation of transistor
in saturation using Proteus393.2.4 Design of interfacing
circuits403.2.4.1 Interfacing Serial (DB9) with PC403.2.4.2
Interfacing MAX232 with serial (DB9)413.2.4.3 Interfacing MAX232
with PIC16f873A423.2.4.4 Remote control encoder PT2262 and decoder
PT2272433.2.4.5 RF transmitter and receiver module443.3 REAL TIME
VIDEO TRACKING453.4 MECHANICAL DESIGN453.5 SOFTWARE DESIGN463.5.1
Flow chart of transmitter and receiver section473.5.2 Flow charts
description513.5.3 PWM CONTROL LOGIC52CHAPTER 4: HARDWARE AND
SOFTWARE DESIGN AND IMPLEMENTATION534.1 Schematic diagram534.1.1
Wireless transmitter schematic diagram534.1.2 Wireless receiver
section schematic diagram554.1.2.1 IR sensor schematic574.1.3
Optical encoder574.1.4 DC Motor drive574.2 PCB design rules594.2.1
Working from the Top594.2.2 Tracks594.2.3 Soldering604.2.4
Electrical Testing604.2.5 PCB designs604.3 Software
implementation634.3.1 Programming in Mikro C634.3.1.1 Process
explanation of main program634.3.1.2 Initialization of the mode of
ports634.3.2 PROGRAM DESCRIPTION654.3.2.1 LCD Pin
descriptions744.3.2.2 Initialization of PWM764.3.2.3 Initialization
of TIMER0 in Timer Mode784.3.2.4 Setup for Serial port794.4
Programming in Visual Basic 6.0814.4.1 Proteus VSM for PIC16824.4.2
Visual basic 6.0 with ISIS 7 professional844.4.2.1 Virtual serial
port844.4.2.2 Visual basic 6.0 with Proteus ISIS 7 professional
results844.5 Project prototype89CHAPTER 5: RESULTS AND
DISCUSSION905.1 Overview of Results905.2 Microcontroller905.3 Motor
Driver Circuit915.4 Open loop Speed Control925.5 IR sensor955.5.1
IR sensor designed calculations955.5.2 IR sensor output
voltage965.5.3 IR sensor characteristics975.6 Closed loop Speed
Control985.7 PWM outputs1015.8 Message and Received Signals1035.9
Real time video tracking outdoor testing results1055.10 PROBLEMS
ENCOUNTERED1065.10.1 Mechanical1065.10.2 Hardware1065.10.3
Software107CHAPTER 6: CONCLUSION AND FUTURE RECOMMENDATION1086.1
Conclusion1086.2 Future Recommendations108REFERENCES110APPENDIX:
AGANTT CHART113APPENDIX B: RECEIVER SECTION C PROGRAM114APPENDIX C:
MECHANICAL DESIGN USING SOLID WORKS120APPENDIX D: VISUAL BASIC
PROGRAM121APPENDIX E: HARDWARE TESTING RESULTS124
List Of Figures
Figure 2.1.4.1: Direct Current motor coupled with tachometer in
block form6Figure 2.1.5.1: Optical encoder rotating disk showing a
ray of light from light source pointing at the photo
detector7Figure 3.1.1.1.1: Wireless transmitter section block
diagram15Figure 3.1.1.2.1: Wireless Receiver Section block
diagram17Figure 3.2.2.1.1: Battery powered power supply20Figure
3.2.2.1.1: Transformer powered power supply21Figure 3.2.2.1.1:
Power supply simulation using 12 V DC as source voltage23Figure
3.2.2.1.2: Power supply simulation using 230 V, 50Hz as source
voltage23Figure 3.2.2.1.3: Oscilloscope output ac to dc level
voltage23Figure 3.2.2.3.3.1: MC oscillator28Figure 3.2.2.3.3.2:
Frequency counter displaying 4MHz crystal28Figure 3.2.2.3.3.3:
Frequency counter displaying Period of 250 nsec29Figure 3.2.2.4.2.1
simulated result for pull up resistor31Figure 3.2.3.1.1.1.1: Ideal
switching action of a transistor schematic32Figure 3.2.3.1.1.3.1.1:
Transistor in cutoff region schematic34Figure 3.2.3.1.1.3.4.1:
Transistor in saturation region schematic36Figure 3.2.3.1.1.4.1.1:
Proteus simulation showing transistor in cutoff region38Figure
3.2.3.1.1.4.1.1: Proteus simulation showing transistor in
saturation region39Figure 3.2.4.2.1: RS23 Interface with
Max23242Figure 3.2.4.3.1: MAX232 interface with PIC16F873A42Figure
3.5.1.1: Flow chart of program in Visual basic 6.048Figure 3.5.1.2:
Flow chart of transmitter section in Microsoft Visio
software49Figure 3.5.1.3: Flow chart of receiver section in
Microsoft Visio Software50Figure 3.5.1.3: Receiver section flow
chart interrupts process51Figure 4.1.1.1: Wireless transmitter
schematic diagram54Figure 4.1.2.1: Wireless receiver schematic
diagram56Figure 4.1.2.1.1 IR sensor schematic57Figure 4.2.1.1:
Transmitter section PCB61Figure 4.2.1.2: Receiver section
PCB62Figure 4.2.1.3: IR sensor section PCB62Figure 4.3.1.2.1:
Configure input and output port64Figure 4.3.1.2.2: Define motor
output pins65Figure 4.3.2.1: Define motor output pins66Figure
4.3.2.2: Off interuppt process66Figure 4.3.2.3: Setting baud rate
at 9600bps67Figure 4.3.2.4: Read input port67Figure 4.3.2.5:
Program to send 1000 if F is given as the input68Figure 4.3.2.6:
Program to send 0100 if Bis given as the input69Figure 4.3.2.7:
Program to send 0010 if L is given as the input69Figure 4.3.2.8:
Program to send 0001 if R is given as the input70Figure 4.3.2.9:
Program to send 1000 if F is given as the input71Figure 4.3.2.10:
Program to send 1100 if 1 is given as the input71Figure 4.3.2.11:
Program to send 1010 if 2 is given as the input72Figure 4.3.2.12:
Program to send 1001 if 3 is given as the input72Figure 4.3.2.13:
Program to send 1110 if 4 is given as the input73Figure 4.3.2.14:
Program to send 0111 if 5 is given as the input73Figure 4.3.2.15:
Program to send 1101 if 6 is given as the input74Figure 4.3.2.16:
Program to send 1011 if 7 is given as the input75Figure 4.3.2.17:
Program to send 0101 if 8 is given as the input75Figure 4.3.2.12:
Configure LCD77Figure 4.3.2.2.1: PWM output78Figure 4.3.2.2.2:
Simplified PWM block diagram78Figure 4.3.2.3.1: Timer1 block
diagram80Figure 4.3.2.4.1: USART transmit block diagram81Figure
4.3.2.4.2: USART received block diagram82Figure 4.3.2.4.3: Setting
the baud rate82Figure 4.4.1: Visual basic GUI83Figure 4.4.1.1:
Transmitter and receiver circuit simulation using ISIS 7
professional85Figure 4.4.2.1.1: Virtual Terminal for data
display86Figure 4.4.2.2.1: Forward button is pressed hence the
motor moves in clockwise direction (1010)88Figure 4.4.2.2.2:
Reverse button is pressed hence the motor moves counterclockwise
direction (0101)89Figure 4.4.2.2.3: Left button is pressed hence
the motor moves in leftward direction (1000)90Figure 4.4.2.2.4:
Right button is pressed hence the motor moves in right direction
(0010)90Figure 5.4.1: Fast (speed at 10 RPM)94Figure 5.4.2: Average
speed at (8 RPM)95Figure 5.4.3: Slow (speed at 5 RPM)96Figure
5.5.1.1: IR sensor to determine R197Figure 5.5.1.2 IR sensor
simulation output at black time98Figure 5.5.1.3 IR sensor
simulation output at white time98Figure 5.5.2.1: Sensor
characteristics99Figure 5.6.1: Closed loop response graph with
speed maintained at 10 rpm100Figure 5.6.2: Closed loop response
graph with speed maintained at 8 rpm101Figure 5.6.3: Closed loop
Response graph with speed maintained at 5 rpm102Figure 5.7.1: PWM
output showing the graph of motors running at slow speed 5
rpm103Figure 5.7.2: PWM output showing the graph of motors running
at average speed 8 rpm104Figure 5.7.3: PWM output showing the graph
of motors running at Fast speed 10 rpm104Figure 5.8.1: Message
signal [Voltage Vs time]105Figure 5.8.2: Received signal [Voltage
Vs time]105Figure 5.9.1: Real time image captured at CH1106Figure
5.9.2: Real time image captured at CH1106
List of TablesTable 3.2.2.3.3.1: Frequency and period output
parameters29Table 3.2.4.1.1: RS232 pin assignments (DB9 PC signal
set)40Table 3.2.4.2.1: RS232 Line Type and Logic Level41Table
4.2.2.1: Motor driver data inputs58Table 5.2.1 Voltage regulator
LM780592Table 5.3.1 Voltage regulator LM781293Table 5.4.1 Open loop
speed Measurements obtained when the reference input was set at
fast speed94Table 5.4.2 Measurements obtained when the reference
input was set at Average speed94Table 5.4.3 Open loop speed
measurements obtained when the reference input was set at fast
speed95Table 5.5.1.1 Sensor outputs represented in tabular
form98Table 5.6.1 Closed loop speed measurements obtained when the
reference input was set at fast speed100Table 5.6.2 Closed loop
speed measurements obtained when the reference input was set at
fast speed100Table 5.6.3 Closed loop speed measurements obtained
when the reference input was set at fast speed101
LIST OF ABBREVIATIONS
PC -Personal ComputerPCB -Printed Circuit BoardDC -Direct
CurrentPIC -Peripheral Interface Controller NASA -National
Aeronautics and Space AdministrationEEMO -Extreme Environment
Mission OperationRS232 -Recommended Standard 232IC - Integrated
CircuitMC - MicrocontrollerI/O -Input / OutputTTL
-Transistor-Transistor LogicIR -Infra RedOSC -OscillatorRX
-ReceiverTX -TransmitterLCD -Liquid Crystal DisplayPWM -Pulse Width
ModulationAC -Alternating currentRF -Radio-FrequencyUSB -Universal
Serial BusRx -ReceiverRAD -Rapid Application DevelopmentEMF
-Electro Motive ForceVB -Visual BasicGUI -Graphical User
InterfacePID -Proportional Integral ControllerRPM -Revolutions Per
MinuteUSART -Universal Synchronous Asynchronous Receiver
Transmitter
2
CHAPTER 1
INTRODUCTION
1.1 Overview of the Project
This chapter gives an overview of the whole project, starting
with the project background, problem statement, project objectives,
and scope.
1.2 Background Study of the Project
As robotics technology is rapidly advancing, removing humans
from the battlefield may change a societys understanding of war and
how it may be conceptualized. Unmanned robotic systems replacing
humans in acts of conflict conveniently suits a nation intolerance
of casualties during violent conflict because robotic systems are
capable of solving repeated problems more efficiently and
effectively than human beings. In addition, further removing humans
from the process of war may give the appearance that war is an
impersonal activity that does not physically or emotionally burden
the populace (McDaniel 2008). Robotics is a wide technology area
that also encompasses a subset of valuable enabling technologies.
Teleported mobile robotic systems are remotely operated vehicles
designed to perform tasks in coordination with human operators.
However, teleportation can be realistically enhanced by a level of
automation removing challenges such as constant monitoring (Dastur,
2009). The aim of this proposal is to develop a video tracking and
wireless speed control using microcontroller for military
application. Teleoperating the robot from the remote location will
allow a user to have complete command and control over the robot
via visual aids which keeps the operator aware of the remote
environment, thus enabling him to witness the accomplishment of
task. 1.3 Problem statement
Nowadays, in military application, one of the long standing
challenging aspect in mobile robotics is the ability to maintain a
real time video tracking and wireless speed control, avoiding
obstacles especially in battlefield and unknown environment. The
requirement to get rid of delay to obtain a real-time location of
an object would reduce the number of military personnel injured or
killed in combat situations. To overcome these issues, a real time
video tracking and wireless speed control for military application
is introduced (Ogata, 2002). The features of combat robot and
wireless camera are proposed here in this project. The accuracy and
tracking performance of the robot can be improved using closed loop
feedback (complex structure that can compensate all disturbances).
The variation and accuracy of the speed can be improved using PWM
controller.
1.4 Aim of the project
The aim of this project is to design a real time video tracking
and wireless speed control robot using microcontroller for military
application.
1.5 Objectives of the project
Specifically, the objectives are:1. To design a transmitter and
receiver module using microcontroller.2. To perform video tracking
using wireless camera, and3. To perform wireless speed, position,
and firing options control based on PWM. Lastly, closed loop model
on the receiver section.
1.6 Scope of the project
The general aim of the study is to design a video tracking and
wireless speed control of military robot. This robot is radio
operated; self powered, and has all the controls like a normal car.
It has got gun and camera mechanism installed on it. The laser
provides options for firing an enemy remotely when required; this
is not possible until a wireless camera is installed. The camera
sends real time video which could be seen on a remote monitor so
that action can be taken accordingly. The robot can silently enter
into enemy area and send all the information through its tiny
camera eyes. It is designed for fighting as well as suicide
attack.Furthermore, we will then focus on elaborating and designing
a suitable transmitter and receiver module using
microcontroller-based circuit. A PIC microcontroller was selected
for this project but there are other microcontrollers like the 8051
series, Motorola, Hitachi, Texas and Arm which can be equally
useful. Finally, priority will be given to the software design and
implementation in order to develop a suitable algorithm that will
prompt interaction with the military robot.
1.7 Organization of the report
The work presented in this thesis has been covered in six
Chapters.
Chapter 1 provides some introduction through background study,
aim, objectives and scope of the project.
Chapter 2 discusses the literature review carried out by
analyzing similar works done in the past and some recent relevant
research in the field.
Chapter 3 begins with relevant theories and simulation of
various circuits. It also includes concise PWM control logic and
its application on the current system.
Chapter 4 includes detailed information on circuit schematic,
PCB design and microcontroller source codes.
Chapter 5 lists all of the hardware and software testing results
and concludes with a detailed analysis on each of them.
Chapter 6 concludes the work done throughout the project and
provides few recommendations on improving efficiency for systems to
be designed in the future.
CHAPTER 2
THEORETICAL BACKGROUND AND LITERATURE REVIEW
2.1 Theoretical background
In order to familiarize myself with the project, some
theoretical background research on the topic was carried out. This
research included relevant theories on Direct Current motor, its
principle of operation, significance of its back e.m.f, its speed
measurement, model of separately excited Direct Current motor, last
but not the least Direct Current motor controller.
2.1.1 Principle of operation of a Direct-Current motor
Based on the research it was understood that a motor is a device
that converts an electrical energy to mechanical energy. According
to Faradays law, whenever a current carrying conductor is placed in
a magnetic field; it experiences a mechanical force. Hence, when a
supply is given, the interaction between the flux produced by the
current carrying conductor and the flux produced by the permanent
magnet called the main flux, magnetic repulsion and attraction
takes place, this exerts a magnetic force on the conductor which
causes the rotation on the system.
2.1.2 Significance of back Electromotive Force
The speed of the motor can be measured based on the concept of
back e.m.f induced in the motor when it is running. At normal
running condition, the difference between back e.m.f and supply
voltage is very small. Back e.m.f regulates the flow of armature
current and it automatically alters the armature current to meet
the load requirement. According to Faradays law of electromagnetic
induction whenever a conductor cuts the lines of flux, e.m.f will
be induced in the conductor. This induced e.m.f in the armature
always acts in the opposite direction of the supply voltage.
According to Lenzs law, the direction of induced e.m.f is always
opposite with the main cause producing it.
2.1.3 Speed control of Direct-Current Motor
To start with this project, a device that will measure the speed
to enable closed loop control of the motor shaft is needed.
Currently, there are several methods which can be used to measure
the speed. However, we will discuss speed measurement by using
optical encoder and tachometer.
2.1.4 Speed control by using tachometer
The speed measurement using tachometer is based on the concept
of back e.m.f induced in the motor at running condition. The
direction of induced e.m.f is always opposite with the main cause
producing it.
Figure 2.1.4.1: Direct Current motor coupled with tachometer in
block form
The magnitude of the e.m.f is given by;
where; Electromotive force Constant based on motor rotation
Magnetic flux Speed rotation in revolution per minuteHence, the
actual relationship between motor speed and back E.M.F is given
as:
Thus, the motor speed is directly proportional to the E.M.F
voltage and inversely proportional to the field flux.
2.1.5 Speed control by using optical encoder
The optical encoder type is one of the best methods to measure
speed of dc motor. This contains an optical disc, which has slots
cut into it, that shines a beam of light from a transmitter across
a small space and detects it with a receiver the other end. The
signal is picked up when a slot is between the transmitter and
receiver. Figure 2.1.5.1: Optical encoder rotating disk showing a
ray of light from light source pointing at the photo detector
This will have an output that switch to +5V when the light is
blocked, and about +0.5V when the lights is allowed to pass through
the slots in the disc. The frequency of the output waveform is
given by;
where; Frequency of output waveform Speed of the motor in
revolution per minute Number of slots at the disc
Hence, from the frequency equation, the speed of dc motor in rpm
is given by;
At the end of this study, the operation of dc motor is
understood. Also, different types of speed measurement techniques
have been discussed. Lastly, IR sensor will be used for the speed
measurement in this project as it was recommended one of the best
techniques for speed detection.
2.2 Literature Review
2.2.1 Reviews on video tracking and wireless speed control
robotics from 1966 to 2008
Researchers have pioneered the art and science of robotics
technology over the past 66 years. Mobile robotics research has
played a key role in the application of robots in our world. A
mobile robot is a mechanical device that can perform preprogrammed
physical task; it may act under the control of a human or under the
control of preprogrammed software (Li, 2001). Teleoperated mobile
robotics is remotely operated vehicles designed to perform tasks in
coordination with human operators (Dastor, 2009). Teleoperated
mobile robotics can be realistically enhanced by a level automation
removing challenges such as constant monitoring. Nils Nilsson
developed the first mobile robot SHAKEY at Stanford University from
1966 to 1972. It was the first mobile robot with the ability to
reason and react to its environment. This robot possessed a visual
range finder, a camera and binary tactile sensors. It was the first
mobile robot to use artificial intelligence to control its actions.
Its main objective was to navigate through highly structured
environments. Shakey has had a substantial influence on present-day
artificial intelligence and robotics. Using a TV camera, a
triangulating range finder, and bump sensors, Shakey was connected
to DEC PDP-10 and PDP-15 computers via radio and video links.
Interoperating programs with varying levels of sophistication
provided Shakey with the ability to combine simple movements and
environmental perception into robust, complex tasks, enabling it to
achieve goals given by a user. The system also generalized and
saved these plans for possible future use. Inducted into the Robot
Hall of Fame in 2004, Shakey is today on display at the Computer
History Museum in Mountain View, California (Nilsson, 1984).Lunar
rover, developed in the 1970s at the Jet Propulsion Laboratory, was
designed for planetary exploration. Using a TV camera, laser range
finder and tactile sensors, the robot categorized its environment
as traversable, not traversable and unknown. Alunar roverorMoon
roveris aspace explorationvehicle designed to move across the
surface of theMoon. Some rovers have been designed to transport
members of ahuman spaceflightcrew, such as theApollo Lunar Roving
Vehicle; others have been partially or fullyautonomous robots, such
asLunokhod 1 (Weisbin, et al., 2008).Flakey was developed between
1982 1995; fully functional in 1985. It was a mature custom-built
mobile robot platform, approximately one meter high and 0.6 meter
in diameter. The hardware has remained stable with relatively minor
additions to the sensing and communications capabilities since
1985. There are two independently-driven wheels, one on each side,
providing a maximum linear velocity of about 500mm/sec and turning
velocity of 100 deg/sec. Flakeys sensors included a ring of 12
sonar range finders, wheel encoders, and a video camera used in
combination with a laser to provide dense depth information over a
small area in front of the vehicle. Flakeys onboard computers
included a workstation and other processors dedicated to sensor
interpretation, motor control, and radio communications (Saffioti,
1993).Hans Moravec developed CART in the Artificial Intelligence
laboratory at Stanford. Cart is a card-table sized mobile robot
controlled remotely through a radio link, and equipped with a TV
camera and transmitter. A computer has been programmed to drive the
cart through cluttered indoor and outdoor spaces, gaining its
knowledge about the world entirely from images broadcast by the
onboard TV system and performed obstacle avoidance by gauging the
distance between CART and obstacles in its path. The system is
moderately reliable, but very slow. The cart moves about one meter
every ten to fifteen minutes, in lurches. After rolling a meter, it
stops, takes some pictures and thinks about them for a long time.
Then it plans a new path, and executes a little of it, and pauses
again. Moreover, In 1964-71The cart evidently sat unused in an ME
laboratory until 1966 when Les Earnest, a senior research scientist
who had recently joined the Stanford Artificial Intelligence Lab
(SAIL), found it and talked its creator, James Adams, into letting
SAIL use it to try navigating on the road around SAIL under
computer control using visual references. However the radio links
and other electronics that had existed earlier had vanished, so he
recruited Electrical Engineering PhD student Rodney Schmidt to
built a low power television transmitter and radio control link and
undertake the visual guidance project (Moravec, 1983).From 1993 to
2001 LURCH (for Large, Useful Robot Controlling Hazards) was
designed for control of robot functions in realistic outdoor
terrain and is operated using high-level directives from a remote
station connected via a packet-switched radio network. LURCH was
created by modifying an Andros Mark V-A robot from Remotec, Inc. to
incorporate SRIs planning and control system. Enhancements include
onboard control of the mobile base and a manipulator arm based on a
ruggedized PC system. Onboard sensors include stereoscopic vision,
16 ultrasonic sensors, and encoders for all robot, manipulator, and
camera motions.ERRATIC and Pioneer 1994present, is a smaller
version of flakey with the same differential drive and sonar
sensors, but without vision capabilities. Addressing the need for
an easy-to-construct, low-cost robot development platform, SRI
designed ERRATIC to run as a robot server from a host computer over
a remote serial connection. It provides basic functions of
forward/back velocity and angular position integration stall
sensing, and sonar ranging. Pioneer I is a production version of
the ERRATIC platform. The real-time controller for ERRATIC
(Saphira) is based on software developed at SRI on the Flakey
project; it was a commercial version by Erratic made by real world.
The software runs a reactive planning system with a fuzzy
controller, behavior sequencer, and deliberative planner with
integrated routines for sonar sensor interpretation, map building,
and navigation (Ericson, 2003).From 1995-present robotic systems
are becoming smaller, lower power, and cheaper, enabling their
application in areas not previously considered. This is true of
vision systems as well. SRIs Small Vision Module (SVM) is a
compact, inexpensive real-time device for computing dense stereo
range images, which are a fundamental measurement supporting a wide
range of computer vision applications. We describe hardware and
software issues in the construction of the SVM, and survey
implemented systems that use a similar area correlation algorithm
on a variety of hardware. The hardware consists of two CMOS 320x240
grayscale imagers and lenses, low-power A/D converters, a digital
signal processor and a small flash memory for program storage. All
of these components are commercially available. The SVM is packaged
on a single circuit board measuring 2" x 3" (Figure 1).
Communication with a host PC for display and control is through the
parallel port. During operation, the DSP and imaging system consume
approximately 600mW. SRI is developing the next generation of this
device, which will feature nearly a 600-percent performance
improvement (Konolige, 1995).The Centibots were developed from 2002
to 2004, they are mobile coordinated robots that can autonomously
and effectively explore map and survey the interior of unknown
building structures. The Centibots marked a milestone in robotics,
representing the largest collection (more than 100) to date of
coordinated autonomous mobile robots. These autonomous team robots
were designed to augment the situational awareness of human teams
such as crisis response teams in situations that could pose a
threat to people. Centibots improve upon current robot
architectures, which rely on large, power-hungry subsystems for
mobility, communication and control, and are limited to only
individual or small teams of robots (Konolige, et al, 2003).LAGR
was developed 2005 present, Real-time vision and learning
technologies are at the core ofthe DARPA Learning Applied to Ground
Robotics (LAGR) program to develop autonomous off-road navigation.
The goal is to develop sensing- and-camera-based techniques for
learning the mobility properties of objects in a new environment
and planning and control techniques for using this information to
avoid such difficulties as loose sand, bushes, and cul-de-sacs.SRI
developed color-and-texture-based techniques for learning and
recognizing paths and obstacles; a real-time, stereo-based visual
odometry technique for precisely locating the robot as it moved
through complex outdoor environments; mapping of features for later
runs; and very efficient, low-level control techniques so the robot
could rapidly traverse planned paths and quickly free itself
(Erkan, et al, 2007).Trauma Pod and Medical Automation Robots was
developed 2005 present. SRI is the lead integrator on a
collaborative DARPA program to develop a futuristic
battlefield-based, unmanned medical treatment system dubbed the
Trauma Pod. This system could stabilize injured soldiers within
minutes of a trauma and administer life-saving medical and surgical
care prior to evacuation and during transport. Related developments
are under way: dexterous robotic tools to improve patient outcomes
and enable new procedures through development of nimble, smaller
endoscopic tools; additional automation tools for the operating
room; and remote delivery of trauma care. SRIs M7 surgical robot
conducted the first-ever acceleration compensated medical procedure
in zero gravity flight for NASA. The M7 was also the first surgical
robot to be successfully deployed to an undersea habitat simulating
the rigors of outer space in NASAs Extreme Environment Mission
Operation (NEEMO), demonstrating remote surgery over 1,200 miles of
public Internet. One year later, the M7 demonstrated the first
autonomous ultrasound guided medical procedure in the same undersea
laboratory. Last but not the least, telerobotics Assistance for the
Elderly and Disabled was presented in 2008 by SRIs
multidisciplinary approach to solving major global challenges has
prompted researchers to invent robot-based solutions that would
help manage assistance and care of the elderly and the disabled.
Robots built on SRIs telepresence technology could provide
real-time remote monitoring, physical support, therapeutic advice,
and communication between patient and caregiver, and among the
patient, family members, and clinical personnel (Lanuzzi,
2008).From the above journals reviewed, it is concluded that the
topic of research is an advanced area of control engineering which
is commonly being explored by control engineers. The application of
real time video tracking and wireless speed control robot to solve
complex problems is rapidly increasing.
CHAPTER 3
SYSTEM DESIGN
3.1 Overview of the design process as block diagram
The block diagram represented in Figure 3.1.1 gives an intuitive
description of the various stages involved in order to achieve real
time video tracking and wireless speed control. As seen below, the
project consists of two parts, transmitter section and receiver
section.
Figure 3.1.1: Overview of the design shown as a block
diagram
3.1.1 Wireless transmitter and receiver section block diagram
and description
3.1.1.1 Wireless transmitter section block diagram and
description
The Transmitter section consists of RS232, PIC16F873A
microcontroller, encoder, RF TX Module. This section is based on
computer control. The visual basic program downloaded into the PC
enables the rapid application development (RDP) of graphical user
interface which will allow the user to control the speed and
positioning of the robot from the computer. This is made possible
by interfacing the microcontroller with the computer using MAX232
through RS232 serial communication. RS232 (recommended standard
232) support both synchronous and asynchronous transmissions and
its user data is send as a time series of bits. Max232 is an
integrated circuit that converts signals from an RS-232 serial port
to signals suitable for use in TTL compatible digital logic
circuits such as the microcontroller. The serial data sends from
the PC through RS232 gets converted to parallel data and is fed to
the PIC microcontroller and vice versa. The microcontroller PIC
converts the received data to pulses which undergo modulation by
the encoder. RF TX transmits the modulated signals to the RF Rx
section.
Figure 3.1.1.1.1: Wireless transmitter section block diagram
3.1.1.2 Wireless receiver section block diagram and
description
The Receiver section consists of RF receiver module, decoder,
Micro controller, motor driver, transistor, and dc motors.
RF_RX_315MHz receives the transmitted signals. This signal
undergoes demodulation to suppress the carrier and decode back the
original data. The output is finally fed to the Micro controller
(PIC), which gives the directives to three major circuits
respectively. These include the motor-driver circuit, and the
firing control and lastly the LCD circuit depending on the user
input. Output from the microcontroller is fed to C1815 transistors
before going to the L293D motor driver circuit. This is because the
motors attached to the output of the driver needs high current to
activate. The signals received by the motor-driver circuit will
enable the motor to choose the direction that it is supposing to be
running in and also to come to a complete stop if that is what the
user instructed. Furthermore, one of the signals received from user
inputs will be a control reference. The control reference inputted
will be fed into the PIC in-built PWM circuit to generate an
appropriate duty ratio that will be sent to the wheels of the
motor, these PWM control signals will directly control the speed
and direction of the dc motor with the aid of the motor driver. The
variation of the PWM is directly proportional to the increase and
decrease of the motor speed. Notice that, although the voltage has
fixed amplitude, it has a variable duty cycle which means the wider
the pulse, the higher the speed and vice versa. The signals
received by the transistor will turn the laser gun on/off. And
lastly, to accomplish a closed loop model, infra red (IR) sensor
mounted on the motor shaft is fed back to the microcontroller.
Infra red detectors convert incoming infra red light into electric
current. The microcontroller is interfaced with Liquid Crystal
Display (LCD) for speed display purposes.
Figure 3.1.1.2.1: Wireless Receiver Section block diagram
3.2 Hardware design details
3.2.1 Microcontroller
3.2.1.1 Choice of microcontrollerThere are many types of
microcontroller available in the market for example Motorola, Atmel
and PIC microcontroller. Although main specifications are a little
bit different; however the concepts are similar with each other.
Basically, microcontrollers must contain at least two primary
components random access memory (RAM), and an instruction set
(Hill, 2000). RAM is a type of internal logic unit that stores
information temporarily. RAM contents disappear when the power is
turned off. While RAM is used to hold any kind of data, some RAM is
specialized, referred to as registers. The instruction set is a
list of all commands and their corresponding functions. During
operation, the microcontroller will step through a program (the
firmware). Each valid instruction set and the matching internal
hardware that differentiate one microcontroller from another.Most
of the microcontrollers also contain read-only memory (ROM),
programmable read-only memory (PROM) or erasable programmable
read-only memory (EPROM) (Hill, 2000). All of these memories are
permanent: they retain what is programmed into them even during
loss of power. They are used to store permanent lookup tables.
Often these memories do not reside in the microcontroller; instead,
they are contained in external ICs, and the instructions are
fetched as the microcontroller runs. This enables quick and
low-cost updates to the firmware by replacing the ROM. After going
through number of journals and books the microcontroller type
chosen for this project is a PIC microcontroller. PIC MC is a
family of Harvard architecture that has separate storage (program
or data memories can have different bits depth) and signal pathways
for instruction and data. A microcontroller with Harvard
architecture can both read an instruction and perform a data memory
access at the same time, even without a cache. It can thus be
faster for a given circuit complexity because instruction fetches
and data access do not contend for a single memory pathway. 3.2.1.2
PIC microcontroller for transmitter and receiver
In transmitter section, PIC16F873A micro controller is chosen to
be used as the control system of the robot. This is due its low
power consumption (wide operating voltage range from 2.0 to 5.5 V)
high speed Flash/EEPROM technology, easy to program (only 35
single-word instructions execution) and its pin out compatibility
to other 28/40pin like PIC16F877A microcontrollers. Furthermore,
the PIC 16F873A microcontroller has the ability to withstand both
commercial and industrial temperature ranges. However, the most
important reason for selecting this chip is because of its built-in
PWM Generator module. Pulse Width Modulation is critical to modern
digital motor controls. By adjusting the pulse width, the speed of
a motor can be efficiently controlled without larger linear power
stages. These modules are built into the Capture/Compare/PWM (CCP)
peripheral. As previously mentioned PIC16F873A has two CCP modules.
Each CCP module is software programmable to operate in one of three
modes: 1) A Capture input, 2) A Compare output and 3) A Pulse Width
Modulation (PWM) output. For the CCP module to function, Timer
resources must be used in conjunction with the CCP module. The
desired CCP mode of operation determines which timer resources are
required.While in receiver section, PIC 16F877A microcontroller has
been selected for the purpose of controlling the speed of the dc
motor on the receiver section. It is a simple but powerful
controller only 35 single word instructions to program the chip.
This controller chip has been selected based on several reasons
these are; its portable and consumes less current. Small in size
and equipped with sufficient output ports more also, it has
built-in PWM module which allow us to vary the duty cycle of the
motor drive. And lastly, it provides an ease of programming and
reprogramming (up to 10,000,000 cycles). MC communicates with the
outside world through the input and output (I/O) port pins. The
number of I/O pins per controllers varies greatly, plus each I/O
pin can be programmed as an input or output (or switch during the
running program). The load (current draw) that each pin can drive
is usually low. If the output is expected to be a heavy load, then
it is essential to use a driver chip or transistor buffer. The
entire pins have multiple functions, depending on the operating
mode and data control registers.
3.2.2 Power supply circuit
3.2.2.1 Transformer and regulator IC choice
PIC16F873A microcontroller requires a stable 5V TTL input to
activate. Also, the encoder PT 2262 and RF_Tx_315MHz requires
stable 9 V TTL input to operates. Power supply circuit is designed
for this purpose because dc lead-batteries do not provide
consistently stable output voltage. An LM7805 and LM7809 are used
to regulate the input voltage. LM78** series has three legs; the
input line voltage, the output regulated voltage and common ground.
According to the datasheets, the reference voltage should be
slightly higher than the desired output voltage hence the source in
this circuit is 12 V - 1 A lead acid battery. To avoid the excess
energy dissipated on the regulator IC, a heat sink is introduced. A
backup circuit is designed using, 230 V ac source, bridge
rectifier, filter, regulator and centre tapped step down
transformer. From the requirement stated above 5 V dc and 9 V dc
level voltages are required to activate the ICs. Therefore, LM7805
and 7809 are needed to regulate the voltage in order to fulfill the
requirement. Block diagram for the arrangement is given below.
12 V, DCDiodeFilter LM78**Figure 3.2.2.1.1: Battery powered
power supply
In Figure 3.2.2.1.1, the transformer is used to step down the
240 AC supply voltage. A bridge rectifier coupled with filter
circuit convert the AC current to DC current and suppresses all the
remaining AC levels. The regulator received and regulates the DC
voltage to the required level.
230 V, 50 Hz AcTransformer 25:1Bridge Rectifier Filter Regulator
LM78**Figure 3.2.2.1.1: Transformer powered power supply
3.2.2.2 Power supply simulation and discussion
3.2.2.2.1 Decoupling Capacitors and bridge rectifier
The bridge rectifier converts AC to DC, the output of the bridge
rectifier is fed to the stabilizing capacitors. The decoupling
capacitors C1 and C2 are used to stabilize the output in order to
maintain a consistently stable output. From Figure 3.2.2.2.3 we can
see that the line in blue represents the voltage after been
filtered by capacitor C1, the voltage at this stage is 12.245 V.
This 12.245 V is regulated to 5 V by LM7805. The remaining ac
component is filtered out by capacitor C2 in order to maintain a
consistently stable output. Lastly, the desired output has been
determined and it represents the voltage level in red.
230 Vrms, 50 Hz AC supply25:1 centre-tapped step down
transformerBridge rectifier 1B4B42Filter 2.2 mF and 48 uF capacitor
C1 and C2 respectively.Voltage regulator LM7805 Digital voltmeter
and Oscilloscope
3.2.2.2.2 Desired output parametersAs stated earlier PIC16F873A
microcontroller requires a stable 5 V TTL input to activate. Also,
the encoder PT 2262 and RF_Tx_315MHz requires stable 9 V TTL input
to operates. Power supply circuit is simulated and it provides
consistently stable output voltage using LM7805 and LM7809 to
regulate voltage. Most MC operates under a recommended current, 5
mA. If the microcontroller is driving several circuits therefore
the current will be set to exceed 5 mA. As seen from Figure
3.2.2.1.1 the desired output current and voltage have been
determined. Also, LM7809 regulator was used to determine the dc
level voltage that will activate the encoder PT 2262 and
RF_Tx_315MHz. From the components prepared, power supply circuit
connections were made using Multisim 11.0 software as shown in
Figure 3.2.2.1.1 and Figure 3.2.2.1.2. Figure 3.2.2.1.1: Power
supply simulation using 12 V DC as source voltage Figure 3.2.2.1.2:
Power supply simulation using 230 V, 50Hz as source voltage
Figure 3.2.2.1.3: Oscilloscope output ac to dc level voltage
3.2.2.2 Power supply design calculations
It is of importance to check if the power supply simulation
agrees with our calculated values. Referring to figure 3.2.2.1.2
the calculations can be obtained using mathematical equations given
below;
The solution given above is for the power supply design
calculations, it is based on the design the power supply will be
developed. Analysis will be made to see if the design calculations
correspond with the hardware implementation. Hence, the objective
of this task is accomplished. Also from the power supply simulation
the output was regulated to 5 V, 9 V and 12 V which serves as the
input supply to the microcontroller circuit, motor driver circuit,
and the laser gun circuit.
3.2.2.3 Parameters selection and circuit design calculations
3.2.2.3.1 MC oscillator design calculations and simulation
Microcontroller operates functionally if a clock signal is
supplied to it. Availability of different oscillator frequencies
makes it necessary to review on past and present works this will
lead you towards understanding various types of oscillator
frequencies and their respective applications. Therefore, it is
required to make the selection depending upon the requirements and
specifications, such as; Clock speed (high speed) RC oscillator Low
power crystals Internal RC mode
3.2.2.3.2 Frequency selection
In this project it is required to use a high performance crystal
with a high speed in order to get rid of delay and speedup wireless
transmission of data (bytes). An important notice is stated in the
RF module RX_PT 2272 datasheet, say, if the module is used with
microcontroller, the frequency should be under 4 MHz. With respect
to this a 4 MHz frequency oscillator is selected. This entails that
with a clock frequency of 4 MHz, the processor utilized in this
project can process data 4 million times in every seconds for every
clock cycle. Another reason for its selection is that ceramic
oscillator provide more stable frequency signal that other
oscillators like RC oscillator although are cheaper and consume
less power but produce inaccurate frequency which is not suitable
for timing applications. Accordingly, after conducting numerous
literatures a consensus is reached and a 4 MHz clock is selected
based on energy efficiency (consume less power) and operational
speed (stable frequency). Two 22 pF capacitors were use to filter
out external noise from interfering the crystal frequency. Aside
from the oscillator, another essential circuit for this
microcontroller is the Master Reset circuit. Once a low input is
given to the pin 1 (MCLR/THV), the microcontroller will be reset
and start to execute the very first instruction which is already
been programmed into it. Therefore, in the circuit, a pull-up
resistor is connected to the pin. Once the pull-up resistor is
omitted, the microcontroller will be reset. Now, the period can be
obtained by substituting 4 MHz for the clock source. So:Let,The
instruction cycle frequency = The instruction cycle time = Now,
(3.2.2.3.2.1)
Therefore the instruction cycle time i.e. the period can be
returned as, (3.2.2.3.2.1)
3.2.2.3.3 Justification of results using Multisim 10.0 In this
project, Multisim 11.0 software was used in order to justify our
calculated results.
Figure 3.2.2.3.3.1: MC oscillator
Frequency Counter was used to verify the amount of frequency fed
into the MC as the frequency is the rate at which the periodic
waveform repeats itself and is measured in Hz.
Figure 3.2.2.3.3.2: Frequency counter displaying 4MHz
crystal
We know that, period (T) is the reciprocal of frequency (), and
referred to the time it takes a periodic pulse waveform ( ) to
repeats itself at a fixed interval and is measured in sec. Hence,
by simulation, the period can be returned as;
Figure 3.2.2.3.3.3: Frequency counter displaying Period of 250
nsec
Table 3.2.2.3.3.1: Frequency and period output parameters
ParametersCalculated valuesSimulated values
Frequency4MHz4MHz
Period250ns250ns
From the results obtained, the simulation results have solemnly
justified the calculated results this entails that our design is
correct. Therefore, the objectives are achieved.
3.2.2.4 Choice of resistors between MC and encoder
The output from the MC has a limited supply of current which is
not enough to transmit data to the encoder. To solve this problem,
pull up resistors were connected in series with the MC output pins
in order to boost up the current to a mA level that can enable the
transmission.
3.2.2.4.1 Calculated results
Design parameters;
;
(3.2.2.4.1.1)
(3.2.2.4.1.2)
(3.2.2.4.1.3)
3.2.2.4.2 Simulated results for pull up resistor
From the result obtained using MULTISIM 11.0 we may say that,
the simulation results have justified the calculation results.
Figure 3.2.2.4.2.1 Simulated result for pull up resistor
It should be noted that are selected as. Therefore, the current
flowing through each of the above mentioned resistors to activate
the encoder is 5.000 mA.
3.2.3 DC MOTOR
This project required the design of a 4 wheel car as it is for
military application therefore two motors are required to control
the movement of the robot in all direction. However the control is
the back wheel type whiles the front wheels moves freely. DC geared
motors were selected over the stepper motors because dc motor can
deliver high torque at higher speed than steppers, a feedback using
IR can be used which can report back to microcontroller the actual
operating speed for error correction and lastly, the requirement of
the project was that the movement of the robot should be smooth in
correspondence with reference input speed which can be realized
practically only through dc motors as stepper motors moves in steps
upon receiving input signals.
3.2.3.1 DC MOTOR DRIVER CIRCUIT
DC motors draw a relatively higher current in comparison to
servo motors. The PIC 16F877A microcontroller can only provide a
maximum of 25 mA current from its I/O pins which is insufficient
for motor operation. Therefore, an L293D motor driver was used
which can provide a maximum of 2.0 A current to dc motors. Also,
this IC has an equivalent circuit of a dual H-bridge which implies
that one IC is used for bidirectional control of two motors
simultaneously.
3.2.3.1.1 Motor driver L293D INPUT CIRCUIT
The output from the microcontroller is approximately a 3.3 mA
current and the motor driver L293D needs high current in order to
drive the motor, to solve this problem transistor is used as a
switch. Transistor, when used as an electronic switch is normally
operated alternately in cutoff and in saturation. Digital circuits
make use of the switching characteristics of transistors.
3.2.3.1.1.1 Transistor used as an electronic switch
The basic operation of transistor as a switching device is
illustrated in Figure 3.2.3.1.1.1.1. In the first part, the
transistor is in cutoff region because the base-emitter junction is
not forward-biased. In this condition, there is, ideally, an open
between collector and emitter, as indicated by the switch
equivalent. While in the second part, the transistor is in the
saturation region because the base-emitter junction and the
base-collector junction are forward-biased and the base current is
made large enough to cause the collector current to reach its
saturation value. In this condition, there is, ideally, a short
between collector and emitter, as indicated by the switch
equivalent. Actually, a voltage drop of up to a few tenths of a
volt normally occurs, which is the saturation voltage,
Figure 3.2.3.1.1.1.1: Ideal switching action of a transistor
schematic
3.2.3.1.1.2 Analysis of a transistor switching circuit for
cutoff and saturation
3.2.3.1.1.2.1 Conditions in cutoff
As mentioned earlier, a transistor is in the cutoff region when
the base emitter junction is not forward-biased. Neglecting leakage
current, all of the currents are zero, and is equal to,
(3.2.3.1.1.2.1.1)
3.2.3.1.1.2.2 Conditions in saturation
When the base-emitter junction is forward-biased and there is
enough base current to produce a maximum collector current, the
transistor is saturated. The formula for collector saturation
current is,
(3.2.3.1.1.2.2.1)
Since is very small compared to, it can usually be neglected.
The minimum value of base current needed to produce saturation
is;
(3.2.3.1.1.2.2.2)
should be significantly greater than to keep the transistor well
into saturation.
3.2.3.1.1.3 Design calculations of the L293D driver input
circuit
3.2.3.1.1.3.1 Condition 1 (transistor in cutoff)
The criterion used to analytically determine the output voltage
() when the transistor is in cutoff i.e. the Square wave fed to the
transistor (C1815) is at 0V can be returned as;*Note: - All
resistors chosen are 1 K each
1.0KV+ = 12V1.0K1.0KV+ = 12VFigure 3.2.3.1.1.3.1.1: Transistor
in cutoff region schematic
From above diagram it is seen that when the input, the
transistor is in cutoff (i.e., it act as an Open switch) and hence
3.2.3.1.1.3.1.1 Verification of transistor results in cutoff region
by voltage divider rule
According to the rule, the voltage across an element is equal to
the resistance of the element divided by the total resistance of
the series circuit and multiplied by the total impressed
voltage:Now;
(3.2.3.1.1.3.2.1)
Hence, the output voltage is equal to 12V and is fed to the
driver chip L293
3.2.3.1.1.3.1.2 Using ohms law to determine the Base Current
(3.2.3.1.1.3.3)
3.2.3.1.1.3.1.2 Condition 2 (transistor in saturation)
The criterion used to analytically determine the output voltage
() when the transistor is in cutoff i.e. the Square wave fed to the
transistor (C1815) is at 0 V can be returned as;*Note: - All
resistors chosen are 1 K each 1.0KV+ = 12V1.0K1.0KV+ = 12VFigure
3.2.3.1.1.3.4.1: Transistor in saturation region schematic
From above diagram it is seen that when the input, the
transistor is in saturation (i.e., it act as an closed switch) and
hence
3.2.3.1.1.3.1.2.1 Verification of transistor results in
saturation region by Voltage Divider Rule
According to the rule, it states that the voltage across an
element is equal to the resistance of the element divided by the
total resistance of the series circuit and multiplied by the total
impressed voltage:Now;
Hence the output voltage is equal to 0V
3.2.3.1.1.3.1.2.2 Using Ohms to determine the Base Current
Hence, the base current is 0 ATherefore , the design
calculations shows that if a 0 V input is fed as an input to a
transistor in cutoff region the corresponding output will be the
voltage supplied at the collector junction likewise if a 5 V input
is fed to a transistor in saturation region the corresponding
output will be 0 V. To generate high current the four outputs pins
of the PIC microcontroller goes through a transistor to the L293D
driver.3.2.3.1.1.4 Transistor circuit simulation using ISIS 7
professional software
Simulation of L293D driver input circuit was performed using
ISIS 7 professional software based the above calculated design
parameters. The simulation results are shown below.
3.2.3.1.1.4.1 Simulation of transistor in cutoff region using
ProteusFrom the aforementioned components, connection were made
successfully using ISIS 7 professional as shown in figure
3.2.3.1.1.4.1.1
Figure 3.2.3.1.1.4.1.1: Proteus simulation showing transistor in
cutoff region
As explained earlier, the transistor is in cutoff only when the
base emitter junction is not forward-biased. Neglecting leakage
current, all of the currents are zero. From the diagram above we
can see that when the reference voltage V1 = 0 V, its results to a
negative current -1.943 pA. According to ohms law, at constant
temperature voltage is directly proportional to current. Due to the
fact that the circuit is now acting as an open circuit, voltage V2
directly flow through the output. Indicators were used to at the
reference and output stage to indicate when the voltage is either
high or low. At this condition, the reference stage indicator is
low while the output stage indicator is high. This proved to us
that the calculated results were correct and can activate the
motors. Therefore, the dc output 12 V is fed as an input to the
driver IC L293D.
3.2.3.1.1.4.2 Simulation of transistor in saturation using
Proteus
The transistor is in saturation only when the base-emitter
junction is forward-biased and there is enough base current to
produce a maximum collector current. According to ohms law, at
constant temperature, voltage is directly proportional to current.
From the diagram above we can see that when the reference voltage
V1 = 5 V, its results to a positive current 4.277 mA Due to the
fact that the circuit is now acting as a closed circuit, voltage V2
does not flow through the output directly. Indicators were used at
the reference and output stage to indicate when the voltage is
either high or low. At this condition, the reference stage
indicator is high while the output stage indicator is low. This
proved and justified our calculated results
Figure 3.2.3.1.1.4.1.1: Proteus simulation showing transistor in
saturation region
This proved to us that our calculated results were correct and
can activate our motors. Hence, the dc output 12 V is fed as an
input to the Motor Driver IC L293.3.2.4 Design of interfacing
circuits
Since the circuit design and components selection is being
achieved successfully, design and discussions on how to provide
interaction to enable transmission and reception of signals between
selected components is given below.
3.2.4.1 Interfacing Serial (DB9) with PC
Presently, most PCs has a 9 pin connector on either the side or
back of the computer. From Table 3.3.1.1 it is seen that the PC can
send data (bytes) to the transmit pin (i.e. pin 2) and receive data
(bytes) from the receive pin (i.e. pin 3. The Serial port (DB9)
rs232 (recommended Standard 232) is much more than just a connector
to PC because it converts data from parallel to serial and changes
the electrical representation of the data. If the connector on the
PC has female pins, therefore the mating cable needs to have a male
pin connector to terminate in a DB9 connector and conversely. Data
bits flow in parallel from the PC because it uses many wires at the
same time to transmit whereas serial flow in a stream of bits from
the serial connector because it transmit or receive over a single
wire. The serial port create such a flow by converting the parallel
data to serial on the transmit pin (i.e. pin 2) and conversely. The
serial port has a built-in computer chip called UART used in
translating data between parallel and serial forms. Table
3.2.4.1.1: RS232 pin assignments (DB9 PC signal set)
Pin 1Input DCDData Carrier Detect
Pin 2InputRXDReceived Data
Pin 3OutputTXDTransmitted Data
Pin 4Output DTRData Terminal Ready
Pin 5NilNilSignal ground
Pin 6InputDSRData Set Ready
Pin 7 Output RTSRequest To Send
Pin 8InputCTSClear To Send
Pin 9InputRIRing Indicator
3.2.4.2 Interfacing MAX232 with serial (DB9)
Max232 is an integrated circuit that has a dual driver/receiver
and typically converts signals from an RS-232 serial port to
signals suitable for use in TTL compatible digital logic circuits
such as the microcontroller. The serial data sends from the PC
through RS232 gets converted to parallel data and is fed to the PIC
microcontroller and conversely. When a TTL level is fed to Max232
IC, it converts TTL logic 1 to between -3 V and -15 V, and converts
TTL logic 0 to between +3 V to +15 V and conversely when converting
from RS232 to TTL. The table below clarifies the RS232 transmission
voltages at a certain logic state are opposite from RS232 control
line voltages at the same logic state.
Table 3.2.4.2.1: RS232 Line Type and Logic Level
Rs232 line type and logic levelRs232 voltageTTL voltage to/from
MAX 232
Data transmission (Rx/Tx) logic 0+3V to +15V0V
Data transmission (Rx/Tx) logic 1-3V to -15V5V
Control signals (RTS/CTS/DTR) logic 0-3V to -15V5V
Control signals (RTS/CTS/DTR) logic 1+3V to +15V0V
Figure 3.2.4.2.1: RS23 Interface with Max232
3.2.4.3 Interfacing MAX232 with PIC16f873A
To enable communication between the PC and the Microcontroller
the MAX232 IC circuit serves as a tool of interface. As stated
earlier, MAX232 converts parallel data (bytes) transmitted from the
PC to serial bits stream because most digital devices require TTL
or CMOs logic levels. The first step to consider when connecting
the device to RS232 serial port is transformation of RS232 voltage
levels into 0 and 5 volts. This is not possible without the RS232
level converters such as MAX232. In this project, MAX232 is one of
the most important circuits used in order to interface PIC16F873A
or modem of the computer. From Figure 3.2.4.3.1 it is seen that the
output pin 10 of CMOS or TTL is fed to pin 17 of PIC16F873A and the
output pin 18 of PIC16F873A is fed to CMOS or TTL. Hence, this is
how the microcontroller communicates with the MAX232 IC.
Figure 3.2.4.3.1: MAX232 interface with PIC16F873A
3.2.4.4 Remote control encoder PT2262 and decoder PT2272
The circuit is made up of digital encoding chips PT 2262 for
high power transmitter modulation signal paired with high
sensitivity decoding chip matching circuit PT 2272 for long
distance and wireless control (speed and position). Both chips have
12 bits of maximum tri-state address pins providing up to 531,441
(or 3^12) address codes; by that means, it drastically reduce any
code interference and unauthorized code scanning possibilities.
Both chips encode data and address pins into a serial waveform
suitable for RF modulation. Furthermore, when PT 2262 encodes the
code address and data set at A0 ~ A5 and A6/D5 ~ A11/D0 the output
is fed to DOUT (pin 17) only if TE (pin 14) is pulled to 0 (low
state). This waveform is fed to RF modulator for transmission. The
modulated radio frequency is received by the RF demodulator at the
receiver section and reshaped it back to its original waveform. The
decoder PT 2272 is then used to decode the waveform and set the
corresponding output pins. It has a built-in oscillator circuitry
that allows a precision oscillator to be constructed by connecting
a resistor between OSC1 (pin 15) and OSC2 (pin 16) which determines
the fundamental frequency of the encoder PT 2262. Therefore, for
PT2272 to decode correctly the received waveform, the oscillator
frequency PT 2272 must be 2.5 ~ 8 times that of transmitting PT
2262. In this project, 4.7 Mohm and its correspondence oscillator
resistance 820 K* is selected for PT 2262 and PT 2272 respectively.
Note that, 820 K* operates when PT 2272s Vcc = 5 V to 15 V. This
entails that if the supply is lower than 5 V, a lower oscillator
resistor value for both PT 2262 and PT 2272 should be used.
3.2.4.5 RF transmitter and receiver module
One of the main objectives of this project is to achieve
wireless communication between the transmitter and receiver section
this is made possible using RF_TX_315 MHz transmitter and RF-Rx_315
MHz receiver module. In this project, a low cost transmitter and
receiver module is used to transmit signals up to 100 meters at
specified frequencies and hence the antenna design, Linton college
working environment and supply voltage will seriously impact the
effective distance. It short distance, and battery power device
development fits our requirement as we are to demonstrate only
within the college premises. RF_TX_315 have wide operating voltage
range (3 V 12 V), current range, transfer rate of , transmitting
power of and lastly antenna length of 24 cm. While RF-Rx_315
operating voltage range starts from , operating current range ,
bandwidth of 2 MHz, its sensitivity is , and a transfer rate of and
lastly data output is TTL. They both have the same modulation
technique (ASK/OOK), the same frequency (315 MHz). The encoded
waveform from DOUT (pin 14) of PT 2262 is fed to RF_Tx_315 MHz
modulator for transmission. The modulated radio frequency is
received by the RF demodulator at the receiver section and reshaped
it back to its original waveform. It is important to note that
since the module is used with microcontroller, the clock frequency
should be less than or equal to 4 MHz. More also, keep distance
between oscillator and the RF modules to avoid the disturbance from
oscillator.
3.3 REAL TIME VIDEO TRACKING
Another important objective of this project is to obtain real
time video tracking. To achieve that Digital Surveillance camera
was selected among other wireless camera. This camera is selected
based on its transmission range and high resolution. It enables the
transmission and reception of real time video up to 328.083 ft with
a very high resolution. The camera transmitter and receiver need 9
V and a current of 200 500 mA to power on. Screws were used to
install the camera on the robot, and then a 9 V battery is used to
power the transmitter. The wireless receiver is connected to
USB-enabled which enables the wireless receiver to be plugged into
the USB port of the PC. Another advantage of selecting this camera
is because of it size. It portability definitely will reduce
complexity of the mechanical design.
3.4 MECHANICAL DESIGN The mechanical design of this robot
consists of the chasis of the main structure of the military robot.
The entire model was designed in Solidworks software. This was done
in order to reduce make the real fabrication easier, faster and
less expensive (due to exact dimensions of the parts). Individual
mechanical components were designed separately and then assembled
together to check if they fit with each other. During the design
process, wireless camera slots, later gun stand, sensor slots,
wiring, DC and servo motor positions were put into considerations.
All chassis was design was made of hard plastic. The entire set of
designs is attached in Appendix C.
3.5 SOFTWARE DESIGN The software design serves as a vital role
in the operation of the whole system, the system will not operate
without the software. An algorithm needs to be established to
enable the PIC controllers read the input and respond accordingly.
The programming language selected for this project is the C
program. The C program will enable communication between the user
and the system, and many different interfaces in the system. With
the software downloaded into it, microcontroller acts as brain of
the whole video tracking and wireless speed control system. It will
receive the desired speed from user through PC via the RS232 serial
port. The actual speed will be compared with the desired speed and
the correction will be done by microcontroller in order to maintain
the desired speed of the motor. The flow chart diagram developed
will give an intuitive description of the system software. The
programs are divided into two parts which are main program and
interrupt program. The microcontroller will always loop the main
program until an interrupt occurred. When the controller receives
an interrupt flag, then it will jump to interrupt the process.
3.5.1 Flow chart of transmitter and receiver sectionThe system
flowcharts were designed as follows:
Figure 3.5.1.1: Flow chart of program in Visual basic 6.0
Figure 3.5.1.2: Flow chart of transmitter section in Visual
studio
Figure 3.5.1.3: Flow chart of receiver section in Microsoft
Visio Software
CLEAR INTERRUPTION FLAGGET VALUE OF SPEEDGAIN = GAIN
-1?ERROR=REF DETECTED SPEEDREF=DETECTED SPEED?NOCLEAR COUNTERRESET
TIMERRETURN FROM INTERRUPTIONSEND SPEED IN RPM TO LCD
YESNO
NO
YES
Figure 3.5.1.4: Receiver section flow chart interrupts
process
3.5.2 Flow charts description
At the beginning of the program, the visual basic interface
serves as the user input to the system as the project requires the
control of the military robot using PC. The transmitter section
gets it reference input from the PC via RS232 serial communication.
This condition is satisfied only if the reference input is received
else it will wait until it gets the reference input. If the
condition is satisfied a corresponding output will be transmitted
on to the receiver section. On the receiver section, interrupt
occurs after every 0.5 sec. The microcontroller will execute the
interrupt program instead of the main program when it gets the
interrupt flag. At first, the microcontroller reads the reference
speed. Then it compares the reference speed with the detected speed
to compute the error speed. When the detected speed is greater than
the reference speed, a speed down process takes place i.e., the
error voltage generated will speed down the process until it track
the reference input. Likewise, when the reference input is greater
than the detected speed, a speed up process takes place i.e., the
error voltage generated will speed up the process until it track
the detected speed. Since the system is intended to work
continuously; therefore after reaching the end of subroutine, the
microcontroller starts reading signal voltages again as indicated
in the feedback loop.
3.5.3 PWM CONTROL LOGIC
Pulse width modulation is a very good technique used in the
microcontroller to control the speed and position of the motor.
Power supplied to the motor has constant amplitude but varying
pulse-width or duty cycle. Duty cycle refers to the ratio of pulse
width to period (time taken to complete one cycle). The duty cycle
of PWM is determined by the pulse width since the frequency is held
constant while the on-off time is varied. Thus, the power increases
duty cycle in PWM. Duty cycle is returned mathematically as;
Basically, the speed of a DC motor is a function of the input
power and the drive characteristics. While an area under an input
pulse width train is a measure of average power available from such
an input. Two processes of PWM are used in this project to ensure
that the speed is maintained at a given input. These are; the speed
down and the speed up process. The program execute the speed down
process whenever the detected speed of the motor is higher than the
reference speed, in such condition error signal is generated to
ensure that the detected speed maintains the input. Whereas the
speed up process is executed whenever the reference input is less
than the detected speed, error signal is generated in order to
speed up the process to ensure that the reference completely
maintain the output.
CHAPTER 4
HARDWARE AND SOFTWARE DESIGN AND IMPLEMENTATION
4.1 Schematic diagram
4.1.1 Wireless transmitter schematic diagramAs designed in
chapter 3, the Transmitter section contains RS232, PIC
microcontroller, and wireless Module. This section is based on
computer control. The visual basic program downloaded into the PC
enables the rapid application development (RDP) of graphical user
interface which will allow the user to control the speed and
positioning of the system from the computer. This is made possible
by interfacing the microcontroller with the computer using MAX232
through RS232 serial communication. RS232 (recommended standard
232) support both synchronous and asynchronous transmissions and
its user data is send as a time series of bits. Max232 is an
integrated circuit that converts signals from an RS-232 serial port
to signals suitable for use in TTL compatible digital logic
circuits such as the microcontroller. The serial data sends from
the PC through RS232 gets converted to parallel data and is fed to
the PIC microcontroller and vice versa. The microcontroller PIC
converts the received data to pulses which undergo modulation by
the encoder. Wireless module transmits the modulated signals to the
RF Rx section.
Figure 4.1.1.1: Wireless transmitter schematic diagram
4.1.2 Wireless receiver section schematic diagramThe receiver
section contains wireless receiver module, PIC16F877A
microcontroller, L293D motor driver, LCD and DC motor. The RF Rx
receives the transmitted signals. This signal undergoes
demodulation to suppress the carrier and decode back the original
data. Depending upon the input given by the user a corresponding
output will be outputted by the microcontroller. From the circuit
it is clearly seen that Port B, C and D are defined as the
microcontroller outputs. Where Port B of the microcontroller
controls the LCD circuit, Port C controls the servo motor and laser
gun and port D controls the motor driver circuit. Port D & C
(RD7, RD6, RD5, RD4 and RC7) are fed to their respective circuit
through C1815 transistors to ensure high current and high speed.
The signals received by the motor-driver circuit will enable the
motor to choose the direction that it is supposing to be running in
and also to come to a complete stop if that is what the user
instructed. Furthermore, one of the received signals received from
user inputs will be a control reference. The control reference
inputted will be fed into the PIC in-built PWM circuit to generate
an appropriate duty ratio that will be sent to the wheels of the
motor, these PWM control signals will directly control the speed
and direction of the dc motor with the aid of the motor driver. The
variation of the PWM is directly proportional to the increase and
decrease of the motor speed. Notice that, although the voltage has
fixed amplitude, it has a variable duty cycle which means the wider
the pulse, the higher the speed and vice versa. Furthermore, the
receiver section is interfaced with an IR sensor for detecting the
speed. Detected speed is sent to the microcontroller through pin 8
for computation. The circuit for IR sensor is given in figure
Figure 4.1.2.1: Wireless receiver schematic diagram
4.1.2.1 IR sensor schematic Figure 4.1.2.1.1 IR sensor
schematic
4.1.3 Optical encoderThis is a simple wheel encoder based on the
idea that white stripes will reflect IR light, while black ones
will absorb it. This will result in a series of electrical pulses
as the wheel is rotating, providing the microcontroller with
precious information that can be used to calculate displacement,
velocity or even acceleration. It is now clear that this kind of
sensor has to be Always ON, to detect every single white stripe
passing in front of it, to achieve accurate results. IR detector
consists of two characteristics 1). High light illuminate low
resistance and low voltage drop 2). Low light illuminate high
resistance and high voltage drop.
4.1.4 DC Motor driveThe 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. This device is suitable for use
in switching applications at frequencies up to 5 kHz.A minimum of
three pins are required for each motor namely: The Enable (E) (Pin1
& 9) the input A (pin 2 and 10) and input B (pin 7 and 15). In
this project, the motor driver section was tested independently
with an external supply to verify the working operation of the
driver. After I have tested and verified that the logic (i.e.,
forward, reverse, left, right and stop) works correctly, the inputs
are then given to the output (port D4, D5, D6, and D7) of
PIC16F877A microcontroller. The idea behind testing the motor
driver circuit independently is for ease of trouble shooting. The
motor rotates in either direction depending on the input pin value
it receives from the microcontroller. Its operation is summarized
in Table 4.2.2.1.
Table 4.2.2.1: Motor driver data inputsNoEnableInput AInput
BRotation
Pin2Pin7Pin10Pin15
111010Forward
210101Reverse
311000Left
410010Right
510000Stop
4.2 PCB design rules
4.2.1 Working from the TopPCB design is always done looking from
the top of your board, looking through the various layers as if
they were transparent. This is how all the PCB packages work. The
only time you will look at the work from the bottom is for
manufacturing or checking purposes. This through the board method
means that you will have to get used to reading text on the bottom
layers as a mirror image.
4.2.2 TracksThere is no recommended standard tracks size. What
track size you use will depend upon (in order of importance) the
electrical requirement of the design, the routing space and
clearance you have available, and your personal reference. Every
design will have a different set of electrical requirements which
can vary between tracks on the board. All but basic non electrical
device will require a mixture of track sizes. As a general rule
though, the bigger the track width, the better. Bigger tracks have
lower dc resistance, lower inductance, can be easier and cheaper
for the manufacturer to etch, and are easier to inspect and rework.
Changing tracks from large to small and then back to large again is
known as necking or necking down. This is often required when you
have to go between IC or component pads. This allows you to have a
big low impedance tracks, but still have the flexibility to route
between tight spots.In practice, the track width will be dictated
by the current flowing through it, and the maximum temperature rise
of the track you are willing to tolerate. Note that every track
will have a certain amount of resistance, so the tracks will
dissipate heat just like a resistor. It should be noted that the
wider the track, the lower the resistance. The thickness of the
copper on your PCB also plays a part, as will any solder coating
finish. The thickness is normally specified in ounces per square
foot with 1oz copper being the most common. Other thicknesses can
be order like 0.5oz, 2oz and 40oz. The thicker copper layers are
useful for high current, high reliability designs.
4.2.3 SolderingSoldering considerations need to be taken into
account when laying out the board. There are three basic soldering
techniques hand, wave and reflow. Hand soldering is the traditional
method typically used for prototypes and small production runs.
Major impacts when laying out the board include suitable access for
the iron, and thermal relief for pads. Non-plated through double
sided boards should allow for ample room to get the soldering iron
onto the top side pads.
4.2.4 Electrical TestingFinished PCB undergo checked for
electrical continuity and shorts at time of manufacture. This is
done with an automated flying probe or bed of nails test machine.
It checks that the continuity of the tracks matches the PCB file.
Based on rules and conditions transmitter and receiver PCB layouts
was developed. 4.2.5 PCB designs
Before proceeding to PCB implementation, testing on breadboard
was done and the working operation of the circuit was properly
tested errors were checked and rectified. Hence, it is time to turn
it into a nice Printed Circuit Board (PCB). The PCB design is a
manufactured version of the schematic and a natural and easy
extension of the design process. Eagle 4.09r2 software was used to
position the transmitter and receiver components linked with
thousands of tracks into an intricate design that meets a whole
host of physical and electrical requirements. This software is
chosen because it has a very neat layout and proper PCB layout is
very often an integral part of the design.
Figure 4.2.1.1: Transmitter section PCB
Figure 4.2.1.2: Receiver section PCB
Figure 4.2.1.3: IR sensor section PCB
The PCB layout schematics were printed out on glossy paper.
Glossy, is the PCB layout transfer paper. The layouts were printed
with a Laser printer. Copper clad laminates were cut using hack saw
into three sizes in accordance with the layouts for the
transmitter, receiver and sensor circuit. To avoid shrinking, a
paper was placed over the glossy to help distribute pressure
through surface irregularities. Pressing iron was used to iron the
already arranged PCB thoroughly for about 15minutes. The copper
clad were allowed to cool off and the glossy paper was nicely
peeled off to reveal the transferred image. In order to replace
missing parts before transferring into etchant a permanent marker
was used. Etchant (HCL acid) was poured into an electric etching
tank. A hole was drilled on the circuit board, tied and hung inside
a potable small tank for about 15 minutes. Once the unwanted copper
was etched away until only a toner image remaining, it was removed
and rinsed it under lots of running water. After it dried up
thinner was used to clean it and made it ready for drilling.
4.3 Software implementation
4.3.1 Programming in Mikro CMicrocontroller acts as the brain of
the whole wireless speed control system. It receives the desired
speed from the user PC through RS232 serial port. The actual speed
is then compared with the desired speed and correction will be done
accordingly by microcontroller so that it will always maintain the
DC motor speed at the speed set by the user. An algorithm has been
developed which makes the microcontroller to read the input and
respond accordingly. These algorithms are represented by the flow
chart in chapter three. These flowcharts are then translated into C
language and compiled using Mikro C, the PIC16F873A and PIC16F877A
development tool. Refer to appendix B for complete C program.
4.3.1.1 Process explanation of main programThere are six parts
of main program in microcontroller. Which are initialization of
ports, PWM, Timer1, setup for serial port, get reference speed and
check noise function.
4.3.1.2 Initialization of the mode of portsGeneral purpose I/O
pins can be considered the simplest of peripherals. They allow the
PICmicro to monitor and control other devices. In general, when a
peripheral is functioning, that pin may not be used as a general
purpose I/O pin. For most ports, the I/O pins direction (input or
output) is controlled by the data direction register, called the
TRIS register. TRIS controls the direction of PORT. A 1 in the TRIS
bit corresponds11111111 to that pin being an input, while a 0
corresponds to that pin being an output. An easy way to remember is
that a 1 looks like an I (input) and a 0 looks like an O (output).
The PORT register is the latch for the data to be output. In this
project, we use port A and E as digital input where it receives
input (H/L) from PT2272 decoder and speed detector respectively
while port B, C and D were used as output ports. To configure port
A and E as input port, it must be programmed by writing 1 to all
its 8 pins. Conversely, to configure port B, C and D as output
port, it must be programmed by writing 0 to all its 8 pins. The
following codes were therefore used for input and output ports
configurations: //main routinevoid main(void){ ADCON1=0x06;
//configure as digital I/O TRISA=0b11111111; //configure port A as
input TRISB=0b00000000; //configure port B as output
TRISC=0b00000001; //all port C as input except pin 1
TRISD=0b00000000; //configure port D as output TRISE=0b00000011;
//all port E as input except pin 1&2Figure 4.3.1.2.1: Configure
input and output port
When the PIC powers up, the default ADCON1 sets all the analog
ports ON to use the ports as digital I/O you must appropriately
configure by means of loading 0x06 to ADCON1 register. //define pin
used#define sec_flag flag.F0 //count every second#define ir
PORTC.F0 //PORTC.PIN0 = infrared input//define motor output
pins#define motor1_fwd PORTD.F4 //PORTD.PIN4 =
motor1_Forward#define motor1_rwd PORTD.F5 //PORTD.PIN5 =
motor1_Reverse#define motor2_fwd PORTD.F6 //PORTD.PIN6 =
motor2_Forword#define motor2_rwd PORTD.F7 //PORTD.PIN4 =
motor2_Reverse#define servo1 PORTC.F7 //PORTC.PIN7 = define
Servo1#define laser PORTC.F1 //PORTC.PIN1 = define laserFigure
4.3.1.2.2: Define motor output