Você está na página 1de 60

MONASH UNIVERSITY SUNWAY CAMPUS

THE PEARL HUNTER


ECE 3091

Group 10: THE LIGHTSABER

KESHAV RAMREKHA TRIANDI TANRI OMAR ABDULLAH

21630283 21827559 21837473

Contents
List of Figures ................................................................................................................................................ 4 List of Tables ................................................................................................................................................. 5 Acknowledgement ........................................................................................................................................ 6 Abstract ......................................................................................................................................................... 7 Chapter 1 : Requirements Definition ............................................................................................................ 8 1. Introduction .......................................................................................................................................... 8 1.1 Objective ......................................................................................................................................... 8 1.2 Capabilities of the final prototype .................................................................................................. 9 1.3 Purpose of this Report .................................................................................................................... 9 CHAPTER 2: LITERATURE REVIEW ............................................................................................................... 10 2. Introduction .................................................................................................................................... 10

2.1 Robot 1: Line following robot (MOBOT competition)....................................................................... 10 2.2 Robot 2: Hyper Squirrel..................................................................................................................... 11 2.3 Robot 3: The $50 Robot with Sharp IR edge detection .................................................................... 12 2.4 Robot 4: The OMNI-WHEEL ROBOT .................................................................................................. 13 2.4 Literature review conclusion ............................................................................................................ 14 CHAPTER 3: TEAM ORGANIZATION AND MANAGEMENT .......................................................................... 15 Introduction ................................................................................................................................................ 15 3.1 Planning Methods ................................................................................................................................. 15 3.1.1 Work Breakdown Structure ........................................................................................................... 15 3.1.2 Schedule for Network Activities (Critical Path Diagram) ............................................................... 16 3.1.3 Gantt Chart..................................................................................................................................... 17 3.1.4 Responsibility Matrix ..................................................................................................................... 19 3.1.5 Cost Estimation .............................................................................................................................. 20 3.1.6 Risk analysis ................................................................................................................................... 21 CHAPTER 4: THE LIGHTSABER DESIGN (Prototype 1).................................................................................. 22 4. THE SUB-SYSTEMS ........................................................................................................................... 22 Introduction ........................................................................................................................................ 22 4.1 Mechanical sub-system ................................................................................................................. 22 4.2 Locomotion sub-system ................................................................................................................ 24 4.3 Electronics Sub-system ................................................................................................................. 26 4.4 Pearl Detection and Collection ..................................................................................................... 30 4.5 Assessment of Prototype 1 ........................................................................................................... 34 CHAPTER 5: The Lightsaber (Prototype 2) .................................................................................................. 37 2

5.1 Faults identified ................................................................................................................................ 37 5.2 Prototype 2 The Design .................................................................................................................. 38 5.2.1 Mechanical sub-system.............................................................................................................. 38 5.2.2 Locomotion sub-system ............................................................................................................. 39 5.2.3 Electronics Sub-system .............................................................................................................. 40 5.2.4 Pearl Detection and Collection .................................................................................................. 42 CHAPTER 6: Evaluation ............................................................................................................................... 46 6.1 Problems and Solutions .................................................................................................................... 46 6.1.1 Hardware ................................................................................................................................... 46 6.1.2 Software ..................................................................................................................................... 47 6.2 Improvements and Optimization ...................................................................................................... 47 6.3 The Final Competition ....................................................................................................................... 48 6.3.1 Match 1 ...................................................................................................................................... 48 6.3.2 Match 2 ...................................................................................................................................... 49 6.3.3 Match 3 ...................................................................................................................................... 50 6.3.4 Match 4 ...................................................................................................................................... 50 Conclusion ................................................................................................................................................... 51 References .................................................................................................................................................. 52 Appendix ..................................................................................................................................................... 53 Appendix A Testing Scheme for Prototype 2 ....................................................................................... 53 i. ii. iii. iv. Chassis strength .......................................................................................................................... 53 Speed .......................................................................................................................................... 54 The 90o left turn .......................................................................................................................... 54 Battery Life .................................................................................................................................. 55

Appendix B Full Code written for the Arduino Duemilanove .............................................................. 56

List of Figures
Figure 1: The platform of the black pearl project ......................................................................................... 8 Figure 2: Final Prototype ............................................................................................................................... 9 Figure 3: Design layout of the Pikachu robot.............................................................................................. 10 Figure 4: Design layout of the Hyper Squirrel robot ................................................................................... 11 Figure 5: Design layout of the $50 robot robot .......................................................................................... 12 Figure 6: Design layout of the omni wheel robot ....................................................................................... 13 Figure 7: Work breakdown Chart................................................................................................................ 15 Figure 8: Critical Path Diagram ................................................................................................................... 16 Figure 9: Gantt Chart Table ......................................................................................................................... 17 Figure 10: Gantt chart Timeline .................................................................................................................. 18 Figure 11: Design layout of the chassis ....................................................................................................... 22 Figure 12: Design layout of the chassis (side view) .................................................................................... 23 Figure 13: Design layout of the chassis (top view) ..................................................................................... 23 Figure 14: Actual view with top layer mounted (side view) ....................................................................... 23 Figure 15: Tamiya Double Gearbox schematics .......................................................................................... 24 Figure 16: Actual view with wheels under test ........................................................................................... 25 Figure 17: Initial prototype with wheels mounted on chassis .................................................................... 25 Figure 18: L293D H-bridge .......................................................................................................................... 26 Figure 19: H-bridge circuit connection ....................................................................................................... 27 Figure 20: H-bridge circuit connected to wheels ........................................................................................ 28 Figure 21: IR sensor circuit .......................................................................................................................... 29 Figure 22: Arduino Duemilanove microcontroller ...................................................................................... 29 Figure 23: The main circuitry as seen on top of the Lightsaber.................................................................. 30 Figure 24: Pearl Detection and Collection method..................................................................................... 31 Figure 25: Flowchart for algorithm of Prototype 1 ..................................................................................... 32 Figure 26: Pearl detection and collection ................................................................................................... 33 Figure 27: The new design for the chassis (widened chassis)..................................................................... 38 Figure 28: The new design for the chassis (increased stability) ................................................................. 39 Figure 29: Addition of ball casters to the chassis ....................................................................................... 39 Figure 30: Use of the Sharp IR rangefinder for wall and robot detection and avoidance .......................... 40 Figure 31: Use of the Sharp IR rangefinder for wall and robot detection and avoidance .......................... 41 Figure 32: Flowchart for Prototype 2 .......................................................................................................... 42 Figure 33: Start of Algorithm (Path 1) ......................................................................................................... 43 Figure 34: Path 2 ......................................................................................................................................... 44 Figure 35: Path 3 ......................................................................................................................................... 44 Figure 36: Path 4 ......................................................................................................................................... 45 Figure 37: Lightsaber Prototype 2............................................................................................................... 48 Figure 38: Inability to return to base after getting stuck ............................................................................ 49 Figure 39: New path taken after confusion ................................................................................................ 50 Figure 40: Deflection of chassis frame ........................................................................................................ 53 Figure 41: The 90o left turn ......................................................................................................................... 54

