Top Banner
Holonomic Spherical Mobile Robot Omnidirectional spherical body robot using wireless control AKMAL KARLSSON TARA MOHAMMED-AMIN Bachelor’s Thesis at ITM Supervisor: Nihad Subasic Examiner: Nihad Subasic TRITA-ITM-EX 2020:27
62

Holonomic Spherical Mobile Robot - KTH

Apr 26, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Holonomic Spherical Mobile Robot - KTH

Holonomic Spherical Mobile Robot

Omnidirectional spherical body robot using wireless control

AKMAL KARLSSONTARA MOHAMMED-AMIN

Bachelor’s Thesis at ITMSupervisor: Nihad SubasicExaminer: Nihad Subasic

TRITA-ITM-EX 2020:27

Page 2: Holonomic Spherical Mobile Robot - KTH

AbstractThe purpose this project is to construct a holonomic mobilerobot driven with omni wheels. The finished product willbe a robot platform within a spherical shell body controlledby input commands defining speed and direction from awireless communication medium.

Keywords: Mechatronics, Holonomic robot, Omnidirec-tional, DC motor, Control Theory

Page 3: Holonomic Spherical Mobile Robot - KTH

ReferatTitle in Swedish goes here

Syftet med detta projekt ar att konstruera en holonomiskrobot, vilket kan uppfyllas med hjalp av omnihjul som kandrivas i samtliga riktningar i planet. Den fardiga produktenkommer placeras i en sfarisk kropp och ta in hastighet- ochriktningssignaler fran en tradlos kommunikationsmodul.

Nyckelord: Mekatronik, Holonomisk robot, Omniriktning,DC motor, Reglerteknik

Page 4: Holonomic Spherical Mobile Robot - KTH

Acknowledgements

We would like to thank our supervisor Nihad Subasic for providing us with valuableknowledge and support. The interactive environment between students and teacherswas extremely helpful, especially during these difficult times of Covid-19.

We also want to express our gratitude to Seshagopalan Thorapalli Muralidharanwho helped us tackle problems we came across and showed great availability in timesof need.

Furthermore we would like to express gratitude to Staffan Qvarnstrom, who wasresponsible for purchase of components and parts.

When we had difficulties constructing the spherical body, Mats Bejhem gave usvaluable information and the discussions we had with him helped us think outsidethe box and move forward. For that we are very thankful.

Last but not least, we want to thank The Royal Institute of Technology forgiving us the opportunity to do this project and providing us with resources andhelpful teachers.

Page 5: Holonomic Spherical Mobile Robot - KTH

Contents

1 Introduction 21.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Theory 42.1 Omnidirectional mobility . . . . . . . . . . . . . . . . . . . . . . . . 4

2.1.1 Omni wheels . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Control theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.4 Robot Dynamic Model . . . . . . . . . . . . . . . . . . . . . . . . . . 72.5 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.6 Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.6.1 DC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.6.2 H-bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.7 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.7.1 Gyroscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.7.2 Accelerometer . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.7.3 Bluetooth communication . . . . . . . . . . . . . . . . . . . . 11

3 Implementation 123.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.1.1 Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.2 Motor carrier . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.1.3 Spherical body . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.2 Electronic components . . . . . . . . . . . . . . . . . . . . . . . . . . 153.2.1 DC motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.2.2 Batteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.2.3 Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.2.4 HC-05 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.2.5 Arduino Uno . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.3 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Page 6: Holonomic Spherical Mobile Robot - KTH

4 Results 20

5 Discussion 215.1 Construction of spherical body . . . . . . . . . . . . . . . . . . . . . 215.2 Construction of motor carriers . . . . . . . . . . . . . . . . . . . . . 215.3 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

6 Conclusion 24

Bibliography 25

Appendices 27

A Wiring diagram i

B DC motors datasheet iii

C HC-05 datasheet vi

D Arduino datasheet xx

E Code xxv

Page 7: Holonomic Spherical Mobile Robot - KTH

List of Figures

2.1 Conceptual figure of non-holonomic (A) versus holonomic drive (B), cre-ated in Adobe Illustrator. . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2 Omni wheel for holonomic mobility [6]. . . . . . . . . . . . . . . . . . . . 52.3 Kinematic diagram created in Illustrator. . . . . . . . . . . . . . . . . . 62.4 System at rest. Illustration created in Inkscape. . . . . . . . . . . . . . . 72.5 System not at rest. Illustration created in Inkscape. . . . . . . . . . . . 82.6 Two types of Microcontroller Unit (MCU)s. An Arduino to the left, a

Raspberry Pi to the right [11]. . . . . . . . . . . . . . . . . . . . . . . . 82.7 Conceptual figure of a DC motor. . . . . . . . . . . . . . . . . . . . . . . 92.8 Conceptual figure of an H-bridge, with four switches controlling the mo-

tor M. Created in PowerPoint. . . . . . . . . . . . . . . . . . . . . . . . 102.9 Three Pulse Width Modulation (PWM) diagrams with 25%, 50% re-

spective 75% duty cycle [14]. . . . . . . . . . . . . . . . . . . . . . . . . 102.10 A gyroscope [16]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.1 Used platform design, as seen from above. Created in Illustrator. . . . . 123.2 A CAD model of seperate interlocking parts, rendered in KeyShot. . . . 133.3 Spherical body of the mobile robot. . . . . . . . . . . . . . . . . . . . . 143.4 Separate parts of the assembled DC motor [18], [19]. . . . . . . . . . . . 153.5 Breadboard with 400 holes [21]. . . . . . . . . . . . . . . . . . . . . . . . 163.6 Bluetooth communication module HC-05. . . . . . . . . . . . . . . . . . 163.7 MCU Arduino Uno [23]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.8 Software logic flowchart, created in draw.io. . . . . . . . . . . . . . . . . 19

4.1 Finished holonomic mobile robot. . . . . . . . . . . . . . . . . . . . . . . 20

5.1 A model of a motor carrier, 3D-printed. . . . . . . . . . . . . . . . . . . 22

A.1 Wiring diagram, created in EasyEDA. . . . . . . . . . . . . . . . . . . . ii

Page 8: Holonomic Spherical Mobile Robot - KTH

List of acronymsAI Artificial Intelligence

PID Proportional-Integral-Derivative

DC Direct Current

MCU Microcontroller Unit

PWM Pulse Width Modulation

SPP Serial Port Protocol

PCB Printed Circuit Board

IMU Inertial Measurement Unit

1

Page 9: Holonomic Spherical Mobile Robot - KTH

Chapter 1

Introduction

1.1 BackgroundMobile robots have had an important role in industries in an accelerating fashionand their use will likely only increase as automation progresses. There is also anincreased cultural awareness of such robots through popular media. This was theinitial inspiration for a mobile robot with a spherical body.

Some benefits of a closed body spherical robot is that the system can be con-tained and isolated which could prove to be useful in hazardous environments. An-other benefit is the easy access to relatively difficult paths and its ability to moveeffortlessly in all directions in a space which contains obstacles [1]. The most com-mon mobile robots in industrial applications are often limited to planar and smoothworking areas, this is where a spherical mobile robot could prove to be advantageousin traversing non-uniform surfaces.

The main cover of this project is to create a holonomic robot with three omni-wheels in a spherical body which will be controlled remotely and is able to movesmoothly on the desired path. Further developments of the conceptual design wouldbe to install autonomous drive and steering with the help of various sensor systems;adding a head or other limbs which would be held up with the help of magnetic sys-tems to make the robot more relatable to humans; or integrating a voice-feedbackArtificial Intelligence (AI) to make the robot do what the user wishes in a directway.

A robot of any kind have different purposes, depending on the workplace andability. For a holonomic robot it could for example be transport of smaller objectsin office environments, or in bumpy and rough areas such as in a garden.

A challenge that may come up are how can movement be realised with a holo-nomic system for a mobile robot with spherical body. Another challenge is tobalance the weight and size of the spherical body and the force of the mechanicaldrive of the robot so that the whole system moves forward, rather than having therobot driving around inside the sphere without moving it, like a hamster in a wheel.

2

Page 10: Holonomic Spherical Mobile Robot - KTH

1.2 PurposeThe main purpose of this project is to examine how a holonomic robot with aspherical shell body can be designed and constructed. A secondary objective isto investigate what kind of control law in combination with relevant sensor datawould be best suited for smooth movement. Given limited resources, the focuswas to increase knowledge about the field of mobile robotics, rather than creatinga product with high market value. With stated purpose the following researchquestions needed to be answered:

• How can an omnidirectional mobile platform be adapted to a spherical body?

• What communication medium is best suited for a robot of this kind?

