University of Southern Queensland [604653]
University of Southern Queensland
Faculty of Engineering and Surveying
Building a Two Wheeled Balancing Robot
A dissertation submitted by
Mr Peter Miller
In fulfilment of the requirements of
Courses ENG4111 and 4112 Research Project
towards the degree of
Bachelor of Engineering (E lectrical and Electronic)
Submitted: October, 2008
i
Abstract
Two wheeled balancing robots are an area of research that may well provide the
future locomotion for everyday robots. The uni que stability control that is required to
keep the robot upright differentiates it from traditional forms of robotics. The inverted pendulum principle provides the mathematical modelling of the naturally
unstable system. This is then utilised to develop and implemen t a suitable stability
control system that is responsive, timely and successful in achieving this objective.
Completing the design and development phase of the robot requires careful
consideration of all aspect s including operating condition s, materials, hardware,
sensors and software. This process provides the ongoing opportunity of
implementing continued improvements to its perceived operation whilst also
ensuring that obvious problems and potential faults are removed before construction.
The construction phase entails the manu facture and assembly of the robots
circuits, hardware and chassis with the software and programming aspects then
implemented. The later concludes the robot s production where the final maintenance
considerations can be determined. These are essential for ensuring the robots continued serviceability.
The analysis and evaluation of the completed robot provides the ability to
assess the robots effectiveness and efficiency in maintaining stability. This allows a
comparison to be undertaken between the actual system performances and the
anticipated project objectives. The opportunity to calibra te and perform additional
fine tuning of the design is also explored. The project is concluded with comments
on each aspect of the project with recommendations for improvement, additional
capabilities and future areas of investigation.
ii
iii
Certification
I certify that the ideas, desi gns and experimental work, results, analyses and
conclusions set out in this dissertation ar e entirely my own effort, except where
otherwise indicated and acknowledged.
I further certify that the work is original and has not been previously submitted for assessment in any other course or ins titution, except where specifically stated.
Peter Miller Student: [anonimizat]: 0050031502
Signature
29OCT08 Date
iv
Acknowledgements
I would like to extend my appreciation and love to my family for all their continuing support, care and consideration. For my loving wife who ha s given me every
opportunity to succeed, for my fantastic son who has always shared the interest, and
my beautiful daughter who always knew I could do it, thank you for sharing the journey with me. And, thank you to my mu m and dad, Audrey a nd Phil, for all the
support and guidance over the years.
Finally, I would like to thank my supervisor Mark Phythian.
v
Table of Contents
Abstract i
Acknowledgements iv List of Figures viii
List of Tables x
List of Appendices xi
List of References xii
Chapter 1 – Introduction
1.1 Two Wheeled Balancing Robots 1
1.2 Inverted Pendulum Theory 2 1.3 Autonomous Stability 6 1.4 Project Objectives and Timeline 7 1.5 Methodology 8 1.6 Risk Assessment 9 1.7 Conclusion 11
Chapter 2 – Literature Review
2.1 Introduction 12
2.2 Existing Two Wheeled Balancing Robots 13 2.3 Purpose and Benefits of Two Wheeled Robots 16
2.4 Modes of Operation and Control 18
2.5 Implications and Ethics of Technology 18
2.6 Conclusion 19
Chapter 3 – Design and Development
3.1 Introduction 20
3.2 Control System 20
3.3 Software and Programming Concept 26
3.4 Design Considerations 31
3.4.1 Operating Environments 31
3.4.2 Materials, Size and Weight 32
3.4.3 Wheels 33
3.4.4 Motors 34
3.4.5 Sensors 37
vi
3.4.6
Microcontroller 41
3.4.7 Components / Circuits 43
3.4.8 Stability Control Requirements 44
3.4.9 Power Source 46
3.4.10 Locomotion Control 49
3.4.11 Communications 50
3.4.12 System Integration 50
3.4.13 Safety Features 52
3.4.14 EMR / EMI 53
3.5 Design Concept “Oshy” 54
3.6 Resources 56
3.7 Conclusion 57
Chapter 4 – Manufacture and Assembly
4.1 Introduction 58
4.2 Printed Circuit Boards 58
4.3 Wheel Base 61
4.4 Power Source 62
4.5 Interaction System and Upper Layer 62
4.6 Software and Programming 63
4.6.1 Simulation 63
4.6.2 Microchip Program 64
4.7 System Integration and Overview 64
4.8 Future Maintenance Considerations 65
4.9 Conclusion 66
Chapter 5 – Data Analysis 5.1 Introduction 67
5.2 Calibration and Tuning 67
5.3 Stability Analysis 68
5.4 Locomotion Analysis 68
5.5 System Performance Overall 69
5.6 Conclusion 69
vii
Chapter 6 – Conclusion and Recommendations
6.1
Introduction 70
6.2 Discussion 70
6.2.1 Difficulties Experienced 70
6.2.2 Design Advantages and Disadvantages 71
6.2.3 System Performance and Results 71
6.2.4 Results versus Expectations 72
6.3 Conclusion 72
6.4 Recommendations 72
6.4.1 Improvements and Alterations 72
6.4.2 Additional Features and Capabilities 72
6.4.3 Future Areas of Investigation 73
Bibliography 74
viii
List of Figures
1.1 Views of the two wheeled balancing robot 2
1.2 Displacement, velocity and acceleration parameters 4
1.3 Inverted pendulum parameters 4
1.4 Wheel parameters 5
1.5 Dissertation completion timeline 8
2.1 Segway HTi series two wheeled transport 14
2.2 Emiew 2 by Hitachi 15
2.3 nBot by David Anderson 15
3.1 Input 1 – Angle membership function 22
3.2 Input 2 – Angular velocity membership function 23
3.3 Input 3 – Displacement membership function 23
3.4 Input 4 – Velocity membership function 23
3.5 Output – Motor output membership function 24
3.6 Angle and angular velocity rule set surface plot 26
3.7 Displacement and velocity rule set surface plot 26
3.8 Microcontroller structure chart 27
3.9 Microcontroller main program flowchart 28
3.10 Sensors and locomotion desire d sub-routine flowcharts 29
3.11 Fuzzy control and locomotion res ponse sub-routine flowcharts 30
3.12 Control system functionality 30
3.13 Differential drive motion 35
3.14 L298 motor driver PCB 37
3.15 Sharp GP2D12 sensor (Sharp) 40
3.16 Microcontroller circuit 43
3.17 Maximum tilt angle variables 45
3.18 Voltage monitoring circuit 47
3.19 12V distribution circuit 49
3.20 Low voltage distribution circuit 49
3.21 Overall system interaction block diagram 51
ix
4.1 Microco
ntroller circuit PCB 59
4.2 12V distribution PCB 60
4.3 5V and 3.3V distribution PCB 60
4.4 Gyroscope and accelerometer PCBs respectively 61
4.5 Wheel base layers 61
4.6 Power source layer front and rear views respectively 62
4.7 Interaction system and upper la yer front and rear views 62
4.8 Manufactured and assembled r obot front and rear views 65
x
List of Tables
1.1 Risk Assessment of Research Project 10
3.1 Fuzzy controller membership functions 22
3.2 Angle and angular velocity rule relationship 24
3.3 Displacement and velocity rule relationship 25
xi
List of Appendices
A Project Specification 77
B Matlab Programming 78
C Microcontroller Programming 89
xii
List of References
Anderson, DP, 2007, nBot Balancing Robot, viewed 20th March 2008, <
http://www.geology.smu.edu/~dpa-www/robo/nbot/ >
Bush, L 2001, Fuzzy Logic Controller for the Inverted Pendulum Problem. Deepa, S, Sivanandam S & Sumathi, S 2007, Introduction to Fuzzy Logic using MATLAB, Springer, New York. Florian, RV, 2007, Correct equations for th e dynamics of the cart-pole system,
Center for Cognitive and Neural Studies, viewed 15th May 2008, <
http://www.coneural.org/florian/papers/05_cart_pole.pdf >
Larson, T, 2008, Balancing Robot Project – Bender, viewed 20th March 2008,
<
http://www.tedlarson.com/robots/balancingbot.htm >
McComb, G & Predko, M 2006, Robot Builder s Bonanza, McGraw-Hill, Sydney.
Segway Inc, 2008, Simply moving, viewed 20th March 2008, <
http://www.segway.com/ >
Simon, D 2001, Kalman Filtering, Embedded Systems Programming.
1
Chapter 1
Introduction
Robotics has always been played an integral part of the human psyche. The dream of
creating a machine that replicates hu man thought and physical characteristics
extends throughout the existence of manki nd. Developments in technology over the
past fifty years have established the f oundations of making these dreams come true.
Robotics is now achievable through the miniaturisation of the microprocessors which performs the processing and computations. New forms of sensor devices are being developed all the time further providing m achines with the ability to identify the
world around them in so many different ways.
Effective and efficient control system designs provide the robot with the
ability to control itself and operate aut onomously. Artificial intelligence (AI) is
becoming a definite possibility with adva ncements in non-linear control systems
such as neural networks and fuzzy controllers. Improved synthetics and materials allow for robust and cosmetically aesthe tic designs to be implemented for the
construction and visual aspects of the robot.
Two wheeled robots are one variation of robot that has become a standard
topic of research and exploration for young engineers and robotic enthusiasts. They
offer the opportunity to develop control sy stems that are capable of maintaining
stability of an otherwise unstable system. Th is type of system is also known as an
inverted pendulum. This research project aims to bring this, and many of the
previously mention aspects of a robot toge ther into the building of a two wheeled
balancing robot with a non- linear, fuzzy controller.
This field of research is essential as robots offer an opportunity of improving
the quality of life for every member of the human race. This will be achieved
through the reduction of human exposur e to hazardous conditions, dangerous
environments and harmful chemicals and the provision of continual 24 Hr assistance
and monitoring for people with medical c onditions, etc. Robots will be employed in
many applications within society includi ng carers, assistants and security.
1.1 Two Wheeled Balancing Robots
A robot that is capable of balancing upr ight on its two wheels is known as a two
wheeled balancing robot. The following figure contains the physical view for the
robot designed as part of this project. Th e process of balancing is typically referred
to as stability control. The two wheels ar e situated below the base and allow the
robot chassis to maintain an upright positi on by moving in the dire ction of tilt, either
forward or backward, in an attempt to ke ep the centre of the mass above the wheel
axles. The wheels also provide the locomotion thus allowing the robot to transverse across various terrains and environments.
2
This type of
robot provides a challengi ng problem and has resulted in many
useful and interesting designs being devel oped. One such two wheeled robot that has
become a commercial success is the Segway by Segway Inc. The immediate impact
has been within the personal transportation area where an alternative to cumbersome
wheelchairs is now available. Segway proves a comfortable mobility opportunity for
the elderly or people with disability thus improving there individual sense of
independence at the same time. The theory us ed to maintain stability of these robots
is based on the inverted pendulum theory which is covered in the following section
1.2.
Figure 1.1 Views of the two wheeled balancing robot
1.2 Inverted Pendulum Theory
To develop a reliable and capable control system for a two wheeled balancing robot,
an understanding of the parameters within th e system is essential. Representation of
these can be achieved through a mathematical model. Inverted pendulum theory is
more traditionally known as Pole and Cart theory and although the two wheeled balancing robot does not direc tly compare to the Pole and Cart, the same principles
are in effect. Within the system model, th e cart equates to the wheels whilst the pole
equates to the robot’s chassis.
(Florian 2007) presents an updated vers ion of the pole and cart system which
have been utilised as the theory basis for this project. The equations were derived by
utilising Newton’s second law with adde d corrections from previous versions
published by researchers. These correctio ns concluded that the gravitation
acceleration is in fact a pos itive value, and that the frictional force between the wheel
and horizontal surface should be incorporated in the equation.
3
Friction coefficients have been neglected in this project as the robot will be
expected
to transverse across numerous types of terrains and surfaces. If the
coefficients were to be considered during the control systems design and
implementation, then additional sensors, ci rcuitry and power consumption would be
required to derive these new values whilst in operation. The time, effort and
resources required to create this capability far exceed any benefits that could be
expected with there inclusion.
It is necessary to generalise the eff ects of the left and right wheels and
incorporate them together under the combin ed term “wheels”. This simplifies the
calculations as both wheels will work in unison to maintain stability. For
determining specific torque (forces) requirements for each individual wheel, the wheels value can be halved for an approxima te single wheel value. This approach is
considered acceptable as the terrain and su rface will vary between the wheels on
certain terrains.
The aim of the inverted pendulum principl e is to keep the wheels beneath the
centre of the robot chassis’s mass. If the robot begins to tilt forward, then to maintain
stability, the wheel will need to move forward to return beneath the chassis mass. If this is not maintained, the robot will simply fall over. The following system dynamics are associated with the mathematical problem.
System Dynamics
The following system dynamics are utilised within the mathematical problem of the
two wheeled balancing robots stability c ontrol (inverted pendulum approach).
x Displacement (Horizontal) (m)
x Velocity (Horizontal) (ms-1)
x Acceleration (Horizontal) (ms-2)
Angular displacement (Vertical) (rad s)
Angular velocity (Vertical) (rad s-1)
Angular accelerati on (Vertical) (rad s-2)
M
wh Mass of the wheels and drive shafts (Kg)
Mrc Mass of the robot chassis (Kg)
2l Height of the robot chassis (m)
4
Figure 1.2 Displacement, velocity and acceleration parameters
Figure 1.3 Inverted pendulum parameters
5
F
Horizontal force applied by wheels (N)
xu F F*
Ff Friction force between wheels and surface (N)
x f f u F F*
) * ( )] ( ) [(2x N Sgn Cos Sin l M g M M Fwh rc rc wh wh f
N
Reactive force on robot chassis from the wheel (N)
y y x xu N u N N* *
Nwh Reactive force on wheels (N)
y wh wh u N N*
) ( ) (2 Cos Sin M g M M Nrc rc wh wh
g Gravitation acceleration (9.8ms-2)
Gwh Gravity effect on wheels (Kg*m*s-2)
y wh wh u g M G* *
Grc Gravity effect on robot chassis (Kg*m*s-2)
y rc rc u g M G* *
wh Friction coefficient of wheels on surface
rc Friction coefficient of drive shafts
N
x Reactive force in the direction of x (N)
) * * (2 Sin l Cos l x M Nrc x
Ny Reactive force in the direction of y (N)
) * * ( *2 Cos l Sin l g M Nrc y
Figure 1.4 Wheel parameters
wh Wheel torque (rotational force) (Nm)
Cos r Fwh wh wh * *
rwh Wheel radius (m)
Fwh Horizontal force of a wheel (left or right) (N)
2FFwh
6
The desired m
otor torque is estimated during the motor considerations within
hapter 3. Motor torque is the force applied to the wheel before frictional and
echanical losses are subtracted. The result ant torque, also known as applied torque,
fer he importance of selecting the
displayed in the wheel torque
quation. This indicates that a larger radius for the wheel would require a larger
torque to be applied by the motor.
e view as 94% or 87% of the torque available is
now required compared to the previous 100%.
Cm
ris e
red to as wheel torque in these equations. T
correct radius of wheel is evident from the effects
e
The cosine function within the wheel to rque equation details the advantage of
tilting the robot chassis in the direction desi red locomotion. If the robot was to begin
moving forward and the tilt angle in that direction is increased, then the torque
required to move the robot in that direction will be reduced. For example, when the
angle of tilt is 0o, the cosine multiplier will be 1 equating to 100% of the torque.
When the angle of tilt increases to 20o or even 30o, then the multiplier will equal 0.94
and 0.87 respectively. This could b
The following equations will provide a reliable and accurate model for
developing and implementing a suitable non linear control system for the two
wheeled balancing robot.
Angular acceleration
rc whrc
M Ml3
rc wh
Cos M 2* 4
orizontal acceleration
rc
M MSin l M FCos Sin g
2* **
rc whrc
M MCos Sin l M Fx
2* H
tability
Stability for the two wheeled balancing robot lies in its ability to maintain the robot
chassis in an upright, equilibrium, position. Balancing a robot automatically without
uman interaction is known as autonomous stability because it does this by self
governance. The inverted pendulum theory provides the equations required to
nd reactions that occur in the process. It is then necessary to
e and efficient control syst em that is capable of responding to the
eframe so that stability can be attained, and then 1.3 Autonomous S
h
ascertain m
otion, force a
apply an effectiv
sensory inputs within a minimal timmaintained.
This project aims to solve this proble m of maintaining stability of the two
wheeled balancing robot by designing a reliable control system capable of
functioning within a PIC mi crocontroller. A non-linear control system known as a
fuzzy controller will be developed allowi ng a more robust and stable system
compared to the linear equivalents current ly available. Additional problems inherent
in such a design will be explored within chapter 2.
7
1.4 Pr
l system capable of maintaining
tability of the robot. The resultant phys ical circuitry requirements were then
rt of the third goal.
project. These key
oals/objectives are defined as follows:
. A non-linear control system will be desi gned and then simulated to ascertain
d incl uding the necessary circuitry, sensors
and circuit boards. Additional, the unit will be configured with an interface
ource requirem ents
sourced. Manufacture and assembly will begin with the final outcome of this
provements to the
robustness of the stabilit y and locomotion before co mpletion of the project
sim ulation,
manufacture and testing processes used to derive the robot will be submitted oject Objectives and Timeline
The project objectives were broken into se veral key goals. The first was to review
and evaluate literature encompassing inve rted pendulum theory and two wheeled
balancing robots. This provided the basis for an inform ed design approach based on
previous experiences and procedures by ot hers. The second goal was associated with
the development of a microcontroller based contro
sfinalised in a microcontroller unit de sign as pa
Goal four required a finalised robot design including integr ation all of its
necessary components, sensors and PCB’s be fore the manufacturing and assembly of
the robot was completed. The following goal was to attain an analysis and evaluation of the measured performance data to establish its limitations, capabilities and potential shortfalls. Information obtained during each of these steps including the
resultant outcomes were then compiled, conc luding this research
g
1.
Research will be conducted into the th eory of an inverted pendulum and the
various considerati ons that may be necessary dur ing the construction of a two
wheeled balancing robot. This will present an indicati on of the potential
problems, resources required and timef rames expected. This will provide
overall direction of the project.
2
if
it is capable of stabilising the initial design concepts. Once a design is
established, progression to the next objective may occur.
3.
Design of a microcontroller unit capabl e of achieving the control system
derived above will be complete
for future incorporation of lo comotion (trajectory) control.
4. The robot design will be finalised with the resulta nt res
step being the construction of th e two wheeled balancing robot.
5.
An analysis and evaluation will be performed on the robot to assess the overall system performance. This will provide continual im
dissertation.
6.
A completed final dissertation c onsisting of the design,
to the University of Southern Queensland for assessment. This will examine the successfulness of the project in overcoming the problems and objectives
previously defined.
8
The tim
eline in the following figure contains the chapters that were
completed during the course of this projec t. Initially the research and literature
review chapters were comp leted together in late May. The design and development
omponent was then completed in August where the manufacturing and assembly
componc
ents of the following chapter then begun. Data analysis was completed
concurrently with the assembly stage in an attempt to identify any potential shortfalls
inherent in the design as well as improving overall effectiveness and efficiency of
the robot. Conclusions and recommendations were completed in late October with
the final submission.
Figure 1.5 Dissertation completion timeline
1.5 Methodology
he research project was divided into chap ters, each a sequential step in the process
d balancing robot. This approach was
tilised in an attempt to progress the project from one task to the next as it was
efined so that it builds on the previ ous task thus evolving the
roject is critical in determining plans for conducting research
nd performing the design work. Chapter 2 provides the second step in which a
thorougT
of developing and building the two wheeleuundertaken. Each is drobot within the goals and requirements generated. This ultimately led to the
completion of the two wheeled balancing r obot that met the objectives within the
timeframe available.
The first chapter formed the first step where key points and objectives were
established including the idea of what a two wheeled balancing robot actually is. Understanding your pa
h understanding of pr evious projects and appro aches is desired. This
established the foundations for making info rmed decision based on the previous
experiences and problems encountered. This can help introduce an avoidance of problems, adequate planning of resources and the effective app lication of effort.
9
The third step in the methodology was to apply the acquired knowledge in
key areas so that the control system was achieved with the resources available. Once
this was determined, simulation of the stability control system and additional
parameters was attempted before settling on the next step of constructing the robot.
The simulation task tested the derived sub -routines of the software based controller
which was undertaken within the ‘MPLAB’ pr ogram. This form of testing provides
valuable data on the likely stability capabil ity of the control system. This provides
the opportunity to design out faults or s hortfalls before resources; time and money
are inadvertently wasted. This ensured a complete, well planned, and capable
machine was developed.
The next step entailed the manufacture of PCB’s, chassis, drive shafts, etc
followed by the process necessary to make the robot a realisation. This was the rewarding section where the hard work finally began evolving into an actual machine. The following step was to analys e the actual performan ce of the robot and
ascertain its ability in achi eving the objectives of stabil ity and balance. This also
provided the opportunity to cal ibrate and perform additional fine tuning of the design
allowing the machine to become more eff ective and efficient in its performance.
The final component comprises of a co mplete assessment of each process
undertaken, the choices made and achievem ents obtained during the project as well
as evaluation of the final robots eff ectiveness. This expanded to include
recommendations for future work that could be undertaken in an effort to improve areas of the process or design, addition of capabilities, or how to overcome problems
that may have been encountered.
1.6 Risk Assessment
The risk assessment contained within the following table is an assessment of the perceived risks associated with the work to be undertaken in the research project.
The table is broken into seve ral components consisting of th e task to be performed,
the hazard, the associated risks, possible risk control measures, the rating of the risk
and potential exposure expected. No substant ial risks or hazards are expected during
the course of this project. Risk Ratings are defined as follows:
Extremely slight risks are prac tically impossible to occur.
Very slight risks are unlikely to occur.
Slight risks are possible but unlikely to occur.
Significant risks are possibl e and likely to occur.
Substantial risks are very likely to occur.
How often the persons involved will be exposed to defined risks is known as risk
exposure. These have been defined as follows:
Rarely occurs only few times during the course of the project.
Occasionally occurs once or twice in a month.
Regularly occurs weekly.
Frequently occurs each day.
Continuously is a constant exposure to the risk at all times.
10
Task Hazard Associated Risks Risk Control Measures Risk Rating Risk
Exposure
Literature review
and research tasks. Eye strain.
Muscular cramps. Short term pain.
Discomfort. Regular breaks.
Use of adequate lighting and
ergonomic furniture.
Very Slight Regularly
Manufacture and
assembly of robot
assemblies and
components. Physical injury from tools or
materials.
Electrocution from power tools.
Exposure to Battery.
Damage to sensitive components
and costly parts. Pain and/or physical injury.
Chemical burn from battery.
Lost project time.
Increased costs due to
replacement components and
parts. Use of Personal Protection
Equipment (PPE).
Adequate training in tools and
material usage is undertaken. Slight Regularly
Programming,
software design,
simulation and
analysis. Eye strain.
Muscular cramps.
Fatigue. Short term pain.
Discomfort.
Loss of concentration. Regular breaks.
Correct calibration of
monitors and positioning of
computer peripherals.
Use of adequate lighting and
ergonomic furniture. Significant Frequently
Report writing and
compilation. Eye strain.
Muscular cramps.
Fatigue. Short term pain.
Discomfort.
Loss of concentration. Regular breaks.
Correct calibration of
monitors and positioning of
computer peripherals.
Use of adequate lighting and
ergonomic furniture Slight Regularly
Robots operation. Robot falling, tipping or
colliding. Injury to people or damage to
equipment and surroundings. Reduce robots weight.
Incorporate sensors to avoid
potential collisions. Slight Continuously
Table 1.1 Risk Assessment of Research Project
11
1.7 Conclusion
The dissertation aims to evaluate the pr ocess from gathering knowledge in the field
of control system and robotics, through to apply them in the design, simulation,
manufacture and subsequent analysis of th e completed two wheeled balancing robot.
A review of the literature available on this type of r obot suggests that a non-linear
control system has not been readily achie ved. This research project achieved a non-
linear stability control system based on the fuzzy controller thus proving that this
type of system can actually be achieved.
It is hoped that the results from this research project will encourage future
engineers and robotic enthusia sts to attempt a non-linear design for use in other robot
control systems. For this two wheel balancing robot, it is anticipated that further research beyond this project, will progress in to visual and audio recognition systems
allowing communication and autonomous navigation to be incorporated.
12
Chapter 2
Literature Review
A two wheeled balancing robot consists of a robot chassis and two wheels. As its name suggests, it has the ability of maintaining an upright “balanced” position which is referred to as its stability. It is unique compared to multi-wheeled or track robots because of this ability. It also has the capac ity to turn on the spot making it far easier
to manoeuvrer. This makes the two wheeled balancing robot an ideal candidate for working in confined areas or in transportation applications.
This area of research is typically undertaken by engineers and enthusiasts as
an approach towards developing their resear ch, design and analysis techniques. This
robot is chosen as the inve rted pendulum system is na turally unstable and provides a
classical control problem. Developing and implementing a suitable stability control
system that is responsive, timely and su ccessful can be achieved via linear or non-
linear approaches. This chapter reviews the lite rature that is available in an attempt
to gain an understandin g and appreciation of two wheeled balancing robots.
2.1 Introduction
A two wheeled robot is basica lly a robot chassis comprisi ng of a symmetrical shape.
This shape can be sectored into severa l layers where the various components are
installed and integrated. Components of th e robot may include a core processing
unit, sensors, wheels, power source and asso ciated printed circu it board circuitry. If
the robot is complex, then additional re mote control, autonomous navigations
systems, visual or audio recognition sy stems, etc may be incorporated. The two
wheels at the base of the robot chassis pr ovide the locomotion wh ich is typically DC
motor driven with gearboxes and shaft encoders affixed.
This type of robot is typically undertaken as a self development process
allowing young engineers and robot enthusiasts to learn and develop control systems
to satisfy their needs. It also provides a tool for comparing the success of various
types of control systems for the typical stab ility control problem. Segway has led the
world with its commercial success of its tw o wheeled transportation device. As more
and more people realise the appl ications of this type of robot within transportation
and beyond, the demand will continue to grow steadily in the future. This includes the field of human mobility.
Human mobility is currently, just a dr eam for many people with disabilities
who as otherwise home bound or limited in opportunity. These robots offer new
hope that these people can become part of the world around them again. With an
aging population in the western world, the ma rket will also continue to grow for
home environment robots that could act as care-takers, providing services to the
elderly. In the office environment, two wheeled robots will act as servants and
perform basic tasks such as mail collection and distribution.
13
Two wheeled balancing robots com
prise of sensors that provide the ability to
see and feel the environment around them. Accelerometers, inclinometers, motor
encoders and gyroscopes form the stability and motion sensor families available to provide inputs or feedback to control systems. These include information
corresponding to the robots current vertical or horizontal positioning and direction.
These inputs can be combined in a process known as sensor fusion. Kalman filter is one type that provides a best approximation from the multiple sensor inputs, allowing the devices inherent inaccuracies to be overcome.
A microcontroller provides the computational power to allow the robot to
balance itself, based on the sensor input in formation. However, the effectiveness is
related to the control system that has been implemented. Two different approaches can be undertaken for implementing a control system, they can be either software or
hardware based. For this project, a softwa re based control system will be derived.
Control systems are further classed as either Linear or Non-Linear control systems. Due to the difficulty and complexity in applying non-linear systems, linear is generally preferred.
Linear systems include State Space control, Proportional Integral and
Derivative (PID) controller, Linear Qu adratic Regulator (LQR) and pole placement
controllers. More recently, developments in non-linear control systems have evolved
approaches such as neural networks and fu zzy control. The later will be attempted
within this project as non-linear control systems provide a far more effective and
efficient controller. The motor driver signals will be enhanced by incorporation of in-line PID controllers.
2.2 Existing Two Wheel ed Balancing Robots
Previous two wheeled balancing robot proj ects include the Segway, nBot, Bender,
Emiew and Emiew 2. The Emiew 2 robot is the enhanced (evolved) version of the
original Emiew. They were both designed and created by Hitachi whilst the Segway
was designed and developed by Dean Kamen who later formed the company Segway Inc. The remaining robots that were review ed were created by r obot enthusiasts who
have continued to improve the robus tness of their designs over time.
The design concepts between these robot s are very similar. Each typically
utilise a gyroscope to measure tilt, shaf t encoders to measure distance and a
microcontroller for performing the comput ations. These components combine to
provide the basis of maintaining stabil ity. Inclinometers or accelerometers are
sometimes added to reduce the effects of gyroscope drift thus enabling a more
accurate input signal fo r the control system.
Linear control systems are the most co mmon due to a larger availability of
literature in this field and an easier im plementation process. Modern developments
into neural networks and fuzzy controller s are encouraging a new approach in non-
linear control systems. Many of the enthus iast suggested that a non-linear approach
would have improved the robustness of the st ability control in th ere robots hence a
fuzzy controller will be attempted in this project.
14
Segway (Segway 2008) is the commercially available two w
heeled robot that
is currently in its 2nd generation of released models. It is marketed to the world as a
transport alternative with the image contained within the following figure. Its
advertising suggests the robot is ideal for adventure, commuting, law enforcement
and transportation in general. Its trajectory control is based on the tilting direction of the handlebars which is provided by the ri der. This robot is capable of achieving a
speed of 20 Km/h and is available in Australia for a cost between $9385 and $10795
depending on the model.
Figure 2.1 Segway HTi series two wheeled transport (McComb & Predko 2006)
EMIEW (Kageyama 2007) stands for “Excellent Mobility and Interactive
Existence as Workmate”. It was the first two wheeled robot produ ced by Hitachi and
was released in March of 2005. It stood at a height of 1.3 m and weighed over 70
Kg. Emiew 2 followed in November 2007 and is approximately half the size of Emiew at 0.8 m and 13 Kg. Its design concep t hoped to reduce the safety risks that
were associated with Emiew larger size, incorporating reducti ons in height and
weight.
The robot responds to speech commands and is intended to work in office
type environments. To avoid obstacles and people within its path, the robot utilises
laser radar to derive a map of its surround area. The knees contai n an additional set
of wheels that can be utilised when stab ility becomes too difficult to maintain. In
additional to these features, the robot ha s the ability to raise each wheel by
approximately 30 mm allowing it to avoid small obstacles. Emiew is contained in the following figure.
15
Figure 2.2 Emiew 2 by Hitachi (Kageyama 2007)
David Anderson, an enthusiast, has developed the robot named nBot
(Anderson 2007). This robot ut ilises a gyroscope and a ccelerometer whose outputs
are fused together by a Kalman filter, thus providing an accurate input to control the
stability. At present, the robot is in its fourth revision and has the ability of
navigating a 7.3 metre distance before retu rning and repeating the lap once again.
One of the strong capabilities of this robot is the ability to transverse rough terrain
and even travel down sets of stairs.
Figure 2.3 nBot by David Anderson (Anderson 2007)
16
Bender (Larson 2008) is a robot m
ade from aluminium and PVC plastics. Its
weight is mounted higher in the chassis as it was suggested by Ted Larson that this
makes the robot easier to balance. Whilst experimenting with the gyroscope and
accelerometer positioning within the robot, he also discovered that the system was
much more stable when they were positione d lower in the chassis. These ideas for
improving the stability of the robot could be very beneficial during the design phase
and initial development.
Other projects on the internet that have not been specified here have
presented interesting ideas in the application of the robots construction, control
approaches and the resources used. Some robots have b een made from Lego blocks
whilst others from old materials found ar ound the home. Different approaches to
measuring the tilt were also employed w ith one such robot achieving its tilt
measurement through use of paired Infra-Red (IR) sensors. One is place at the front
of the undercarriage whilst th e other at the back. The di stance to the ground is
measured by both and then compared for the actual difference. This difference
provides the magnitude value whilst the shorte r measured distance indicates a tilt in
that particular direction.
The majority of these projects have em ployed linear based control systems in
the designs and projects. Many stated that their system di d provide a stable system
but oscillations about the vertical position were very common. It was also noted that frequent over or under corrections lead to in cidences where total loss of stability was
experienced. This evidence suggests that robust stability can be achieved if a non-linear approach was undertaken; this project aims to fill this void by providing an insight into the non-linear fuzzy controll er, its capabilities a nd limitations through
this application.
2.3 Purpose and Benefits of Two Wheeled Robots
The purpose of two wheeled robots is difficult to limit to a specific role as they can complete numerous tasks with the nece ssary attachments installed. One purpose
could be to access a hazardous or confined environment which would be difficult to
manoeuvrer around for a track or multi-wheeled vehicle. This is eas ily achieved by a
two wheel robot as it can turn on the spot by rotating the right wheel forward whilst the left rotates backward and vice versa.
Robots don’t require annual leave, superannuation or a salary. There down-
time would be minimal being an electronic based machine when compared to there
mechanical counterparts. Maintenance cost s could be equated to a human’s annual
health insurance and would form the onl y expenditure after procurement. These
ideas contribute to the benefits of any two wheeled robot independent of their
purpose that they may be called upon to fulfil.
17
They could be controlled rem
otely or autonomously, depending on the terrain
and frequency of obstacles around them. In cities and comm unal areas of society, it
is very common for recreational, social a nd vocational areas to be reasonably flat,
therefore traction would be the main c oncern. Waterways and very rough terrain
would be the only problem with this curre nt level of design. Society could benefit
substantially from sharing their environmen t with two wheeled robot assistants. The
following roles are only a small sample of the greater potential of possibility.
A robot could fulfil the role of a home health assistant as it doe not require
rest. It could provide 24 Hr comfort for fam ilies with sick or elderly members. They
could easily manoeuvre about the home a nd provide wireless connectivity to the
internet or private networks. This could be us ed to raise alarms if an incident occurs
or if other additional sensors such as a heart monitor enter an alarm state. A built in
camera, speaker and microphone could pr ovide a means of communication for
medical personnel online, di rect to the patient.
It could be utilised as a warehouse track ing robot where item statuses can be
easily tracked as part of a schedule, or manually when re quested by clients. It could
automatically update the companies system and databases through a wireless connection. Other available f eatures would be the ability to perform audits, stock
checks as well as conduct security tasks whilst on duty within the warehouse environment.
In a fire warden role, the robot coul d access a smoke filled area and evaluate
the risks before any human lives woul d be placed in danger. A camera would
provide visual images to the fire co mmander whilst temperature sensors would
measure hot spots on bulkheads, deck head s and flooring. IR sensors could search
for trapped people or living creatures and provide mapping of obstacles within the
room. All indications, measurements and in formation could be relayed directly to
fire commanders allowing a swift and effective effort to prevent life loss and reduce potential damage.
Another purpose could be a general communication robot. They would
perform the tasks of a travelling telephone , videophone, fax, Voice Over IP (VOIP),
MSN messenger or interface for any other messaging means that may become available in the future. When it receives a call request, it could utilise it sensors to
locate the person by itself. Room sensors co uld be wirelessly integrated with the
robot so it can easily identify people with in a larger area. This could also be
extended to include the detection of intr uders where the robot would investigate
detections before raising the alarm with authorities.
An aim of this project is for the comp leted two wheeled ro bot to be capable
of recovering deliberate tilt caused by physical force. This could be caused in the
real world by an ill adult or child falling over or even passing out thus bumping into
the robot. This would allow the robot to maintain stability and seek assistance from other people by raising the alarm. Beyond this project timeline, it is anticipated that
the robot will also become capable of remote control trajectory and multimedia
interaction.
18
2.4 Modes of Operation and Control
Autonomous operation is the goal of mo st robot developers. Being autonomous
suggests the robot is capable of making the decisions itself and performing the
necessary actions. It is self-directed and self reliant. This type of control system is
self contained with no outside control interaction from humans. Autonomous
systems are typically difficult to implemen t due to the complexity of inputs and
outputs, and the variables available. Common problems are associated with the sensitivity, responsiveness and other reactive factors of the components used within the final system.
Non-autonomous operation is much easier to implement as a human still
makes the decisions on what actions to undertake. This is typically achieved via
remote control facilities for the human. Within the two wheeled balancing robot
projects encountered during the literature review, it can be seen that stability control
is normally autonomous controlled whilst the trajectory is predominantly non-
autonomous based. Sensory such as cameras and radar devices could provide terrain identification and object detec tion to assist an autonomous trajectory design but this
is outside the scope of this pr oject due to time constraints.
2.5 Implications and Ethics of Technology
Implications of technologies, especially asso ciated with robotics, bring a fear that
people will no longer be competitive for em ployment opportunities, particularly, in
the future. This idea is encouraged with the offer of cheap labour robots that are slowly becoming available in the marketpl ace. Although this appears to be true on
face value, the majority of jobs that robot s are undertaking include those that people
consider to be hard labour, repetitive and hazardous.
Reducing the exposure of people to ha rmful chemicals, environments and
conditions as well as the risk of physical injury should be embraced by society. A robot can easily have parts replaced if an in cident occurs but replacing an arm for a
human is not quite as simple. This idea also applies with repetitive tasks were human
workers may become fatigued or bored which ultimately leads to mistakes or potentially fatal errors. These mistakes can cause significant resource and time loss
for a company or organisation. This is easily avoided by using robots as they don’t become bored and with adequate maintenance schedules in place, they will remain accurate and precise in performing th eir roles with minimal downtime.
It is unlikely that society will witne ss a large reduction in employment. In
fact, there would be a redi stribution of employment due to changing vocational
needs. Instead of mining deep underground with the threat of suff ocation, collapse or
expose, the worker can now be employed on the surface, providing maintenance and engineering functions on th e robots and associated equi pment. Ultimately, robots
will increase the collective work output of nations further strengthening economic
security for its citizens and providing an opportunity for pe ople to achieve a
balanced work/life/home lifestyle.
19
Other im
plications suggest that robots could fulfil ro les of personal assistants,
carers and helpers thus reducing the stress and workloads of families living with
disability or medical co nditions. This would reduce medical and household costs
further decreasing burdens on families and people in general. This could also extend to the public health system where each pe rson receiving treatment can be monitored
and attended to for 100% of the time. Qu ality of life could also be improved for
those who lack the ability of motion. People around the world will have the ability to
retain their independence, even into the later years of their lives.
Negative implications may occur if corporations or governments begin
eliminating a large volume of human job pos itions without creating positions in other
fields/areas. Unfortunately, this relies on all members of society accepting their
moral and ethical responsibilities and oblig ations as people of the community. This
can be achieved by implementing law to prot ect this from occurr ing. There is some
potential for negative impacts due to neg ligent use of the tech nology but the positive
gains within all levels of societ y far exceed any perceived risks.
2.6 Conclusion
Two wheeled balancing robots consist of a robot chassis, two wheels and a stability control system. Additional components and attachments may be fitted depending on
the task required to be performed. There stre ngths lie in the ability to turn on the spot
and easily manoeuvre in confined areas. St ability is achieved by keeping the wheels
beneath the mass of the robot chassis. Utilising a non-linear control system for
stability will allow a more effective and robust control to be implemented.
Two wheeled balancing robots offer a re volutionary transportation capability.
They also offer the ability to fulfil any role and complete any task such as a carer or
worker within the community. Now that an understanding and knowledge of two
wheeled balancing robots have been achieved, the following chapter will begin the design and development section of this project.
20
Chapter 3
Design and Development
The design phase of a project is fundamental in evolving the ideas, requirements and objectives of the components that together, will form the completed robot. Development and careful design considerations provide the engineer with the ability of ensuring that the concept remains viable as it progresses. It also provides the
opportunity to make continued improvements in its operation, en suring that obvious
problems and potential faults are removed ear ly in the project. This ultimately saves
valuable time and resources over the duration of the project.
3.1 Introduction
The literature review conducted in the pr evious chapter provided a wealth of
information on past robotic projects that had been completed by enthusiast and
engineers alike. This indicated that linea r control systems with remote controlled
locomotion were very common which inspired this project to undertake a completely
different approach. This revolved around a design based on a non-linear fuzzy controller for stability. The review provided ideas and consideration which will be explored in the following sections of th is chapter. These include how it will move,
how it will sense the environment around it, how it will be powered and what it will
be made from.
The two wheeled balancing robot will be broken into two distinctive
components of operation. The first is th e balancing component “Microcontroller
system” which will fulfil the fundamental goals of the project. This encompasses the sensors, chassis, locomotion and microcontro ller with its associated control system.
The second involves the intera ction of the robot with the controller as well as with
people it may encounter. This component is called th e “Interaction system” and
encompasses the wireless network conn ectivity, interaction computer, audio
components and web cameras.
3.2 Control System
The purpose of a control system is to keep a system or plant, within a specified range
of elements and set variables. This coul d refer to numerous applications such as
production, assembly and industrial plan ts through to computer, electrical and
electronic systems. For this project, it re fers to the control system charged with
maintaining stability of the robot chassis. Controlling the stabi lity of the balancing
robot requires sensors to detect the direction and rate of mo tion as well as a decision
based application that will pr ovide the response signals to the motors. Many forms of
linear systems such as LQR, lead-lag, PI D, state feedback and pole placement are
commonly used in roboti c stability designs.
21
Advancem
ents in non-linear control sy stems such as neural networks and
fuzzy controllers present the opportunity for developing far superior, responsive
control systems. Non-linear is the preferred control system for this robot as a
reliable, robust and stable platform can be achieved. There are several types of fuzzy
controllers derived to date including the direct fuzzy (non-adaptive), adaptive, fixed
and supervisory fuzzy controllers.
The fuzzy controller operates differently to these classical linear controllers
as it refers to a set of rules to provide a range of responses, rather then a single
predetermined output variati on to the input. The input of the fuzzy controller
undergoes fuzzification upon entry. Fuzzifica tion is the process of modifying the
input into the required rule base format. The inference mechanism then determines which set of rules are referred to for deci ding on the necessary output response. Once
this resultant action is determined, it th en undergoes defuzzifi cation before being
outputted to the system under control.
Ideally, adaptive fuzzy control would have been chosen as it is capable of
learning how to improve its performance but it had to be overlooked due to time
constraints. This is achieved by co mparing the output response and the
corresponding feedback valu es returned to the controller. By monitoring and
reducing system errors, the controller will learn to control more effective and
efficiently then it would by utilising its default rule set. The idea of combining
several fuzzy controllers was also contemplated but the risk of increased complexity
and difficulty controlling changes was too large. These cascaded systems could have
comprised of speed, stability and locomotion controllers.
The goal of the fuzzy controller being implemented is to be capable of
recovering from deliberately induced tilt above the rate of 15
o per second. These
results are not easily realized under linear control systems thus a fuzzy controller
approach is preferred. Choosing a sampling ra te that will be capable of performing
successfully was taken on the principle of Nyquist sampling theorem. This suggests
that the sampling rate is twice that of the highest operating frequency of the system.
A Direct Fuzzy Controller was designed for this project encompassing four
inputs and a split output. Th ese inputs are displacement (horizontal) provided by the
shaft encoders, velocity (hor izontal) derived from the derivative of the displacement,
angle (vertical) provided by the inertial sensors and angular velocity (vertical)
derived from the derivative of the angle. The output signal will be split and provided to the left and right motor controller routines.
22
Size ValueInput 1
(rad) Input 2
(rad/s) Input 3
(m) Input 4
(m/s) Output
(%)
Negative Large (NL) 1 -pi/5 -5 -0.1 -0.45 -100
Negative Medium (NM) 2 -pi/9 -2 -0.07 -0.3 -70
Negative Small (NS) 3 -pi/28 -1 -0.04 -0.15 -30
Centre (CE) 4 0 0 0 0 0
Positive Small (PS) 5 pi/28 1 0.04 0.15 30
Positive Medium (PM) 6 pi/9 2 0.07 0.3 70
Positive Large (PL) 7 pi/5 5 0.1 0.45 100
Table 3.1 Fuzzy controller membership functions
For the system to be balanced at equ ilibrium, all four inputs are ideally at
zero. The fuzzy process encompasses seven memberships for rating the strength of
the inputs within this system and is contained in the previous table. These
memberships are then incorporated with each of the inputs and output to form
functions known as membership functions. The name of these types of membership
functions comes from its shape, such as tr iangular which was chosen for this project.
Triangular, trapezoid, gaussian and bell membership functions are a few that
may be produced. They represent linguistic values such as positive large through to
negative large with a minium, maximum a nd centre value. The shape they undertake
reflects how the values a portrayed. This is particularly important as centroid of area
was used in the defuzzification of the tr iangular output membership function. This
allowed an actual value to be selected based on the fuzzy rule set.
Figure 3.1 Input 1 – Angle membership function
23
Figure 3.2 Input 2 – Angular veloci ty membership function
Figure 3.3 Input 3 – Displacement membership function
Figure 3.4 Input 4 – Velocity membership function
24
Figure 3.5 Output – Motor output membership function
The previous figures contain the visu al representations of the respective
membership functions. As seven membership functions were decided on for each of
the four inputs, 2401 conjunctive rules (7*7*7*7=2401) would be required. This was
reduced to approximately 427 rules by giving th e vertical inputs a higher priority, as
maintaining a small vertical angle is cruc ial for preserving stability. The horizontal
inputs are only enacted upon when the vertical is in a centred state. It is essential to
reduce the rule set as much as possible as its size directly impacts on the processing
time necessary to search it.
Angle
Angular
Velocity NL NM NS CE PS PM PL
NL PL PL PM PM PS PS CE
NM PL PM PM PS PS CE NS
NS PM PM PS PS CE NS NS
CE PM PS PS CE NS NS NM
PS PS PS CE NS NS NM NM
PM PS CE NS NS NM NM NL
PL CE NS NS NM NM NL NL
Table 3.2 Angle and angular velocity rule relationship
25
Displacement
Velocit y NL NM NS CE PS PM PL
NL PM PM PM PS PS PS CE
NM PM PM PS PS PS CE NS
NS PM PS PS PS CE NS NS
CE PS PS PS CE NS NS NS
PS PS PS CE NS NS NS NM
PM PS CE NS NS NS NM NM
PL CE NS NS NS NM NM NM
Table 3.3 Displacement and velocity rule relationship
The previous tables cont ain the rule relationships of the vertical and
horizontal input sets respectively. This pr ovides the fundamental component of the
rule base. For example, if the angle and a ngular velocity were both negative medium,
then a response of positive medium is required at the motors. If the output required
was nil (centre), then the horizontal relationship would provide the output response.
The defuzzification method known a Centro id of Area (COA) was the preferred
method for the output as it allows an accurate translation to real output values. With
the output already scaled between 0 and 100, this could be translated directly to the percentage of PWM required.
Procedures (Deepa, Sivanandam & Su mathi 2007) for creating the fuzzy
control system within Matlab “Simulink” are simplified by a built in fuzzy toolbox.
The following figures contain surface plots for each of the rule sets that were
created. These reflect the rule relationships contained within the previous tables. The
resultant plots are very similar at first gl ance but the vertical rule set contained a
more rigid surface. The horizontal rule set provided a more gradual variance which is
more reflective of a fuzzy control system . Simulation of the controller was then
possible with the use of the ‘slcp’ co mmand although this avenue was not pursued.
26
Figure 3.6 Angle and angular veloc ity rule set surface plot
Figure 3.7 Displacement and velocity rule set surface plot
3.3 Software and Programming Concept
Programming involves the structure of l ogical sequences and processes that are
incurred in reaction to various input va riables of a system. This programming will
enact an output action or outcomes in response depending upon its construction. The
program containing this programming is know n as software. Software may comprise
of several programs incorporated together to form a ‘software package’. Software is
typically used to control hardware or external devices although it is more prominently used to control other software programs and processes today.
27
W
hen a software program appears to be performing numerous tasks
seamlessly, it usually contains several prog rams working in conjunction. To achieve
this, programs are again broken into rou tines and sub-routines which reduce the
overall size of the main program. This improves efficiency and responsiveness by
only calling blocks of programming that are necessary for the specific task at hand.
This has the effect of reducing th e microcontrollers processing time.
The programming necessary for the two wheeled robot encompasses the
microcontroller and interaction sy stems. The microcontroller is required to read in an
assortment of sensors, provide computation on these inputs, make a judgement on the necessary actions to undertake and then respond by providing drive signals to the
motors. This is purely to enact stabili ty and locomotion control programming. The
programming was completed in C programming language and then compiled for the microcontroller by the software tool, MPLAB.
The programming goal of the interac tion system was to incorporate a
wireless (WiFi) connection thus allowi ng remote locomotion control, access to
onboard sound and visual devices, and to provide a means of reprogramming the
microcontroller. The Microsoft Robotics development Studio package would have
provided the programming tool using visu al basic programming techniques. This
component was not completed due to the tim eframe but it will be endeavoured in the
future.
Figure 3.8 Microcontroller structure chart
The structure chart in the previous fi gure represents the basic direction and
purpose of system signals. Design of the ma in program was achieved by using this
chart to create flowcharts to represent ea ch of the tasks and actions necessary for
completing the microcontroller’s function. The main program will be quite small,
calling on the sub-routines to perform speci fic actions. The sub-routines represent
blocks of steps needed for successful completion of the task. Understanding the variables and identifying the input/output por ts necessary is crucial for simplifying
the process of deriving these sub-routines.
28
Figure 3.9 Microcontroller main program flowchart
The main program begins with an ‘Initi alise’ block which sets up the stored
values and lookup tables. This block is only executed upon start-up or reset. The
remainder of the looped program contains four main sub-routines and a decision
block. The sub-routines are discussed in the subsequent paragraphs below. The
decision block has been incorporated to de termine if the bumper collision switches
have been activated.
Upon activation the program will end causing the robot to stop driving the
motors, thus releasing any driving force that may have been applied. The program may be reinitialised at this point by resetting the microcontroller. If the switches are not activated, then the program will conti nue through the looped ‘while’ sequence.
The first sub-routine is called ‘Sensors’. Its initial block reads the digital
sensor inputs before storing there values . The next reads analogue sensor inputs
before applying an A/D conve rsion and storing the value in memory. The next block
performs a Kalman Filtering estimation of the inertial sensors with the final block deriving the angle, angular velocity, displa cement and velocity values (stability
values) which are then stored for use with in the ‘Fuzzy Control’ sub-routine.
29
Sub-routine ‘Locom
otion Desired’ r eads the user provided forward,
backward, left and right dir ection control signals. The following two blocks then
determine a resultant left and right motor response respectively, which is stored for
use within the next locomotion sub-routine. These values are also used within the subsequent block to derive an offset valu e for the vertical angle measurement. This
will allow the robot chassis to be tilted in to the direction of desired travel thus
allowing more torque to be achieved.
Figure 3.10 Sensors and locomotion desi red sub-routine flowcharts
The ‘Fuzzy Control’ sub-routine forms the core of the control system. The
initial block converts the stability values to there respective equivalent linguistic
membership values. The next block then compares these values with the rule set to determine the desired output response for the motors. The remaining block then
performs a defuzzification to arrive at a motor output signal response.
The final sub-routine ‘Locomotion Res ponse’ begins by utilising the desired
locomotion output and fuzzy control output si gnals within the calculation of the final
motor output responses for each of the motors. Two more blocks then perform PID
calculations on each of these motor responses with the final block actually providing
the output to drive the motor circuitry.
30
Figure 3.11 Fuzzy control and locomotion response sub-routine flowcharts
Figure 3.12 Control system functionality
31
3.4 Design Considerations
Design considerations are an important f actor when compiling a design because they
facilitate an informed decision on the limitations, operating conditions and
capabilities of the final product. This pro cess may also highlight areas for further
investigation that could improve, simplify or make a product more cost effective. This includes commercial aspects that may be undertaken if the product was to
become mass produced or if an alternate material or component usage was to be
implemented to reduce the poten tial manufacturing costs.
Design considerations for the two wheeled robot encompassed operating
environments, motors, wheels, sensors, microcontroller, co mmunications, power
source, safety features, electromagnetic f actors and various forms of control. All
these considerations were then sub-in vestigated to determine dimensions,
configuration, temperature parameters, ma intenance requirements, availability,
efficiency, etc. Consideration of these factors combine togeth er to guarantee the
necessary capability is achieved successfu lly within the timeframe and resources
available.
3.4.1 Operating Environments
The operating environment of the machine refers the conditions under which it will
be performing its tasks. Primarily, th is can be broken down into two main
environments, indoors and outdoors. The outdoor environment woul d be much more
hash with exposure to numerous varietie s of weather including rain and hail.
Temperature variation could be as much as 50oC and when combined with
continuous direct sunlight, could pose serious performan ce degrading if a robust
design was not incorporated.
An indoor design proves to be a simp ler process as the environment is
normally regulated by air-condit ioners. This also reduces the expose to dust and dirt
particles, direct wetting and even direct sunlight (UV). The terrain is also smoother
when compared to the rough outdoors through paving, carpeting and tiling.
Neglecting to adequately prepare a machine for its operating environment may lead to premature breakdown, potential safety im plication and loss of productivity in a
commercial situation.
The operating conditions expected for this robot includes both indoor and
outdoor environments. Ideally, the robot will be capable of travelling across outdoor
areas with up to 100mm crevices within th e confines of local infrastructure. These
include sandy beaches, sports ovals and bicy cle tracks. Incorporating some form of
waterproofing would provide protection from rain or accidental wetting as moisture
entering the robot could cause corrosion (m echanical) or short circuit (electronic)
damage. It will not be operated during wet we ather conditions so external casing and
coverings are not deemed essential.
32
The m
aximum temperature expected is approximately 60oC. This remains
below the rated maximum temperatures of IC’s, components, cable and part ratings.
Direct sun could raise the temperature be yond this posing a pote ntial problem unless
cooling is implemented with in the robot chassis but th is will not be pursued.
Vibration would remain manageable for the final size and weight of the robot. Extra
care was taken in reducing the vibration ri sk by securely fastening all components
and circuitry in place as well as the incl usion of rubber matting between the motors
and chassis.
3.4.2 Materials, Size and Weight
The materials used in a design limit the dur ability, strength, maintainability, energy
efficiency and operating capability of the product. They also impact on the size and
contribute to the total weight of the final design. A heavier material such a metal is typically stronger then lighter materials such as plastics but it requires more energy
to move. The size of the design impacts on its ability to naviga te around, through or
over obstacles as well as its transportability.
Materials that could have been used in the robots construc tion include metals,
alloys, wood, plastics and other synthetics . Heavier metals were excluded early due
to the increased weight that would impair the stability control of the robot. Although
wood was an option, it is a potential igniti on source in higher temperatures and is
also very difficult to moul d. Rubber strips could also be utilised in the shock
resistant precautions that may be experien ced from falls, bumps or rough terrain but
this was only incorporated to support the battery and motors w ithin their mounts.
As the robot will be utilised in a pe ople environment, a maximum height of
0.8 m was chosen as it approximates to a child’s height. The robot chassis has a
multi-platform layout where each platform (layer) contains a unique component of
the robot systems. An average height of 120 mm will separate each layer with the
exception of the power level due to the limited battery sizes available. This is 150 mm. Additional layers could be added to the top of the chassis, permitting easy expansion of the robots capabilities thus a llowing greater flexibility for adaptability
and enhancements.
A diameter of 280 mm was chosen for the layers as it provided ample area to
mount the PCB’s, components, etc. This being a rounded shape as opposed to square allows the robot to easily revolve on the spot and around narrow areas without
having to square itself up with the perime ter. A combination of alloy metal for the
frame and plastic for the layers was used as they provided a compromise between
weight, durability and strength. Utilising trigonometry mathematics, a metal length
of 275 mm was derived for mounting the layers and adjoining the si de lengths of 510
mm. The metal width was a standard 97 mm wide.
33
Several options are available for joini ng the chassis p
ieces together such as
bolts, screws and welding but rivets were the preferred method in this case. Epoxy
adhesives were utilised in joining the plastic pieces together. Additional plastic brackets were manufactured to attach sens ors and PCB’s which were also affixed
into place with epoxy. The completed chassis weight goal was initia lly 5 Kg but this
was exceeded by 1 Kg by the final manufact ured product. The weight values were
calculated for each respective layer as follows:
Upper layer, 0.5 Kg,
Interactive system layer, 0.5 Kg,
Power layer, 7 Kg,
Spare layer 0 Kg,
Microcontroller layer 1 Kg,
Motor & wheels level, 2.5 Kg,
Chassis structure, 6 Kg,
TOTAL combined weight, 17.5 Kg.
An outer skin layer such as a thin plastic sheeting (1-2 mm ) could be applied
to the robot allowing a sleek appearance. The sensors would require that the outer
skin is cut to allow proximity detection, etc. Removable panels would be required to allow the maintainer or operator to access ce rtain areas of the robot for maintenance
and connection of peripherals. This option has not been pursued.
To improve the ability to balance, the aim was to place the larger weights
higher in the chassis layers. This principle can be equated to balancing a broom in
the palm of your hand. When the broom head is within your palm and the handle upwards, it is difficult to maintain the leng th in a vertical position. Reattempting this
task with the handle in your palm and the broom head high proves far easier to balance. Another goal was to centre the weight over the wheel axles, for each layer, to contribute to the stability of the robot.
The battery acts as a destabilising infl uence on the system due to its large
weight of 7 Kg in the upper half of the robot chassis. This allows the robot to
maintain stability easier as more torque can now be generated. Total weight of the robot was initially se t at a maximum value of 15 Kg but this was overs hoot by a total
of 2.5 Kg.
3.4.3 Wheels
The wheels provide traction a nd locomotion for the robot as well as support for the
robot chassis. The diameter of the wheel s hould be chosen to best reflect the torque
requirements of the machine. The tyre used will impact on traction and the smoothness of the motion experienced by the inertial sensors and sensitive
components onboard. The number of wheels to be used in a design should depend on
requirements of the capabilities.
34
To overcome poor traction, higher leve ls of torque are required which is
ultimately supplied by the motor. Ideally the tyre traction would have maximum
contact with the ground and minimal resistance through the drive system. A width
between 30-45 mm of a rubber tread was deemed acceptable as it would provide
reasonable grip for most te rrains and weather conditions. It would also prove ideal
for turning on the spot which is a major feature of a two wheeled balancing robot.
Each of the two wheels will be independen tly controlled in either direction by
a dedicated motor. The wheel could potentia lly have a large diameter such as a
bicycle wheel but this would prove impractic al for manoeuvring in confined areas or
indoors. The diameter required for the wheels was approximated between 150-190
mm so that proportionality could be maintain ed with the anticipated robot height of
800 mm and weight of 17.5 Kg. The diameter played an important factor in the
torque calculations that are further discu ssed within the motor section that follows.
Two plastic wheels with so lid rubber tyres were chosen due to there reduced
cost and lower associated weight compar ed to its metal count erparts. The wheel
diameter was 187 mm with a tyre width of 40 mm. As the tyre is solid, it is not susceptible to being punctured although this tyre will likely increase the vibration
experienced by the onboard circuitry if rough terrain was encountered.
3.4.4 Motors
Motors are an essential component for pr oviding mobility. Without motors to move
the machine, it would prove to be an expe nsive paperweight. Se veral types of motor
are available including Alternating Current (AC) or Direct Current (DC) types.
Variances of these motors include the br ushless, brush, servo and permanent magnet
motors. Another consideration for the moto r is its Revolutions Per Minute (RPM).
As most motors are rate d between 2000-7000 RPM, some form of gearing is
required to reduce the rate experienced at the wheel.
The idea of a motor for each side of the robot, also known as differential
drive, was decided upon early to reduce the potential mechanical complication involved with implementing a single motor sy stem. Using two motors will also allow
the torque to be more effectively applied to the wheel shafts t hus reducing the need
for complex calculations for frictional and rotational losses. Differential drive is displayed in the following figure.
35
Figure 3.13 Differential drive motion
As the right motor moves forward and the left motor moves backwards, the
robot chassis will be turned to the left. If equa l torque is applie d to each of the
motors, the robot will turn on the spot. Th e same principle appl ies if both of the
motor directions are reversed. If the left motor turns forward whilst the right motor
turns backwards, then the robot will turn to the right. If both motors are moving
forward, then the robot will move forward and vice versa. Other considerations for
the turning of the robot should include the a ngle of the robot chassis. With this in
mind, the main goal would be to tilt the chassis in the dire ction the robot is about to
travel.
A supply voltage of 12V was chosen fo r the motors although 6V and 24V are
also fairly common voltages. The motors would be better mounted under the robot chassis to allow a higher clearance fr om the ground. Otherwis e the lower chassis
layer may drag into the ground at a very lower angle of tilt. Stepper motors are too slow to react due to the actually stepping action and will not be capable of balancing
the robot efficiently. A motor with a high volume of torque was a necessity with the final choice being two HG37D670WE12-052 DC Brush motors with a 1:52 gear
head and shaft encoders fitted.
The required torque for the robot can be reduced by leaning forward into the
direction of anticipated travel. This will be attempted within the control system
design component. The RPM estimation of th e motor is 160 RPM. With the chosen
wheel diameter of 187mm, the expected approximated maximum speed is 5.64 km/h.
For a rated motor torque of 7.1Kg/cm, the an ticipated acceleration at the rated input
voltage is 0.086 m/s
2.
Velocity, 157 . 160160* * 187 . 060* * msRPMd vWH
164 . 510003600* 57 . 1 kmh v
Motor force, 1759 . 0
27 . 181 . 7
NcmrTF
36
Acceleration
, 2086 . 075 . 8759 . 0
2
cmsmassFa
Power, W rps T I V P 19 67 . 2 * 1 . 7 * *
The motors have shaft encoders incorporated into their case, rated as 12
pulses per motor revolution or 624 pulses pe r shaft revolution. Shaft encoders are
necessary to obtain linear pos ition measurements before the velocity calculations
may be performed. They are covered furthe r under the sensor section within this
chapter. Although the retailer recomme nded a 7.2 V input, the manufacturer
“Hennkwell” rated the motors input between 6 and 24V. It was concluded that 12V
may be safely applied in its operation. The additional voltage is expected to provide much needed torque to move the total weight of 17.5 Kg.
Motor Control
Motor controllers control the motors rate of turn and its direction by varying the output voltage signal and sett ing its polarity respectively. There a several forms of
motor control with the application dependant on the role and the motor in use. Direct, Relay, transist or or H-bridge (motor bridge) controllers are all common types
available. The later provides the facility for a pulse width m odulation (PWM) signal
output for varying the motor speed.
PWM provides an output voltage that is varied by a duty cycle. This duty
cycle is a percentage of voltage time hi gh compared to voltage output and specifies
the ‘pulse width’. The speed of the moto r is altered by alte ring this duty cycle
percentage. A benefit of this approach is that there is no digital to analogue
conversion necessary so there is no potenti al for induced noise or interference on the
signal. It is recommended (McComb & Predko 2006) that PWM is run at frequencies over 18 KHz, higher than the maximum hu man hearing frequency, to avoid hum
noise generation within the motors.
For controlling the robots motors, PWM w ill provide the best option as using
direct voltage level inputs may cause the robot to ‘hunt’ about its position. This occurs as the equilibrium point is exceeded consistently in either direction thus
causing an oscillating effect. The microcontroller cannot drive the motors directly at the necessary current so a H-bridge, called this due to its transistor configuration, will boost the PWM signal to the motor. Sm aller motor control changes such as
those in PWM, reduce the robots power requirements hence it is an added improvement to the robots design.
A custom designed H-bridge circuit in corporating protection diodes and dual
H-bridges was created but not pursued after a commer cially available kit, “L298
Motor driver” was discovered. This proved more economi cal and saved substantial
time when compared to the cost of ma nufacturing and constructing the PCB.
Configuring the purchased H-bridge circuit for 12V operation allows each bridge circuit peak output curre nt to be 2.92 A.
37
Figure 3.14 L298 motor driver PCB (Solarbotics)
The H-bridge circuit also offers LED i ndication of the direction each motor is
driven as well as an additional regulated 5V power supply output. This proved
beneficial for isolating the gyroscope circuitry from th e main 5V distribution and
reducing the gyroscopes EMI impact on the sy stem. The control inputs to the driver
allow forward or reverse rotation as well as braking of the motors . Another benefit of
the motor driver is the thermal shutdown protection incorporated into the PCB.
3.4.5 Sensors
Sensors provide the robot w ith the ability to interpre t the environment around them.
Without sensors, the robot would blindly execu te a series of instructions without the
capacity to re-evaluate its progress and make adjustments. Sensors are available in
two forms, analogue and digi tal. Analogue sensors provid e a range of values in
response to its sensitivity which have the benefits of measuring rates or volumes.
Digital sensors only provide an on or off value and are ideal for an absolute
indication. Sensors may be connected by parallel or serial connections to the
microcontroller or Analogue to Digital Convert ers (ADC) depending on the actual
sensor used.
Accelerometers, gyroscopes and inclinom eters are the most common types of
sensors utilised in robots and machines that require stability cont rol. They provide a
means of measuring acceleration, velocity a nd direction. If multiple axes were to be
measured with certain type of sensor th en a sensor would be required for each
particular axis. By combining different sensors through a process known as sensor
fusion, certain sensor problems such as gyroscope drift and noise can be overcome
and kept within the required accuracy. Co mmonly, a gyroscope and inclinometer are
combined.
Laser range finders, sonar range finders, ultrasound, microwave or Infra-Red
(IR) sensors can be utilised for detection of physical obstacles in the robots path or
proximity. The range finders provide a greater range of detection but are also much more expensive. These would have been a preferred option if mapping was part of the robots task. These sensors are mostly ac tive devices as they require a transducer
to transmit an energy signal whilst another transducer receives the reflected signal.
Some sensors such as the IR type also come in passive form which relies on the
signals already present in the surround environment to reflect from other objects.
38
Other form
s of sensors include contact sensors to detect a bump with an
object, light sensors to dete ct lighting changes or conditions, thermal sensors to
detect temperature variation and sound sensors that can de tect the presence of sound
waves. Contact sensors will be incorporated into the r obots design to stop the robot
moving in any direction. This is aimed at pr eventing damage to obsta cles or injury to
people. The five most common sens ors used in robotic design are IR,
accelerometers, gyroscopes, inclinometers and shaft encoders.
The sensor requirements for the project include inertial sensors for stability
sensing, proximity detection for object detection and bumper sensors for contact
detection. An accelerometer, gyroscope and shaft encoders form the inertial sensors.
IR sensors form the proximity detection wh ilst standard bumper switches provide the
contact detection. They are discussed further in the following paragraphs.
Accelerometers
Accelerometers provide a means of meas uring acceleration along an axis, also
known as force. They are susceptible to position noise which can be avoided by
incorporating filtering on their digital or PWM output lines. Accelerometers are
commonly found in airbag and braking cont rol systems of vehicles. Their main
purpose is to measure changes in speed. It is classed as an analogue device as the
voltage varies with respect to the rate of change.
This device will be used to determine th e change in speed with relation to the
robots tilt, its change in accelerati on. The model chosen was the ADXL311JE
accelerometer provided by Excelpoint, NSW. It is specified as a high shock resistant, low power, dual axis accelerometer. This model provides a bandwidth capability
within the 1-3 KHz range. The accelerometer output will be combined with the
gyroscope output to compensate for gyrosco pe drift thus creating a better stability
control signal. Acceleration of the t ilt can be defined by the expression:
Sin Gravity *
A common problem of being unable to differentiate between the tilt
acceleration and the actual locomotion accele ration will be avoided by using both
axes. One axis will detect upward/downw ard motion whilst the other will detect
forward/backward motion. Rough terrain could pose a problem if large bumps or vibration are encountered through the robot chassis. Fitting the device higher in the
robot chassis implies a more reliable reading as greater distance will be covered for
the same angle of tilt but previous research (Larson 2008) suggests that better
accuracy is achieved when the device is pl aced lower in the chassis. This will be
attempted.
Gyroscopes
A gyroscope presents a means of measuri ng rate of rotation (angular rate) but a
common problem is the output drifts over time. This occurs when the vibrating
resonator is rotated, causi ng additional vibration at an angle to the originating
vibration. This is also known as Corio lis Effect. A more reliable and accurate
reading can be achieved by fusing both a gyroscope and inclinometer together. This uses the inclinometer to detect the rota tion and correct the out put signal from the
gyroscope.
39
This device will be used
to determine the angle of tilt of the robot chassis.
The original model chosen was the ADXR150 gyroscope pr ovided by Excelpoint,
NSW. The device was not utilised due to th e difficulty experienced in attaching the
32 lead ball grid array to a circuit. The replacement device was the Angular-Rate
sensor XV-3500CB. The device is capable of 5V or 3.3V operation with a deflection
range of +/-100o. The gyroscope output will be combined with the accelerometer
output at set intervals to compensate for the Coriolis effect thus creating a better
stability control signal. As per the acceler ometer, the device will be mounted low
within the robot chassis to provide better accuracy.
Sensor Integration – Kalman Filter
Sensor integration is the process of combining multiple sensor responses together into a single, more reliable output sign al. In the sensor integration of an
accelerometer and a gyroscope, the resultant da ta provides a much mo re reliable tilt
angle value. This is achieved as the syst em has now compensated for gyroscope drift
that would otherwise provide imprecise indi cations. The majority of sensors have a
degree of unreliability that becomes inherent over time as well as introduced noise
which can also be overcome by this process.
Originally developed in 1960 by DR R Kalman for Apollo spacecraft,
Kalman filters are one approach that is used to perform sensor integration. They are described as a recursive filter and provide output estimation fo r the state of the
system based on past and present sensor measurements whilst also overcoming
sensor noise and other system disturbances. Simple and extended Kalman filters are two of the types that are available whic h are used on linear or non-linear systems
respectively.
The extended Kalman filter was the chosen option for the project. An
inclinometer could have also been incor porated with the gyroscope to reduce “gyro
drift” but this approach as overlooked with the addition of an accelerometer into the
inertial system. Simon (2001) presents a Ka lman filtering approach that will be
utilised as the basis for performing the sensor fusion within this project. This is covered further within the programming a nd software component of chapter 4.
Shaft Encoders
Shaft encoders are typically mounted on th e motor shaft before the gearing down at
the wheels as a higher count per revoluti on increases its effective accuracy. They
provide a means of measuring distance travelled and its direction which is then used as feedback within the moto r control computations. This also provides a function for
deriving velocity within the microcontroll er. Optical encoders are one type that
counts every time it detects a light reflec tion. Magnetic encoders are another type
which counts every time it detects a magnetic influence passing its sensor.
40
The best approach to
efficiently ut ilise the encoders is to use the
microcontroller’s onboard counter inputs. This does not ut ilise the microcontroller
processing directly which allows ot her computations to be performed
simultaneously. The microcontroller progr amming should reset the counter input
upon actuation of the motors and then perfor m a read of the counter once the motors
are stopped. These counts can then be multiplied by the distance of each pulse to
produce a distance reading fo r horizontal displacement.
This approach will be undertaken in th e project. The motors chosen were
HG37D form which were pre-fitted with shaft encoders rated at 12 pulses per motor revolution or 624 pulses per shaft revoluti on. With a wheel diameter of 187 mm
(circumference 587.4778mm), this equa tes to 48.9565 mm per pulse of motor
revolution or 0.9415 mm per pulses of shaft revolution. Potential errors in counting
could be induced by travelling over uneven terrain or through the loss of traction.
Infra-Red (IR) Sensors
IR sensors can be utilised for detection of physical obstacles in the robots proximity.
These sensors are mostly active devices as they require a transducer to transmit an energy signal whilst another transducer receives the reflected signal. The output
voltage varies with the distance to the de tected object. The IR transmitted signal is
often modulated to allow differentiation betw een the required IR si gnal and spurious
IR emissions. This allows the sensor to overcome noise and false triggering.
Ideally, IR sensors would be placed at 90
o angles around the lower and upper
layers of the robot chassis to provide more stringent detection network but the added
cost of approximately $15 per sensor made this approach uneconomical. IR sensors
could have been utilised for measuring th e distance from the chassis to the ground
also but since this robot is expected to traverse uneven grounds and environments, it
would be impractical to use in this manner.
Figure 3.15 Sharp GP2D12 sensor (Sharp)
Sharp IR GP2D12 sensors have been in corporated in the robots design for
proximity detection. This will ensure the robot maintains a safe distance from
obstacles, people and hazards. Three have been fitted in total with two attached to
the lower layer with one facing forward whils t the other rearward. The third has been
fitted much higher up facing forward as a fail safe sensor for elevated object detection. This was aimed at detecting objects that may not have a lower base such as tabletops or lamp shades. The pulse cy cle duration of the device is 39ms with a
44ms start up delay.
41
The orienta
tion of the IR sense had the emitter LED on top to improve the
reception of the signal as suggested by the manufacturer. This improves the
reflectivity of the signal. It was also suggested that addition of 10uF bypass
capacitors near the sensor would improve its performance, so they have been
incorporated also. Distance detection will be set for 20 cm on the lower layer sensors
and 30 cm on the upper layer. The rated voltages for distance detection are as
follows:
10 cm, 2.45 V,
20 cm, 1.35 V,
30 cm, 0.95 V,
40 cm, 0.75 V,
50 cm, 0.55 V,
80 cm, 0.4 V.
3.4.6 Microcontroller
The purpose of a microcontrolle r is to complete computations and process data by
executing instructions or programming. Th ey contain all the necessary components
expected of a computer system in a singl e Integrated Chip (IC). These include the
processor itself, RAM, ROM and input/outputs. Since they are small in size, they are typically implemented in embedded sy stems and can be found in numerous
household appliances.
Ideally, a microcontroller will maintain a fast response with minimal power
consumption and low susceptibility to in terference. The IC should contain all the
devices necessary for operational require ments such as timers, ADC, DAC, and
PWM outputs. This reduces the need for additional peripherals and hardware to be incorporated which would only increase the complexity required and the power
requirements needed. The microcontroller s hould also be reprogrammable to allow
improved operation and upgrades over it intended lifespan and beyond.
The choice of microcontroller was di fficult due to the large range and
variations available. A 24-bit wide instruction microcontroller was favoured over the
common 8-bit counterparts due to the extra inherent capabilities. The PIC chips are very common and easily available from the manufacturer Microchip, hence they are
the preferred supplier. It was also noted th at the manufacturer has incorporated lead-
free product packaging for its products identifying an environmentally friendly product.
The idea of a redundant microcontrolle r was contemplated but overlooked
due to the nature of this r obots design. For safety critical or essential applications,
additional microcontrollers could be incorp orated to ensure operability in all
circumstances. There are 20, 30 and 40 Mi llion Instructions per Second (MIPS)
versions with the high performance cont roller, PIC24H, chosen for its superior
capability. This could be substituted for a cheaper, low performance controller in the
future if commercial production of this robot was viable.
42
The added benefits of using 16-bit a ddressing IC’s include the 0 to 65535
range as opposed to the 0 to 255 range from
an 8-bit IC. This also provides a 216
memory addressing range. Other considera tions include de-rating of the bus to an
approximate 50-80% of its rated raw maxi mum. This reduces power consumption
and improves efficiency as well as lowers the operating temperature. Features that
are favoured in a microcontro ller include the following:
Lower power function, energy saving features,
Reliable,
Reprogrammable,
Onboard ADC,
Useable PWM input/outputs,
Low cost,
Necessary number of Input / Output pins,
Timers,
Voltage comparator.
The PIC24HJ256GP206 microcontroller was the chosen option at 40 MIPS
with low power consumption. It operates on a voltage between 3-3.6V and provides
all the functionality required for the project including a total of 53 input/output pins.
This includes 8 PWM outputs and an 18 cha nnel analogue to digital converter. PWM
will provide the output driver control for the motors whilst the ADC will provide
sensor input digitalising. The IC package supplied was a 64 pin TQFP which initially
proved difficult gaining a circuit board in the correct size scale but this was
eventually overcome.
43
Figure 3.16 Microcontroller circuit
The controller contains 16 KB of RAM and 256 KB of programmable flash
allowing the stability control algorithm a nd associated control programming to be
easily stored and run. The chip can handle 24-bit wide instructions with the C
programming completed within the software package ‘MPLAB’. A debugger/programmer ICD 2.5 was sourced form an electronic supplier online for performing the microchip flash programming. Additional connectivity was added to the design to allow reprogramming whilst fitt ed inside the robot. The previous figure
contains the developed microcontroller circuit.
3.4.7 Components / Circuits
Components form the building blocks of circ uits which in turn provide the capability
and reality of a machines operation. Components include resistors, capacitors,
transistors, switches, sensors and IC’s. Th ey are typically assembled together on a
PCB to form a robust, compact and localised circuit. Components are given tolerances in which they may vary from th e prescribed rated value. They are also
rated on there power carrying capability and temperature variation characteristics.
Ideally, circuits are designed to be maintenance free with materials and
components that will maintain toleran ce over significant time and operational
circumstances. If a single component was to fail, significant damage could be imposed on the robot or those around it through the malfunctioned actions. This may
also occur if the PCB track widths or wire gauges were not checked to ensure they are capable of maintaining the currents that will be developed whilst in operation.
44
Electrolytic capacitors p
ose the only si gnificant maintenance consideration to
this robot’s circuitry as th ey are prone to leakage af ter they exceed there short
lifespan. The components utilised with in the robot designs will be those
commercially available through local and onl ine electronic stores . Higher reliability
and tolerance items with wider temperature ranges could also be incorporated into
the design if the robot’s operational sp ecifications were to be improved on.
Additional considerations that were encompassed in the circuit designs included the
use of pull up resistors, bypass capacitors and shorter leads to provide extra
protection of signals an d resistance to noise.
Circuits for voltage monitoring of the battery, motor control and the
interaction computer could have been designed and created uniquely, but commercial available options proved more economical both financially and time wise. The major peripherals such as th e web cameras and speaker system were
purchase for similar reasons. Power distri bution circuitry was specifically designed
and created for application within the robots system. The main circuits utilised
within the design can be summarised into the following PCB’s:
12V power distribution,
3.3V & 5V power distribution,
Voltage monitor,
Microcontroller,
H-bridge,
Interaction computer,
Accelerometer sensor board.
3.4.8 Stability Control Requirements
Stability refers the ability to maintain a firm upright position without inherent
movement. Being balanced suggests that st ability has been achieved as no further
motion should occur. To achieve this, there mu st be some type of control or force in
place that inhibits the unwanted motion. This cont rol would need to counteract
forces or influences in a reasonable timef rame or stability would be easily lost.
Stability control is the funda mental aim of this project. In terms of the robot,
without stability control, it will merely fa ll over. The way in which the robot chassis
will maintain stability revolves around the control instructions programmed within
the microcontroller system. These will read inputs from the inertial devices
(accelerometer, gyroscope, shaft encoders), bump detectors and IR sensors, then create a reactive output signal for controlling the motors. This will be implemented by a fuzzy control system as discussed previously.
A possible stability method that was overlooked during the project would
be to incorporate a system that relies on a fo rm of brakes attached to the wheels. This
would allow the motor torque to be direct ly applied to the r obot chassis when the
brakes were engaged. The brakes could be disengaged and torque applied again
through motion of the wheels. This option would have provided stability control
with, theoretically, no horizontal displa cement or acceleration thus reducing the
complexity required in the fuzzy control system. Unfortunately, this idea was not
conceived early enough in the proj ect to allow investigation.
45
Stability is even m
ore of a challe nge when travelling up or down steep
inclines. This will cause the gravitational fo rce to move from the vertical plane and if
the system cannot account for this, it will become unstable. Idea lly, a value will be
added to the measured angle of rotation to compensate for these forces. Determining
the maximum allowable angle of tilt for th e robot chassis required a trigonometric
approach. As the motor will be mounted to the undercarriage, the extra height will
add to the radius of the wheel and thus provide an adjacent le ngth value of 125 mm.
A hypotenuse length of 140 mm is then f ound. The following calculations were
performed: Hypotenuse Length L
H = 140mm
Adjacent Length L A = 125mm
140125
HA
CalLLCos
77 . 261401251CosCal
90Cal Max
23 . 63 77 . 26 90Max
Therefore, the maximum tilt before recovery is no longer possible occurs at an angle
greater then 60o or pi/3 rad.
Figure 3.17 Maximum tilt angle variables
46
3.4.9 Power Source
A power source is essential for providing energy to a machine. Without energy, a
machine would simply not operate. If an insufficient power source was implemented,
a machine would not function correctly nor would it perform adequately. Power
sources may be AC through electrical main supplies or gene rators. They may also be
DC from devices such as batteries. Batteri es are rated by voltage output and ampere
hours (AH). AH refers to the current that they can supply per hour.
Batteries will be an essential component in allowing the robot to maintain
autonomous operation. Otherwise a direct connection between the robot and a power
source would need to be maintained at al l times. Ideally, the best practise is to
minimise the total power consumption durin g this design phase so a smaller power
system may be implemented. This is an important factor as power systems are
typically the heaviest elem ent of a robot or device.
The design should aim for low power devices such as the microcontrollers
and other components that have already b een chosen. 6V, 12V and 24V supplies are
the most common battery systems available. The robots system voltage was chosen to be 12V because of the better options available when choosing the motors and
various circuits to implement. It also permits the creation of simple DC-DC
conversion circuits encompassing 3.3V and 5V within the robots system. The battery
proved to be a significant expendi ture of this projects budget.
PWM was chosen for the motor control in an attempt to reduce the total
current (power) supply required in mainta ining stability. The idea of a redundant
power supply system was considered unnecessary in this application. It could be an
additional option if it was to be utilised in critical applications. Ideally the chosen
battery will also have a lower internal resistance which will allow the maximum
power delivery to the motors through higher curr ent capability. The types of batteries
available include the following:
Nickel-Metal Hydride (NiMH),
NiMH is the best rechargeable battery option available as it may be recharged
hundred of times without memory effect . It is also bette r for high current
applications such as robotics and has a low internal resistance.
Nickel-Cadmium (NiCad),
NiCad batteries are prone to memory effect and are highly toxic.
Alkaline,
Zinc batteries provide a better perfor mance and are low current charging.
Lead-Acid,
Lead-acid are a long lasting battery but they are typically heavier and larger
compared to its counterparts. There is also a potential problem that gas may build up in poorly circulated areas during charge up.
Zinc based,
Zinc batteries are prone to draining at fast rates.
47
Various configurations of battery connections (McCom
b & Predko 2006)
were considered including a series connection between two batteries that would
allow the voltage to be doubled. This could be beneficial for higher motor voltage
usage. A parallel connection of the batteri es would allow the current to be doubled.
The disadvantage with these approaches is that both batteries would require
replacing if one begins to exhibit poor pe rformance. If a series connection between
two batteries was used as well as a single connection from one of them, they would
discharge at different rates pr oving a potential disadvantage.
A solar panel for recharging whilst the robot was active could have provided
a boost to the battery. Although feasible, it was not pursued due to the extra costs
involved. Isolation of power supply cables w ithin the robot could have been
achieved with opto-isolators. They are av ailable in IC form and may have been
beneficial for use with the sensor power connections.
Filtering out noise on the power sour ce with bypass capacitors was an
essential addition for preserving stable ope ration. These were installed on the input
voltage connector for each of the PCB’s. A filter capacitor was installed, close to the battery terminals as another interference preventative measure. Unfortunately, noise
is typically introduced by motors and other analogue devices which form the
majority of the robots components.
A voltage monitoring circuit was initia lly designed but became uneconomical
both financially and time wise when a similar 12V LM3914 LED display based
voltage meter was discovered from an electronics supplier. Although not
implemented, one of the LED’s could provide a signal for use as an interrupt. This
would effectively warn the control system of imminent power fa ilure which inturn
would call a recharge sub-routine, redire cting the robot back to the user for
recharging. The implemented voltage monito ring can be initiated at any time via a
switch. The switch ensures that the voltage meter can be isolated from the battery,
preventing it from being inadvertently drained.
Figure 3.18 Voltage monitoring circuit (Dick Smith Electronics)
48
The power requirem
ents of the robot were initially estimated at
approximately 20A. Protecting the robots components from damage by over voltage
or voltage spikes during the recharge pr ocess requires that they are disconnected
from the battery. This has been incorporated by selecting a DC female connector that
breaks the connection upon ch arger connection. A physical isolation switch before
the 12V distribution board was also implem ented. Overcharge protection circuitry
could have been developed but manually checking the voltage meter was deemed
acceptable for the project.
The simpler approach of utilising a single battery and implementing DC-DC
conversions for lower voltages was chosen . The battery select ed to meet these
requirements was the lead acid type, rated at 12V 26Ah. Choosing the type of battery
proved difficult due to the in herent large weight but economically it was the best
choice for the current required. The following current allowances we determined with a peak current of 21A expected:
Interaction computer system 10 Amps,
3.3V & 5V distributi on circuitry, 5 Amps,
Motor circuit, 6 Amps.
This battery is easily capable of supplying the motor stall currents as well as
maintaining maximum current draw of the ci rcuits and interaction computer. Voltage
regulators were designed into the distribution boards. A LM 7812 CT regulator in
conjunction with high power transistors regulates the 12V supply. A LM 7805 CT
and LM317 regulator supports the 5V and 3.3V supplies respectively. A diode was
also used on the input of 12V board to protect from accidental reversal of the
polarities. Blade fuses were utilised for circuit protect of the 12V circuits. The
following figures contain the volta ge distribution circuit boards.
49
Figure 3.19 12V distribution circuit
Figure 3.20 Low voltage distribution circuit
3.4.10 Locomotion Control
Locomotion refers to the ability to move. This can be achieved numerous ways
through the use of wheels, legs or any ot her means. Control of locomotion implies
that the direction, speed and distance th e object travels can be determined and
directed by either the object itself or an operator. This can be implemented through
an algorithm or control system that could incorporate various components such as visual based detection systems, proximity detection sensors or even GPS devices.
50
Tim
e restraints have restricted the ac hievement of this section but the goal
was to establish a wireless network connect ion via a USB WiFi device attached to
the interaction computer. Mi crosoft Robotics Developer St udio would have provided
the tools to control the robot through a simp le visual basic program utilising internet
explorer. The web cameras would be availabl e for providing a visual display to the
operator at the remote location.
3.4.11 Communications
Communications allows the operator or mainta iner to interact with the robot through
either a direct connection or wireless link. This would allow the robots actions such
as locomotion to be controlled. It w ould also allow maintenance activities,
monitoring of the systems and reprogr amming of the microcontroller to be
completed remotely. Allowing remote cont rol through a wireless connection has the
benefits of operating in areas or regions considered uninhabitable for human beings.
This also allows the robot to be opera ted or maintained by skilled users in a
completely different geographic location.
A WiFi wireless network connection has been incorporated within the
interaction system which allows the robot to maintain a communication link with its operator or fellow robots. Interaction with people can also be achieved by streaming
the video imagery captured by the robo ts cameras and the audio from the
microphones back to the operato r. The speaker system is capable of projecting the
user’s voice at the robots location as well as the facility to add a 7in LCD screen to
the upper layer of the robot for disp laying the operator’s video image.
3.4.12 System Integration
System integration refers to ensuring the components and sections of the robot, each
work together to ensure a smooth operation and performance of its tasks. Integrating
each of the systems ensures signals and responses between each is interpreted and responded to as expected. Size of cabling between systems, layers and components
including its current capacity and EMI susc eptibility will impact on the successful
transmission and reception of signals.
The idea of either a single control or distributed control for the robots
functions was considered. ‘Distributed’ means that each task/component has its own microcontroller for managing its function. The advantages ar e that this approach is
more reliable and less comple x although it may cost more in hardware to implement.
Centralised control refers to a single control system.
The microcontroller chosen to provide the stability control function provides
the overall system integration although th e interaction computer maintains the
interaction tasks. The functionality that the microcontroller bri ngs, include standard
digital data, analogue and PWM input/out put signal integration. The following
overall system block diagram shows four main components of that will make up the
complete system.
51
The intera
ction system is integrated by the PC based interactive computer
which will provide the locomotion, WiFi connection, reprogramming and interaction
functionality in the projects mature form . But for this project, the integration
computer does not integrate with the microcontroller therefore ea ch remains unique
at this stage. The upper layers of the robot form the interaction computer whist the
sensors and microcontroller of the lower half form the integrated microcontroller unit.
Figure 3.21 Overall system interaction block diagram
52
Other con
siderations that are necessary when incorporating these components
together include cable lengths as power losses and reduced signals strength may
occur. Physical separation of cabling was used to restrict interference between
system components. This was achieved by spacing four separate cable-through holes
on each layer of the robot chassis. The fr ont two were used to pass data cabling
whilst the rear two contained analogue a nd power cables. The wiring utilised within
the robot design for the following circuits were as follows:
Battery connectivity, 14 AWG,
12 V distribution, 18 AWG,
Motor driver circuits, 18 AWG,
3.3V & 5V distribution, 30 AWG,
Data carrying cables, 30 AWG.
Control and functionality
The core control and functionality facility of the robot is contained on the rear panel
of the upper layer. There are two reset butt ons installed for the microcontroller unit
and interaction computer. Tw o LED displays are provided for voltage indication of
the low voltage supplies while the WiFi an tenna contains an LED to indicate when
the device is active.
A robot on/off switch was incorporated to provide an isolation point from the
battery as well as a separate switch for is olation of the voltage meter. A recharge
connector for charging onboard battery has been fitted for convenience thus forming
a central location for all the frequent operation tasks that the operator may be required to perform.
3.4.13 Safety Features
Safety features are an essential element of any design. They assure the safety of
people involved with the machine, th e machine itself and the world around it.
Reducing the risk to people should always be the first objective in all designs. If
potential hazards can be identified during th e design and testing phases, then safety
features targeting those part icular hazards can be deve loped to reduce the risks.
The main potential hazards created by a two wheeled balancing robot are
those associated with it falling. Damage to the robot itself may expose lead-acid
from the battery or create sharp surfaces which may cause cuts or abrasions to people. To reduce the lead-acid risk, the ba ttery has been securely fastened within
the centre of the power layer to create a physical separation from the outside world. As an additional feature, th e battery is covered with sh eets of rubber before being
encased in a protective metal shield. The rubber improves the already snug fit and allows absorption of any potential impact forces.
The physical weight of the robot itself has been kept to a minimum to reduce
the impact force and applied pressure upon contact. It may become possible to
sustain an electrical shock from the power circuits if they become exposed during a
fall. An outer skin can easily be applied as a future addition to present a physical barrier of protection. Electri cal shock hazards remain a lo w risk due to the voltages
used in the design so residual cu rrent detectors are not required.
53
Other hazards m
ay be induced from crashing, bumping or even accidental
ramming of objects and people. Due to th e robots intended use, redundant stability
control and power supplies have not been incorporated. Ideally, deployable skids
could have been developed to maintain an upright positio n until the microcontroller
is capable of maintaining stability. A form of magnetic actuation could manoeuvre
the skids in place. This would be beneficial in the event of a power failure or system
lock up. This would require consideration of actuated angles, battery voltage levels,
etc so has not been employed yet.
Incorporation of a cushion belt aro und the horizontal centre of the robot
chassis would offer buffer protection to its elf and its surroundings. This would utilise
bumper contact switches underneath to det ect contact. Four contact sensors have
been included around the robots waist but not the cushion itself. This provides a safety feature whereby it could either b ack away once contact has been made or
completely shutdown removing any app lied force through its locomotion.
It is intended that the IR sensors will maintain adequate distance hence the
contact switches are only fitted for safe ty. Smooth design and rounded layers should
allow the robot to easily clear obstacles near it and reduce the risk of injury to others.
3.4.14 EMR / EMI
Electromagnetic radiation (EMR) and El ectromagnetic interference (EMI) are
representational of noise introduced by radio frequency or magnetic sources. They
inhibit signal detection and introduce noise which may co rrupt control signals and
distort communication signals. EMR relate s to the emission of electromagnetic
radiation by the device whilst EMI relates to its susceptibility to spurious emissions.
Ideally a device will exhibit low EMR and high EMI.
The most well-known sources of interf erence to a signal are the power
supplies and common conductors which cause induced current fluctuations or cross
coupling. The mechanisms available to counter these occurrences revolve around physical separation and/or barrier separati on which are used to reduce the magnitude
of the coupling. Both forms together pr ovide physical isolat ion with the added
shielding protection. Coupling occurs through magnetic, electric, conductive and electromagnetic means.
The separation technique in practical terms is the isolation between the
analogue and digital circuits through a physical distance &/or by providing a barrier
to restrict coupling thus minimising its eff ects. Grouping of simila r signal types also
adds the benefit of localising fault findi ng during the devices life span. Power supply
distribution can be optimised for minima l interference by providing independent
voltage supplies for e ach of the analogue and digital circuits.
54
Several separation techniques were utilis ed in the design of the two wheeled
robot. This included a separate power s upply for the inherently noisy gyroscope.
This was provided by the H-brid ge circuit which itself is h
igh in current usage and
connected to noisy motors. Physical sepa ration of power, data and analogue signals
was achieved by provision of four separate cable-through holes on each layer of the
robot chassis. The front two holes were sp ecified for data cables whilst the back two
were analogue and power cables respect ively. Common signal cabling was also
grouped together.
Where possible, power cabling was r un low on the layer whilst the data
cabling was run high. When this could not be avoided, cables were run at 90o angles
to reduce there susceptibility. Filtering on both the power supplies and input of each
PCB was made by the use of bypass capacito rs. Separate PCB’s were utilised for
digital and analogue circui ts where possible. Reduci ng the clock frequency and
increasing the rise time of circuits was considered in an attempt to reduce the EMR
factor of the robot. Due to the low DC vo ltages used within the robot, shielding or
screening was not incorporated.
3.5 Design Concept “Oshy”
The final design concept offers a goal for completing the robot and making it a
reality. It provides an overview of what th e system will comprise of and provides an
insight into how it will function as a w hole. Interpreting the interoperability and
integration of these com ponents will allow problems or incompatibilities to be
determined earlier in the manufacturing and assembly stage. This will reduce the potential losses that may be encountered in rework or redesign that may become
necessary due to problems found late in th e creation of the r obot. The two wheeled
robots design concept is summarised as follows: 1.
Expected operating environments.
a. Indoor & outdoor environments,
b. Operated in dry conditions only,
c. Be capable of terrain with 100mm crevices,
d. Operate in temperatures below 50oC.
2.
Materials, Size and Weight.
a. A riveted alloy metal chassis frame,
b. Layers and brackets manufactured from plastic Perspex,
c. Weight fitted higher in robot’s chassis,
d. Maximum weight of 17.5Kg.
e. Maximum height of 0.8 m.
3.
Control System
a. Fuzzy control system,
b. Inputs: Angle, angular velocity, displacement, velocity,
c. Output: Motor control,
d. Implement 7 value membership functions,
e. Utilise centroid of area defuzzification,
f. Implement a 427 Rule set,
g. Recover before 60o or pi/3 of tilt occurs.
55
4. Programming
a. Main program with several sub-routines,
b. Simulation of programming within MPLAB.
5. Locomotion components.
a. 187mm diameter plastic wheels with solid rubber tyres, 40mm width,
b. 12V DC Brush motors HG37D670WE 12-052 with a 1:52 gear head,
c. L298 H-Bridge Motor Driver,
d. PWM driven control.
6.
Sensors.
a. ADXL311JE Accelerometer,
b. XV-3500CB Gyroscope and board,
c. Kalman Filter for sensor fusion of inertial sensors,
d. Proximity detection by Sharp IR GP2D12 sensors,
e. Bumper contact switches,
f. Motor shaft encoders (pre-f itted on specified motor).
7.
Microcontroller,
a. Microchip 24-bit PIC24HJ256GP206.
8.
Manufacture printed circuit boards.
a. 12 V power distribution,
b. 3.3V & 5V power distribution,
c. Voltage monitor,
d. Microcontroller,
e. Accelerometer.
9.
Power Source.
a. 12V Lead-Acid Battery 26Ah,
b. LM3914 Battery voltage monitor,
c. Transformer 12V 1.5A for recharging,
d. Current estimations,
Interaction computer system, 10A.
5V distribution circuitry, 5A.
Motor circuit, 6A.
10.
Interaction system.
a. EPIA-V PIII 800MHz computer,
b. WiFi network adapter,
c. USB Web cameras,
d. USB Speaker system,
e. PCI USB port card.
56
11. System integration.
a. Create a central control panel on th e rear panel of the upper layer,
b. Install a reset button for the microcontroller unit,
c. Install a reset button for the interaction computer,
d. LED displays for voltage indication of the voltage supplies,
e. A main on/off switch for robot circuits,
f. Voltage meter isolation switch,
g. Add a recharge connector for charging the onboard battery.
12. Safety Features.
a. Add collision detection bumper switches (see sensors),
b. Incorporate a smooth and circular chassis design,
c. Fit brackets and attach sensor s within the robot chassis,
d. Encase the battery inside robot chas sis with rubber shock absorption.
13.
EMR / EMI
a. Provide physical separation of cable types via four spaced through
layer holes,
b. Cross cabling at 90o angles to reduce there susceptance to
interference,
c. Add filtering and bypass capacitors to circuits,
d. Separate boards where possible for analogue and digital components,
e. Group common cabling together,
f. Provide the gyroscope with a 5V su pply from the H-bridge driver,
g. Utilise the following wiring sizes for circuits,
Battery connectivity, 14 AWG,
12 V distribution, 18 AWG,
Motor driver circuits, 18 AWG,
5V & below distribution, 30 AWG,
Data carrying cables, 30 AWG.
3.6 Resources
The resources required during the project included computer hardware and specialist
software for the construction, programming and report compilation. Materials for the
construction of the robots chassis included metal cable tray lengths, plastic perspex
and rivets. Microcontrollers and some in ertial sensors were supplied by larger
companies as samples whilst additional sensors for proximity and collision detection, cabling for data and power, DC motors and a battery were purchased specifically for
the project.
The majority of the resources required during the project were predominantly
available although voltage regu lator components proved the most difficult to acquire
locally. These include the following items: 1.
Chassis construction materials,
a. 2x 1800mm x 100mm Cable tray lengths, $50.
b. 6x 300mm x 300mm Plastic Perspex, sheet $30.
c. 100x 5mm Rivets, $5.
57
2. Locomotion,
d. 2x DC motor 160RPM 12V, $100.
e. 2x Plastic wheel 187mm, $25.
f. 2x Shaft 13.001mm to 6mm, $15.
g. 1x L298 H-Bridge Motor Driver, $30.
3. Power system,
h. 1x 12V DC Battery 26Ah, $125.
i. 1x Battery voltage meter, $15.
j. 1x Transformer 12V 1.5A, $30.
4.
Stability control and sensors,
k. 4x Contact sensors, $20.
l. 3x IR proximity sensors, $36.
m. 1x Gyroscope, $20.
n. 1x Accelerometer, sample.
o. 1x Microcontroller PIC 24HJ256GP206, sample.
p. 1x ICD 2.5 Debugger/Programmer USB MPLAB, $65.
q. Assorted circuit board components, materials and cabling, $200.
5.
Interactive components,
r. 1x EPIA-V PIII 800MHz embe dded computer system, $100.
s. 1x Pico DC-DC power supply, $40.
t. 1x WiFi adapter, $30.
u. 2x USB Web cameras, $30.
v. 1x USB Speaker system, $25.
w. 1x PCI USB port card, $10.
It is estimated that the total budget co st was approximately $1000. Items that
were more economical to purchase included the pre-designed H-bridge motor driver
and battery voltage meter. A lthough circuit versions for th ese had been derived, the
additional time making the PCB’s and e quivalent costs in components did not
provide any benefits within the project. This allowed more time to be focused on the control system and software co mponents later in the project.
Matlab, MPLAB and Microsoft programs were required for performing the
analysis, interpretation and representation of resultant data. Access to the necessary
tools, equipment and hardware was achieve d locally in Newcastle, NSW where the
project was undertaken. This did not incur additional expenditure to that of the
resources listed above.
3.7 Conclusion
A fully capable design concept has been developed for the two wheeled balancing
robot which will provide the fundamental hardware necessary in achieving the goals
outlined by the project. Manufact uring and assembly of the components, circuits and
devices will provide the conversion from concept to actual physical robot. The
software and programming direction ha s been provided by this chapter but
subsequent development and simulation will be continued within the following.
58
Chapter 4
Manufacture and Assembly
The construction phase entails the manufactur e of PCB’s, chassis, drive shafts, etc
which are then assembled to make the robot a realisation. This is the most rewarding
chapter where the hard work of design and development will finally evolve into the
actual physical robot. The software a nd programming conc ludes the robots
production which will also encompass a si mulation process aimed at improving the
effectiveness and efficiency of the progr amming prior to its implementation. The
maintenance considerations necessary in ensuring the robots ongoing serviceability
are also explored.
4.1 Introduction
The design and development considerations of the previous chapter were thorough
and investigated numerous aspects of the robots potential functionality, capability
and adaptability. The outcome defined the required resources and devices necessary
in manufacturing the systems, PCBs, bracket s and chassis. Once the availability of
the resources and components was confirme d, the microcontroller programming was
able to commence. The construction wa s broken into the following stages:
1. Order and purchase the resources and commercial items required,
2. Manufacture and assemble the robot chassis,
3. Assembly and installation of the interaction system and upper layer
peripherals,
4. Manufacture the necessary PCBs, bracket s, motor mounts and battery mount,
5. Installation of IR sensors, bumper sensors and PCB’s,
6. Installation of battery, motors and remaining components,
7. Manufacture and installation of all cabling.
During each stage of the construction, testing of the devices, PCB’s and
components was completed in an effort of reducing the need for fault finding further
within the project. Unfortunately, a defective motor gear head and a delay in several components lead to this phase exceeding the anticipated completion time. It was then necessary to extend the timeline to Oct ober for this chapter thus reducing the
schedule for data analysis. This also impacted on the ability to effectively test and implement the microcontroller programming.
4.2 Printed Circuit Boards
Printed Circuit Boards can be manufactured via several different processes. The most
common method is to utilis e a prototyping PCB which c ontains predrilled holes
requiring the links to be soldered in place to form the branches. Another option is to
purchase a blank board and etch the design in to it. This would have allowed a more
efficient PCB to be developed during the initial stages of the designing process.
59
Ideally, it would ha ve been beneficial to desi gn and develop the PCB’s with
sof
tware programs such as “Electronic Workbench” or “Altium Designer” but the
additional costs and time invol ved were the deciding fact or to move to prototype
boards. The ease of modifying and making changes to the layout provided a better
option for the robot’s circuitry both economically and time wise.
Figure 4.1 Microcontroller circuit PCB
The previous figure contains the manuf actured microcontroller PCB. The aim
was to allow ease of traceability and rem ovability for fault finding or future
modification procedures. The use of c onnectors and plugs throughout the PCB’s
allowed ease of removal in all cases. The L298 bridge motor driver PCB and the battery voltage monitor PCB were pictured within chapter 3. The following figures
contains the manufactured power distribution PCB’s.
60
Figure 4.2 12V distribution PCB
Figure 4.3 5V and 3.3V distribution PCB
The following figure contains the inerti al sensors. The gyroscope PCB was
received preassembled but the accelerometer board had to be designed to allow a
simpler implementation within the robots system. These PCB’s were then mounted
on the underside of the spare layer.
61
Figure 4.4 Gyroscope and accelerometer PCBs respectively
4.3 Wheel Base
The wheel base comprises of the motors and wheels layer, and the microcontroller
layer. These contain the microcontroller P CB, H-bridge, motors and the low voltage
distribution PCB. The layer above these remains vacant as the battery and power
components of the robot were raised within the chassis wh en it was discovered that it
would achieve better stability control. The following figure contains the wheel base
layers.
Figure 4.5 Wheel base layers
62
4.4 Power Source
The power source layer contains the 12V di stribution PCB, fuse rack and battery.
The 3.3V & 5V (low voltage) PCB was fitted within the wheel base layers to reduce
the susceptibility to noise and losses. Th e power distribution P CB’s were previously
pictured within the PCB section. The bumper switches have been glued on the
underside of the power layer to allow ease of battery removal in the future. These
bumper switches could be moved directly onto the power layer at a later stage if they
were fastened with bolts or simila r thus fully freeing up the spare layer.
Figure 4.6 Power source layer front and rear views respectively
4.5 Interaction System and Upper layer
The interaction system comprises of th e interaction PIII EPIA-V computer, 80GB
HDD, webcams, speakers and WiFi network device. The hardware was implemented
but due to time constraints, the planned visual basic programmi ng for performing the
microcontroller reprogramming, video and a udio streaming, and locomotion control
was not completed. The primary form of connectivity with these devices was USB
via a PCI host adaptor. The following figure contains the interaction system.
Figure 4.7 Interaction system and upper layer front and rear views respectively
63
4.6 Software and Programming
The software and programming phase was expe cted to complete both a visual basic
software application that would be used to control the interaction system and a
program for controlling the microcontroller system. As discussed previously, the
interaction software was not created due to time limitations. The microcontroller program primarily focused on the controlling the wheel base thus the stability of the
robot. This was achieved by reading va rious digital and analogue inputs and
providing a motor control output signal.
The task of creating the program code was first attempted within Matlab
where work begun on the fuzzy controller. Th e rule base and membership functions
that were created are displayed within chap ter 3. The original in tent was to develop
the full complement of the programming within Matlab to allow a complete simulation to be performed prior to impl ementation. An added benefit of this
approach was that the Matlab code can be easily converted to C programming
language through the Matlab applic ation “Real Time Workshop”.
This attempt failed to achieve workable results within a reasonable timeframe
at which point the decision to directly code the program into C language was made. This approach utilised the “MPLAB” Micr ochip software app lication designed for
programming the PIC24HJ microcontrolle r that was previously chosen. The
immediate problem with this approach was that the freely available student version
would not be an efficient compiler. This had a potential to impact on the speed and efficiency of the fuzzy controller.
4..6.1 Simulation
Simulations are used to provide a cheap and simple method for evaluating the
effectiveness and efficiency of a control system, circuit or de vice. They reduce the
potentially high expenses a nd long time delays that ar e inherent with using and
possibly damaging live systems. It also allo ws similar systems to be evaluated under
the same test parameters and conditions thus permitting a fair and accurate comparison of the derived results. To achieve this, a model is derived either mathematically or theoretically from the real system that best represents the accuracy
needed and the variables to be evaluated.
This model is then used to simulate the real system in response to the control
system, circuit or device being assessed. Simulation was first attempted within Matlab but difficulties in simulating the robots movements, etc caused time to
become a concern. The Matlab programmi ng is contained within Appendix B. As
MPLAB provided a simulation to ol that reflects the micr ocontroller’s response and
operation, it was decided that pursuing th is option would stop the project from
running overtime. A discussed in the fo llowing section, th e microcontroller
programming was not completed hence th e simulation phase was not conducted.
64
4.6.2 Microchip Program
The main program derived for operation with in the microcontroller is contained at
Appendix C. The aim was to first validate the completed program by the simulation
component followed by implementation testi ng within the completed robot. Ideally,
the final program would have had the PID motor controllers, Kalman filter, locomotion desired sub-routine and proximity sensors incorporated but this was not achieved within the timeframe available. Difficulty was also experienced with initialising the timers, c onverters and data lines.
These were further compounded by the ICD 2.5 programming device
problems encountered. Upon initial checks, th e device was able to read and access
the microcontroller chip but later during th e testing phase of the motor sequences, it
was discovered that the device no longer r ecognising the microcontroller. Additional
testing and fault finding failed to restore the connection between the devices which cost significant time. Although implemen tation was not achieved, the derived
program contains the fundamental structur e and routines that, with supplementary
research and testing, can be completed successfully.
4.7 System Integration and Overview
Integration of the sensors, PCB’s and moto rs with the microcontroller was successful
although it was disappointing that the inter action system was not completed. This
would have allowed true system integrati on with all components contained within
the robot. The components and devices chosen allowed simple connectivity with the
microcontroller through its digital, analogue and PWM input/outputs.
Upon completion of the construction, operation was undertaken as expected
with no rubbing, noise and vibration experi enced. The completed robot is contained
in the following figure.
65
Figure 4.8 Manufactured and assembled robot front and rear views respectively
4.8 Future Maintenance Considerations
Maintenance considerations ar e essential for ensuring the av ailability of electronic or
electrical equipment and devices. It pr ovides a means of determining potential
failures before they occur, allowing the maintenance actions to be completed at the
operators convenience and not during essential opera tional time. These are often
performed periodically or even before us e. For the constructe d robot, the following
maintenance inspection activities are requi red at the necessary time intervals:
Before use,
Check and ensure wheel shafts ar e clear and free of obstructions.
Daily,
Clean and wipe IR sensors, webcams and all surfaces ensuring no
dust build up is evident, especially on PCB’s,
Ensure battery terminals are securely fastened,
Check and test bumper switch operation, repair if necessary.
Check and ensure the motors, battery and PCB’s are securely
fastened.
66
Weekly,
Check the battery for leakage and corrosion, repair/replace as
required,
Check electrolytic capacitors for le akage, repair/rep lace as required.
Monthly,
Test and check motor and gear head operation, replace if necessary.
Six monthly,
Test and check battery overall operation, replace if necessary.
Additional maintenance activities may be implemented depending on the
robots operating environments. There may be unforeseen problems that will become
evident with further exposure to high leve ls of vibration th roughout the robots
chassis. If the robot was to become commer cially available, then further action such
as development of replacement procedures encompassing motor, PCB and other
component repairs may be developed but this is not required for this project.
4.9 Conclusion
A successful design and development stage cemented the foundations for a successful manufacture and assembly of the actual two wheeled balancing robot. The implementation of the robots hardware wa s easily achieved providing the system
integration and functionality. The majority of the difficulties encountered throughout
the project were associated with the softwa re and programming phase of this stage.
Software and hardware failure impact ed upon completion of the interaction
system whilst programming alone inhibited th e projects completion. An analysis and
evaluation of the systems performance w ill now be undertaken to ascertain the
resultant limitations and capabilities of th e programming and to provide a means of
overcoming the discovered operational shortfalls.
67
Chapter 5
Data Analysis
The analysis phase provides an opportuni ty to assess and evaluate the robots
effectiveness and efficiency in maintaining stability and providing locomotion. This allows a comparison to be undertaken between the actual system performances and
the anticipated project obj ectives. The opportunity to calibrate and perform
additional fine tuning of the design is also explored with the aim of achieving the
best result possible in mind.
5.1 Introduction
Data assessment and evaluation was to be performed by measuring a combination of
input sensors. These include the gyroscopes rate of rotation, th e accelerometers rate
of acceleration, the shaft encoders counter values and the motor output drive values.
These and the response times would then be evaluated to determine recoverability, system response and ultimately efficiency. The original aim was to have Matlab form the basis of the complete system simulation but this was discarded due to coding problems and time restraints.
The resultant data would provide results for various levels of tilt and sudden
bursts of acceleration experienced by the robot chassis. These could then be
compared with each set of derived respons e times and values for the varying applied
motor power. The expectations of the initial results were that an effective stability
platform would be easily achieved. It was anticipated that effective and efficient
stability would be accomplished before co mpletion of the simulation stage as the
programming can be altered to reduce res ponse time and improve output reaction.
5.2 Calibration and Tuning
Calibration and tuning are es sential methods for establis hing and setting the baseline
of devices, sensors and systems. Misali gnment from poor or incorrect calibration
may cause a device or system to provide in adequate responses and detection possibly
leading to further failure or significant damage. The aim of this topic was to identify
potential benefits that may be acquire d through calibration of the two wheeled
balancing robots components. The items to be calibrated and the level to perform
these too must first be determined. The following items are calibration candidates within the project:
Drive motors,
Sensors and encoders,
PID controller (gains),
Fuzzy controller membership functions.
68
Calibra
ting and testing the motors, en coders and sensors before operation
will ensure operability and that the best configuration of the control system is
achieved. This will account for possible ‘out of tolerances’ and other unforeseen
losses that may be inherent . If the motors are not sequential in operation, then
inadvertent turning of the robot chassis will occur. Incorre ct detection by the
encoders and other sensors would also impact on the robots sense of positioning. This would cause delays in the correct posit ioning and further increase the volume of
calculations the program must undertake.
Tuning the controllers is an essential step in ensuring the stability control
system is responsive and timely. The fuzzy c ontroller is considered quite difficult to
tune due to the increased complexity of utilising numerous membership functions and inputs. Incorporating PI D controllers for the enhancement of the motor driver
signals also requires that the proportiona l, integral and derivative values are
optimised for peak motor performance. The programming difficulties encountered
have restricted the implementation of these intended steps and procedures.
5.3 Stability Analysis
Performing an analysis requi res the particular performance to be measurable or
reasonably estimated. Accurately measuring the actual stability of the robot chassis
is difficult but it can be achieved by l ogging the values reco rded by the robots
sensors. Another approach would be to take video footage of the robot with markings and measurement indications set in th e background to allow determination of
distances, angles and compare these to the response times.
By assessing the potential impact on the analysis data from mechanical,
electrical and programming properties, pot ential improvements and redesign aspects
can be derived. These would contribute to increasing the overall stability of the
system as well as its efficiency. The m echanical properties of the robots design
included physical layout, shape, weight , weight distribution, and height. The
electrical properties encompassed capabi lity and installed hardware whilst the
programming properties include performance, efficiency and ability.
The particular attributes that were to be investigated from the stability
analysis activities include the response to various rates of acceleration both forward
and backward, the affect of induced force an d tipping, and the addition or removal of
mass onto the robot chassis. The preference was to assess the recorded inertial
sensors over time with respect to motor out put signals but an act ual analysis was not
conducted due to the microcontroller’s program difficulties.
5.4 Locomotion Analysis
Locomotion analysis is secondary to the primary requirement of achieving stability.
Unfortunately, the interaction system was designed to provide the locomotion
control via the WiFi connecti on and as the system was not completed, an analysis of
locomotion cannot be achieved. The physic al, hardware, software and program
would have been fully explored potentia lly requiring much more time then would
have been necessary for the st ability analysis previously.
69
Completing this stage would have b een achieved by measuring the response
times, output drive signals, and assessing the robots ability to maintain stability for
varying sensor inputs and terrains. This would assist with determining the minimum
and maximum interval rates that the micr ocontroller system could process data,
feedback and send out the compensating motor control signals. This would have allowed further improvements to be made to the locomotion control and its system
components.
5.5 System Performance Overall
The overall system performance is difficult to determine due to the program difficulties encountered but it is highly li kely that a successful implementation of a
two wheeled balancing robot would have been achieved. Additional proximity sensors, an inclinometer and incorporat ion of a much more capable interaction
system would allow the robot to conduct fully autonomous control and interaction
with the world around it.
The microcontroller is a 40 MIPS high pe rformance controller thus providing
the maximum opportunity for the programmi ng to perform. The programming of the
microcontroller provides the only known area of potential improvement from this
design approach and implementation; ther efore, system perf ormance would have
been a reflection on the efficiency, effectiv eness and robustness of the final program.
5.6 Conclusion
Performing calibration of devi ces and components prior to tuning of systems allows
a reasonable analysis of the robots performa nce. Analysing each of the performance
objectives allows further improvements to be made in the robots operation and
responsiveness. Evaluating the overall performance of the completed robot also provides a benchmark to work from, a nd provides potential for redesign and
enhancement work.
Unfortunately, the project was unable to implement the ideas and approaches
originally intended for providing a thor ough analysis and evaluation due to the
programming. Ideally, this phase would have also seen the developed robot utilised
as a test platform for several types of linear control system . This would have
provided a direct comparison between the successfulness of numerous forms of
controllers.
70
Chapter 6
Conclusion and Recommendations
Conclusions and recommendations are necessa ry to provide comment on each aspect
undertaken as part of the project. The analysis and evaluati on stage provided the
specific information that can be used to ascertain the successfu lness of several key
areas of performance. This is then expanded into several recommendations for improvements, addition of extr a capabilities and future areas of investigation. This
also provides the opportunity to share an awareness of th e problems encountered that
would complement the future work recommendations.
6.1 Introduction
The data analysis performed within the previous chapter was initiated to provide a reasonable assessment and evaluation of th e robots ability to meet its design
objectives. The review of the analysis performed suggested that the simulation process could have been competed more successfully if more time was available to develop a complete system model with in Matlab. From the observations and
discussions previously presented, this chapter will provide recommendations for
future work, improvements and additional areas of investigation.
6.2 Discussion
Several key aspects are discussed in the following sub-sections. These include the
difficulties experienced, advantages and disadvantages of the design phase, the results versus the expectations of the robots performance.
6.2.1 Difficulties Experienced
The difficulties experienced throughout the project include theory, hardware,
software and programming related problem s. The main theoretical difficulty
encountered was associated with unders tanding the operation and mathematics
behind Kalman filtering techniques. This was necessary for implementing sensor fusion of the inertial sensors within th e programming. This aspect would have
required substantial time to rectify hen ce the simpler approach of following the
programming provided by Simon (2001) was pursued.
Gaining a thorough unders tanding of fuzzy cont rol systems and their
implementation appeared to take a substantial amount of time early within the project. The tuning and simulating aspects could have been further investigated
possibly leading to the development of an adaptive (self-tuning) fuzzy controller.
This would have been a substantial improvement over the fuzzy controller implemented as part of the project.
71
The 1:52 gear head supplied with the right d
rive motor stripped the teeth off a
cog within a very short pe riod of operation. Unfortunately, the item was supplied
from the USA which delayed the assembly stage for sometime. It is unclear at this
time if the gear head and motor combination is suitable for the loads and weight of
the derived robot. Difficulty was also experienced in ac quiring critical components
such as the 7805 and 7812 voltage regulators. These remained on back order for six
weeks before they were eventually received.
The interaction system encountered seve ral difficulties early in the project.
On installation, the interaction computer was functioning and it appeared that the
visual basic software development would be relatively straight forward. It was then
discovered that an incompatibility between the computer and PCI host adaptor was
causing the computer system to crash. This was soon followed by a hard drive failure causing the stage to exceed the allocated timeframe. It was at this time the interaction system was deemed non-essential and no longer pursued.
Programming of the microcontroller proved to be the most difficult challenge
of the entire project. Although learning C programming was not overly difficult,
completing the hardware initialisation, fuzzy controller, Kalman filter and other sub-routines within the programming caused excessive time consumption for the project.
This was further compounded as the simu lation phase could not be adequately
completed. It is unlikely that the project w ould have been as completed on time if the
simulation modelling was pursued fully ev en though a robust program could have
been developed.
6.2.2 Design Advantages and Disadvantages
The shape, size and layout of the robot proved the most advantageous aspects of the robots design. The cylinder shape proved ideal for manoeuvring on the spot. This
was evident during assembly and performance maintenance activities on the robot as
turning it on the spot allowed easy access fr om the one location. The child like size
made the robot easy to move, handle and to access each of the layers. The platform
layout allowed grouping of systems and P CB’s without overcrowding thus sampling
the maintenance and fault finding procedures.
There were no disadvantages discovered with the design of the robot. The
battery posed a potential disadvantage from its inherent weight of 7 Kg. This
accounts for a significant portion of the total weight as well as the space required to
store it within the robots chassis. The impact from the battery may have been reduced by selecting a smaller physical size and rated battery but then the capability
and operability would be adversely affected. There is also a potential that the motor
and gear head combination may have been underrated for the specific task.
6.2.3 System Performance and Results
The actual performance of the hardware aspects of the robot cannot be fully guaranteed without completi on of the microcontrollers programming. It is
anticipated that the manufactured robot w ould have been fully capable in achieving
stability, locomotion and interaction stre aming. No actual performance results are
available at this time.
72
6.2.4 Results versus Expectations
At the beginning of the project, the expect ations were quite substantial. The goal was
to develop a robot th at was so robust that it could recover from significant and
deliberately induced tilt. As problems and difficulties started to become evident in
the programming, the expectations reduced to simply providing a robot that could
maintain stability. Incompletion of the pr ogram has proved devastating as hence the
results are not reflective of the expectations.
6.3 Conclusion
The project as a whole was very successful in deriving a two wheeled balancing robot with all the c onsiderations necessary tin ensuring it could meet the required
capabilities and objectives. The software and programmi ng side was disappointing
with the majority of the difficulties en countered in these areas. This could be
overcome with time but unfortunately, time was not plentiful. The following
recommendations provide direction for futu re work and suggested areas of further
investigation.
6.4 Recommendations
It is recommended that this approach be undertaken again but with an experience
programming background. The difficulties encountered could have been easily
overcome if significant time was availabl e to further develop the programming
necessary to perform the significant functions of Kalman filter, controllers and other sub-routines. The following sub-sections contain the suggest ed improvements,
additions and possible areas for future investigation.
6.4.1 Improvements and Alterations
Improvements to the current version of the robot can eas ily be achieved through the
microcontrollers programming. This would pr ovide the fundamental benefits faster
control responses, effective and efficient computations and improved overall system
performance. Completing the software im plementation of the interaction system
would allow the operator to have video a nd audio streaming capabilities, locomotion
control and microcontroller reprogramming capability. Alth ough the hardware would
not require any significant change, the co mpletion of visual basic programs would
complete the process.
6.4.2 Additional Features and Capabilities
Additional feature or capabil ities that may improve the effectiveness, efficiency or
operability of the robot incl ude the addition of arms. This would allow the robot to
interact with its surrounds thus providing a larger impact on the operability it may
now achieve. This could be further extended to include grippers at the end of each
arm that would be capable of effectively lifting large masses or obscure shapes. The
number of arms fitted would increase the complexity of the control systems in place
but the enhanced capability may be beneficial.
73
Although not fully explorer, the web cam vision could be expanded to
incorporate stereo vision. This would a llow the robot to autonomously navigate,
identify and avoid obstacles through th e added vision capability. The voltage
monitoring circuit could provi de a signal to the microcont roller that would indicate
that a low voltage measurement has been established. This woul d call upon a ‘return
to charge station’ procedure which would ensure the robot returns safely before
power is lost to its systems.
To better transverse uneven terrain such as stairs, the wheels could be
enhanced to allow an upward and/or downward extension to its height. This could either apply a force in the direction of trav el onto the obstacle to push itself up or it
could raise the wheel over the obstacle itself . This would allow th e robot to travel up
stairs or over obstacles whilst maintaining balance.
An outer skin may be incorporated for cosmetic and well as shielding effect
for the robot. A skin that allows the IR se nsors to easily see th rough would be ideal,
allowing a smooth covering of the outer side . This would also be protective against
dust, water and other forms of intrusion into the sensitiv e circuits within. A cushion
belt could be added to the bumper switch arrangement to allow a softer collision in the event one may occur.
6.4.3 Future Areas of Investigation
The following recommended areas of investig ation involve differe nt approaches to
the stability control problem. The potential benefits from these approaches include the reduction of energy consumption, redu ced horizontal moveme nt and protection
from falling over. The first area focuses on a rotating robot chassis that is capable of
a potential 180
o horizontal rotation on its verti cal axis. The weight could be
distributed in such a way that any chassi s movement would redistribute the weight
thus perform a form of stability control. Th e benefit of allowing the chassis to rotate
would remove the need for the wheels to move forward or backward along the horizontal plane.
A form of braking system could be deve loped that in effect, locks the wheels
to the ground thus maintaining the robots horizontal positioning. The motor force is then used to move the robot chassis and not the wheels to ma intain stability. It would
appear as a forward or backward swaying motion from the side of the robot. This
would reduce the complexity of the stability control system that is currently in place as both the horizontal and vertical axes would both be easily controlled.
Incorporating a form of gravity powere d counter weight system within the
chassis would alleviate the need for excessive power consumption that a motor requires. This would have a butter eff ect by further reducing the power source
presence required within the completed r obot. Incorporation of a deployable skid
scheme that would actuate when the microc ontroller is offline, losses power or once
a certain tilt angle is reached. This could be incorpor ated with a form of energised
magnetic lock that raises the skids when system is operable and once de-energised,
the skids are deployed thus preven ting the robot from falling over.
74
Bibliography
[1] Anderson, DP, 2007, nBot Balancing Robot , viewed 20th March 2008,
<http://www.geology.smu.edu/~dpa-www/robo/nbot/ >
[2] Andrade-Cetto, J & Sanfeliu, A 2006, Environment Learning for Indoor
Mobile Robots , Springer, New York.
[3] Angeles, J 2007, Fundamentals of Robotic Mechanical Systems, Springer,
New York.
[4] Banks, D 2006, Microengineering MEMs and Interfacing , Taylor & Francis,
London.
[5] Bates, Hellebuyck, Ibrahim, Jasio, D, Morton, Smith, D, Smith, J &
Wilmshurst 2008, PIC Microcontroller , Elsevier Inc, New York.
[6] Bergren, C 2003, Anatomy of a Robot, McGraw-Hill, Sydney. [7] Bishop, R 2002, The Mechatronics Handbook , CRC Press, London.
[8] Bishop, R 2006, Mechatronics – An Introduction , Taylor & Francis, London.
[9] Bokor, J, Hangos, K & Szederkenyi, G 2004, Analysis & Control of
Nonlinear Process Systems , Springer, New York.
[10] Braunl, T 2006, Embedded Robotics , Springer, Perth.
[11] Bush, L 2001, Fuzzy Logic Controller for the Inverted Pendulum Problem. [12] Carroll, T & Miles, P 2002, Build Your Own Combat Robot, McGraw-Hill,
Sydney.
[13] Chuan-Kai 2001, A Reinforcement Learning Adaptive Fuzzy Controller for
robots .
[14] Dawson, D & Lewis, F 2004, Robot Manipulator Control – Theory and
Practice , Marcel Dekker, New York.
[15] De Almeida, A & Khatib, O 1998, Autonomous Robotic Systems , Springer,
Palo Alto.
[16] Deepa, S, Sivanandam S & Sumathi, S 2007, Introduction to Fuzzy Logic
using MATLAB , Springer, New York.
[17] Dickmanns, E 2007, Dynamic Vision for Percep tion and Control of Motion ,
Springer, London.
[18] Florczyk, S 2005, Robot Vision – Video-based Indoor Exploration with
Autonomous & Mobile Robots , Wiley-VCH, Weinheim.
75
[19]
Florian, RV, 2007, Correct equations for the dynamics of the cart-pole
system , Center for Cognitive and Neural Studies, viewed 15th May 2008,
<http://www.coneural.org/florian/papers/05_cart_pole.pdf >
[20] Holland, J 2004, Designing Mobile Autonomous Robots, Elsevier, Sydney.
[21] Iovine, J 2002, Robots Androids and Animatrons , McGraw-Hill, Sydney
.
[22] Iovine, J 2004, PIC Robotics , M cGraw-Hill, Sydney.
[23] Jain, L, Konar, A, Patnaik, S, Resconi, G & Tzafestas, S 2005, Innovations in
Robot Mobility and Control , Springer, New York.
[24] Kageyama, Y, 2007, New Hitachi robot has a rough debut , Associated Press,
USA Today, viewed 22
nd May 2008,
<http://www.usatoday.com/tech/news/robotics/2007-11-21-robot-
crash_N.htm >
[25] Kurfess, T 2005, Robotics and Automation Handbook , CRC Press, London.
[26] Larson, T, 2008, Balancing Robot Project – Bender, viewed 20
th March 2008,
<http://www.tedlarson.com/robots/balancingbot.htm >
[27] Lewis, F & Sam Ge, S 2006, Autonomous Mobile Robots, Taylor & Francis,
Boca Raton.
[28] McComb, G & Predko, M 2006, Robot Builders Bonanza , McGraw-Hill,
Sydney.
[29] Pelz, G 2003, Mechatronic Systems – Model ling & Simulation with HDLs ,
Wiley, Heidelberg.
[30] Passino, K & Yurkovich, S 1998, Fuzzy Control , Addison-Wesley, Sydney.
[31] Sandin, P 2003, Robot Mechanisms and Mechani cal Devices Illustrated ,
McGraw-Hill, Sydney.
[32] Segway Inc, 2008, Simply moving , viewed 20
th March 2008,
<http://www.segway.com/ >
[33] Shircliff, D 2002, Build a Remote-Controlled Robot , McGraw-Hill, Sydney.
[34] Simon, D 2001, Kalman Filtering , Embedded Systems Programming.
[35] Stone, P 2007, Intelligent Autonomous Robotics – A Robot Soccer Case
Study , Morgan & Claypool, Austin.
[36] USQ, 2008, ENG4111/4112 Research Project 1 & 2 , Study Material,
University of Southern Queensland.
76
[37] Vernon, D 1991, Machine Vision – Automated Visual Inspection & Robot
Vision , Prentice Hall, Sydney.
[38] Williams, D 2003, PDA Robotics – Using Your Personal Digital Assistant to
Control Your Robot, McGraw-Hill, Sydney.
[39] Williams, K 2003, Amphibionics – Build Y our Own Reptilian Robot ,
McGraw-Hill, Sydney.
[40] Wise, E 2005, Robotics Demystified , McGraw-Hill, Sydney.
[41] Xie, M 2003, Fundamentals of Robotics – Linking Perception to Action ,
World Scientific Publishing, London.
77
Appendix A
78
Appendix B
Matlab Programming
[System] Name='Stability' Type='mamdani' Version=2.0 NumInputs=4 NumOutputs=1 NumRules=427 AndMethod='prod' OrMethod='max' ImpMethod='min' AggMethod='max' DefuzzMethod='centroid' [Input1] Name='theta-angle' Range=[-1 1] NumMFs=7 MF1='NL':'trimf',[-625 -0.628 -0.35] MF2='NM':'trimf',[-0.628 -0.35 -0.11] MF3='NS':'trimf',[ -0.35 -0.11 0]
MF4='CE':'trimf',[-0.11 0 0.11] MF5='PS':'trimf' ,[0 0.11 0.35]
MF6='PM':'trimf',[0.11 0.35 0.628] MF7='PL':'trimf',[0.35 0.628 625] [Input2] Name='dottheta-anglevelocity' Range=[-7 7] NumMFs=7 MF1='NL':'trimf',[-4000 -5 -3] MF2='NM':'trimf',[-5 -3 -1] MF3='NS':'trimf',[-3 -1 0] MF4='CE':'trimf',[-1 0 1] MF5='PS':'trimf',[0 1 3] MF6='PM':'trimf',[1 3 5] MF7='PL':'trimf',[3 5 4000] [Input3] Name='x-distance'
Range=[-0.12 0.12]
NumMFs=7 MF1='NL':'trimf',[-24 -0.1 -0.07] MF2='NM':'trimf',[-0.1 -0.07 -0.04] MF3='NS':'trimf',[ -0.07 -0.04 0]
MF4='CE':'trimf',[-0.04 0 0.04]
79
MF5='
PS':'trimf' ,[0 0.04 0.07]
MF6='PM':'trimf',[0.04 0.07 0.1]
MF7='PL':'trimf',[0.07 0.1 24] [Input4] Name='dotx-velocity' Range=[-0.5 0.5] NumMFs=7 MF1='NL':'trimf',[-100 -0.45 -0.3] MF2='NM':'trimf',[-0.45 -0.3 -0.15] MF3='NS':'trimf',[-0.3 -0.15 0] MF4='CE':'trimf',[-0.15 0 0.15] MF5='PS':'trimf' ,[0 0.15 0.3]
MF6='PM':'trimf',[0.15 0.3 0.45] MF7='PL':'trimf',[0.3 0.45 100] [Output1] Name='Motor-Output' Range=[-120 120] NumMFs=7 MF1='NL':'trimf',[-10000 -100 -70] MF2='NM':'trimf',[-100 -70 -30] MF3='NS':'trimf',[-70 -30 0] MF4='CE':'trimf',[-30 0 30] MF5='PS':'trimf',[0 30 70] MF6='PM':'trimf',[30 70 100]
MF7='PL':'trimf',[70 100 10000]
[Rules] 1 1 -1 -1, 7 (1) : 1 1 1 1 1, 7 (1) : 1 1 2 -1 -1, 7 (1) : 1 1 2 1 1, 7 (1) : 1 2 1 -1 -1, 7 (1) : 1 2 1 1 1, 7 (1) : 1 1 3 -1 -1, 6 (1) : 1 1 3 1 1, 6 (1) : 1 1 4 -1 -1, 6 (1) : 1 1 4 1 1, 6 (1) : 1 1 5 -1 -1, 5 (1) : 1 1 5 1 1, 5 (1) : 1 1 6 -1 -1, 5 (1) : 1 1 6 1 1, 5 (1) : 1 2 2 -1 -1, 6 (1) : 1 2 2 1 1, 6 (1) : 1 2 3 -1 -1, 6 (1) : 1 2 3 1 1, 6 (1) : 1 2 4 -1 -1, 5 (1) : 1 2 4 1 1, 5 (1) : 1 2 5 -1 -1, 5 (1) : 1
80
2 5 1 1, 5 (1) : 1
2 7 -1 -1, 3 (1) : 1 2 7 1 1, 3 (1) : 1 3 1 -1 -1, 6 (1) : 1 3 1 1 1, 6 (1) : 1 3 2 -1 -1, 6 (1) : 1 3 2 1 1, 6 (1) : 1 3 3 -1 -1, 5 (1) : 1 3 3 1 1, 5 (1) : 1 3 4 -1 -1, 5 (1) : 1 3 4 1 1, 5 (1) : 1 3 6 -1 -1, 3 (1) : 1 3 6 1 1, 3 (1) : 1 3 7 -1 -1, 3 (1) : 1 3 7 1 1, 3 (1) : 1 4 1 -1 -1, 6 (1) : 1 4 1 1 1, 6 (1) : 1 4 2 -1 -1, 5 (1) : 1 4 2 1 1, 5 (1) : 1 4 3 -1 -1, 5 (1) : 1 4 3 1 1, 5 (1) : 1 1 7 1 1, 7 (1) : 1 1 7 1 2, 7 (1) : 1 1 7 1 3, 6 (1) : 1 1 7 1 4, 6 (1) : 1 1 7 1 5, 5 (1) : 1
1 7 1 6, 5 (1) : 1
1 7 1 7, 4 (1) : 1 1 7 2 1, 7 (1) : 1 1 7 2 2, 6 (1) : 1 1 7 2 3, 6 (1) : 1 1 7 2 4, 5 (1) : 1 1 7 2 5, 5 (1) : 1 1 7 2 6, 4 (1) : 1 1 7 2 7, 3 (1) : 1 1 7 3 1, 6 (1) : 1 1 7 3 2, 6 (1) : 1 1 7 3 3, 5 (1) : 1 1 7 3 4, 5 (1) : 1 1 7 3 5, 4 (1) : 1 1 7 3 6, 3 (1) : 1 1 7 3 7, 3 (1) : 1 1 7 4 1, 6 (1) : 1 1 7 4 2, 5 (1) : 1 1 7 4 3, 5 (1) : 1 1 7 4 4, 4 (1) : 1 1 7 4 5, 3 (1) : 1 1 7 4 6, 3 (1) : 1 1 7 4 7, 2 (1) : 1 1 7 5 1, 5 (1) : 1
81
1 7 5 2, 5 (1) : 1
1 7 5 3, 4 (1) : 1 1 7 5 4, 3 (1) : 1 1 7 5 5, 3 (1) : 1 1 7 5 6, 2 (1) : 1 1 7 5 7, 2 (1) : 1 1 7 6 1, 5 (1) : 1 1 7 6 2, 4 (1) : 1 1 7 6 3, 3 (1) : 1 1 7 6 4, 3 (1) : 1 1 7 6 5, 2 (1) : 1 1 7 6 6, 2 (1) : 1 1 7 6 7, 1 (1) : 1 1 7 7 1, 4 (1) : 1 1 7 7 2, 3 (1) : 1 1 7 7 3, 3 (1) : 1 1 7 7 4, 2 (1) : 1 1 7 7 5, 2 (1) : 1 1 7 7 6, 1 (1) : 1 1 7 7 7, 1 (1) : 1 2 6 1 1, 7 (1) : 1 2 6 1 2, 7 (1) : 1 2 6 1 3, 6 (1) : 1 2 6 1 4, 6 (1) : 1 2 6 1 5, 5 (1) : 1 2 6 1 6, 5 (1) : 1
2 6 1 7, 4 (1) : 1
2 6 2 1, 7 (1) : 1 2 6 2 2, 6 (1) : 1 2 6 2 3, 6 (1) : 1 2 6 2 4, 5 (1) : 1 2 6 2 5, 5 (1) : 1 2 6 2 6, 4 (1) : 1 2 6 2 7, 3 (1) : 1 2 6 3 1, 6 (1) : 1 2 6 3 2, 6 (1) : 1 2 6 3 3, 5 (1) : 1 2 6 3 4, 5 (1) : 1 2 6 3 5, 4 (1) : 1 2 6 3 6, 3 (1) : 1 2 6 3 7, 3 (1) : 1 2 6 4 1, 6 (1) : 1 2 6 4 2, 5 (1) : 1 2 6 4 3, 5 (1) : 1 2 6 4 4, 4 (1) : 1 2 6 4 5, 3 (1) : 1 2 6 4 6, 3 (1) : 1 2 6 4 7, 2 (1) : 1 2 6 5 1, 5 (1) : 1 2 6 5 2, 5 (1) : 1
82
2 6 5 3, 4 (1) : 1
2 6 5 4, 3 (1) : 1 2 6 5 5, 3 (1) : 1 2 6 5 6, 2 (1) : 1 2 6 5 7, 2 (1) : 1 2 6 6 1, 5 (1) : 1 2 6 6 2, 4 (1) : 1 2 6 6 3, 3 (1) : 1 2 6 6 4, 3 (1) : 1 2 6 6 5, 2 (1) : 1 2 6 6 6, 2 (1) : 1 2 6 6 7, 1 (1) : 1 2 6 7 1, 4 (1) : 1 2 6 7 2, 3 (1) : 1 2 6 7 3, 3 (1) : 1 2 6 7 4, 2 (1) : 1 2 6 7 5, 2 (1) : 1 2 6 7 6, 1 (1) : 1 2 6 7 7, 1 (1) : 1 3 5 1 1, 7 (1) : 1 3 5 1 2, 7 (1) : 1 3 5 1 3, 6 (1) : 1 3 5 1 4, 6 (1) : 1 3 5 1 5, 5 (1) : 1 3 5 1 6, 5 (1) : 1 3 5 1 7, 4 (1) : 1
3 5 2 1, 7 (1) : 1
3 5 2 2, 6 (1) : 1 3 5 2 3, 6 (1) : 1 3 5 2 4, 5 (1) : 1 3 5 2 5, 5 (1) : 1 3 5 2 6, 4 (1) : 1 3 5 2 7, 3 (1) : 1 3 5 3 1, 6 (1) : 1 3 5 3 2, 6 (1) : 1 3 5 3 3, 5 (1) : 1 3 5 3 4, 5 (1) : 1 3 5 3 5, 4 (1) : 1 3 5 3 6, 3 (1) : 1 3 5 3 7, 3 (1) : 1 3 5 4 1, 6 (1) : 1 3 5 4 2, 5 (1) : 1 3 5 4 3, 5 (1) : 1 3 5 4 4, 4 (1) : 1 3 5 4 5, 3 (1) : 1 3 5 4 6, 3 (1) : 1 3 5 4 7, 2 (1) : 1 3 5 5 1, 5 (1) : 1 3 5 5 2, 5 (1) : 1 3 5 5 3, 4 (1) : 1
83
3 5 5 4, 3 (1) : 1
3 5 5 5, 3 (1) : 1 3 5 5 6, 2 (1) : 1 3 5 5 7, 2 (1) : 1 3 5 6 1, 5 (1) : 1 3 5 6 2, 4 (1) : 1 3 5 6 3, 3 (1) : 1 3 5 6 4, 3 (1) : 1 3 5 6 5, 2 (1) : 1 3 5 6 6, 2 (1) : 1 3 5 6 7, 1 (1) : 1 3 5 7 1, 4 (1) : 1 3 5 7 2, 3 (1) : 1 3 5 7 3, 3 (1) : 1 3 5 7 4, 2 (1) : 1 3 5 7 5, 2 (1) : 1 3 5 7 6, 1 (1) : 1 3 5 7 7, 1 (1) : 1 4 4 1 1, 7 (1) : 1 4 4 1 2, 7 (1) : 1 4 4 1 3, 6 (1) : 1 4 4 1 4, 6 (1) : 1 4 4 1 5, 5 (1) : 1 4 4 1 6, 5 (1) : 1 4 4 1 7, 4 (1) : 1 4 4 2 1, 7 (1) : 1
4 4 2 2, 6 (1) : 1
4 4 2 3, 6 (1) : 1 4 4 2 4, 5 (1) : 1 4 4 2 5, 5 (1) : 1 4 4 2 6, 4 (1) : 1 4 4 2 7, 3 (1) : 1 4 4 3 1, 6 (1) : 1 4 4 3 2, 6 (1) : 1 4 4 3 3, 5 (1) : 1 4 4 3 4, 5 (1) : 1 4 4 3 5, 4 (1) : 1 4 4 3 6, 3 (1) : 1 4 4 3 7, 3 (1) : 1 4 4 4 1, 6 (1) : 1 4 4 4 2, 5 (1) : 1 4 4 4 3, 5 (1) : 1 4 4 4 4, 4 (1) : 1 4 4 4 5, 3 (1) : 1 4 4 4 6, 3 (1) : 1 4 4 4 7, 2 (1) : 1 4 4 5 1, 5 (1) : 1 4 4 5 2, 5 (1) : 1 4 4 5 3, 4 (1) : 1 4 4 5 4, 3 (1) : 1
84
4 4 5 5, 3 (1) : 1
4 4 5 6, 2 (1) : 1 4 4 5 7, 2 (1) : 1 4 4 6 1, 5 (1) : 1 4 4 6 2, 4 (1) : 1 4 4 6 3, 3 (1) : 1 4 4 6 4, 3 (1) : 1 4 4 6 5, 2 (1) : 1 4 4 6 6, 2 (1) : 1 4 4 6 7, 1 (1) : 1 4 4 7 1, 4 (1) : 1 4 4 7 2, 3 (1) : 1 4 4 7 3, 3 (1) : 1 4 4 7 4, 2 (1) : 1 4 4 7 5, 2 (1) : 1 4 4 7 6, 1 (1) : 1 4 4 7 7, 1 (1) : 1 5 3 1 1, 7 (1) : 1 5 3 1 2, 7 (1) : 1 5 3 1 3, 6 (1) : 1 5 3 1 4, 6 (1) : 1 5 3 1 5, 5 (1) : 1 5 3 1 6, 5 (1) : 1 5 3 1 7, 4 (1) : 1 5 3 2 1, 7 (1) : 1 5 3 2 2, 6 (1) : 1
5 3 2 3, 6 (1) : 1
5 3 2 4, 5 (1) : 1 5 3 2 5, 5 (1) : 1 5 3 2 6, 4 (1) : 1 5 3 2 7, 3 (1) : 1 5 3 3 1, 6 (1) : 1 5 3 3 2, 6 (1) : 1 5 3 3 3, 5 (1) : 1 5 3 3 4, 5 (1) : 1 5 3 3 5, 4 (1) : 1 5 3 3 6, 3 (1) : 1 5 3 3 7, 3 (1) : 1 5 3 4 1, 6 (1) : 1 5 3 4 2, 5 (1) : 1 5 3 4 3, 5 (1) : 1 5 3 4 4, 4 (1) : 1 5 3 4 5, 3 (1) : 1 5 3 4 6, 3 (1) : 1 5 3 4 7, 2 (1) : 1 5 3 5 1, 5 (1) : 1 5 3 5 2, 5 (1) : 1 5 3 5 3, 4 (1) : 1 5 3 5 4, 3 (1) : 1 5 3 5 5, 3 (1) : 1
85
5 3 5 6, 2 (1) : 1
5 3 5 7, 2 (1) : 1 5 3 6 1, 5 (1) : 1 5 3 6 2, 4 (1) : 1 5 3 6 3, 3 (1) : 1 5 3 6 4, 3 (1) : 1 5 3 6 5, 2 (1) : 1 5 3 6 6, 2 (1) : 1 5 3 6 7, 1 (1) : 1 5 3 7 1, 4 (1) : 1 5 3 7 2, 3 (1) : 1 5 3 7 3, 3 (1) : 1 5 3 7 4, 2 (1) : 1 5 3 7 5, 2 (1) : 1 5 3 7 6, 1 (1) : 1 5 3 7 7, 1 (1) : 1 6 2 1 1, 7 (1) : 1 6 2 1 2, 7 (1) : 1 6 2 1 3, 6 (1) : 1 6 2 1 4, 6 (1) : 1 6 2 1 5, 5 (1) : 1 6 2 1 6, 5 (1) : 1 6 2 1 7, 4 (1) : 1 6 2 2 1, 7 (1) : 1 6 2 2 2, 6 (1) : 1 6 2 2 3, 6 (1) : 1
6 2 2 4, 5 (1) : 1
6 2 2 5, 5 (1) : 1 6 2 2 6, 4 (1) : 1 6 2 2 7, 3 (1) : 1 6 2 3 1, 6 (1) : 1 6 2 3 2, 6 (1) : 1 6 2 3 3, 5 (1) : 1 6 2 3 4, 5 (1) : 1 6 2 3 5, 4 (1) : 1 6 2 3 6, 3 (1) : 1 6 2 3 7, 3 (1) : 1 6 2 4 1, 6 (1) : 1 6 2 4 2, 5 (1) : 1 6 2 4 3, 5 (1) : 1 6 2 4 4, 4 (1) : 1 6 2 4 5, 3 (1) : 1 6 2 4 6, 3 (1) : 1 6 2 4 7, 2 (1) : 1 6 2 5 1, 5 (1) : 1 6 2 5 2, 5 (1) : 1 6 2 5 3, 4 (1) : 1 6 2 5 4, 3 (1) : 1 6 2 5 5, 3 (1) : 1 6 2 5 6, 2 (1) : 1
86
6 2 5 7, 2 (1) : 1
6 2 6 1, 5 (1) : 1 6 2 6 2, 4 (1) : 1 6 2 6 3, 3 (1) : 1 6 2 6 4, 3 (1) : 1 6 2 6 5, 2 (1) : 1 6 2 6 6, 2 (1) : 1 6 2 6 7, 1 (1) : 1 6 2 7 1, 4 (1) : 1 6 2 7 2, 3 (1) : 1 6 2 7 3, 3 (1) : 1 6 2 7 4, 2 (1) : 1 6 2 7 5, 2 (1) : 1 6 2 7 6, 1 (1) : 1 6 2 7 7, 1 (1) : 1 7 1 1 1, 7 (1) : 1 7 1 1 2, 7 (1) : 1 7 1 1 3, 6 (1) : 1 7 1 1 4, 6 (1) : 1 7 1 1 5, 5 (1) : 1 7 1 1 6, 5 (1) : 1 7 1 1 7, 4 (1) : 1 7 1 2 1, 7 (1) : 1 7 1 2 2, 6 (1) : 1 7 1 2 3, 6 (1) : 1 7 1 2 4, 5 (1) : 1
7 1 2 5, 5 (1) : 1
7 1 2 6, 4 (1) : 1 7 1 2 7, 3 (1) : 1 7 1 3 1, 6 (1) : 1 7 1 3 2, 6 (1) : 1 7 1 3 3, 5 (1) : 1 7 1 3 4, 5 (1) : 1 7 1 3 5, 4 (1) : 1 7 1 3 6, 3 (1) : 1 7 1 3 7, 3 (1) : 1 7 1 4 1, 6 (1) : 1 7 1 4 2, 5 (1) : 1 7 1 4 3, 5 (1) : 1 7 1 4 4, 4 (1) : 1 7 1 4 5, 3 (1) : 1 7 1 4 6, 3 (1) : 1 7 1 4 7, 2 (1) : 1 7 1 5 1, 5 (1) : 1 7 1 5 2, 5 (1) : 1 7 1 5 3, 4 (1) : 1 7 1 5 4, 3 (1) : 1 7 1 5 5, 3 (1) : 1 7 1 5 6, 2 (1) : 1 7 1 5 7, 2 (1) : 1
87
7 1 6 1, 5 (1) : 1
7 1 6 2, 4 (1) : 1 7 1 6 3, 3 (1) : 1 7 1 6 4, 3 (1) : 1 7 1 6 5, 2 (1) : 1 7 1 6 6, 2 (1) : 1 7 1 6 7, 1 (1) : 1 7 1 7 1, 4 (1) : 1 7 1 7 2, 3 (1) : 1 7 1 7 3, 3 (1) : 1 7 1 7 4, 2 (1) : 1 7 1 7 5, 2 (1) : 1 7 1 7 6, 1 (1) : 1 7 1 7 7, 1 (1) : 1 4 5 -1 -1, 3 (1) : 1 4 5 1 1, 3 (1) : 1 4 6 -1 -1, 3 (1) : 1 4 6 1 1, 3 (1) : 1 4 7 -1 -1, 2 (1) : 1 4 7 1 1, 2 (1) : 1 5 1 -1 -1, 5 (1) : 1 5 1 1 1, 5 (1) : 1 5 2 -1 -1, 5 (1) : 1 5 2 1 1, 5 (1) : 1 5 4 -1 -1, 3 (1) : 1 5 4 1 1, 3 (1) : 1
5 5 -1 -1, 3 (1) : 1
5 5 1 1, 3 (1) : 1 5 6 -1 -1, 2 (1) : 1 5 6 1 1, 2 (1) : 1 5 7 -1 -1, 2 (1) : 1 5 7 1 1, 2 (1) : 1 6 1 -1 -1, 5 (1) : 1 6 1 1 1, 5 (1) : 1 6 3 -1 -1, 3 (1) : 1 6 3 1 1, 3 (1) : 1 6 4 -1 -1, 3 (1) : 1 6 4 1 1, 3 (1) : 1 6 5 -1 -1, 2 (1) : 1 6 5 1 1, 2 (1) : 1 6 6 -1 -1, 2 (1) : 1 6 6 1 1, 2 (1) : 1 6 7 -7 -7, 1 (1) : 1 6 7 7 7, 1 (1) : 1 7 2 -7 -7, 3 (1) : 1 7 2 7 7, 3 (1) : 1 7 3 -7 -7, 3 (1) : 1 7 3 7 7, 3 (1) : 1 7 4 -7 -7, 2 (1) : 1 7 4 7 7, 2 (1) : 1
88
7 5 -7 -7, 2 (1) : 1
7 5 7 7, 2 (1) : 1 7 6 -7 -7, 1 (1) : 1 7 6 7 7, 1 (1) : 1 7 7 -7 -7, 1 (1) : 1 7 7 7 7, 1 (1) : 1
89
Appendix C
Microcontroller Programming
////////////////////////////////////////////////////// ///////////////
// ENG4112 Research Project Part 2 // Microcontroller Stability Program // "Bullding a Two Whee led Balancing Robot"
// // Author: Peter Miller // Version: 27OCT08 ////////////////////////////////////////////////////// ///////////////
#include "p24HJ256GP206.h" /*Include header definition
file*/ ////////////////////////////////////////////////////// ///////////////
// Defined values ////////////////////////////////////////////////////// ///////////////
// Vertical angle membership function for fuzzy controller #define ANGLE_NL_LOWER -625
#define ANGLE_NL_UPPER -0.5
#define ANGLE_NM_LOWER -0.5
#define ANGLE_NM_UPPER -0.22
#define ANGLE_NS_LOWER -0.22
#define ANGLE_NS_UPPER -0.08
#define ANGLE_CE_LOWER -0.08
#define ANGLE_CE_UPPER 0.08
#define ANGLE_PS_LOWER 0.08
#define ANGLE_PS_UPPER 0.22
#define ANGLE_PM_LOWER 0.22
#define ANGLE_PM_UPPER 0.5
#define ANGLE_PL_LOWER 0.5
#define ANGLE_PL_UPPER 625
// Vertical anglular velocity membership function for fuzzy controller #define ANGLE_VEL_NL_LOWER -4000
#define ANGLE_VEL_NL_UPPER -4
#define ANGLE_VEL_NM_LOWER -4
#define ANGLE_VEL_NM_UPPER -2
#define ANGLE_VEL_NS_LOWER -2
#define ANGLE_VEL_NS_UPPER -0.06
#define ANGLE_VEL_CE_LOWER -0.06
#define ANGLE_VEL_CE_UPPER 0.06
#define ANGLE_VEL_PS_LOWER 0.06
#define ANGLE_VEL_PS_UPPER 2
#define ANGLE_VEL_PM_LOWER 2
#define ANGLE_VEL_PM_UPPER 4
90
#define ANGLE_VE
L_PL_LOWER 4
#define ANGLE_VEL_PL_UPPER 4000
// Horizontal displacement membersh ip function for fuzzy controller
#define DISP_NL_LOWER -24
#define DISP_NL_UPPER -0.08
#define DISP_NM_LOWER -0.08
#define DISP_NM_UPPER -0.06
#define DISP_NS_LOWER -0.06
#define DISP_NS_UPPER -0.025
#define DISP_CE_LOWER -0.025
#define DISP_CE_UPPER 0.025
#define DISP_PS_LOWER 0.025
#define DISP_PS_UPPER 0.06
#define DISP_PM_LOWER 0.06
#define DISP_PM_UPPER 0.08
#define DISP_PL_LOWER 0.08
#define DISP_PL_UPPER 24
// Horizontal velocity membership function for fuzzy controller
#define VEL_NL_LOWER -100
#define VEL_NL_UPPER -0.45
#define VEL_NM_LOWER -0.45
#define VEL_NM_UPPER -0.3
#define VEL_NS_LOWER -0.3
#define VEL_NS_UPPER -0.15
#define VEL_CE_LOWER -0.15
#define VEL_CE_UPPER 0.15
#define VEL_PS_LOWER 0.15
#define VEL_PS_UPPER 0.3
#define VEL_PM_LOWER 0.3
#define VEL_PM_UPPER 0.45
#define VEL_PL_LOWER 0.45
#define VEL_PL_UPPER 100
// Output membership function for fuzzy controller #define NL_LOWER -625
#define NL_UPPER -0.38
#define NM_LOWER -0.38
#define NM_UPPER -0.23
#define NS_LOWER -0.23
#define NS_UPPER -0.085
#define CE_LOWER -0.085
#define CE_UPPER 0.085
#define PS_LOWER 0.085
#define PS_UPPER 0.23
#define PM_LOWER 0.23
#define PM_UPPER 0.38
#define PL_LOWER 0.38
#define PL_UPPER 625
91
#define NL 1
#define NM 2
#define NS 3
#define CE 4
#define PS 5
#define PM 6
#define PL 7
////////////////////////////////////////////////////// ///////////////
// In
itiate global variables
////////////////////////////////////////////////////// ///////////////
static float Accel_input;
static float Accel_digital;
static float Gyro_input;
static float Gyro_digital;
static float Bumpers1_4_input;
static float Angle;
static float Angle_vel;
static float Displace;
static float Disp_vel;
static float Fuzzy_output;
static float Kalman_ouput;
static float K_output;
static float PID_output;
static float Left_motor_PID;
static float Right_motor_PID;
static int Left_shaft_input;
static int Right_shaft_input;
static int Left_encoder_counter;
static int Right_encoder_counter;
static in t Angle_fuzzied;
static int Angle_vel_fuzzied;
static int Displace_fuzzied;
static int Disp_vel_fuzzied;
static int Fuzzy_motor_output;
static int Motor_output;
static int Left_encoder_input;
static int Left_motor_output;
static int Right_motor_ouput;
static int Right_encoder_input;
static int Left_drive_outputl1;
static int Left_drive_outputl2;
static int Right_drive_ouputl3;
static int Right_drive_ouputl4;
static int Enable_drive_output;
92
////////////////////////////////////////////////////// ///////////////
// Function sets ////////////////////////////////////////////////////// ///////////////
int Sensors();
//void Locomotion_Desired();
// Functi on not implemented at this time
static int Fuzzy_Control();
int Horizontal_Fuzzy ();
int Locomotion_Response();
//float PID_Function (); // Function not implemeneted at this time static float Kalman_Function ();
////////////////////////////////////////////////////// ///////////////
// Main program // // Input : Nil. // Output : Nil. // Summary : Initialises the system, then calls functions within a while loop. // ////////////////////////////////////////////////////// ///////////////
int main ()
{ // Initialisation of micr ocontroller hardware
//PORTA = 0x00; // Turn off port A PORTB = 0x00; // Turn off port B
PORTC = 0x00; // Turn off port C
PORTD = 0xFF; // Turn on port D
//PORTE = 0x00; // Turn off port E PORTF = 0x00; // Turn off port F
PORTG = 0xFF; // Turn on port G
TRISB = 0xFFFF; // Configure all PortB as input,
TRISC = 0xFFFF; // Configure all PortC as input
TRISD = 0x0000; // Cconfigure all PortD as output
//TRISE = 0xFFFF; // Confi gure all PortE as input
TRISF = 0xFFFF; // Configure all PortF as input,
TRISG = 0xFFFF; // Cconfigure all PortG as input
AD1PCFGL = 0xFFFF; // Assign analogue ope ration to pins
Gyro_input= ; // Gyroscope input ANO 7-8 Accel_input=; // Acce lerometer input ANO 4-5
AD_converters=; // A/D conversion sequence Bumpers1_4_input=_LATG0x000F; // Bumpers 1-4 input RG 0-3
Left_shaft_input=_LATG0x3000; // Left shaft encoder input RG 12-13
Right_shaft_input=_LATG0xC000; // Right shaft encoder input RG 14-15
Left_drive_outputl1=LATDbits.LATD0x10; // Left shaft output RD 4
93
Left_drive_outputl2=LATDbits.LATD0x08; // Left shaft output RD 3
Right_drive_outputl3=LATDbits.LATD0x04; // Left shaft output RD 2
Right_drive_outputl4=LATDbits.LATD0x02; // Right shaft output RD 1
Enable_drive_output=L
ATDbits.LATD0x01; // Motor output enable RD 0
Left_encoder_counter=; // Left encoder counter sequence Right_encoder_counter=; // Ri ght encoder counter sequence
Timer_interupt=; // Timer for completing cycle // Initialisation of timin g cycles and counters.
while (Bumpers1_4_input) // while (Bumpers are true) sequence
{ Sensors (Angle, Angle_vel, Displace, Disp_vel); //Locomotion_Desired (); // Functi on not implemented at this time
Fuzzy_Control (Fuzzy_motor_output); Locomotion_Response (); } return (0);
}
94
////////////////////////////////////////////////////// ///////////////
// Sensor function
// // Input
: Left_shaft_input, Righ t_shaft_input, Bumpers1_4_input,
Gyro_input, // Accel_input. // Output : Angle, Angle_vel, Displace, Disp_vel, Gyro_digital, Accel_digital. // Summary : Reads the digital and analogue sensor inputs. Converts to digital,
// calls the Kalman function and provides the 4 stability output values. // ////////////////////////////////////////////////////// ///////////////
static Sensors (Angle, Angle_vel, Displace, Disp_vel)
{ // Read digital sensor inputs for Bumpers and Shaft encoders Left_shaft_input / / Left shaft encoder input RG 12-13
Right_shaft_input / / Right shaft encoder input RG 14-15
Bumpers1_4_input // Bumpers 1-4 input RG 0-3
// Read analog sensor inputs & convert to digital (Gyroscope & accelerometer)
Gyro_input // Gyroscope input ANO 7-8 Accel_input // Accelerometer input ANO (x)4-5(y)
// Perform A/D conversion calculations Gyro_digital= ; // Gyroscope digital value Accel_digital= ; // Acce lerometer digital value
// Proximity detection sens or input (ANO 0-2), Not im plemented at this time.
// Kalman filtering sequence Kalman_ouput=Kalman(K_output); / / Kalman filter sensor fused output
// Stability value calculations Angle=Kalman_output; Angle_vel= "calculate derivative of Angle";
Displace=((Right_shaft_i nput+Left_shaft_input)/2);
Disp_vel= "calculate deri vative of Displace";
return (Angle, Angle_vel, Displace, Disp_vel);
}
95
////////////////////////////////////////////////////// ///////////////
// Locom
otion Desired function
//
// Input : Nil at this time. // Output : Nil at this time. // Summary : Function not implemented as the interaction computer input is not // available at this time. // ////////////////////////////////////////////////////// ///////////////
static void Locomotion_Desired ( void)
{ // Read desired direction control – No t implemented under current project.
// Left motor desired response calculations – Not implemented under current project.
// Right motor desired response calculations – Not implemented under current project. // Offset angle calculations for tilt in the direction of travel – Not implemented under
current project } return (0);
}
96
////////////////////////////////////////////////////// ///////////////
// Fuzzy Co
ntrol function
//
// Input : Angle, Angle_vel, Displace, Disp_vel. // Output : Fuzzy_motor_output. // Summary : Performs the fuzzy controll er function. Fuzzification, rule base
// and defuzzification is completed. // ////////////////////////////////////////////////////// ///////////////
static int Fuzzy_Control (Fuzzy_motor_output)
{ { // Angle fuzzification sequence
if (Angle<=ANGLE_NL_UPPER)
Angle_fuzzied=NL; if ((Angle<=ANGLE_NM_UPPER)&&(Angle>ANGLE_NM_LOWER))
Angle_fuzzied=NM; if ((Angle<=ANGLE_NS_UPPER)&&( Angle>ANGLE_NS_LOWER))
Angle_fuzzied=NS; if ((Angle<=ANGLE_CE_UPPER)&&(Angle>ANGLE_CE_LOWER))
Angle_fuzzied=CE; if ((Angle<=ANGLE_PS_UPPER)&& (Angle>ANGLE_PS_LOWER))
Angle_fuzzied=PS; if ((Angle<=ANGLE_PM_UPPER)&&(Angle>ANGLE_PM_LOWER))
Angle_fuzzied=PM; if (Angle>ANGLE_PL_LOWER)
Angle_fuzzied=PL; } { // Anglular velocity fuzzification sequence
if (Angle_vel<=ANGLE_VEL_NL_UPPER)
Angle_vel_fuzzied=NL; if
((Angle_vel<=ANGLE_VEL_NM_UPPER)&&(Angle_vel>ANGLE_VEL_NM_LOWER)) Angle_vel_fuzzied=NM; if
((Angle_vel<=ANGLE_VEL_NS_UPPER) &&(Angle_vel>ANGLE_VEL_NS_LO
WER)) Angle_vel_fuzzied=NS; if
((Angle_vel<=ANGLE_VEL_CE_UPPER) &&(Angle_vel>ANGLE_VEL_CE_LO
WER)) Angle_vel_fuzzied=CE; if
((Angle_vel<=ANGLE_VEL_PS_UPPE R)&&(Angle_vel>ANGLE_VEL_PS_LO
WER)) Angle_vel_fuzzied=PS;
97
if
((Angle_vel<=ANGLE_
VEL_PM_UPPER) &&(Angle_vel>ANGLE_VEL_PM_LO
WER))
Angle_vel_fuzzied=PM; if (Angle_vel>ANGLE_VEL_PL_LOWER)
Angle_vel_fuzzied=PL; } { // Displacement fuzzification sequence
if (Displace<=DISP_NL_UPPER)
Displace_fuzzied=NL; if ((Displace<=DISP_NM_UPPER)&&(Displace>DISP_NM_LOWER))
Displace_fuzzied=NM; if ((Displace<=DISP_NS_UPPER) &&(Displace>DISP_NS_LOWER))
Displace_fuzzied=NS; if ((Displace<=DISP_CE_UPPER) &&(Displace>DISP_CE_LOWER))
Displace_fuzzied=CE; if ((Displace<=DISP_PS_UPPER) &&(Displace>DISP_PS_LOWER))
Displace_fuzzied=PS; if ((Displace<=DISP_PM_UPPER)&&(Displace>DISP_PM_LOWER))
Displace_fuzzied=PM; if (Displace>DISP_PL_LOWER)
Displace_fuzzied=PL; } { // Displacement velocity fuzzification sequence
if (Disp_vel<=VEL_NL_UPPER)
Disp_vel_fuzzied=NL; if ((Disp_vel<=VEL_NM_UPPER)&&( Disp_vel>VEL_NM_LOWER))
Disp_vel_fuzzied=NM; if ((Disp_vel<=VEL_NS_UPPER)&&( Disp_vel>VEL_NS_LOWER))
Disp_vel_fuzzied=NS; if ((Disp_vel<=VEL_CE_UPPER)&&( Disp_vel>VEL_CE_LOWER))
Disp_vel_fuzzied=CE; if ((Disp_vel<=VEL_PS_UPPER)&& (Disp_vel>VEL_PS_LOWER))
Disp_vel_fuzzied=PS; if ((Disp_vel<=VEL_PM_UPPER)&&( Disp_vel>VEL_PM_LOWER))
Disp_vel_fuzzied=PM; if (Disp_vel>VEL_PL_LOWER)
Disp_vel_fuzzied=PL; } // Rule based sequence { if (Angle_fuzzied<CE)
{ if (Angle_fuzzied=NL) /* [NL, -, -, -] */
if (Angle_vel_fuzzied=NL||(Angle_vel_fuzzied=NM))
Fuzzy_output=PL; if ((Angle_vel_fuzzied=NS)||(Angle_vel_fuzzied=CE))
98
Fuzzy_output=PM;
if ((Angle_vel_fuzzied=PS)||(Angle_vel_fuzzied=PM))
Fuzzy_output=PS; if (Angle_vel_fuzzied=P
L)
Horizontal_Fuzzy (Fuzzy_output); if (Angle_fuzzied=NM) /* [NM, -, -, -] */
if (Angle_vel_fuzzied=NL)
Fuzzy_output=PL; if ((Angle_vel_fuzzied=NM)||(Angle_vel_fuzzied=NS))
Fuzzy_output=PM; if ((Angle_vel_fuzzied=CE)||(Angle_vel_fuzzied=PS))
Fuzzy_output=PS; if (Angle_vel_fuzzied=PM)
Horizontal_Fuzzy (Fuzzy_output); if (Angle_vel_fuzzied=PL)
Fuzzy_output=NS; if (Angle_fuzzied=NS) /* [NS, -, -, -] */
if (Angle_vel_fuzzied=NL||(Angle_vel_fuzzied=NM))
Fuzzy_output=PM; if ((Angle_vel_fuzzied=NS)||(Angle_vel_fuzzied=CE))
Fuzzy_output=PS; if (Angle_vel_fuzzied=PS)
Horizontal_Fuzzy (Fuzzy_output); if ((Angle_vel_fuzzied=PM)||(Angle_vel_fuzzied=PL))
Fuzzy_output=NS; }
{ if (Angle_fuzzied=CE) /* [CE, -, -, -] */
if (Angle_vel_fuzzied=NL)
Fuzzy_output=PM; if ((Angle_vel_fuzzied=NM)||(Angle_vel_fuzzied=NS))
Fuzzy_output=PS; if (Angle_vel_fuzzied=CE)
Horizontal_Fuzzy (Fuzzy_output); if ((Angle_vel_fuzzied=PS)||(Angle_vel_fuzzied=PM))
Fuzzy_output=NS; if (Angle_vel_fuzzied=PL)
Fuzzy_output=NM; } { if (Angle_fuzzied>CE)
if (Angle_fuzzied=PS) /* [PS, -, -, -] */
if ((Angle_vel_fuzzied=NL)||(Angle_vel_fuzzied=NM))
Fuzzy_output=PS; if (Angle_vel_fuzzied=NS)
Horizontal_Fuzzy (Fuzzy_output); if ((Angle_vel_fuzzied=CE)||(Angle_vel_fuzzied=PS))
Fuzzy_output=NS;
99
if ((Angle_vel_fuzzied=PM)||(Angle_vel_fuzzied=PL))
Fuzzy_output=NM;
if (Angle_fuzzied=PM
) /* [PM, -, -, -] */
if (Angle_vel_fuzzied=NL)
Fuzzy_output=PS; if (Angle_vel_fuzzied=NM)
Horizontal_Fuzzy (Fuzzy_output); if ((Angle_vel_fuzzied=NS)||(Angle_vel_fuzzied=CE))
Fuzzy_output=NS; if ((Angle_vel_fuzzied=PS)||(Angle_vel_fuzzied=PM))
Fuzzy_output=NM; if (Angle_vel_fuzzied=PL)
Fuzzy_output=NL; if (Angle_fuzzied=PL) /* [PL, -, -, -] */
if (Angle_vel_fuzzied=NL)
Horizontal_Fuzzy (Fuzzy_output); if ((Angle_vel_fuzzied=NM)||(Angle_vel_fuzzied=NS))
Fuzzy_output=NS; if ((Angle_vel_fuzzied=CE)||(Angle_vel_fuzzied=PS))
Fuzzy_output=NM; if ((Angle_vel_fuzzied=PM)||(Angle_vel_fuzzied=PL))
Fuzzy_output=NL; } } // Defuzzification sequence
{
if (Fuzzy_output<CE)
if (Fuzzy_output=NL)
Fuzzy_motor_output=-100; if (Fuzzy_output=NM)
Fuzzy_motor_output=-70; if (Fuzzy_output=NS)
Fuzzy_motor_output=-30; if (Fuzzy_output=CE)
Fuzzy_motor_output=0; if (Fuzzy_output>CE)
if (Fuzzy_output=PS)
Fuzzy_motor_output=30; if (Fuzzy_output=PM)
Fuzzy_motor_output=70; if (Fuzzy_output=PL)
Fuzzy_motor_output=100; } return (Fuzzy_motor_output);
}
100
////////////////////////////////////////////////////// ///////////////
// Horizontal Fuzzification function
// // Inpu
t : Displace_fuzzied, Disp_vel_fuzzied.
// Output : Fuzzy_output. // Summary : The function performs the s econd series of rule base comparison
// for the Fuzzy control f unction (Horizontal adjustment).
// ////////////////////////////////////////////////////// ///////////////
int Horizontal_Fuzzy (Fuzzy_output)
{ if (Displace_fuzzied<CE)
if (Displace_fuzzied=NL)
if
((Disp_vel_fuzzied=NL)||(Disp_vel_fu zzied=NM)||(Disp_vel_fuzzied=NS))
Fuzzy_output=PM; if
((Disp_vel_fuzzied=CE)||(Disp_vel_fu zzied=PS)||(Disp_vel_fuzzied=PM))
Fuzzy_output=PS; if (Disp_vel_fuzzied=PL)
Fuzzy_output=CE; if (Displace_fuzzied=NM)
if ((Disp_vel_fuzzied=NL)||(Disp_vel_fuzzied=NM))
Fuzzy_output=PM; if
((Disp_vel_fuzzied=NS)||(Disp_vel_fu zzied=CE)||(Disp_vel_fuzzied=PS))
Fuzzy_output=PS; if (Disp_vel_fuzzied=PM)
Fuzzy_output=CE; if (Disp_vel_fuzzied=PL)
Fuzzy_output=NS; if (Displace_fuzzied=NS)
if (Disp_vel_fuzzied=NL)
Fuzzy_output=PM; if
((Disp_vel_fuzzied=NM)||(Disp_vel_fu zzied=NS)||(Disp_vel_fuzzied=CE))
Fuzzy_output=PS; if (Disp_vel_fuzzied=PS)
Fuzzy_output=CE; if ((Disp_vel_fuzzied=PM)|| (Disp_vel_fuzzied=PL))
Fuzzy_output=NS; if (Displace_fuzzied=CE)
if
((Disp_vel_fuzzied=NL)||(Disp_vel_fu zzied=NM)||(Disp_vel_fuzzied=NS))
Fuzzy_output=PS; if (Disp_vel_fuzzied=CE)
Fuzzy_output=CE; if ((Disp_vel_fuzzied=PS)||(Disp_vel_fu zzied=PM)||(Disp_vel_fuzzied=PL))
Fuzzy_output=NS;
101
if (Displace_fuzzied>CE)
if (Displace_fuzzied=P
S)
if ((Disp_vel_fuzzied=NL)||(Disp_vel_fuzzied=NM))
Fuzzy_output=PS;
if (Disp_vel_fuzzied=NS)
Fuzzy_output=CE; if
((Disp_vel_fuzzied=CE)||(Disp_vel_fu zzied=PS)||(Disp_vel_fuzzied=PM))
Fuzzy_output=NS; if (Disp_vel_fuzzied=PL)
Fuzzy_output=NM; if (Displace_fuzzied=PM)
if (Disp_vel_fuzzied=NL)
Fuzzy_output=PS; if (Disp_vel_fuzzied=NM)
Fuzzy_output=CE; if
((Disp_vel_fuzzied=NS)||(Disp_vel_fu zzied=CE)||(Disp_vel_fuzzied=PS))
Fuzzy_output=NS; if ((Disp_vel_fuzzied=PM)|| (Disp_vel_fuzzied=PL))
Fuzzy_output=NM; if (Displace_fuzzied=PL)
if (Disp_vel_fuzzied=NL)
Fuzzy_output=CE; if
((Disp_vel_fuzzied=NM)||(Disp_vel_fu zzied=NS)||(Disp_vel_fuzzied=CE))
Fuzzy_output=NS; if
((Disp_vel_fuzzied=PS)||(Disp_vel_fu zzied=PM)||(Disp_vel_fuzzied=PL))
Fuzzy_output=NM; return (Fuzzy_output);
}
102
////////////////////////////////////////////////////// ///////////////
// Locom
otion Response function
//
// Input : Motor_output. // Output : Nil. // Summary : The function calculates the moto r responses and drives the motors as
// required. // ////////////////////////////////////////////////////// ///////////////
int Locomotion_Response ()
{ //float Left_motor_PID=0, Right_motor_PID=0; // Left motor output calculations // Desired input has not impl emented under current project
Motor_output=Fuzzy_motor_output; // Left motor PID calculations Left_motor_PID=PID_Function(PID_output); // Right motor output calculations // Desired input has not impl emented under current project
Motor_output=Fuzzy_motor_output; // Right motor PID calculations
Right_motor_PID=PID_Function(PID_output);
// Simplified version of motor output pr ogramming due to no locomotion control
implemented at this time. // Apply motor brakes if (Motor_output=0)
Left_drive_outputl1=1; Left_drive_outputl2=1; Right_drive_outputl3=1; Right_drive_outputl4=1; Enable_drive_output=1; // Backward motor direction
if (Motor_ouptut<0)
if (Motor_ouptut=-30)
Left_drive_outputl1=0; Left_drive_outputl2=1; Right_drive_outputl3=0; Right_drive_outputl4=1; Enable_drive_output=1; // Time sequence for 30% duty cycle not implemented at this time. if (Motor_ouptut=-70)
103
Left_drive_outputl1=0;
Left_drive_outputl2=1; Right_drive_outputl3=0; Right_drive_outputl4=1; Enable_drive_output=1; // Tim
e sequence for 70% duty cycle not implemented at this time.
if (Motor_ouptut=-100)
Left_drive_outputl1=0; Left_drive_outputl2=1; Right_drive_outputl3=0; Right_drive_outputl4=1; Enable_drive_output=1; // Time sequence for 100% duty cycle not implemented at this time. // Forward motor direction if (Motor_ouptut>0)
if (Motor_ouptut=30)
Left_drive_outputl1=1; Left_drive_outputl2=0; Right_drive_outputl3=1; Right_drive_outputl4=0; Enable_drive_output=1; // Time sequence for 30% duty cycle not implemented at this time. if (Motor_ouptut=70)
Left_drive_outputl1=1; Left_drive_outputl2=0; Right_drive_outputl3=1; Right_drive_outputl4=0; Enable_drive_output=1; // Time sequence for 70% duty cycle not implemented at this time. if (Motor_ouptut=100)
Left_drive_outputl1=1; Left_drive_outputl2=0; Right_drive_outputl3=1; Right_drive_outputl4=0; Enable_drive_output=1; // Time sequence for 100% duty cycle not implemented at this time. return (0);
}
104
////////////////////////////////////////////////////// ///////////////
// PID contr
oller function
//
// Input : Motor_output. // Output : PID_output. // Summary : The PID function has not been implemented at this time. // ////////////////////////////////////////////////////// ///////////////
static float PID_Function (PID_output)
{ PID_output=1; // Motor_ouput used in calculations not implemented at this time.
{ // Proportional calculations not implemented at this time.
// Integral calculations not implemented at this time. // Derivative calculations not implemented at this time.
} return (0);
}
105
////////////////////////////////////////////////////// ///////////////
// Kalm
an Filter function
//
// Input : Gyro_digital, Accel_digital. // Output : K_output. // // Summary : The function performs the Kalman filtering computations. // Code is provided by Simon (2001) "Kalman Filtering". // This function does not contai n original content at this time.
// ////////////////////////////////////////////////////// ///////////////
static float Kalman_Function(K_output)
{ Gyro_digital= ; Accel_digital= ; // A is an n by n matrix // B is an n by m matrix // C is an r by n matrix // xhat is an n by 1 vector // y is an r by 1 vector // u is an m by 1 vector // Sz is an r by r matrix // Sw is an n by n matrix // P is an n by n matrix
float AP[n][n]; // This is the matrix A*P
float CT[n][r]; // This is the matrix CT
float APCT[n][r]; // This is the matrix A*P*CT
float CP[r][n]; // This is the matrix C*P
float CPCT[r][r]; // This is the matrix C*P*CT
float CPCTSz[r][r]; // This is the matrix C*P*CT+Sz
float CPCTSzInv[r][r]; // This is the matrix (C*P*CT+Sz)-1
float K[n][r]; // This is the Kalman gain.
float Cxhat[r][1]; // This is the vector C*xhat
float yCxhat[r][1]; // This is the vector y-C*xhat
float KyCxhat[n][1]; // This is the vector K*(y-C*xhat)
float Axhat[n][1]; // This is the vector A*xhat
float Bu[n][1]; // This is the vector B*u
float AxhatBu[n][1]; // This is the vector A*xhat+B*u
float AT[n][n]; // This is the matrix AT
float APAT[n][n]; // This is the matrix A*P*AT
float APATSw[n][n]; // This is the matrix A*P*AT+Sw
float CPAT[r][n]; // This is the matrix C*P*AT
float SzInv[r][r]; // This is the matrix Sz-1
float APCTSzInv[n][r]; // This is the matrix A*P*CT*Sz-1
float APCTSzInvCPAT[n][n]; // This is the matrix A*P*CT*Sz-1*C*P*AT
106
// The following sequence of functi on calls compute the K matrix.
MatrixMultiply(( float*)A, ( float*)P, n, n, n, ( float*)AP);
MatrixTranspose((float *)C, r, n, ( float*)CT);
MatrixMultiply(( float*)AP, ( float*)CT, n, n, r, (float *)APCT);
MatrixMultiply(( float*)C, ( float*)P, r, n, n, ( float*)CP);
MatrixMultiply(( float*)CP, ( float*)CT, r, n, r, ( float*)CPCT);
MatrixAddition(( float*)CPCT, ( float*)Sz, r, r, ( float*)CPCTSz);
MatrixInversion(( float*)CPCTSz, r, ( float*)CPCTSzInv);
MatrixMultiply(( float*)APCT, ( float*)CPCTSzInv, n, r, r, ( float*)K);
// The following sequence of functi on calls updates the xhat vector.
MatrixMultiply(( float*)C, ( float*)xhat, r, n, 1, ( float*)Cxhat);
MatrixSubtraction(( float*)y, ( float*)Cxhat, r, 1, ( float*)yCxhat);
MatrixMultiply(( float*)K, ( float*)yCxhat, n, r, 1, ( float*)KyCxhat);
MatrixMultiply(( float*)A, ( float*)xhat, n, n, 1, ( float*)Axhat);
MatrixMultiply(( float*)B, ( float*)u, n, r, 1, ( float*)Bu);
MatrixAddition(( float*)Axhat, ( float*)Bu, n, 1, ( float*)AxhatBu);
MatrixAddition(( float*)AxhatBu, ( fl oat*)KyCxhat, n, 1, ( float*)xhat);
// The following sequence of function calls updates the P matrix. MatrixTranspose((float *)A, n, n, ( float*)AT);
MatrixMultiply(( float*)AP, ( float*)AT, n, n, n, (float *)APAT);
MatrixAddition(( float*)APAT, ( float*)Sw, n, n, ( float*)APATSw);
MatrixTranspose((float *)APCT, n, r, ( float*)CPAT);
MatrixInversion(( float*)Sz, r, ( float*)SzInv);
MatrixMultiply(( float*)APCT, ( float*)SzInv, n, r, r, ( float*)APCTSzInv);
MatrixMultiply(( float*)APCTSzInv, ( float*)CPAT, n, r, n,
(float*)APCTSzInvCPAT);
MatrixSubtraction(( float*)APATSw, ( float*)APCTSzInvCPAT, n, n, ( float*)P);
return (K_output);
} // End of file
Copyright Notice
© Licențiada.org respectă drepturile de proprietate intelectuală și așteaptă ca toți utilizatorii să facă același lucru. Dacă consideri că un conținut de pe site încalcă drepturile tale de autor, te rugăm să trimiți o notificare DMCA.
Acest articol: University of Southern Queensland [604653] (ID: 604653)
Dacă considerați că acest conținut vă încalcă drepturile de autor, vă rugăm să depuneți o cerere pe pagina noastră Copyright Takedown.