List of Tables
Table 1: Tabular Comparison of the 4 robots ............................................................................................. 14 Table 2: Responsibility Matrix ..................................................................................................................... 19 Table 3: Cost Estimation ............................................................................................................................. 20 Table 4: Risk Assessment ............................................................................................................................ 21 Table 5: Table of number of pearls collected ............................................................................................. 34 Table 6: Table showing drop in voltage levels of batteries (powering H-bridge and sensors) ................... 35 Table 7:Table showing drop in voltage levels of battery (powering Arduino)............................................ 35 Table 8: Table describing faults identified in Prototype 1 .......................................................................... 37 Table 9: Table for hardware problems and solutions ................................................................................. 46 Table 10: Table for software problems and solutions ................................................................................ 47 Table 11: Table of improvements and Optimization performed ................................................................ 47 Table 12: Table of weight v/s deflection..................................................................................................... 53 Table 13: Speed v/s stability ....................................................................................................................... 54 Table 14: Table of speed v/s angle.............................................................................................................. 55 Table 15: Battery life of LiPo battery .......................................................................................................... 55

Acknowledgement
First and foremost, we would like to thank Dr. Melanie Ooi, the lecturer for ECE 3091. Dr. Ooi proved to be very helpful and was a constant source of encouragement and motivation which helped towards the completion of this project. Our thanks and gratitude also goes to the lab technicians, Mr. Paremanan and Mr. Hasnan, for always being ready to help us with our needs and providing us with all the necessary assistance required in the lab. Last but not least, our thanks go to our friends, who have been constantly helping us out in any way possible, be it to solve a technical problem, or to hang out and relax for a while.

-Members of Group 10: Keshav Ramrekha Triandi Tanri Omar Abdullah

Abstract
Autonomous robots are intelligent machines capable of performing tasks pre-programmed into them. But for them to perform, proper research, planning, testing and debugging must be carried out. Some people ask themselves Who would we be without machines? and the answer is often another question: What would machines be without men? Food for thought? The following report gives an insight about the behind-the-scenes of this project which sees The Lightsaber coming to life. From a single rough sketch to a fully operational robot, this report is the work of three young minds put together.

Chapter 1: Requirements Definition


1. Introduction
1.1 Objective The objective of this project is to design and build a robot which has the ability to collect all polystyrene balls provided in the platform and bring them back to base within a specified time limit, while at the same time preventing other enemy robots from stealing from the home base. The base is defined as one of the corner encircled by an arc line. The purpose of this project is to apply the acquired knowledge in circuit theory and programming onto real life application likewise building the robot in this Pearl Hunter project. Furthermore, students are able to develop problem solving, self-independent and cooperative skills throughout this project.

Figure 1: The platform of the black pearl project

1.2 Capabilities of the final prototype

Figure 2: Final Prototype

In this project, sensors are used as guidance to navigate the robot and also to locate the polystyrene balls. A number of implementation issues did surface, but were solved. The final prototype is capable of navigating its way in the arena and carry the polystyrene balls back to the base. It is also able to prevent wall collision and avoid being hit by enemy robots. 1.3 Purpose of this Report This report comprises the summarized version of the project planning, design description, algorithm, testing scheme and also the problems that the group has encountered during the brainstorming stage circuit design stage assembly stage test and evaluation stage debugging and optimization stage. Moreover, this report explains the required specification for all components in a very clear manner that errors and risk can be identified easily so improvements and optimizations can be conducted to increase the reliability of the complete system. .

CHAPTER 2: LITERATURE REVIEW


2. Introduction
This section will provide information about the research carried out in order to gather ideas and brainstorm for solutions as to how to build and improve The Lightsaber. Research was carried out on various platforms and ideas gathered were then put together for a selection.

2.1 Robot 1: Line following robot (MOBOT competition)


The robot was initially built to compete in the MOBOT competition. The robot is a line following robot capable of following a white strip line on different surfaces in an outdoor environment without its performance being compromised by external conditions (lighting, wind, surface).

The robot chassis was made out of plastic board with servo motors used as wheels. A custom microcontroller was used, with the circuit design soldered on a veroboard to minimize use of space and to be very light.

The robot was fitted with color sensors to detect the white line and to be move forward.

Figure 3: Design layout of the Pikachu robot

While the overall performance of this robot was quite impressive, there were quite a number of issues to solve before finally getting a decent overall performance. IR emitter/detector can easily be flooded by

10

sunlight and be made useless. Without these, performance of robot is compromised. It is essential to make sure the sensors are well shielded to get good results. Varying surfaces and levels were also a problem, as the robot needs to adapt to its surroundings and be able to brake to avoid collisions or going off-track. A DC motor braking technique can therefore be used in this case. The robots performance can be improved by adding a camera to navigate through the course. This, while being a good idea, will increase workload and increase complexity of design and coding. While this robot is fairly easy to understand and make, it lacks a few features required as part of what the robot to be designed for ECE 3091 needs.

2.2 Robot 2: Hyper Squirrel


The Hyper Squirrel is a robot which can perform high speed reactive mapping. The robot travels at fast speeds while making decisions on directions based on input from its sensors. The robot makes use of 2 Sharp IR Rangefinders mounted on a servo motor which scan the environment the robot is placed in and can navigate on its own. The robot was built using acrylic as chassis and treads from a toy car for wheels. This enabled it to navigate through any rough surfaces without any problem. While the rangefinders were used to navigate around, 2 sets of IR emitter-detectors were used as bumper sensors to avoid any collisions with unwanted objects or walls.

Figure 4: Design layout of the Hyper Squirrel robot

11

The Hyper Squirrel is a very interesting project and surely can be used as base for comparison for this current project. The treads make interesting motion wheels and the high-tech advanced mapping technique used by this robot is a very interesting prospect that could be used to find and collect the balls for this current project. The design will however need to be customized and modified so that a ball collection mechanism can be added to the robot which has to fit in the specific constraints set for this project.

2.3 Robot 3: The $50 Robot with Sharp IR edge detection