1.3 ScopeThe requirements of this project is that it should be comprised of mechanical, elec-trical and programmable elements. The scope of this project is to design and con-struct a holonomic mobile robot augmented with gyroscopic sensors, Proportional-Integral-Derivative (PID) controller, omnidirectional wheels and wireless communi-cation.

The duration for the project to be completed is approximately four monthsand the given budget is 1000 SEK. In the midst of the project the virus Covid-19broke out due to a pandemic [2] which hindered development and halted access toprototyping tools and equipment, this unexpected constraint has to be taken intoaccount when evaluating the end result.

1.4 MethodThe execution of this bachelor’s project was divided into modules. In the beginningthe work was mostly theoretical for research purposes. With the help of relevantlessons, labs and studying theses which were related to the work covered in thisthesis, a base of knowledge was formed which kept growing as the constructionphase continued.

The design of the robot platform was continually iterated upon to serve theneeds of the functions. There were many opportunities for trial and error when itcame to construction, from trying to figure out the optimal way to build the motorseats and fittings, to choosing a fitting communication form between user and robot.Writing code for the Arduino Microcontroller Unit (MCU) [3] was also a large partof the work as it was a key task for the robot to command the right wheels inrespect to angular separation, in order to achieve correct system heading. By usinga gyroscope and accelerometer sensor it is possible to keep the mobile robot insidethe spherical body stable by PID control feedback to help regulate input forceswhich drive the system. This is further explained in sections 2.3 and 2.7.

3

Page 11: Holonomic Spherical Mobile Robot - KTH

Chapter 2

Theory

2.1 Omnidirectional mobilityConcerning mobile robots there are two types of drive principles; holonomic or non-holonomic [4]. A holonomic drive means that the total degrees of freedom is thesame amount as the controllable degrees of freedom, this is illustrated in Figure2.1. Generally mobile robots are designed for planar motion, it follows that in atwo-dimensional space a body has three degrees of freedom. This allows translationin two directions (x,y) and rotation (θ).

While conventional vehicles are able to reach any location and rotation in theplane they are not able to do it directly and may require complex maneuvers. Aholonomic mobile platform has the advantage of facing any direction under anyrotational state. Thanks to this property, it orientates itself faster and requires lessspace to rotate.

In simpler terms this means that the robot easily can move in any direction,without a need to rotate or adjust. Comparatively, a car that is parallel parkingcan be described as a non-holonomic drive, as it needs to adjust its position in orderto fit in the desired spot.

A B

Figure 2.1: Conceptual figure of non-holonomic (A) versus holonomic drive (B),created in Adobe Illustrator.

4

Page 12: Holonomic Spherical Mobile Robot - KTH

2.1.1 Omni wheelsTo realize a holonomic drive one could use omni wheels, which are portrayed inFigure 2.2. They allow the object to move in any direction without having to rotatethe wheels, thanks to the angular positions of the rollers [5].

The most basic configuration for holonomic drive with omni wheels is composedof three or four wheels. Since the intention of the robot in this project is to occupyand traverse the inside of a spherical body it should be constrained in a way so thatsurface contact is maintained regardless internal angular position. This is achievedby a structure normal to the mobile robot platform. A three-wheel configurationwas chosen as that is the least amount of omni wheels required for non-holonomicmovement and is well suited for a triangular platform.

Figure 2.2: Omni wheel for holonomic mobility [6].

2.2 KinematicsThe holonomic platform has three wheel hubs, each separated by 120 ◦, positionedin the local frame thay are at vi = 90◦, 210◦, 330◦ where i = 1,2,3. A diagram forplanar motion is obtained in Figure 2.3, where the red vector v is the velocity inputfor the system. Further the system velocity vector is discomposed at each wheel hubinto two vectors, a green vector vi,t represents the translational velocities for eachwheel and is described in the equation system 2.1 and the remaining blue vector isthe projection normal to the motor axis. Velocities vw of each wheel in terms ofrotation and translation are described in Equation 2.2 and [7] :

v1,t

v2,t

v3,t

= vi

cos(α)cos(120◦ + α)cos(240◦ + α)

(2.1)

vw(v1, v2, v3) = vtranslation(v1, v2, v3) + vrotation(v1, v2, v3) (2.2)

5

Page 13: Holonomic Spherical Mobile Robot - KTH

v

v1

v3v2

v1,t

v2,tv3,tR

x

y

Figure 2.3: Kinematic diagram created in Illustrator.

6

Page 14: Holonomic Spherical Mobile Robot - KTH

2.3 Control theoryTo make sure the robot stays stable, a type of control system is required. A PIDcontroller is a simple, yet effective way to go about [8]. It uses feedback to create aninput signal u(t) which is based on the error e(t) between the desired r(t) and actualy(t) output signal e(t)=r(t)-y(t). The input signal is then described according to

u(t) = KP e(t) +KI

∫ t

0e(τ)dτ +KD

d

dte(t) (2.3)

where KP , KI and KD are constants. KP can make the system faster, butit can influence the stability negatively. KI helps reduce the error but can alsohave a damaging effect on the stability. By having the derivative term KD you canimprove stability. Finally, by implementing all three parts, you have a functioningand stable system.

2.4 Robot Dynamic ModelThe dynamic model that enables spherical locomotion along a plane will be de-scribed as if moving on a line. As seen in Figure 2.4, the greater outer circle rep-resents the spherical shell and the smaller inner circle represents the actual mobileplatform with a centre of gravity that is at its lowest energy potential at rest.

By actuating the mobile platform up to an angle θ as seen in Figure 2.5 theoffset centre of gravity generates a torque, because of rolling resistance and frictionbetween the outer shell and ground this torque results in forward motion as thecenter of gravity seeks to return to its lowest energy potential as seen in Figure2.4. This mechanism and angle θ is what will be used by the PID function as theoutput, which will be measured by an onboard gyroscopic circuit element. A morecomprehensive mechanical model is described in [9] by Wei-Hsi Chen et al.

Figure 2.4: System at rest. Illustration created in Inkscape.

7

Page 15: Holonomic Spherical Mobile Robot - KTH

Figure 2.5: System not at rest. Illustration created in Inkscape.

2.5 MicrocontrollerA MCU can be described as an elementary personal computer with the purposeof executing different tasks in an embedded system [10]. It collects and processesdata and information, and based on their value the MCU responds with an output.Depending on the requirements of the functions of the object, there are severalconsiderations to have in mind when chosing a type of MCU. Two common typesare Arduino and Raspberry Pi [11], see Figure 2.6. For this project an Arduino MCUwould be sufficient, while a Raspberry Pi MCU is better suited for more complexrobots which e.g. perform multiple tasks at once or run heavy calculations.

Figure 2.6: Two types of MCUs. An Arduino to the left, a Raspberry Pi to theright [11].

8

Page 16: Holonomic Spherical Mobile Robot - KTH

2.6 Motors

2.6.1 DC motorFor this project a Direct Current (DC) motor was an obvious choice due to thesimplicity of the regulation of rotational speed, which is made possible because ofhow torque and speed depends linearly on the current I and voltage V supply [12].When designing a mobile robot, torque is a feature you want to control across arange of rotational velocities. Absolute angular position of the motor axle is oflittle interest in this project, therefore a DC servo motor was chosen over a steppermotor.

When connecting a direct current to the rotor, a magnetic field is induced. Bysurrounding the copper coil with permanent magnets in the stator, the rotor rotatesdue to magnetic field alignment. Figure 2.7 shows how this works.

Figure 2.7: Conceptual figure of a DC motor.

2.6.2 H-bridgeA H-bridge is a type of circuit which supplies voltage to the motor and functionsas a gate which steers the current in desired directions [12]. The switches areformed as an H, hence the name of the type of bridge. This is illustrated in Figure2.8. Through the use of four transistors that are regulated by commands from aMCU polarity can also be controlled which makes it possible for the motor to driveforwards or backwards.

PWM regulates the switches by turning them on and off persuant to a desiredextent [13]. By letting through full voltage for an amount of time (pulse width) andcutting off all voltage for the rest of the period you obtain an average voltage valuedepending on the size of the pulse width. Practically this will mean the mobilerobot responds with stronger motor power as the user pushes the joystick furtherfrom the origin. In Figure 2.9 duty cycles 25%, 50% and 75% are illustrated in adiagram, as the duty cycle represents the fraction of a time period T the full voltageis on.

9

Page 17: Holonomic Spherical Mobile Robot - KTH

Figure 2.8: Conceptual figure of an H-bridge, with four switches controlling themotor M. Created in PowerPoint.

Figure 2.9: Three PWM diagrams with 25%, 50% respective 75% duty cycle [14].

10

Page 18: Holonomic Spherical Mobile Robot - KTH

2.7 SensorsA sensor can be described as a component which can interpret a physical quantityas an input and then give a certain output, depending on the type of sensor [12].This is comparative to the biological senses which help us orient ourselves throughthe physical world. With the help of physical principles the components can sensethe surrounding world.