This is by far the easiest and perhaps the most interesting robot of its kind. It is made up of easy to find materials and costs less than $50. The robot uses a piece of acrylic as chassis, and 2 pieces of cardboard cut in circular shape for wheels. These are rotated by means of 2 servo motors. The Sharp IR rangefinder is used to make the robot go through its surroundings while avoiding obstacles and walls. Main advantages of this robot were the low costs of building and fairly easy level on of understanding required to build it. The performance on the other side was very basic while not having great purpose. The robot could however be easily modified and improved once built and working.

Figure 5: Design layout of the $50 robot robot

12

2.4 Robot 4: The OMNI-WHEEL ROBOT


This robot is one of the most interesting in its kind and perhaps the most complicated as well. It uses a series of Omni-wheels that can move in any direction at any angle without any prior rotation. This mechanism can be considered for the current project as the polystyrene balls are scattered all over the arena, and our robot needs to be able to move in any direction to move and collect them. The Omni-wheel robot is a very advanced piece of robotics, including 3 Sharp IR rangefinders performing 2D mapping as part of an intelligent navigation system. In addition to those, 3 sonars acted as obstacle detection and avoidance system, while 2 pairs of infrared emitter/detector sets were used for line following system.

Figure 6: Design layout of the omni wheel robot

The omni-wheel robot is one of the best of its kind and built for a specific purpose. But while its superb features make it a hard-to-neglect choice, the cost of purchasing all the items needed to build it by far exceeds the budget limit we are allocated. Budget aside, the fuzzy logic algorithm and coding knowledge required to make it function is sadly one of the qualities we lack for now and would prove a very challenging task to get it right at the very first attempt.

13

2.4 Literature review conclusion


Robot Line Follower Advantages Small Simple design Ability to detect white lines and help with motion System uses high speed reactive mapping Very robust design Can easily detect objects around the arena and move to them Simple design Cheap Materials readily available Disadvantages Inability to perform more complex operations No ball catching mechanism

Hyper Squirrel

Complex software Conveyor belt wheels provide too much friction and limit motion Heavy chassis No specific function Not robust No ball collection system Movement limited by cardboard wheels

$50 robot

Table 1: Tabular Comparison of the 4 robots

Key points identified during literature review: Size: Lightsaber needs to be small in size to enable all sorts of movements. Also, as per the set requirements of the project, the robot needs to fit a 20cmX20cm size. Speed: Lightsaber needs to be fast to be able to collect as many balls as possible during the allowed 5 minutes time limit. Consistency: Lightsaber needs to be consistent in the runs, being able to bring the pearls back to base on as many runs as possible. Cost: Lightsaber needs to be built by using materials which do not exceed the set limit of RM300.

14

CHAPTER 3: TEAM ORGANIZATION AND MANAGEMENT Introduction


No teamwork can be a one-man show and this project was not an exception. To achieve the aims set, the team members worked closely together to be able to be successful. This chapter will detail the work to be done by each team-member and provide a work timeline as well as a proper budget breakdown of the project.

3.1 Planning Methods


3.1.1 Work Breakdown Structure
Group Members: Keshav Ramrekha (KR) Triandi Tanri (TT) Omar Abdullah (OA)

"Black Pearl Project"

Hardware

Electrical

Software

Assembling frame of robot - KR, TT, OA

Build sensors/lever switches- OA

Programming - KR, TT

Assembling motor gearbox - KR

Build H-drivers motor circuit - TT


Figure 7: Work breakdown Chart

15

3.1.2 Schedule for Network Activities (Critical Path Diagram)


This is also another project modeling technique that is used to determine the priority of each element and the most effective path or critical path that must be undertaken for the project to develop according to the proposed time.

Figure 8: Critical Path Diagram

16

3.1.3 Gantt Chart


This is a type of a bar chart that displays the data of the project schedule. They include the start and finish dates of each element in the project schedule. They also include the amount of time required to be spent on each element of the project and identifies the team members responsible for each element in the project schedule. The summary elements comprise of the work breakdown structure.
ID Task Name Start Finish Duration

Research/Planning Motor Gear Ratio Robot Design and Layout IR sensors Phototransistors Assembly Motor Assembly Toggle Switch Design Robot Dimensions Framework Testing Wheel balancing Sensor Sensitivity Robot Construction Circuit building Circuit Troubleshooting Software Research Algorithm Coding Testing Debugging Finishing Coding Finalization Robot Finalization Final Testing Requirement Analysis Design Specifications

7/29/2011 7/29/2011 7/29/2011 7/29/2011 7/29/2011 8/10/2011 8/9/2011 8/10/2011 8/10/2011 8/10/2011 8/11/2011 8/12/2011 8/12/2011 8/12/2011 8/15/2011 8/15/2011 8/17/2011 8/15/2011 8/15/2011 8/29/2011 9/12/2011 9/22/2011 9/29/2011 9/27/2011 10/3/2011 9/29/2011 8/10/2011 8/15/2011

8/12/2011 8/5/2011 8/11/2011 8/9/2011 8/9/2011 8/11/2011 8/9/2011 8/10/2011 8/23/2011 8/10/2011 8/23/2011 8/18/2011 8/12/2011 8/17/2011 8/22/2011 8/17/2011 8/19/2011 9/30/2011 8/26/2011 9/9/2011 9/23/2011 9/28/2011 10/19/2011 10/3/2011 10/10/2011 10/19/2011 8/18/2011 8/29/2011

11d 6d 10d 8d 8d 2d 1d 1d 10d 1d 9d 5d 1d 4d 6d 3d 3d 35d 10d 10d 10d 5d 15d 5d 6d 15d 7d 11d

Figure 9: Gantt Chart Table

17

18
Figure 10: Gantt chart Timeline

3.1.4 Responsibility Matrix


This is a matrix that identifies all the elements in the project schedule and displays the priority of the team members effort in each and every element. This management technique allows you to clarify the team members responsibilities in each task and displays whether there was efficient communication between the assigned team members by viewing their priority in the each specific task.
Task Brainstorming Layout of Robot Algorithm Components Hardware Motor Gear Box Robot Frame Electrical Sensors H-Bridge Software Ball Detection Algorithm Ball Collecting Algorithm Testing Wheel Balancing Test Sensor Sensitivity Test Ball Collecting Algorithm Full Testing Documentation Requirement Analysis Design Specification Presentation Final Report KR P P S P P S S P P P S P P P P P P OA S S P S P P S S P S P P P P P P P TT P P P S P P P P S S S S P P P P P

Table 2: Responsibility Matrix

Note: Primary Responsibility (P) Secondary Responsibility (S)

19

3.1.5 Cost Estimation


This method was done in order to estimate the cost of all the products that had to be bought in the implementation of the robot. This method gives us a rough estimate of the costs of each product for future reference and also determines the budget of the robot.
Tools Diagonal Cutting Pliers Wire Cutter Wire Stripper Solder Sucker Precision Screwdrivers (set) Duwell Needle Files (set) Insulation Tape Materials Plastic-board Polystyrene board Bolts and Nuts Bread Board AAA Battery AA Battery (rechargeable) 9V Battery (rechargeable) 9V Battery connector Ball Caster Battery Holders Gear Box Electrical components Micro-controller Board Sharp IR Rangefinder Ribbon Cable 9V Battery Connector IC (H-drivers) Push Switches Sensors Servo Motor Quantity 1 1 1 1 1 1 3 Quantity 2 1 several 3 6 2 1 1 2 3 2 Quantity 1 1 3 1 1 4 7 2 Price/unit (RM) 1.00 Price/unit 3.00 5.00 10.00 2.00 4.00 Price/unit 55.00 0.50 2.00 20.00 Suppliers Monash Monash Monash Monash Monash Monash Ace Hardware Suppliers Popular Popular Monash Monash Monash Monash Monash Monash Cytron Ace-hardware Monash Suppliers Monash Cytron Monash Monash Monash Ace Hardware JalanPasar E-shore Total Price(RM) 3.00 6.00 5.00 10.00 8.00 55.00 2.00 14.00 40.00 143.00

Maximum budget : RM 300.00


Table 3: Cost Estimation

20

3.1.6 Risk analysis

Hazard No. H4

Description of Hazard Electrical hazard such as contact with any electrical conductor resulting in current flow to the body Consequence Severe Injury Likelihood Unlikely Risk Low

Corrective Actions/ Risk Controls Make sure everything is assembled properly before switching on the power supply Timing During wire connection Responsibility KR, OA, TT

R34

Cause burns Consequence Minor Injury Likelihood Unlikely Risk Low

Wear protective gloves and glasses Timing During soldering Responsibility KR, OA, TT

E3

Prolong repetitive movement/position

Take 5 minutes break for every hour sitting in front of computer Proper lighting, comfortable working environment Risk Low Timing During programming Responsibility KR, OA, TT

Consequence Minor Injury

Likelihood Unlikely

Table 4: Risk Assessment

CHAPTER 4: THE LIGHTSABER DESIGN (Prototype 1)


The Initial Design

4. THE SUB-SYSTEMS
Introduction No project consists of one main system, no matter what the nature of the project is. To facilitate work distribution and verification and problem solving, a problem is always broken down into sub-systems. In the case of The Lightsaber, the project was divided into four main sub-systems; the mechanical subsystem, locomotion sub-system, electronics sub-system and the pearl detection and collection subsystem. The following sections describe the system in greater details. 4.1 Mechanical sub-system After a brainstorming session, the mechanical sub-system was the first issued tackled by the group. The mechanical part is one of the most important parts of the Lightsaber. This will be the whole body of the robot and needs to be very stable and reliable. All other sub-system will be linked to the mechanical part enabling proper functioning of the robot. As the need to be light and fast was clearly identified, the materials chosen to build the chassis were plastic-board, polystyrene and tape (double-sided and normal). These materials are readily available and are cheap.

Figure 11: Design layout of the chassis

22

Figure 12: Design layout of the chassis (side view)

Figure 13: Design layout of the chassis (top view)

Figure 14: Actual view with top layer mounted (side view)

23

4.2 Locomotion sub-system The main aim of this project is to have an autonomous robot which is to be used to detect and collect the pearls and return back to base. To be able in this task, motion of the robot is essential. For the robot to move, wheels with a proper gearbox are used. In this case, the group was provided with a set of Tamiya Double Gearbox system with adjustable gear ratios for different scenarios. The main aim of the project was to get a fast moving robot. Therefore, the gear ratio to be chosen had to be enough to be able to provide enough torque for the Lightsaber to move fast.

Figure 15: Tamiya Double Gearbox schematics

There are four different gearbox designs that are shown in the above diagram and out of this four, two were tried out and tested. The two choices that were considered are A and B. A 344:1 This is the design that provides the highest torque but results in a very slow rotation of the wheel. B- 114.7:1- This is the design that provides the second most torque but provides a larger increase in speed than A. The other two were not chosen since the speed of the wheel would be too fast for easy smooth navigation. 24

Figure 16: Actual view with wheels under test

Figure 17: Initial prototype with wheels mounted on chassis

25

4.3 Electronics Sub-system The electronics sub-system acts like the bridge between the microcontroller and the mechanical system. It is the part that allows all motion to be possible, and at the same time is the carrier of messages from one component to the other. To power the wheels, a dual H-bridge was used. H-Drivers are used for the motor circuit as an integrated chip acts as a controller that connects the batteries, motors and I/O pins from the micro-controller in just one IC. One H-Driverchip can control up to two motors at the same instance.

Figure 18: L293D H-bridge

26

Figure 19: H-bridge circuit connection

In the design of the robot, only one L293D quadruple half H-Drivers were used. After some trials, it is found that both the motors for the wheel and also the servo motor could be controlled by just one HDrivers. From the diagram above, the input voltage to the H-Driver is at pin 1, 8, 9, and 16. The minimum voltage that must be supplied to the H-Driver in order to get the robot moving is around 5V and above to ensure movement stability as some task that the robot has to perform requires more power from the motor than the others. This can be seen when the robot is doing a turn in which one of the motor have to turn clockwise and the other, counter clockwise. From all the trials performed, it is noticed that when the input voltage to the H-Driver is less than 4V the robot is unable to turn accordingly thus by making sure that the input voltage is at least 5V and above, the problem is eliminate Pins 2, 7, 10, and 15 are the I/O pins connected to the micro-controller. These pins are used for controlling the direction of movements of the motors. For example, if pin 2 is set to 1 and pin 7 is set to 0 digital outputs, the motor will turn clockwise whereas if pin 2 is set to 0 and pin 7 is set to 1, the motor will turn counter clockwise. A dual H-bridge is a system component which allows control of 2 motors and allows rotation in both clockwise and anti-clockwise direction. In the case of the Lightsaber, a L293D chip was used to control rotation of motors. 27

Figure 20: H-bridge circuit connected to wheels

The electronics subsystem also consists of the sensor circuits. In the case of the Lightsaber, sensors were used for ball and wall detection. The sensors were connected to the main circuitry of the robot system and powered through a common 5V rail. The sensors used in this project are of infrared type and it is of the 5mm category. It works by the photodiode sensing the amount of reflected energy/light, which is radiated by the transmitter, off any surface. The photodiode will have distinctive output reading across its terminals for different colour surface.