2.7.1 GyroscopeGyroscopes recognize gravity to help orient the object [15]. A balanced rotor, at-tached to a rotating axis so that it can lean to any direction, gets pulled by thegravitational force as the object move in a particular way. Figure 2.10 illustrates agyroscope. This will cause the axis to feel which way is down.

Figure 2.10: A gyroscope [16].

2.7.2 AccelerometerAn accelerometer is a sensor which uses the vibrations caused by different acceler-ations close to the surface of the earth [15]. When these vibrations occur, microcrystals are strained and in turn a voltage is generated which can be translated toan acceleration value for the MCU to interpret.

The purpose of this component in the mobile robot is, as well as the gyroscope,to return data to the PID controller to maintain stability as it moves.

2.7.3 Bluetooth communicationCommunication between a smartphone and a Bluetooth module enables wirelesscommunication and thus control of the MCU [10], this connection requires thesmartphone to act as a master and the Bluetooth module as a slave or listeningdevice. This is all done in the 2.4GHz radio frequency range with a baud rate of9600.

11

Page 19: Holonomic Spherical Mobile Robot - KTH

Chapter 3

Implementation

3.1 Hardware

3.1.1 PlatformThe central platform plate which all motors and electrical components are attachedto is shown in Figure 3.1. This platform was laser cut out of 9 mm thick acrylicsheet.

The design includes 22 M3 mounting holes, where 12 of the holes were threadedso that the motor carriers could be mechanically attached with screws.

Remaining holes are either for redundancy purposes or to be used by a mastfeature with a terminating caster ball, furthermore three squares were cut out andtheir intended function is as a through-via for cables crossing from motors on theunderside of the platform to the micro controller which is mounted top-side. Thegoal when designing the platform plate was to minimize the area as much as possibleas that directly impacted the minimum allowable radius of the outer shell.

Figure 3.1: Used platform design, as seen from above. Created in Illustrator.

12

Page 20: Holonomic Spherical Mobile Robot - KTH

3.1.2 Motor carrierThe purpose of a motor carrier is to provide a structural interface between theplatform plate and the motor.

The final design iteration was realized by laser cutting several flat interlockingpieces that would form a three dimensional structure when assembled, see Figure3.2 where it is illustrated in exploded view.

Figure 3.2: A CAD model of seperate interlocking parts, rendered in KeyShot.

3.1.3 Spherical bodyThe spherical shell of the system was made of a finished product which was alteredfor the project; a world globe as seen in Figure 3.3a [17].

After removing the lamp stand the holes at the poles of the globe were coveredwith 3D printed pole plugs, see Figure 3.3c. These were designed in Solid Edge witha slight radius to match the curvature of the globe. It was important to preventparts extending the sphere, both internally and externally, so the robot could movefreely inside the globe and the outside of the globe to be uniformly spherical. Atlast the pole plugs got glued on to fill the holes.

The globe was initially two hemispheres put together with strong and thickadhesive, which were then seperated using a dremel tool to both cut and smoothedges. The finished product is seen in 3.3b.

13

Page 21: Holonomic Spherical Mobile Robot - KTH

(a) World globe lamp used for spherical body. (b) Separation of the hemispheres of the worldglobe using a dremel.

(c) 3D printed pole plugs to fill the holes ofthe globe seen in (b).

Figure 3.3: Spherical body of the mobile robot.

14

Page 22: Holonomic Spherical Mobile Robot - KTH

3.2 Electronic componentsThis section will present electronic components used for the holonomic mobile robot.They are specifically listed in Table 3.1 and will be shown in the following subsec-tions. Appendix A contains a wiring diagram which shows how these componentsare wired to the Arduino.

Table 3.1: List of electrical components used for this project.

Component Data1x MCU Arduino Uno3x DC motors Maxon motors parts 110147 and 2327663x batteries GP 1604A-U1 / 6LF22 / 9V1x breadboard Luxorparts 400 point breadboard1x bluetooth module HC-05

3.2.1 DC motorsThe used DC motors are shown in figures 3.4. Datasheets for them are seen inAppendix B.

Figure 3.4: Separate parts of the assembled DC motor [18], [19].

3.2.2 BatteriesThe 9V batteries used to drive the DC motors was placed inside the motor carrierswith double-sided tape. Due to the Covid-19 virus it was difficult receiving batteryseats, therefore the poles of the batteries were soldered to wires connecting thesystem.

3.2.3 BreadboardWith a breadboard you can connect multiple wires to the same point [20]. Thiscomponent is easy to use for iterating different circuit designs as no soldering isrequired. In Figure 3.5 the breadboard used is presented.

15

Page 23: Holonomic Spherical Mobile Robot - KTH

Figure 3.5: Breadboard with 400 holes [21].

3.2.4 HC-05A HC-05 is a module which enables communication with the Arduino through Blue-tooth, seen i Figure 3.6 [22]. It uses Serial Port Protocol (SPP) to communicate,connecting with the Arduino through serial communication on pins 0 and 1. Ap-pendix C contains the datasheet for this component.

Figure 3.6: Bluetooth communication module HC-05.

3.2.5 Arduino UnoThe MCU Arduino, shown in Figure 3.7, was used for this project. In Appendix Dyou can find the datasheet for the Arduino.

16

Page 24: Holonomic Spherical Mobile Robot - KTH

Figure 3.7: MCU Arduino Uno [23].

3.3 SoftwareControl and communication with the robot is done through a smartphone app overBluetooth, the app sends x and y values (0-255) as single bytes sequentially aftereach other, which the code only accepts when both values have been received in theserial stream buffer.

whi l e ( S e r i a l . a v a i l a b l e ( ) >= 2) {x = S e r i a l . read ( ) ;de lay ( 1 0 ) ;y = S e r i a l . read ( ) ;

}

Further as seen in Figure 3.8 these values are remapped to an x,y-plane and anangle is calculated between the input vector and positive x-axis, this vector is thendecomposed into three separate vectors for each motor. The PWM value is thenderived from each sub vector by calculating the cosine multiplied with the maximumPWM range and the magnitude of the sub vector.