The IR sensor used in the design is based on the schematic provided by the school. The only variation did to the schematic was the value of the pair of resistors used. The resistor used for the IR transmitter is 120 and the resistor used for the IR receiver is 4.7k .

28

4.7k 120

Figure 21: IR sensor circuit

After performing some test on the micro-controller to determine its threshold between logic 1 and 0, the comparator is ignored and the output of the sensor is connected directly to the micro-controller. The threshold voltage for the given micro-controller is 1.07 V. Any values lower than 1.7 V will be interpreted as logic 0 and those above it will be logic 1. The Arduino Duemilanove was used as the main microcontroller for the Lightsaber due to its small size and lightweight. The board is very small in size and is very light as well. This would be an advantage as it would not add too much weight or take up too much space on the chassis. In addition to that, the Arduino, despite being small in size, has a decent number of I/O ports, some of which can be used as PWM ports to control speed/motion.

Figure 22: Arduino Duemilanove microcontroller

29

Sensors connected to common rail

Battery holder for batteries to power circuit

H-Bridge Arduino Duemilanove

Figure 23: The main circuitry as seen on top of the Lightsaber

4.4 Pearl Detection and Collection This section is the most important section of the project as the main objective is to gather as many pearls as possible in the home base. The initial design made use of the sensory feedback as main source of information about pearls and their position. The Sharp IR rangefinder was used to locate the pearls as the robot moved and calculated the distance separating the distance from the robot to them. This helped the robot keep moving until it reached the pearls. Once it reached the pearls, they would get into the holding area of the Lightsaber, where they would cross the signal between the IR emitter and detector circuit. This would in turn activate two servo motors, which acted like flaps to close and hold the pearls inside the robot. This action would indicate to the robot to start the process of returning to base to drop the pearls safely back into the home base.

30

Servo Motors close flaps upon detection of pearls

IR emitter/detector to detect whether pearl was inside holding area

Pearl
Sharp IR rangefinder used to locate pearls

Figure 24: Pearl Detection and Collection method

31

3.4.1 Ball Collection Algorithm


Start

Move Forward

Detect ball?

NO

Keep moving Forward

YES

Close Flaps

Turn 180 degrees

Move forward

NO
Detect wall

YES

Stop and release balls

Reverse with preset delay

Figure 25: Flowchart for algorithm of Prototype 1

32

The algorithm on the previous page gives an overall idea of how the Lightsaber performed its task of detecting and collecting the ball. It worked using a simple system of detection by using the Sharp IR rangefinder and the IR emitter/detector pair was used to help holding on to the ball. The robot will start moving and as soon as it detects a pearl, it will close the flaps, turn 180o clockwise and return to base. When it detects the wall of the base, it will stop, release the pearl by opening the flaps, and then move backwards, turn to face the arena, but this time at another preset angle.

Pearls

Home Base

Figure 26: Pearl detection and collection

33

4.5 Assessment of Prototype 1 No system can be perfect at the first attempt and as the famous quote goes by Practice makes perfect, the Lightsaber was no perfect robot at its first attempt. Being small and fast did have its advantages but it also came with some disadvantages. While the initial design was thought to be reliable and durable, repeated test runs proved that idea wrong. Wear and tear started being very considerable and consequently impacted on the performance of the Lightsaber. 4.5.1 Overall Performance of Lightsaber As the testing pattern got more intense, the performance of the Lightsaber was found to be consistent at the start but slowly it began to decrease. The number of pearls collected and deposited back to base varied over time, and slowly decreased How was the testing for performance carried out? The Lightsaber was released from the home base and allowed to carry out its task over two minutes. At the end of the time frame, the number of pearls collected was noted and tabulated. The process was repeated so that a more clear idea about the performance of the robot could be seen. Each set is a total of 5 runs for 2 minutes each.

Set 1 Trial 1 Trial 2 Trial 3 32 33 26

Set 2 27 21 22

Set 3 20 19 18

Set 4 23 22 12

Set 5 26 23 14

Total 128 118 92

Table 5: Table of number of pearls collected

From the above table it can be seen that the number of pearls collected decreased over time, indicating a decrease in overall performance levels of the Lightsaber.

34

4.5.2 Battery Life Battery life greatly affects performance of machines and the Lightsaber was no exception. As the testing was done, battery life was considerably reduced and had to be replaced constantly. Rechargeable batteries avoided extra cost of buying new ones, but at the expense of long waiting hours for charging to be complete. The battery levels were regularly monitored to assess performance of the robot.

Set 1 Initial Voltage (Volts) Trial 1 5.28 Final Voltage (Volts) 5.02 Initial Voltage (Volts) 5.31

Set 2 Final Voltage (Volts) 5.11 Initial Voltage (Volts) 5.16

Set 3 Final Voltage (Volts) 4.99 Initial Voltage (Volts) 5.23

Set 4 Final Voltage (Volts) 5.02 Initial Voltage (Volts) 5.11

Set 5 Final Voltage (Volts) 4.88

Trial 2

5.24

5.12

5.27

5.10

5.20

4.86

5.18

4.83

5.13

4.92

Trial 3

5.16

4.96

5.18

4.93

5.23

5.01

5.21

4.82

5.23

4.85

Table 6: Table showing drop in voltage levels of batteries (powering H-bridge and sensors)

Set 1 Initial Voltage (Volts) Trial 1 9.66 Final Voltage (Volts) 9.36 Initial Voltage (Volts) 9.58

Set 2 Final Voltage (Volts) 9.21 Initial Voltage (Volts) 9.67

Set 3 Final Voltage (Volts) 9.35 Initial Voltage (Volts) 9.59

Set 4 Final Voltage (Volts) 9.32 Initial Voltage (Volts) 9.55

Set 5 Final Voltage (Volts) 9.12

Trial 2

9.55

9.15

9.52

9.07

9.36

9.01

9.32

8.99

9.30

9.06

Trial 3

9.35

8.95

9.23

8.93

9.21

7.96

9.17

8.23

9.13

8.29

Table 7:Table showing drop in voltage levels of battery (powering Arduino)

35

4.5.3 Testing of individual components 4.5.3.1(IR emitter/detector circuit) These components were responsible to check whether pearls were inside the holding area of the arena or not. The result of that operation would then enable to servo motors to close the flaps. To check this part, the same concept was used as for the previous section and the number of times it worked was noted. Again, a set of 5 runs over 2 minutes was carried out and repeated. From the tests, it was noted that over the number of runs, only 6 times the sensors had failed to detect a ball inside the holding area. This was either due to a wire coming out hence causing an open circuit or the robot moving too fast and pushing the ball away before the sensors could react to the voltage change.

4.5.3.2 Servo motors (flaps) The servo motors were used to open or close the flaps to either keep hold of the pearls or release them when in the home base. Results were collected over the same number of runs as in the above section From the tests, it was noted that over the number of runs, 9 times the servos had failed to open or close the flaps. This was either due to a wrong connection out hence causing an open circuit or wrong output from sensor readings causing the robot to ignore the decision.

36

CHAPTER 5: The Lightsaber (Prototype 2)


After the old design was tested over and over again, a number of faults were identified and corrective measures were to be taken to improve the performance of the robot.

5.1 Faults identified

Components Chassis

Faults Chassis started bending under weight of all other components mounted on it. Caused robot to move in a curved path. Holding area not wide enough to hold many pearls at one go.

Batteries

The batteries proved a major issue with them discharging fast and not providing enough power to the wheels. Motion of robot became erratic after power drops below full operating limit.

Pearl collection using sensory feedback

The detection of pearls using data obtained from sensors was not always reliable, since the number of pearls detected and collected was low.

Servo motors

Servo motors were found to be under the influence of fluctuating voltage and often were found to close without any signal sent to them. This caused the Lightsaber to miss the pearls.
Table 8: Table describing faults identified in Prototype 1

37

5.2 Prototype 2 The Design


For the prototype 2, the overall layout of the subsystems remained the same, with the same 4 subsystems as mentioned for prototype 1. However, some changes were made to the design and components and are detailed below. The changes were made in order to correct and reduce the faults identified in the previous section 5.2.1 Mechanical sub-system From the previous section it was observed that the chassis of the robot was not strong enough to withstand heavy testing. It was then modified in order to make it stronger and more resistant. The second issue noted was the fact that the holding area for pearls was not as wide as expected, and it was therefore widened to allow more pearls to be held.

Figure 27: The new design for the chassis (widened chassis)

38

Reinforced chassis to make it more stable. Layers of plasticboard interlaced with cardboard

Figure 28: The new design for the chassis (increased stability)

5.2.2 Locomotion sub-system From the initial design, a single ball caster was placed in front of the gearbox and this proved to be unreliable and unstable as the robot was noticed to adopt a curved motion when moving. It was then decided to change the position of the ball caster and add another one, with them being placed in front of the robot at the ends of the holding arms. This greatly increased stability of the robot and helped the robot move in a straight line.

2 ball casters providing increased stability and ability to move in straight line paths.
Figure 29: Addition of ball casters to the chassis

39

To assist the robot in moving around the arena, a Sharp IR rangefinder was placed at the top of the robot. It was programmed to detect walls and other robots, and stop and change directions if ever they came into contact. The Sharp IR rangefinder also helped in the path algorithm used for ball collection, which is described further down in this report.

Sharp IR rangefinder, for wall and robot detection

Figure 30: Use of the Sharp IR rangefinder for wall and robot detection and avoidance

5.2.3

Electronics Sub-system

The main components of the electronics sub-system were kept unchanged, although a few changes were made. The servo motors were removed as well as the IR emitter/detector circuits. The rechargeable batteries used for prototype 1 were all replaced by a single LiPo battery. The main reason for replacing all the batteries with a single LiPo battery was the improved performance, greater power and longer running hours on a single charge. The robot was found to be able to run smoothly for 2.5 hours on a single charge. Both the Arduino and the H-bridge circuitry were powered by the LiPo battery. This also helped reduce overall weight of the robot and with the battery placed at the center of the bottom layer of the robot; the center of gravity was made lower, thus improving stability of the robot.

40

H-bridge Arduino Microcontroller

Switch to ON/OFF the robot

Sharp IR rangefinder powered straight from Arduino

Figure 31: Use of the Sharp IR rangefinder for wall and robot detection and avoidance

41

5.2.4

Pearl Detection and Collection

For the prototype 2, the whole algorithm for ball collection changed, as this time a pre-defined motion path was programmed into the microcontroller. It was noted that in the case of prototype 1 that allowing the robot to move by using the sensors was erratic and a lot of errors were introduced due to unstable chassis, incorrect wheel alignment and wrong return to base movement. The use of a predefined path allowed a more consistent navigation of the robot, with it moving according to the program and returning to base before moving out again. The path algorithm is shown in the pictures below.

Figure 32: Flowchart for Prototype 2

42

Home Base

A
Figure 33: Start of Algorithm (Path 1)

The robot starts to move from point A in the above diagram until it reaches the wall where it turns 900 anti-clockwise. It then detects a second wall where again it turns 90O anti-clockwise. It will then move until it reaches the wall of the home base, and will reverse until it reaches point B.

43

Home Base

Figure 34: Path 2

From point B, it will turn 90o and move forward for 5 seconds and again turn 90o degrees anti-clockwise and move forward until it reaches the wall. It will turn and follow the motion defined by the arrows until it reaches point C.

Home Base

C
Figure 35: Path 3

44

From Figure 30, the robot will move from position C, turn 90o, follow a straight path for 7 seconds, and then again turn left 90o and move until it reaches the wall. The same procedure is used to reach the home base again with turning left each time the Sharp IR rangefinder detects a wall.

Enemy Base

Home Base

Figure 36: Path 4

In path 4 (Figure 31), the robot will follow the path indicated by the arrows after it reaches point D in Figure 30. The purpose of path 4 is to be able to steal the pearls from the enemy base and increase the chances of winning. In the end, the robot covers the area of the arena by covering it section by section using the algorithm showed in the previous figures and each time returns to base to deposit any pearls collected on its way.

45

CHAPTER 6: Evaluation
One of the main issues about this project was the random scattering of the pearls all over the arena and how to collect the pearls and come back to the home base. The whole competition depended on the final number of pearls collected and brought back to base. The main concern was therefore to find the optimized path and method to collect the most number of balls. After trying prototype 1 and noticing its shortcomings, the design was changed to Prototype 2 and test runs were carried out. It was found out that, after extended testing that the Lightsaber performed better while being on a predefined course than on a to-and-fro path using sensor feedback. Prototype 2 was also found out to move in a straight line better than prototype 1 due to its improved chassis and enhanced weight distribution. After the removal of the rechargeable AA and AAA batteries and the 9V battery, and replacing them with the new LiPo battery, it was found out that robot performed in a more consistent way with the drop in voltage levels not as considerable as the previous batteries. The absence of the need to constantly charge up the batteries made it easier to keep testing the robot and also maintaining constant performance for long hours.

6.1 Problems and Solutions