i f ( xAxis !=0 or yAxis !=0) {motorSpeed1 = ( cos ( alpha ) )∗255∗ ( ( xAxis /100)+( yAxis / 1 0 0 ) ) ;motorSpeed2 = ( cos ( alpha +2.0943951024))∗255∗(( xAxis /100)+( yAxis / 1 0 0 ) ) ;

17

Page 25: Holonomic Spherical Mobile Robot - KTH

motorSpeed3 = ( cos ( alpha +4.1887902048))∗255∗(( xAxis /100)+( yAxis / 1 0 0 ) ) ;

The resulting value for motorSpeed can range from -255 to 255, motor polarity con-trolled through the H-bridges depends on the sign of the motorSpeed value enablingclockwise or counter clockwise rotation and the PWM output is the absolute valueof motorSpeed.

The full code can be found in Appendix E.

18

Page 26: Holonomic Spherical Mobile Robot - KTH

Figure 3.8: Software logic flowchart, created in draw.io.

19

Page 27: Holonomic Spherical Mobile Robot - KTH

Chapter 4

Results

Testing was done both by communicating over Bluetooth and hard coding presetdummy input values to verify proper motor responses. Results were interpretedthrough serial monitor outputs and directly driving the motors. Serial monitoroutput could be monitored either through a computer connection over USB orwirelessly through a Bluetooth terminal application.

The finished product is presented in Figure 4.1 where you can see an overviewof the general construction.

(a) Side view of the robot, focused on the omniwheel and DC motor.

(b) Whole picture of the robot in a hemi-sphere.

(c) View from above, rendered in Keyshot.

Figure 4.1: Finished holonomic mobile robot.

20

Page 28: Holonomic Spherical Mobile Robot - KTH

Chapter 5

Discussion

5.1 Construction of spherical bodyWhen deciding upon the enclosure for the whole system the challenge was in findingor designing a suitable outer shell for the mobile robot system, the size of the robotplatform was a deciding factor as it constrained the minimal radius for the shell.

The first idea that was explored was to construct the spherical shell throughadditive manufacturing in the way of 3D printing [24], the idea was to print thetwo hemispheres separately but the available printing volume was too small toaccommodate the minimal desired radius.

The next logical step was to break up the two hemispheres into smaller interlock-ing parts that could fit the printer volume similar to work done in [25]. Ultimatelythis was not the way we chose to proceed with construction of the shell.

Other ideas were explored, such as the use of a vacuum forming machine whichwould require a hemispherical model. This was also deemed as an unsuitable methodas the vacuum forming machine available to us didn’t have the required volume forour purpose.

Finally the solution was to retrofit a plastic world globe, which serendipitouslyhad the correct desired dimensions for this project.

5.2 Construction of motor carriersThe first design of the motor carrier were 3D printed as shown in Figure 5.1. Thisdid not meet our desired specifications as the resolution and general variability ineach printed model was not satisfactory. In the final iteration the motor carrierswere instead constructed by several interlocking parts that were laser cut out ofan acrylic sheet, this method proved to be viable due to consistent dimensions ofprocessed parts.

21

Page 29: Holonomic Spherical Mobile Robot - KTH

Figure 5.1: A model of a motor carrier, 3D-printed.

5.3 GeneralThe intended final design for this robot platform differs from what was achieved.The intention was to have all separate electronic components mounted on a singlecustom fabricated Printed Circuit Board (PCB) in order or save space and foregoexcessive use of cables, due to lack of accessibility to prototyping machines we optedto instead tacking all three separate H-bridge circuits to the platform itself.

This also meant that we had to use a breadboard attached to the platform.Lack of accessibility to proper fabrication machines forced us to scale back our scope,three major missing parts are the integration of an Inertial Measurement Unit (IMU)sensor as it would require additional structure to the platform in order to positionit centrally, with an IMU sensor there would’ve been enough sensor information toimplement a PID system to regulate PWM output instead of manually controllingthe PWM range.

A second missing structure is the stabilising mast with a caster ball at the end,this would prevent the robot platform from tumbling around inside the sphere andrisk turning itself over.

The final missing piece is a proper voltage supply for the Arduino and motors,instead as a compromise three 9-volt batteries were used to power the whole system,two for each motor and a third supplying the third motor and the Arduino. Theproblem with the aforementioned solution is that the motors were not able to reachmaximum torque as they are each rated for 12-volt and thus the robot wasn’t ableto climb the inside of the sphere and achieve desired mobility- Alternatively themotors chosen might have been too weak for their intended purpose altogether,

22

Page 30: Holonomic Spherical Mobile Robot - KTH

would that have been the case then the previously mentioned limitations wouldstill apply as it would require fabrication of new parts and a properly suited powersupply as the 9-volt batteries would prove to be even more insufficient for the taskat hand, it is also worth mentioning that three 9-volt batteries were the best thatcould be achieved due to space limitation in an already overcrowded platform, seeFigure 4.1a.

23

Page 31: Holonomic Spherical Mobile Robot - KTH

Chapter 6

Conclusion

With the right choice of motors it is entirely possible to implement an sphericalomnidirectional holonomic robot, communication and control is possible but notlimited to Bluetooth. Several branches for further development present themselves,such as control aided by PID coupled with an IMU, this would potentially smoothand stabilise mobility and also provide a reliable heading reference. Communicationcould be realised over other means than Bluetooth such as Wi-fi. With a properlytuned PID it should also be possible for the robot to follow a preset path.

24

Page 32: Holonomic Spherical Mobile Robot - KTH

Bibliography

[1] Using Omni Wheels to make Holonomic Drive. https://seas.yale.edu/sites/default/files/imce/other/HolonomicOmniWheelDrive.pdf. [On-line; accessed 11-May-2020].

[2] Folkhalsomyndigheten. https://www.folkhalsomyndigheten.se/smittskydd-beredskap/utbrott/aktuella-utbrott/covid-19/bekraftade-fall-i-sverige/. [Online; accessed 12-May-2020].

[3] Arduino. https://www.arduino.cc/en/guide/introduction. [Online; ac-cessed 11-May-2020].

[4] Nicholas Apazidis. Mekanik 2. Studentlitteratur, Studentlitteratur AB, Lund,2017.

[5] J. Moreno et al. Design, implementation and validation of thethree-wheel holonomic motion system of the assistant personal robot(apr). Sensors, pages 2–4, 2016. doi: 10.3390/s16101658. URLhttps://www.researchgate.net/publication/309002190_Design_Implementation_and_Validation_of_the_Three-Wheel_Holonomic_Motion_System_of_the_Assistant_Personal_Robot_APR.

[6] Generation Robots. https://www.generationrobots.com/en/402779-58mm-omni-wheel-for-lego-nxt.html. [Online; accessed 28-March-2020].

[7] R.P.A. van Haendel. Design of an omnidirectional universal mobile platform.DCT rapporten. Technische Universiteit Eindhoven, 2005. DCT 2005.117.

[8] Lennart Ljung Torkel Glad. Reglerteknik - Grundlaggande teori. Studentlitter-atur, Studentlitteratur AB, Lund, 2006.

[9] Jia-Shiuan Tsai Jackie Yang Pei-Chun Lin Wei-Hsi Chen, Ching-Pei Chen. De-sign and implementation of a ball-driven omnidirectionalspherical robot. pages4–6, 2013. doi: https://doi.org/10.1016/j.mechmachtheory.2013.04.012. URLhttps://doi.org/10.1016/j.mechmachtheory.2013.04.012.

25

Page 33: Holonomic Spherical Mobile Robot - KTH

[10] M. Gudino. Introduction to microcontrollers. 2018. URLhttps://www.arrow.com/en/research-and-events/articles/engineering-basics-what-is-a-microcontroller. [Online; accessed10-February-2020].

[11] Patrick Di Justo. Raspberry Pi or Arduino? One Simple Rule to Choosethe Right Board, 2015. https://www.dfrobot.com/blog-447.html?gclid=Cj0KCQjwjoH0BRD6ARIsAEWO9DtmoB0CgXu8YVFJXc2IzKvfdWrAqyy5gSpn_VCzdMYk50Q12CJgli8aAtGdEALw_wcB [Accessed: 2020-03-29].

[12] Hans Johansson. Elektroteknik. Instutitionen for Maskinkonstruktion, KTH,Stockholm, 2013.

[13] PWM. https://www.arduino.cc/en/tutorial/PWM, . [Online; accessed 12-May-2020].

[14] LED Dimming Using the PULSE Option and PWM. https://www.nightsea.com/articles/pwm-led-dimming/, . [Online; accessed 12-May-2020].

[15] Ryan Goodrich. Accelerometer vs. Gyroscope: What’s the Difference?, 2018.https://www.livescience.com/40103-accelerometer-vs-gyroscope.html [Accessed: 2020-02-14].

[16] Electricalfundablog. URL https://electricalfundablog.com/gyroscope/.

[17] Globe Touch Lamp. https://www.therange.co.uk/lighting/table-lamps/globe-touch-lamp/#722395. [Online; accessed 28-March-2020].

[18] Planetary Gearhead GP 22 L Ø22 mm, 0.2 - 0.6 Nm, Plas-tic Version. https://www.maxongroup.com/maxon/view/product/gear/planetary/gp22/232766, 2020. [Online; accessed 28-March-2020].

[19] A-max 22 Ø22 mm, Graphite Brushes, 6 Watt, with terminals. https://www.maxongroup.com/maxon/view/product/110147, 2020. [Online; accessed28-March-2020].

[20] What Is a Breadboard and How Does It Work? A Quick Crash Course.https://www.makeuseof.com/tag/what-is-breadboard/. [Online; accessed13-May-2020].

[21] Kopplingsdack 400 hal. https://www.kjell.com/se/produkter/el-verktyg/elektronik/elektroniklabb/kopplingsdack-400-hal-p36285. [Online; accessed 13-May-2020].

[22] Arduino and HC-05 Bluetooth Module Tutorial.https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-tutorial/. [Online; accessed13-May-2020].

26

Page 34: Holonomic Spherical Mobile Robot - KTH

[23] ARDUINO UNO REV3. https://store.arduino.cc/arduino-uno-rev3.[Online; accessed 13-May-2020].

[24] R. Ramlan N. Shahrubudin, T.C. Lee. An overview on 3d printingtechnology: Technological, materials, and applications. Elsevier B.V,page 1286, 2019. doi: 10.1016/j.promfg.2019.06.089. URL https://www.researchgate.net/publication/335174416_An_Overview_on_3D_Printing_Technology_Technological_Materials_and_Applications.

[25] J. Nordin J. Haraldsson. Construction of robot for visual demonstration atconferences and fairs. pages 18–26, 2018.

27

Page 35: Holonomic Spherical Mobile Robot - KTH

Appendix A

Wiring diagram

Figure A.1 shows the wiring between the Arduino MCU and the gyroscopic sensor,the HC-05 module and the H-bridges connecting the motors.

i

Page 36: Holonomic Spherical Mobile Robot - KTH

Figure A.1: Wiring diagram, created in EasyEDA.

ii

Page 37: Holonomic Spherical Mobile Robot - KTH

Appendix B

DC motors datasheet

iii

Page 38: Holonomic Spherical Mobile Robot - KTH

max

on

gea

r

332

A-max 22 147-150 54.7 61.5 68.3 68.3 75.1 75.1 75.1 81.9 81.9 81.9 81.9A-max 22 148/150 MR 416/417 59.7 66.5 73.3 73.3 80.1 80.1 80.1 86.9 86.9 86.9 86.9A-max 22 148/150 Enc 22 426 69.1 75.9 82.7 82.7 89.5 89.5 89.5 96.3 96.3 96.3 96.3A-max 22 148/150 MEnc 13 407 61.8 68.6 75.4 75.4 82.2 82.2 82.2 89.0 89.0 89.0 89.0

M 1:1

232763 232766 232772 232778 232782 232788 232794 232796 232803 232809 232815

3.8 : 1 14 : 1 53 : 1 104 : 1 198 : 1 370 : 1 590 : 1 742 : 1 1386 : 1 1996 : 1 3189 : 1 15⁄4 225⁄16

3375⁄6487723⁄845

50625⁄25610556001⁄28561

59049⁄100759375⁄1024

158340015⁄114244285012027⁄142805

1594323⁄500

4 4 4 3.2 4 3.2 4 4 3.2 3.2 4232764 232767 232773 232779 232783 232789 232795 232798 232804 232810 2328164.4 :1 16 : 1 62 : 1 109 : 1 231 : 1 389 : 1 690 : 1 867 : 1 1460 : 1 2102 : 1 3728 : 1

57⁄13855⁄52

12825⁄2082187⁄20

192375⁄832263169⁄676

1121931⁄16252885625⁄3328

3947535⁄27047105563⁄3380

30292137⁄8125

3.2 3.2 3.2 4 3.2 3.2 3.2 3.2 3.2 3.2 3.2232765 232768 232774 232780 232784 232790 232797 232799 232805 232811 2328175.4 : 1 19 : 1 72 : 1 128 : 1 270 : 1 410 : 1 850 : 1 1014 : 1 1538 : 1 2214 : 1 4592 : 1

27⁄5 3249⁄16948735⁄676

41553⁄325731025⁄2704

6561⁄16531441⁄625

10965375⁄1081698415⁄64

177147⁄8014348907⁄3125

2.5 3.2 3.2 3.2 3.2 4 2.5 3.2 4 4 2.5232769 232775 232781 232785 232791 232800 232806 232812

20 : 1 76 : 1 157 : 1 285 : 1 455 : 1 1068 : 1 1621 : 1 2458 : 181⁄4 1215⁄16

19683⁄12518225⁄64

5000211⁄10985273375⁄256

601692057⁄371293135005697⁄54925

4 4 2.5 4 3.2 4 3.2 3.2232770 232776 232786 232792 232801 232807 232813

24 : 1 84 : 1 316 : 1 479 : 1 1185 : 1 1707 : 1 2589 : 11539⁄65

185193⁄21972777895⁄8788

124659⁄26041668425⁄35152

15000633⁄87883365793⁄1300

3.2 3.2 3.2 3.2 3.2 3.2 3.2232771 232777 232787 232793 232802 232808 232814

29 : 1 89 : 1 333 : 1 561 : 1 1249 : 1 1798 : 1 3027 : 1729⁄25

4617⁄5269255⁄208

2368521⁄42251038825⁄832

373977⁄20863950067⁄21125

2.5 3.2 3.2 3.2 3.2 3.2 3.21 2 3 3 4 4 4 5 5 5 5

0.2 0.3 0.4 0.4 0.5 0.5 0.5 0.6 0.6 0.6 0.60.3 0.4 0.5 0.5 0.7 0.7 0.7 0.8 0.8 0.8 0.884 70 59 59 49 49 49 42 42 42 4228 35 43 43 51 51 51 59 59 59 591.0 1.2 1.6 1.6 2.0 2.0 2.0 2.0 2.0 2.0 2.00.5 0.4 0.4 0.4 0.4 0.4 0.4 0.4 0.4 0.4 0.422.7 29.5 36.3 36.3 43.1 43.1 43.1 49.9 49.9 49.9 49.9

maxon gear June 2018 edition / subject to change

Stock programStandard programSpecial program (on request)

overall length overall length

maxon Modular System+ Motor Page + Sensor/Brake Page Overall length [mm] = Motor length + gearhead length + (sensor/brake) + assembly parts

Technical DataPlanetary Gearhead straight teethHousing plasticOutput shaft stainless steel, hardenedBearing at output sleeve bearingRadial play, 10 mm from flange max. 0.1 mmAxial play max. 0.15 mmMax. axial load (dynamic) 20 NMax. force for press fits 100 NDirection of rotation, drive to output =Max. continuous input speed 6000 rpmRecommended temperature range -15…+80°CNumber of stages 1 2 3 4 5Max. radial load, 10 mm from flange 15 N 20 N 25 N 30 N 30 N

Planetary Gearhead GP 22 L ∅22 mm, 0.2–0.6 NmPlastic Version

Part Numbers

Gearhead Data 1 Reduction 2 Absolute reduction 3 Max. motor shaft diameter mm

Part Numbers 1 Reduction 2 Absolute reduction 3 Max. motor shaft diameter mm

Part Numbers 1 Reduction 2 Absolute reduction 3 Max. motor shaft diameter mm

Part Numbers 1 Reduction 2 Absolute reduction 3 Max. motor shaft diameter mm

Part Numbers 1 Reduction 2 Absolute reduction 3 Max. motor shaft diameter mm

Part Numbers 1 Reduction 2 Absolute reduction 3 Max. motor shaft diameter mm 4 Number of stages 5 Max. continuous torque Nm 6 Max. intermittent torque at gear output Nm 7 Max. efficiency % 8 Weight g 9 Average backlash no load ° 10 Mass inertia gcm2

11 Gearhead length L1 mm

Page 39: Holonomic Spherical Mobile Robot - KTH

max

on A

-max

153153

6.010000

2000

4000

6000

8000

0.2 0.4 0.6 1.00.8

2.0 4.0 6.0 10.08.0

110147

M 1:1

110143 110145 110146 110147 110148 110149 110150 110151 110152 110153 110154 110155139840 353017 199807 320206 323856 108828 199424 202921 267433 325492 313302 353019

20 K/W 6.0 K/W 10.2 s 314 s -30…+85°C +125°C

0.05 - 0.15 mm 0.012 mm 1 N 80 N 2.8 N

0.05 - 0.15 mm 0.025 mm 3.3 N 45 N 12.3 N

1 9 54 g

ESCON Module 24/2 454ESCON 36/2 DC 454ESCON Module 50/5 455ESCON 50/5 457

6 9 9 12 12 15 18 24 24 36 48 489240 9690 8500 10200 9170 10000 9770 10500 8480 9630 9110 821083.1 57.9 49.6 45.8 40.5 36 29 23.7 18.4 14.2 9.99 8.846240 6530 5350 7060 6000 6890 6600 7380 5270 6420 5840 49405.91 6.88 7.04 6.96 6.95 6.93 6.92 6.9 6.97 6.86 6.75 6.861.08 0.859 0.77 0.681 0.613 0.534 0.432 0.347 0.283 0.21 0.147 0.13519.4 22.1 19.8 23.7 20.9 22.9 22 23.7 18.9 21.1 19.2 17.63.29 2.59 2.04 2.17 1.72 1.65 1.29 1.12 0.721 0.606 0.393 0.32567 70 69 72 70 72 72 73 70 72 71 70

1.82 3.48 4.42 5.53 6.96 9.09 14 21.5 33.3 59.4 122 1480.106 0.223 0.288 0.363 0.445 0.585 0.891 1.37 2.1 3.69 7.3 8.975.9 8.55 9.73 10.9 12.1 13.9 17.1 21.2 26.2 34.8 48.9 54.3

1620 1120 981 875 790 689 558 450 364 274 195 176500 454 446 444 455 452 457 456 461 468 487 47920.9 20.2 20.1 19.9 19.9 19.9 19.7 19.7 19.8 19.7 19.9 19.8

4 4.25 4.3 4.29 4.19 4.2 4.13 4.13 4.09 4.02 3.9 3.94

Stock programStandard programSpecial program (on request)

Part Numbers

Specifications Operating Range Comments

n [rpm] Continuous operationIn observation of above listed thermal resistance (lines 17 and 18) the maximum permissible winding temperature will be reached during continuous op-eration at 25°C ambient.= Thermal limit.

Short term operationThe motor may be briefly overloaded (recurring).

Assigned power rating

maxon Modular System Details on catalog page 32

April 2019 edition / subject to change maxon DC motor

A-max 22 ∅22 mm, Graphite Brushes, 6 Watt

Motor Data

Thermal data17 Thermal resistance housing-ambient18 Thermal resistance winding-housing19 Thermal time constant winding20 Thermal time constant motor21 Ambient temperature22 Max. winding temperature

Mechanical data (sleeve bearings)23 Max. speed 9800 rpm24 Axial play25 Radial play26 Max. axial load (dynamic)27 Max. force for press fits (static)28 Max. radial load, 5 mm from flange

Mechanical data (ball bearings)23 Max. speed 9800 rpm24 Axial play25 Radial play26 Max. axial load (dynamic)27 Max. force for press fits (static)28 Max. radial load, 5 mm from flange

Other specifications29 Number of pole pairs30 Number of commutator segments31 Weight of motor

Values listed in the table are nominal. Explanation of the figures on page 68.

Option Ball bearings in place of sleeve bearings

Planetary Gearhead∅22 mm0.1 - 0.6 NmPage 337/338

Recommended Electronics:Notes Page 32

Planetary Gearhead∅22 mm0.5 - 2.0 NmPage 339/341

Values at nominal voltage1 Nominal voltage V2 No load speed rpm3 No load current mA4 Nominal speed rpm5 Nominal torque (max. continuous torque) mNm6 Nominal current (max. continuous current) A7 Stall torque mNm8 Stall current A9 Max. efficiency %

Characteristics10 Terminal resistance W11 Terminal inductance mH12 Torque constant mNm/A13 Speed constant rpm/V14 Speed / torque gradient rpm/mNm15 Mechanical time constant ms16 Rotor inertia gcm2

with terminalswith cables

Spur Gearhead∅24 mm0.1 NmPage 345Screw Drive∅22 mmPage 380/381

Page 40: Holonomic Spherical Mobile Robot - KTH

Appendix C

HC-05 datasheet

vi

Page 41: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

1 Tech Support: [email protected]

HC-05

-Bluetooth to Serial Port Module

Overview

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for

transparent wireless serial connection setup.

Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps

Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore

04-External single chip Bluetooth system with CMOS technology and with AFH(Adaptive

Frequency Hopping Feature). It has the footprint as small as 12.7mmx27mm. Hope it will simplify

your overall design/development cycle.

Specifications

Hardware features

Typical -80dBm sensitivity

Up to +4dBm RF transmit power

Low Power 1.8V Operation ,1.8 to 3.6V I/O

PIO control

UART interface with programmable baud rate

With integrated antenna

With edge connector

Page 42: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

2 Tech Support: [email protected]

Software features

Default Baud rate: 38400, Data bits:8, Stop bit:1,Parity:No parity, Data control: has.

Supported baud rate: 9600,19200,38400,57600,115200,230400,460800.

Given a rising pulse in PIO0, device will be disconnected.

Status instruction port PIO1: low-disconnected, high-connected;

PIO10 and PIO11 can be connected to red and blue led separately. When master and slave

are paired, red and blue led blinks 1time/2s in interval, while disconnected only blue led

blinks 2times/s.

Auto-connect to the last device on power as default.

Permit pairing device to connect as default.

Auto-pairing PINCODE:”0000” as default

Auto-reconnect in 30 min when disconnected as a result of beyond the range of connection.

Hardware

Page 43: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

3 Tech Support: [email protected]

Page 44: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

4 Tech Support: [email protected]

Page 45: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

5 Tech Support: [email protected]

AT command Default:

How to set the mode to server (master):

1. Connect PIO11 to high level.

2. Power on, module into command state.

3. Using baud rate 38400, sent the “AT+ROLE=1\r\n” to module, with “OK\r\n”

means setting successes.

4. Connect the PIO11 to low level, repower the module, the module work as server

(master).

AT commands: (all end with \r\n)

1. Test command:

Command Respond Parameter

AT OK -

2. Reset

Command Respond Parameter

AT+RESET OK -

3. Get firmware version

Command Respond Parameter

AT+VERSION? +VERSION:<Param>

OK

Param : firmware version

Example:

AT+VERSION?\r\n

+VERSION:2.0-20100601

OK

Page 46: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

6 Tech Support: [email protected]

4. Restore default

Command Respond Parameter

AT+ORGL OK -

Default state:

Slave mode, pin code :1234, device name: H-C-2010-06-01 ,Baud 38400bits/s.

5. Get module address

Command Respond Parameter

AT+ADDR? +ADDR:<Param>

OK

Param: address of Bluetooth

module

Bluetooth address: NAP: UAP : LAP

Example:

AT+ADDR?\r\n

+ADDR:1234:56:abcdef

OK

6. Set/Check module name:

Command Respond Parameter

AT+NAME=<Param> OK Param: Bluetooth module

name

(Default :HC-05)

AT+NAME? +NAME:<Param>

OK (/FAIL)

Example:

AT+NAME=HC-05\r\n set the module name to “HC-05”

OK

AT+NAME=ITeadStudio\r\n

OK

AT+NAME?\r\n

+NAME: ITeadStudio

OK

7. Get the Bluetooth device name:

Command Respond Parameter

AT+RNAME?<Param1> 1. +NAME:<Param2>

OK

2. FAIL

Param1,Param 2 : the address

of Bluetooth device

Example: (Device address 00:02:72:od:22:24,name:ITead)

AT+RNAME? 0002,72,od2224\r\n

+RNAME:ITead

OK

8. Set/Check module mode:

Command Respond Parameter

AT+ROLE=<Param> OK Param:

0- Slave AT+ ROLE? +ROLE:<Param>

Page 47: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

7 Tech Support: [email protected]

OK 1-Master

2-Slave-Loop

9. Set/Check device class

Command Respond Parameter

AT+CLASS=<Param> OK Param: Device Class

AT+ CLASS? 1. +CLASS:<Param>

OK

2. FAIL

10. Set/Check GIAC (General Inquire Access Code)

Command Respond Parameter

AT+IAC=<Param> 1.OK

2. FAIL

Param: GIAC

(Default : 9e8b33)

AT+IAC +IAC:<Param>

OK

Example:

AT+IAC=9e8b3f\r\n

OK

AT+IAC?\r\n

+IAC: 9e8b3f

OK

11. Set/Check -- Query access patterns

Command Respond Parameter

AT+INQM=<Param>,<Param2>,

<Param3>

1.OK

2. FAIL

Param:

0——inquiry_mode_standard

1——inquiry_mode_rssi

Param2: Maximum number of

Bluetooth devices to respond

to

Param3:

Timeout (1-48 : 1.28s to

61.44s)

AT+ INQM? +INQM: <Param>,<Param2>,

<Param3>

OK

Example:

AT+INQM=1,9,48\r\n

OK

AT+INQM\r\n

+INQM:1, 9, 48

OK

Page 48: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

8 Tech Support: [email protected]

12. Set/Check PIN code:

Command Respond Parameter

AT+PSWD=<Param> OK Param: PIN code

(Default 1234)

AT+ PSWD? + PSWD :<Param>

OK

13. Set/Check serial parameter:

Command Respond Parameter

AT+UART=<Param>,<Param2>,<

Param3>

OK Param1: Baud

Param2: Stop bit

Param3: Parity

AT+ UART? +UART=<Param>,<Param2>,

<Param3>

OK

Example:

AT+UART=115200,1,2,\r\n

OK

AT+UART?

+UART:115200,1,2

OK

14. Set/Check connect mode:

Command Respond Parameter

AT+CMODE=<Param> OK Param:

0 - connect fixed address

1 - connect any address

2 - slave-Loop

AT+ CMODE? + CMODE:<Param>

OK

15. Set/Check fixed address:

Command Respond Parameter

AT+BIND=<Param> OK Param: Fixed address

(Default

00:00:00:00:00:00)

AT+ BIND? + BIND:<Param>

OK

Example:

AT+BIND=1234,56,abcdef\r\n

OK

AT+BIND?\r\n

+BIND:1234:56:abcdef

OK

16. Set/Check LED I/O

Command Respond Parameter

AT+POLAR=<Param1,<Param2> OK Param1:

0- PIO8 low drive LED

1- PIO8 high drive LED

AT+ POLAR? + POLAR=<Param1>,<Param2>

OK

Page 49: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

9 Tech Support: [email protected]

Param2:

0- PIO9 low drive LED

1- PIO9 high drive LED

17. Set PIO output

Command Respond Parameter

AT+PIO=<Param1>,<Param2> OK Param1: PIO number

Param2: PIO level

0- low

1- high

Example:

1. PIO10 output high level

AT+PI0=10,1\r\n

OK

18. Set/Check – scan parameter

Command Respond Parameter

AT+IPSCAN=<Param1>,<Param2

>,<Param3>,<Param4>

OK Param1: Query time

interval

Param2:Query duration

Param3:Paging interval

Param4:Call duration

AT+IPSCAN? +IPSCAN:<Param1>,<Param2>,<P

aram3>,<Param4>

OK

Example:

AT+IPSCAN =1234,500,1200,250\r\n

OK

AT+IPSCAN?

+IPSCAN:1234,500,1200,250

19. Set/Check – SHIFF parameter

Command Respond Parameter

AT+SNIFF=<Param1>,<Param2>,

<Param3>,<Param4>

OK Param1: Max time

Param2: Min time

Param3: Retry time

Param4: Time out

AT+ SNIFF? +SNIFF:<Param1>,<Param2>,<Par

am3>,<Param4>

OK

20. Set/Check security mode

Command Respond Parameter

AT+SENM=<Param1>,<Param2> 1. OK

2. FAIL

Param1:

0——sec_mode0+off

1——sec_mode1+non_seAT+ SENM? + SENM:<Param1>,<Param2>

Page 50: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

10 Tech Support: [email protected]

OK cure

2——sec_mode2_service

3——sec_mode3_link

4——sec_mode_unknow

n

Param2:

0——hci_enc_mode_off

1——hci_enc_mode_pt_t

o_pt

2——hci_enc_mode_pt_t

o_pt_and_bcast

21. Delete Authenticated Device

Command Respond Parameter

AT+PMSAD=<Param> OK Param:

Authenticated Device

Address

Example:

AT+PMSAD =1234,56,abcdef\r\n

OK

22. Delete All Authenticated Device

Command Respond Parameter

AT+ RMAAD OK -

23. Search Authenticated Device

Command Respond Parameter

AT+FSAD=<Param> 1. OK

2. FAIL

Param: Device address

24. Get Authenticated Device Count

Command Respond Parameter

AT+ADCN? +ADCN:<Param>

OK

Param: Device Count

25. Most Recently Used Authenticated Device

Command Respond Parameter

AT+MRAD? + MRAD:<Param>

OK

Param: Recently

Authenticated Device

Address

26. Get the module working state

Command Respond Parameter

Page 51: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

11 Tech Support: [email protected]

AT+ STATE? + STATE:<Param>

OK

Param:

“INITIALIZED”

“READY”

“PAIRABLE”

“PAIRED”

“INQUIRING”

“CONNECTING”

“CONNECTED”

“DISCONNECTED”

“NUKNOW”

27. Initialize the SPP profile lib

Command Respond Parameter

AT+INIT 1. OK

2. FAIL

-

28. Inquiry Bluetooth Device

Command Respond Parameter

AT+INQ +INQ: <Param1>, <Param2>,

<Param3>

….

OK

Param1:Address

Param2:Device Class

Param3 : RSSI Signal

strength

Example:

AT+INIT\r\n

OK

AT+IAC=9e8b33\r\n

OK

AT+CLASS=0\r\n

AT+INQM=1,9,48\r\n

At+INQ\r\n

+INQ:2:72:D2224,3E0104,FFBC

+INQ:1234:56:0,1F1F,FFC1

+INQ:1234:56:0,1F1F,FFC0

+INQ:1234:56:0,1F1F,FFC1

+INQ:2:72:D2224,3F0104,FFAD

+INQ:1234:56:0,1F1F,FFBE

+INQ:1234:56:0,1F1F,FFC2

+INQ:1234:56:0,1F1F,FFBE

+INQ:2:72:D2224,3F0104,FFBC

OK

28. Cancel Inquiring Bluetooth Device

Command Respond Parameter

AT+ INQC OK -

Page 52: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

12 Tech Support: [email protected]

29. Equipment Matching

Command Respond Parameter

AT+PAIR=<Param1>,<Param2> 1. OK

2. FAIL

Param1:Device Address

Param2:Time out

30. Connect Device

Command Respond Parameter

AT+LINK=<Param> 1. OK

2. FAIL

Param:Device Address

Example:

AT+FSAD=1234,56,abcdef\r\n

OK

AT+LINK=1234,56,abcdef\r\n

OK

31. Disconnect

Command Respond Parameter

AT+DISC 1. +DISC:SUCCESS

OK

2. +DISC:LINK_LOSS

OK

3. +DISC:NO_SLC

OK

4. +DISC:TIMEOUT

OK

5. +DISC:ERROR

OK

Param:Device Address

32. Energy-saving mode

Command Respond Parameter

AT+ENSNIFF=<Param> OK Param:Device Address

33. Exerts Energy-saving mode

Command Respond Parameter

AT+ EXSNIFF =<Param> OK Param:Device Address

Page 53: Holonomic Spherical Mobile Robot - KTH

HC-05 Bluetooth module iteadstudio.com 06.18.2010

13 Tech Support: [email protected]

Revision History

Rev. Description Release date v1.0 Initial version 7/18/2010

Page 54: Holonomic Spherical Mobile Robot - KTH

Appendix D

Arduino datasheet

xx

Page 55: Holonomic Spherical Mobile Robot - KTH

Arduino Uno

Arduino Uno R3 Front Arduino Uno R3 Back

Arduino Uno R2 Front Arduino Uno SMD Arduino Uno Front Arduino Uno Back

Overview

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital

input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic

resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything

needed to support the microcontroller; simply connect it to a computer with a USB cable or power it

with a AC-to-DC adapter or battery to get started.

The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip.

Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial

converter.

Revision 2 of the Uno board has a resistor pulling the 8U2 HWB line to ground, making it easier to put

into DFU mode.

Revision 3 of the board has the following new features:

1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new pins

placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage provided

from the board. In future, shields will be compatible both with the board that use the AVR,

which operate with 5V and with the Arduino Due that operate with 3.3V. The second one is a

not connected pin, that is reserved for future purposes.

Stronger RESET circuit.

Atmega 16U2 replace the 8U2.

"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and

version 1.0 will be the reference versions of Arduino, moving forward. The Uno is the latest in a series

of USB Arduino boards, and the reference model for the Arduino platform; for a comparison with

previous versions, see the index of Arduino boards.

Summary

Microcontroller ATmega328

Operating Voltage 5V

Input Voltage (recommended) 7-12V

Page 56: Holonomic Spherical Mobile Robot - KTH

Input Voltage (limits) 6-20V

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

Analog Input Pins 6

DC Current per I/O Pin 40 mA

DC Current for 3.3V Pin 50 mA

Flash Memory 32 KB (ATmega328) of which 0.5 KB used by bootloader

SRAM 2 KB (ATmega328)

EEPROM 1 KB (ATmega328)

Clock Speed 16 MHz

Schematic & Reference Design

EAGLE files: arduino-uno-Rev3-reference-design.zip (NOTE: works with Eagle 6.0 and newer)

Schematic: arduino-uno-Rev3-schematic.pdf

Note: The Arduino reference design can use an Atmega8, 168, or 328, Current models use an

ATmega328, but an Atmega8 is shown in the schematic for reference. The pin configuration is identical

on all three processors.

Power

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

source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The

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

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

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

the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the

voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

The power pins are as follows:

VIN. The input voltage to the Arduino board when it's using an external power source (as

opposed to 5 volts from the USB connection or other regulated power source). You can supply

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

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied

with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of

the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can

damage your board. We don't advise it.

3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA. GND. Ground pins.

Memory

The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of SRAM and 1 KB

of EEPROM (which can be read and written with the EEPROM library).

Input and Output

Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(),

digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a

maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In

addition, some pins have specialized functions:

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

are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low

value, a rising or falling edge, or a change in value. See the attachInterrupt() function for

details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

Page 57: Holonomic Spherical Mobile Robot - KTH

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

using the SPI library.

LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e.

1024 different values). By default they measure from ground to 5 volts, though is it possible to change

the upper end of their range using the AREF pin and the analogReference() function. Additionally, some

pins have specialized functionality:

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

There are a couple of other pins on the board:

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

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.

See also the mapping between Arduino pins and ATmega328 ports. The mapping for the Atmega8,

168, and 328 is identical.

Communication

The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or

other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is

available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels this serial

communication over USB and appears as a virtual com port to software on the computer. The '16U2

firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows,

a .inf file is required. The Arduino software includes a serial monitor which allows simple textual data to

be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being

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

communication on pins 0 and 1).

A SoftwareSerial library allows for serial communication on any of the Uno's digital pins.

The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software includes a

Wire library to simplify use of the I2C bus; see the documentation for details. For SPI communication,

use the SPI library.