6.1.1 Hardware No 1 2 3 Hardware Problems Sensor values changing too fast Driving motors not rotating Dying Batteries Cause & Evolved Solution This was due to the motion of the robot. The sensor was secured properly with tape and values smoothened out. This occurred mainly due to wires coming out of the breadboard. Proper connectors were used to solve the problem. If the voltage supplied by the batteries is too low, the driving motors rotation speed decreases, resulting in a slow forward motion of the robot and sometimes getting stuck in one position while turning 90 degrees. All the batteries were replaced by a single LiPo 8.4V battery which solved these problems. The initial gear-ratio chosen was for a light robot, however even when the robot chassis was changed, performance did not drop so no change was made to the gearbox. The servo motors had faults of jerking without even a microcontroller input. This is due to the connection between the servo and microcontroller not being fixed properly. Servo motors were taken off for Prototype 2.
Table 9: Table for hardware problems and solutions

Gearbox

Servo Motors

46

6.1.2 Software

Number 1

Software Problem Usage of delay in coding to create PWM.

Cause & Solution This is because the delay causes the drving motor rotation to decrease. Therefore, the delay may cause the robot to move ina different speed for old batteries, likely slower and if new batteries, it would increase the speed causing the hardware problem stated before. Solved by replacing batteries with a more powerful LiPo battery which kept voltage at an almost high and constant level. Coding issues and There were issues where the robot did not follow the code inability of robot to programmed into the microcontroller. This problem was solved follow instructions by breaking down the whole software into small pieces and testing individually and then compiling the whole code together once issues were resolved.
Table 10: Table for software problems and solutions

6.2 Improvements and Optimization


Components Prototype I one set of IR sensors one Sharp IR rangefinder Two wheel motors One ball caster as third wheel Two servo motors as flaps Prototype II One Sharp IR rangefinder Widened holding area

Capable of performing a to-andfor pearl detection and collection Weakness Unreliable motion Does not always return to base Changes from N/A previous prototype Functions

Able to detect wall Able to return to base accurately At certain angle, wall or robot detection may not work Servo flaps removed IR sensor circuit removed Widened holding area Improved chassis New LiPo battery No flaps to capture the polystyrene balls

Not applicable reason

Inconsistency of sensors and unreliable chassis was major issues.

Table 11: Table of improvements and Optimization performed

47

6.3 The Final Competition


The final competition was the means by which the overall performance of the robot was to be tested in matches against different opponents. In the competition everything ranging from robustness, creativity to performance was assessed. Prototype 2 competed in the competition and had the following specifications. Size: 19x18cm (fits within preset 20x20cm limit) 1 IR rangefinder Arduino Duemilanove Microcontroller Breadboard containing connections and circuitry for H-Bridge Tamiya Dual Gearbox with gear ratio 114.7:1 1 Lipo 8.4V 1200maH battery

Figure 37: Lightsaber Prototype 2

6.3.1 Match 1 During match 1, Lightsaber performed very well, managing to go through the entire path and algorithm preset and collecting pearls on its way back to base. In the end, it collected 14 pearls with a minimum amount of human interventions needed to help its motion. Eventually it ran out as winner of its match. No notable difficulty in navigation was observed. Design and algorithm was preserved.

48

6.3.2 Match 2 Match 2 was a totally different scenario, where the enemy robot had a different approach to the match. This changed the game plans and soon after the match started, the 2 robots collided and had to be taken back to base. However collision was not the only problem faced in this case. The Lightsaber got stuck amongst pearls and therefore could not come back to base and had to be taken out. The same situation repeated itself and the match was lost in the end as the opponent team collected more pearls. In this match, there was also an example of preventing enemy robots stealing from the home base. The strategy was to time the predefined paths in such a way that Lightsaber returned to home base at regular intervals after completing the path motions. If ever an enemy robot were to come steal, it would either collide on the way to the base or collide in the base, in which case, no pearls could be taken off the home base.

Figure 38: Inability to return to base after getting stuck

49

6.3.3 Match 3 Match 3 started well, with path 1 (mentioned earlier) completed well. However in this match versus team Tornado, there was little that could be done to prevent the fan from blowing off all the pearls from our home base and from the arena into the enemy base. Attempts were made to steal from enemy base after path 4, but with the fan blowing hard the match was lost.

6.3.4 Match 4 Match 4 was a repeat of the scenario from match 2 with the Lightsaber again getting stuck due to a collision with a few pearls at an angle. This prevented it from moving correctly and not returning to base but instead moved to a second loop. It did however work after a human intervention was required, but in the end lost the match due to a smaller number of balls collected compared to the opponent.

New path taken by Lightsaber, after getting confused. Did not return to base initially.

Figure 39: New path taken after confusion

50

Conclusion
Throughout this project, electrical knowledge learned in Monash University is put to practice. Besides, skills and teamwork cooperation are developed during the progress of the project. The planning of the project is arranged properly that every group member has the fair responsibility in this project. And the total cost used for this project is relatively affordable where it does not exceed the maximum planned budget. Although performance in the competition was not as successful as expected in terms of collection of pearls, the robot has considerably high reliability in straight line motion and wall or robot detection and avoidance. Have we had a little more chance to make a few more modifications to the robot, we would have been able to achieve far better results. In conclusion, we are successful in building a robot that is capable of fulfilling every requirement for this project thus we feel a great sense of achievement in it.

51

References
Society of Robots. (2011). Sensors: Sharp IR rangefinder. [Online]. Available: http://www.societyofrobots.com/sensors_sharpirrange.shtml Acroname Robotics. (2011). Sharp GP2Y0A21YK0F IR Package.[Online]. Available: http://www.acroname.com/robotics/parts/R301-GP2Y0A21YK.html Tamiya. (2011). Double Gearbox.[Online]. Available: http://www.tamiyausa.com/product/item.php?product-id=70168 C. McManis. (2006). H-Bridges: Theory and Practice.[Online]. Available: http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/ Price, D. A. Monash Minibot Version 1.0. 2005 Elecrom. (2008). How to make simple Infrared Sensor Modules. [Online]. Available: http://elecrom.wordpress.com/2008/02/19/how-to-make-simple-infrared-sensor-modules/ Ikalogic. (n.d.). Line Sensors. [Online]. Available: http://www.ikalogic.com/tut_line_sens_algo.php HPhy. (n.d.). Schmitt Trigger. [Online]. Available: http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/schmitt.html OP AMPS. LF 324 Datasheet. (2010). Silicon Labs. (2011). MCU Development Kits.[Online]. Available: http://www.silabs.com/products/mcu/Pages/C8051F020DK.aspx Arduino. (2011). ArduinoDuemilanove.[Online]. Available: http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove Society of Robots. (2011). Mobot Competition.[Online]. Available: http://www.societyofrobots.com/competitions_mobot.shtml Society of Robots. (2011). Mobot 2007 Line follow robot tutorial.[Online]. Available; http://www.societyofrobots.com/robot_mobot_2007.shtml Society of Robots. (2011). Hyper Squirrel.[Online]. Available: http://www.societyofrobots.com/robot_hyper_squirrel.shtml Society of Robots. (2011). The $50 Robot.[Online]. Available: http://www.societyofrobots.com/robot_50_robot_sharpIR.shtml Society of Robots. (2011). Omni-Wheel Robot Fuzzy.[Online]. Available: http://www.societyofrobots.com/robot_omni_wheel.shtml#fuzzy

52

Appendix
Appendix A Testing Scheme for Prototype 2
The following pages will describe the testing procedures carried out on Prototype 2 and the discussion of the results obtained. i. Chassis strength

To test the new chassis and whether it would be able to support the weight of the breadboard, microcontroller and battery, a simple test was done whereby objects of varying weight were placed on the chassis and the robot made to move. After a series of 10 test runs for each weight set, the chassis was checked for deflection.

Deflection,

Figure 40: Deflection of chassis frame

Weight 125g 245g 330g

Deflection, (cm) 0.2 0.4

Table 12: Table of weight v/s deflection

The above table shows the deflection observed when different weights were applied. For small weights the deflection was negligible. When the weight was increased, the deflection was about 0.2-0.4cm, which was still very low. The total weight of the circuits, Arduino and battery did not exceed 300g and therefore was well within the limit of negligible deflection. Chassis was therefore reliable for operation with all the components integrated on it for the test runs.

53

ii.

Speed

To test the speed of the robot, it was tested over a number of test runs. The test was to test the robot with all the components on it and allow it to complete the predefined path. The robot having a considerable weight now was tested at different PWM speeds to find an optimum PWM value to ensure enough speed and stability in motion.

PWM Value Time taken to complete path 150 120 100 80 3min 08s 3min 48s 4min 10s 4min 32s

Stability/Issues Too fast. Unstable Fast. Motion not entirely straight Stable Very Stable. Straight line motion

Table 13: Speed v/s stability

From the above table it can be seen that the robot was found to move perfectly well in a straight line motion with a PWM speed of 80. That speed was chosen for the competition as it offered great stability and enabled the robot to move well within the time limit of 5minutes.

iii.

The 90o left turn

To be able to make the 90o left turn, a lot of testing was done to find the optimum PWM value that would enable the robot to turn at 90o. A reference mark was set and deviation and angle calculated from there. 90o reference

Figure 41: The 90 left turn

54

PWM value 120 150 100 80

Delay 500 300 550 600


Table 14: Table of speed v/s angle

Angle (estimated) 110 25 80 90

From the above table, the speed of 80 and delay of 600 was chosen to make the robot turn at 90O.

iv.

Battery Life

The battery life of the LiPo battery was tested over a series of test runs with initial value and final value noted.

No of test runs 15 20 25 50

Initial Value (V) 8.34 8.28 8.23 8.20


Table 15: Battery life of LiPo battery

Final Value (V) 8.30 8.17 7.99 7.64

From the above table it can be noted that the voltage drop is not that considerable and the voltage level still being above the average operating limit, the robot performed well even at a high number of test runs. Charging time was only 25minutes for full charge, and was therefore an advantage over normal rechargeable AA, AAA batteries which have a charging time of 8 hours for full recharge.

55

Appendix B Full Code written for the Arduino Duemilanove


//18th October 2011 //Written by Triandi Tanri //Modified by Keshav Ramrekha

#include <Servo.h> int motor_left[] = {3, 5}; int motor_right[] = {6, 11}; int wall = 4; int counter = 0; //Define pins for left motor //Define pins for right motor //Initialize a counter for walls //Initialize counter

void setup() { Serial.begin(9600); pinMode(motor_left[1], OUTPUT); pinMode(motor_left[0], OUTPUT); pinMode(motor_right[0], OUTPUT); pinMode(motor_right[1], OUTPUT); ; } void loop(){ //Main loop

//Pin definitions

float walls = analogRead(wall)*0.0048828125; Serial.println(walls); forward(); if(counter<2 && walls>2.5){ path_1(); } else if(counter==2 && walls>2.2){ path_2(); } else if(counter>2 && counter <5 && walls>2.5){ path_1();

// Converting reading from sensor to voltage

56

} else if(counter==5 && walls>2.2){ path_3(); } else if(counter>5 && counter<8 && walls>2.5){ path_1(); } else if(counter==8 && walls>2.2){ path_4(); } else if(counter>8 && counter<12 && walls>2.5){ path_1(); } else if(counter==12 && walls>2.2){ backward(); delay(750); left(80,80); delay(600); forward(); delay(1500); left(80,80); delay(600); forward(); delay(500); counter = 0; } } void path_1(){ counter++; // backward(); // delay(400); left(80,80); delay(650);

57

motor_stop(); delay(500); forward(); delay(500); } void path_2(){ counter++; backward(); delay(750); left(80,80); delay(620); motor_stop(); delay(200); forward(); delay(3000); left(80,80); delay(700); forward(); delay(500); } void path_3(){ counter++; backward(); delay(750); left(80,80); delay(620); motor_stop(); delay(200); forward(); delay(4500); left(80,80); delay(700); forward(); delay(500); } 58

void path_4(){ counter++; backward(); delay(750); left(80,80); delay(500); motor_stop(); delay(200); forward(); delay(500); }

//-----------MOTOR FUNCTIONS----------------// void motor_stop(){ digitalWrite(motor_left[0], LOW); digitalWrite(motor_left[1], LOW); digitalWrite(motor_right[0], LOW); digitalWrite(motor_right[1], LOW); //delay(2000); } void forward(){ analogWrite(motor_left[0], 80); digitalWrite(motor_left[1], LOW); analogWrite(motor_right[0], 80); digitalWrite(motor_right[1], LOW); }

void left(byte a, byte b){ analogWrite(motor_left[1], a); digitalWrite(motor_left[0],LOW); analogWrite(motor_right[0], b); digitalWrite(motor_right[1], LOW); //delay(1000); }

59

void right(byte a, byte b){ analogWrite(motor_left[0], a); digitalWrite(motor_left[1], LOW); analogWrite(motor_right[1], b); digitalWrite(motor_right[0], LOW); } void backward(){ analogWrite(motor_left[1], 90); digitalWrite(motor_left[0], LOW); analogWrite(motor_right[1], 90); digitalWrite(motor_right[0], LOW); }

60

Você também pode gostar