Programming

The Arduino Uno can be programmed with the Arduino software (download). Select "Arduino Uno from

the Tools > Board menu (according to the microcontroller on your board). For details, see the

reference and tutorials.

The ATmega328 on the Arduino Uno comes preburned with a bootloader that allows you to upload new

code to it without the use of an external hardware programmer. It communicates using the original

STK500 protocol (reference, C header files).

You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit

Serial Programming) header; see these instructions for details.

The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available . The

ATmega16U2/8U2 is loaded with a DFU bootloader, which can be activated by:

On Rev1 boards: connecting the solder jumper on the back of the board (near the map of Italy)

and then resetting the 8U2.

On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground, making it easier to put into DFU mode.

You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and Linux) to

load a new firmware. Or you can use the ISP header with an external programmer (overwriting the

DFU bootloader). See this user-contributed tutorial for more information.

Automatic (Software) Reset

Page 58: Holonomic Spherical Mobile Robot - KTH

Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is

designed in a way that allows it to be reset by software running on a connected computer. One of the

hardware flow control lines (DTR) of the ATmega8U2/16U2 is connected to the reset line of the

ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops

long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by

simply pressing the upload button in the Arduino environment. This means that the bootloader can

have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.

This setup has other implications. When the Uno is connected to either a computer running Mac OS X

or Linux, it resets each time a connection is made to it from software (via USB). For the following half-

second or so, the bootloader is running on the Uno. While it is programmed to ignore malformed data

(i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the

board after a connection is opened. If a sketch running on the board receives one-time configuration or

other data when it first starts, make sure that the software with which it communicates waits a second

after opening the connection and before sending this data.

The Uno contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace

can be soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to disable the

auto-reset by connecting a 110 ohm resistor from 5V to the reset line; see this forum thread for

details.

USB Overcurrent Protection

The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts and

overcurrent. Although most computers provide their own internal protection, the fuse provides an extra

layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break

the connection until the short or overload is removed.

Physical Characteristics

The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively, with the USB

connector and power jack extending beyond the former dimension. Four screw holes allow the board to

be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil

(0.16"), not an even multiple of the 100 mil spacing of the other pins.

Page 59: Holonomic Spherical Mobile Robot - KTH

Appendix E

Code

1 /*2 Code for holonomic robot3 Written by: Akmal Karlsson , Tara Mohammed -Amin4 MF133X Degree project in Mechatronics5 */6 // Required for calculating angles .7 # include <math.h>8 // Motor 1 pins:9 int m1in2 = 7;

10 int m1in1 = 5;11 int enable1 = 6;1213 // Motor 2 pins:14 int enable2 = 11;15 int m2in2 = 13;16 int m2in1 = 12;1718 // Motor 3 pins:19 int enable3 = 3;20 int m3in2 = 4;21 int m3in1 = 2;2223 double xAxis = 0;24 double yAxis = 0;25 // Initial value of 140 represent middle of joystick .26 int x = 140;27 int y = 140;28 int motorSpeed1 = 0;29 int motorSpeed2 = 0;30 int motorSpeed3 = 0;31 double alpha = 0;32333435 void setup () {36 Serial .begin (9600) ;37

xxv

Page 60: Holonomic Spherical Mobile Robot - KTH

38 // Declaring pins:39 pinMode (m1in2 , OUTPUT );40 pinMode (m1in1 , OUTPUT );41 pinMode (m2in2 , OUTPUT );42 pinMode (m2in1 , OUTPUT );43 pinMode (m3in2 , OUTPUT );44 pinMode (m3in1 , OUTPUT );454647 }4849 void loop () {50 // Read the incoming data from the Smartphone Android App51 while ( Serial . available () >= 2) {52 x = Serial .read ();53 delay (10);54 y = Serial .read ();55 }56 delay (500);5758 // Simulate smartphone input , for testing purposes . Comment out next

two lines in live.59 //x = 140;60 //y = 140;6162 // Values incoming from HC -05 BT module have the range 0-255, next is

to remap them to a standard xy -plane with range ( -100 ,100){x,y},if statement is required to define a deadzone , 140 being centerwith +-10 tolerance .

63 if (x < 130 or x > 150) {64 xAxis = map(x ,0 ,255 , -100 ,100);65 }66 else if (x > 130 and x < 150) {67 xAxis = 0;68 }69 if (y < 130 or y > 150) {70 yAxis = map(y ,0 ,255 , -100 ,100);71 }72 else if (y > 130 and y < 150) {73 yAxis = 0;74 }75 // Calculate the angle between input vector and pos -x axis.76 alpha = atan(yAxis/xAxis);7778 //If input vector / joystick has left center position then PWM is

calculated for each motor , offset by 120 deg (rad in code) for eachmotor.

79 if (xAxis !=0 or yAxis !=0) {80 motorSpeed1 = (cos(alpha)) *255*(( xAxis /100) +( yAxis /100));81 motorSpeed2 = (cos(alpha +2.0943951024) ) *255*(( xAxis /100) +( yAxis

/100));82 motorSpeed3 = (cos(alpha +4.1887902048) ) *255*(( xAxis /100) +( yAxis

/100));83 }

xxvi

Page 61: Holonomic Spherical Mobile Robot - KTH

84 //If joystick is back at center position motorSpeeds have to be resetto 0.

85 if (x == 140 and y == 140) {86 motorSpeed1 = 0;87 motorSpeed2 = 0;88 motorSpeed3 = 0;89 }90 // Each motor has two conditions for CW or CCW rotation , depending on

sign of motorSpeed .91 // Motor control92 if ( motorSpeed1 > 0) {93 digitalWrite (m1in2 ,HIGH);94 digitalWrite (m1in1 ,LOW);95 analogWrite (enable1 ,abs( motorSpeed1 ));96 }97 else if ( motorSpeed1 <0) {98 digitalWrite (m1in2 ,LOW);99 digitalWrite (m1in1 ,HIGH);

100 analogWrite (enable1 ,abs( motorSpeed1 ));101 }102103 if ( motorSpeed2 > 0) {104 digitalWrite (m2in2 ,LOW);105 digitalWrite (m2in1 ,HIGH);106 analogWrite (enable2 ,abs( motorSpeed2 ));107 }108 else if ( motorSpeed2 <0) {109 digitalWrite (m2in2 ,HIGH);110 digitalWrite (m2in1 ,LOW);111 analogWrite (enable2 ,abs( motorSpeed2 ));112 }113114 if ( motorSpeed3 > 0) {115 digitalWrite (m3in2 ,LOW);116 digitalWrite (m3in1 ,HIGH);117 analogWrite (enable3 ,abs( motorSpeed3 ));118 }119 else if ( motorSpeed3 <0) {120 digitalWrite (m3in2 ,HIGH);121 digitalWrite (m3in1 ,LOW);122 analogWrite (enable3 ,abs( motorSpeed3 ));123 }124125126 // Redundant and outdated code for motor control .127 // Motor 1 control128 //if (alpha > -1.5707963268 & alpha < 1.5707963268 ) {129 // digitalWrite (m1in2 ,HIGH);130 // digitalWrite (m1in1 ,LOW);131 // // analogWrite (enable1 ,abs( motorSpeed1 ));132 //}133 // else if (alpha < -1.5707963268 & alpha > 1.5707963268) {134 // digitalWrite (m1in2 ,LOW);135 // digitalWrite (m1in1 ,HIGH);

xxvii

Page 62: Holonomic Spherical Mobile Robot - KTH

136 // // analogWrite (enable1 ,abs( motorSpeed1 ));137 //}138139 // Motor 2 control140 //if (( alpha +2.0943951024) > 0.5235987756 and (alpha +2.0943951024) <

3.6651914292 ) {141 // digitalWrite (m2in2 ,HIGH);142 // digitalWrite (m2in1 ,LOW);143 // analogWrite (enable2 ,abs( motorSpeed2 ));144 //}145 // else if (( alpha +2.0943951024) < 0.5235987756 and (alpha

+2.0943951024) > 3.6651914292 ) {146 // digitalWrite (m2in2 ,LOW);147 // digitalWrite (m2in1 ,HIGH);148 // analogWrite (enable2 ,abs( motorSpeed2 ));149 //}150151 // Motor 2 control152 //if (( alpha +4.1887902048) > 2.617993878 & (alpha +4.1887902048) <

5.7595865316 ) {153 // digitalWrite (m3in2 ,HIGH);154 // digitalWrite (m3in1 ,LOW);155 // analogWrite (enable3 ,abs( motorSpeed3 ));156 //}157 // else if (( alpha +4.1887902048) < 2.617993878 & (alpha +4.1887902048)

> 5.7595865316 ) {158 // digitalWrite (m3in2 ,LOW);159 // digitalWrite (m3in1 ,HIGH);160 // analogWrite (enable3 ,abs( motorSpeed3 ));161 //}162163 // For serial monitor debugging .164 // Serial .print ("\n x: ");165 // Serial .print(x);166 // Serial .print ("\n y: ");167 // Serial .print(y);168 // Serial .print ("\n motorSpeed1 : ");169 // Serial .print( motorSpeed1 );170 // Serial .print ("\n motorSpeed2 : ");171 // Serial .print( motorSpeed2 );172 // Serial .print ("\n motorSpeed3 : ");173 // Serial .print( motorSpeed3 );174175176 }

xxviii