Nano Sumo Robot

DIPLOMA PROJECT

Nano Sumo Robot

Table of Contents

1.Introduction

1.1Introduction in robotics

1.2 Motivation

1.3Implementation

2.Hardware part/Mechanical design

3. Electronic description

3.1 Schematic design

3.1 Design Rule Check (DRC) post processing

3.2 Electronic part description

4. Communication

4.1 Serial communication

4.2 Bluetooth

4.2.1 Classes of Bluetooth

4.2.2 Master, Slave and Piconets

4.2.3 Bluetooth Address and Names

4.2.4 Connecting process

4.2.5 Bonding and Pairing

5. Programming part

5.1 The general algorithms

5.2 The specific algorithms

6. Results

7. Conclusions

8. References

9. Annexes

Introduction

Introduction in robotics

In my diploma project I will describe how to build a nano sumo robot. First I would start with the meaning of the word robot which comes from the Slavic word “robota”, which means labor.

In a scientific definition of the robotics theology defined by Robotics Industry Association (RIA) is-“ as a re-programmable, multifunctional manipulator designed to move material, parts, tools or specialized devices through variable programmed motion for a variety of tasks”.[1]

Robotics can be considered a very important branch of technology which has the purpose to create different types of robots which will help the humans in different areas .When we speak about the robotic branch we think at many areas of the technology including: design, construction, operation of robots, sensory feedback, and information processing.

When we want to build a robot, whatever the purpose of it, we must consider three major basic similarities which can be apply to any robot.

The first one is the mechanical part: All the robots need to have some kind of mechanical construction, form or shape that usually is given by the future use.

This mechanical aspect usually deals with a real world application and requires a design in accordance with the future utilization. The mechanical aspect can cause the most problems because the designer need to come with different type of solution so that robots can perform various tasks and deal with the physics of the environment around it, example: gravity, friction, resistance…etc.

The second one is the electrical part: When we speak about robots we need to take in consideration the electrical aspect which can be found, in the form of wires, sensors, circuits, batteries …etc.

The electrical part can be defined as a flow of electric charge which is travelling along the electrical circuit and also is carrying the electrons through the wires.

Any robot need to be power, and the power is in form of electricity which will travel through the wires and will power supply the electronics. In the case of the robots, and also in the case of my project the electrical circuit is power supply by a battery.

Sensing is also a very important part in the electrical part because the sensors use the electrical signals in order to determine things like heat, sound, position, and energy status.

The electrical aspect of robots is used in most of the cases for movement: as in the controls of motors which are used mostly were motion is needed and also for the sensing part which can help the robot to take information from the environment.

The third is can be considerate the most hard part of a robot. All robots need to have a programming part in order to execute the tasks. This part it may take more time because after the program is build and execute the tasks he need do we have to improve and optimized the process. A program is the part when the robot takes decides when or how to do something.

When we speak about robotics branch we need to take in consideration how the robot can be control. There are three types of controlling the robot such as: autonomous robots, semiautonomous and the robots that are control manually. An autonomous robot has complete control over its actions and can think for itself. It can learn and adapt very much like AI. AI stand for artificial Intelligence, robots with this kind of programing interact with their environment on their own without a control source. Robots with AI create solutions to objects/problems they encounter by using their preexisting programing to decide, understand, learn and/or create. Sometimes autonomous robot are also control with an RC(Remote Control) .This kind of robot which has this type of program has a preexisting set of commands that it will only do if and when it receives a signal from a control source, most of the time the control source is a human being with a remote control. This is very used in robotics because is very easy to control the robot.

For my project I choose to build a robot which can be control by using a remote control, my case is a PHILIPS remote control with which start and stop the robot. Also the robot has an artificial intelligence because is it built to be autonomous and take decide by himself decision based on the information received from the sensors.

A semiautonomous robot is controlled by its programming and is restricted to do what its programming tells it. It cannot learn further than a certain point. This is a very limited robot which is used mostly in the industry.

A robot which is controlled manually is very rudimentary because he always needs someone or something to control him. It needs to be told what to do, how to do it, and when to do it. It cannot learn or think for itself.

1.2Motivation

I’ve chosen this project because is something unique due to the dimensions (25x25x25mm, 25g) and also because until know there are not many prototype in the world.

One of the reasons that I choose this subject is that sums up all the knowledge form different fields like: programming, electronics and mechanics that I have aquarist in the last four years.

The other reason that made me choose this topic was the significance of this new technology in our days. The humans tend to replace with robots the most dangerous and even sometimes impossible activities for humans to do. Robots are good because it has speed, efficiency, low maintenance, no labor disputes, can be accurate and it can do it continuously. This is the reasons that we can find robots in many areas such as:

1. Industrial robots. Industrial robots are robots used in an industrial manufacturing environment. Usually these are articulated arms specifically developed for such applications as welding, material handling, painting and others. If we judge purely by application this type could also include some automated guided vehicles and other robots.

Industrial robots are being intense use in manufacturing processes or assembly line processes. They are both programmable and reprogrammable to accomplish various task whit speed, precision and quality. Industrial robots are most common use in the automotive field where they manage jobs such as welding, painting, assembly, etc. These robots perform jobs that are difficult or hazardous for humans.

If industrial robots are well maintained eventual malfunctions can be easily predicted and resolved. Manufacturing plants that use the help of robots tend to run smooth without problems and whit less and less help from humans.

2. Aerospace robots. Aerospace robots are a special category which includes robots used in the International Space Station, robots used aboard Space Shuttles and even robots used in Mars rovers. They have to meet special requirements so they can function in special conditions and with great precision.

Aerospace robots are also used by scientists to explore the outer space. Rather than a scientist go into space they sent robots because they avoid the risk of losing their lives. They can explore space and obtain the same results without their lives being in danger.

3. Healthcare delivery. This category includes robots used in the medical field. A great possible advance will be made along with the introduction of robots in surgery. Because of that it can be possible to perform surgery on a patient that is in a remote area provided the proper tools and set-up.

4. Robots resembling humans and robotic pets. This kind of robots has the purpose to entertain and to make our life easier.

5. Military robots. This is also a special category which includes bomb disposal robots, reconnaissance drones and different type of transportation robots. They can also be used in search and rescue operations or by law enforcement officers. Military robots can be used in war conflicts so that soldier’s life is no longer in danger.

6. Entertainment robots. In this category we have robots from toy robots such as the running alarm clock or robosapien to articulated robots arms used as motion simulators.

7. Hobby and competition robots. These are robots made for fun and for competitions: sumo-bots, line followers.

8. Robots used at home. This is a vast category which includes robotic vacuum cleaners, robotic pool cleaners, robotic sweepers, etc. This king of robots are designed to accomplish different chores around the house

This technology will evolve and create faster and advance robots which will perform more different fields such as: Construction, Health, Nuclear , Navigation systems, Aerospace, Lab automation and Military.

1.3 Implementation

Nano-robotics is concerned with manipulation of Nano-scale objects by using micro or macro devices, and construction and programming of robots with overall dimensions .Building Nano-robots involves sensors, actuators, control, power, and communications. Nowadays robotics if focused on creating new ways to design, manufacture and control micro/ Nano-robots in three areas miniature mobile robots, bio-inspired febrile adhesives, and micro/Nano-manipulation systems.

During my research I found that in order to realize miniature mobile robots we need to take in consideration a lot of things as: locomotion which is the capability to develop a biologically inspired design methodology.

It is crucial for us to use new and advance materials in our miniature robots because we need materials which are very light and strong.

The purpose of this diploma project is to design and implement an autonomous robot that meets the specifications needed to compete in a Nano sumo robot competition. Although this robot is developed to compete in a tournament, but the technology can be used for unlimited applications such as engineering, medicine, military etc. For example, the robot can be used to explore small or dangerous places, or even perform everyday tasks. For this robot I have to consider many aspects of the design such as mechanical, electrical, coding, and controlling.

First I have to approach my robot from the mechanical point of view because the building blocks(in my case this blocks represent the electronics) are also the body of the robot .At this point I have to take in consideration the size of the robot and the specifications. Choosing the motors is also important because I needed motors which can combine the best performance in power, size (in my case it is very important due to the small size of the robot), consumption and cost. After choosing the motors I decided on what type of sensors I should use and how can they help me accomplish my gold. I need two types of sensor: phototransistors sensors in order to detect the line of the ring and distance sensors (proximity sensors) in order to detect de adversary.

The brain of the robot is a microcontroller which will control the reaction and movement of the robot .I choose a simple and small microcontroller because I already had an experience with At Mega 328 and I have an idea on how to use this specific controller which is inexpensive and meets all the my requirements. Another important component of my robot is the motor driver which will cose it is very important due to the small size of the robot), consumption and cost. After choosing the motors I decided on what type of sensors I should use and how can they help me accomplish my gold. I need two types of sensor: phototransistors sensors in order to detect the line of the ring and distance sensors (proximity sensors) in order to detect de adversary.

The brain of the robot is a microcontroller which will control the reaction and movement of the robot .I choose a simple and small microcontroller because I already had an experience with At Mega 328 and I have an idea on how to use this specific controller which is inexpensive and meets all the my requirements. Another important component of my robot is the motor driver which will control the direction of the robot.

The aim of this project is to obtain a robot which will reproduce the traditional Japanese wrestling –“sumo”. Sumo is the Japanese word for wrestling. Similar to traditional sumo matches, two opponents (robots) face each other in a ring named a “dohyo” (see Figure 1). The object is to stay in the ring while pushing the opposing robot out of the ring. The robot that stays in the ring the longest wins the match.

The challenge is to design and build a robot that can find its opponent (often accomplished with infrared or Ultra-sonic sensors) and push it out of the arena, which is called a "Dohyo" or "sumo-ring". A robot should also avoid leaving the “Dohyo”. This is something that it can be accomplished by using a sensor that detects the edge of the ring.

Autonomous robots are self-propelled and self-controlled, without tethers .After positioning and start the robot, no remote control, power, positioning, or other help can be provided.

The robot must care for itself until the round ends. As long as all other requirements are met, Nano Sumo Robot can be made out of any material, in my case the chassis is from PCB. They can use any type or size of electric motors or electric-powered locomotion. The robot can have any type of processors, electronics, sensors or batteries.

There are many popular classes of robots, based on size of the robot and ring:

1.5 Classification of the robots:

“This classification can be found in the robotics competitions and also the general specifications:

1-Mega-sumo, these robots may mass up to 3 kg and fit inside a 20 cm by 20 cm box, no height restriction.

The Mega-sumo ring measures 154.0 cm (a bit over 60.5 inches) in diameter.

2-Lego-sumo-Up to 1000 g mass, 15 cm by 15 cm, no height restriction.

The ring measures 77.0 cm (a bit over 30 inches) in diameter. For this type of category the participants we will use specific kit in order to build and program.

3-Mini-sumo-Up to 500 g mass, 10 cm by 10 cm, number of height restriction.

The ring measures 77.0 cm (a bit over 30 inches) in diameter.

4-Micro-sumo-Up to 100 g mass must fit in a 5 cm cube.

The ring measures 38.5 cm (a bit over 15 inches) in diameter.

5-Nano-sumo-Must fit in a 2.5 cm cube.

The ring measures 19.25 cm (a bit over 7.5 inches) in diameter.

6-Femto-sumo-Must fit inside a 1 cm cube.”[4]

General description of the ring:

Nano sumo ring:

Fig.1 Nano sumo-ring/Dimension 19.25 cm (a bit over 7.5 inches) in diameter.

The Dohyo or in popular language Ring is defined as the area surrounded by and including the border line. The ring is a large (depend of the category of the robot), flat disc. It is made of a smooth rigid material, such as wood. For the Mega sumo is the only category where the ring is a bit different because it is made of metal. This kind of ring for Mega sumo is made of metal because is the most dangerous category so for protective purposes we use magnets to keep the robot on the floor. The top surface is dull black, except for a thin border that is shiny white. This specification of the ring is applied to all the rings from national and international completions. The space where battles take place must not contain any people, object, lights, cameras or anything else that could distract or interfere with the robots.

Nano-sumo robots are small autonomous mobile robots designed specifically for sumo style competition. The Nano-sumo robot competition rules restrict for the Nano sumo length and width to 2.5 cm x 2.5 cm. Another important specification is that the robot cannot weigh more than 25 grams. Unlike larger battle robots, nano-sumo robots are not allowed to damage the opponent robot, they are only allowed to push it off the “dohyo” (ring).

To be effective, Nano-sumo robot must be able to do the following:

stay on the dohyo

target (aim at) the opponent

hunt for the opponent

Attack the opponent.

[3]http://www.robotchallenge.org/competition/

2. Mechanical/Hardware part

Usually the mechanical part is where you start when designing a robot, as it contains not just the chassis and wheels, but also the motors with the reduction gears. I know that you are thinking that the motors could also be included in the electrical part, as they transform electrical energy into mechanical energy, but we chose to treat them in the mechanical part of our presentation. The motors are one of the most important components in any robot, as they are the starting point in the conception of any robot, because they dictate chassis dimensions, battery size, motor driver capabilities and sensor response time.

The chassis has the role of offering support for all the other components, and also it has to protect them, especially the sensors which are quite exposed in the front side of the robot if it would crash into a wall or something.

The robot is formed from 7 plates that combine in a cube of approximately 25 mm x25 mm x 25 mm. We cut 2 holes of 7 mm X 9 mm because we need space for the wheels. Moreover, on the lateral plates, we also have holes of 18mm x 9 mm. Their role is to accommodate the wheels and the motor drivers. The bottom plate is formed from 2 plates that will be cut in a way in which the final surface will be 25 mm X 25 mm. We need to have the line sensors at height, so we have to stick 2 plates one over each other. The drawing itself follows on the next page.

For my project I decide to place all the important components such as: microcontroller, quartz crystal, driver on the top board because they provide easy access according to the design of the robot.

On the side plates I’ve placed the distance sensors because in this way the robot may have a larger area to detect rival robot and to react more quickly than if it only had sensor in the front. This also can be considerate a strategy because each sensor will have a flag different in order to be more efficient.

These side plates, which are 4, one of each side of the cube have a different dimension compared to plates above and below. On the bottom of the robot I will place the motors parallel to each other because I don’t have enough space to put them into each other's extension.

The Nano-Sumo rules are for a 25mm x 25mm size robot. I looked around for a while and the only gearbox I could find that would fit my working envelope was the SolarBotics #GM-15.

Here is what you get. 6.0mm diameter x 20mm length planetary gearbox with a pager motor. The output shaft is made for a drive belt. The motor's output shaft comes out on each side of the robot gearbox holder.

Due to the lack of space we have to mount the motors eccentrically which means that the output of the motors will not be on the same line causing a disadvantage. To compensate for this, I had chosen wheels which are wider to increase the contact with the ground.

The wheels are another important part of a robot, because they transfer energy from the motor to the ground. So the wheels are really important especially at corners, where you need as much traction as possible so the robot can stay on the line. This is why we chose some wide wheels, poured out of Shore A20 silicone (this is the hardness of the silicone) which is really soft and offers loads of traction.

We milled the bottom part of the robot and also the laterals in order to make room for the wheels.

The bottom part is form by two parts because the line sensors are thick and we needed the plate on which the sensors are soldered to be higher for the sensor to work properly.

In designing the plates we also took in consideration the dimensions of the cuttings. In this way I did not encounter any problems whit the dimensions of the robot. The dimensions of the robot remained in the limit of the specifications.

After designing the robot in EAGLE I decided to make a prototype using a 3D printer. After designing the robot using the SOLIDWORKS program and also went through the process of rendering I obtain the final view of the robot. This prototype printed using 3D printer I will use to test the robot. This will be the enemy because it has the same weight, length as a usual adversary. This prototype it will help me to improve and optimize the programming part of the nano sumo robot.

Fig .1.2. The overview of the project “nano sumo robot” in the program SOLIDWORKS.

A good designer must have to go through all the steps to obtain a good final product

Here we have the mechanical design of the motors which was made in a specific program called CATIA.[4]

[4] https://solarbotics.com/download.php?file=158

3. Electronic description

EAGLE (for: Easily Applicable Graphical Layout Editor) by CadSoft Computer is a flexible, sexpandable and scriptable EDA application with schematic capture editor, PCB layout editor, auto-router and CAM and BOM tools. EAGLE contains a schematic editor, for designing circuit diagrams. Parts can be placed on many sheets and connected together through ports.

The PCB layout editor allows back annotation to the schematic and auto-routing to automatically connect traces based on the connections defined in the schematic.

EAGLE saves Gerber and PostScript layout files, Excellent& Drill files. These standard files are accepted by many PCB fabrication companies.

In my diploma project I choose to build a Nano sumo robot which requires 7 very accurate electronic boards which will also serve as the body (chassis) of the robot due to the fact that the robot must fit in a 1 inches cube.

Electric part of the project contains all the steps that I fallowed in order to build a professional boards by using Eagle methods, design the PCB electronic module according to the schematic diagram.

Design requirements:

1. Schematic design (SCM)

1.1 Functional description of the schematic diagram;

1.2 Schematic diagram printed in A4 format, with information of student placed in the title block;

1.3 Design Rules Check (DRC) post-processing report;

1.4 “Bill of materials” (BOM) post-processing report;

2. Layout design (PCB)

2.1 The layout shall be generated using only 2 electrical layers, top and bottom;

2.2 All components shall be placed on the top side and on the bottom side of the printed circuit board;

2.3 The width of the signal connections (0.256 mm);

2.4 The width of the ground/power connections (0.406mm);

2.5 The electrical and non-electrical layers in A4 format, at 1:1 scale (“artwork” type post-processing), as follows:

A. electrical layers:

– Top electrical layer

– Bottom electrical layer

B. non-electrical layers:

– Solder mask

– Silk mask

– Drill drawing

2.6 Each layer processed at point 2.5 shall be placed in a rectangular standard drawing format (see point 1.2), which shall contain a title block with the identification information of the student, name of layer, rotation, scale, revision, etc.

3.0 Mechanical design

3.1 The robot is formed from 7 plates that combine in a cube of approximately 25 mm x25 mm x 25 mm

3.2 The central plate (which has the motors) has 2 holes in it of 7 mm X 9 mm which accommodate the wheels of the robot. The lateral plates also have holes in it of 18mm x 9 mm which also accommodate the wheels and the motor drivers.

3.3 The central plate is formed from 2 parts that stick one over each other in order to make room for the line sensors (the front part of the plate will be taller).

3.4 The bottom plate is formed from 2 plates that will be cut in a way in which the final surface will be 25 mm X 25 mm.

Schematic design (SCM)

Nano Sumo (Description of the Project)

Nano Sumo is a 2.5 (cm)x2.5 (cm)x2.5 (cm) robot which fights against another robot on a black circular ring with the diameter 19.25 cm and with a white border of 0.625 cm. The robot is totally autonomous and it uses sensors with infrared light.

The robot is composed of 2 motors, 6 sensors, a microcontroller, resistances and capacitors and a start/stop module that makes the robots start at the same time.

The electronic components used in this project are the following:

Resistors:

Resistor 10R

Resistor 100R

Resistor 10k

Capacitors:

Capacitor 1uF

Capacitor 22pF

Oscillator: 8MHz

Voltage regulator: 3.3 V

Motor Driver

Sensor Line: IR

Sensor Enemy: IR

Microcontroller: ATMEL-328

Battery: 3.7 V – 150mAh

Motors: 6mm

3.1 Schematic design

In the process of building the boards, first i start by designing the schematic of the robot. This was the easiest part because after I decide what kind of components I will use I start by adding the liberties which contains the exact components which will be used in my project.

In this part I just place the components that i need and connected them by respecting the specifications. All this specifications can be found in the datasheet. After building the electrical schematic of my project i continue by generating the Design Rules Check (DRC) post-processing report. This report is very important because it detects the possible errors which may occur in the schematic. After optimization and checking the DRC we can move to the most important and the hardest part which is the designing the board.

This process can be made by going to file and switch to board bottoming this moment the schematic it will change in real component which will be place according to the preferences of the designer.

After placing all the components and connect all the signals, networks, holes and optimized paths then I move step by step through the process of "finishing-smoothing-glossing".

In this part I create the signals, networks and place the components on the top or on the bottom of the board. Because my project has small dimensions I need to make dual layer PCB boards which is the reason that I place so many holes in order to connect the layers. After creating the top and bottom networks I went to the next step which is solder mask process. Solder mask o is a thin lacquer-like layer of polymer that is usually applied to the copper traces of a printed circuit board (PCB) for protection against oxidation and to prevent solder bridges from forming between closely spaced solder pads. Solder mask is not always used for hand soldered assemblies, but is essential for mass produced boards and usually his traditionally color is green but is now available in many colors. In electronic design automation, the solder mask is treated as a layer of the printed circuit board, and is described as a Gerber file like any other layer, such as the copper and silkscreen layers. In EAGLE in order to obtain the solder mask we need tStop (which defines the solder mask) and tCream (which defines the stencil) layer data, but rather accepted the automatically generated rectangular data that comes along with the land patterns. This process was made for all the PCB boards (top and bottom) in order to protect the electrical circuits.

Silkscreen is normally used on the component side to identify components, test points, PCB and PCBA part numbers, warning symbols, company logos and manufacturer marks. It isn’t uncommon to have silkscreen required for the solder side as well but if you are price sensitive.

In order to obtain the silkscreen in EAGLE we need to select the Dimension, tPlace, tNames, and tValues layers which will be included on the silkscreen. Too see what the silkscreen layer looks like, go to the Layers menu and deselect all layers except those four. In my project I made this process just for the top layers of the robot.

The next step was to create the drill drawing which is the cutting process that uses a drill bit to cut or enlarge a hole of circular cross-section in solid materials.

After I went through all the steps of “finishing-smoothing-glossing" I create the Gerber file which will contain the important file which are needed: top and bottom layer, solder mask, silkscreen and drill. This Gerber file can be done very easily, directly from EAGLE, CAM processor which is the one who writes Gerber files. The Gerber format is an open 2D bi-level vector image file format. It is the de facto standard used by printed circuit board (PCB) industry software to describe the printed circuit board images: copper layers, solder mask, legend, drill holes.

One usage is the transfer of PCB design data from design to manufacturing. PCBs are typically designed on a specialized Electronic Design Automation (EDA) or a computer-aided design (CAD) system. The CAD systems output Gerber files which are sent to PCB fabricators to transfer the design information. The fabricator loads them into his computer-aided manufacturing (CAM) system to prepare data for each step of the PCB production process like I did in my case. Gerber files are also used to transfer drilled holes information, however, for historic reasons Excellon files are used more often for this.

Another use of Gerber viewers is to visualize the PCB layers this is why after creating the Gerber file I install the program GERBERLOGIX the version 2.9.7 where I could visualize all the circuit exactly in the way that the company that will manufacture will see the boards.

Fig. 3.1 Schematic design of the Nano sumo robot

3.2 Design Rules Check (DRC) post-processing report

Date and Time: 05/26/13 12:00:00

–––––––––––––––––

Checking Schematic: NANO SCHEMATIC

–––––––––––––––––

Power and ground nets: -0.406 mm

Thickness of lines at the cuts of the cube: – 1 mm

Thickness of signals: 0.2 mm and 0.1 mm

Vias: – 0.4 mm

Tab. 3.1 “Bill of Materials” (BOM) post-processing report

Fig. 3.2 Layout Design (PCB)

This represents the layers of the robot in final state. We obtain this form after performing all steps in the design process.

Fig. 3.3 Top Electrical Layer

This represents the top layer of the robot. In this picture we can observe the important pads which are place on the top of the robot. This are: the microcontroller, the motor driver, 3.3V regulator and quarts oscillator.

Fig. 3.4 Bottom Electrical Layer

This represents is the bottom layer of the robot. Here we can observe all the sensors (two line sensor and also the other four proximity sensors which are uses to detect the enemy) and the transitions from one board to the other.

Fig. 3.5 Solder Mask Top Layer

This represents the top layer with solder mask. This shows as the places where the circuit will be expose in order to solder on it .This will help as to solder the component and also to make the transitions between the PCB places. This solder mask has an informative role.

Fig. 3.6 Solder Mask Bottom Layer

This represents the bottom layer with solder mask. This shows as the places where the circuit will be expose in order to solder on it .This will help as to solder the component and also to make the transitions between the PCB places on the bottom of the robot. This solder mask has an informative role.

Fig. 3.7 Silk Screen Top Layer

This represents the silks screen which is found only on the top layer of the robot. This process will help us to know information about where to place the component and also if we have other type on information which was inscribed on the PCB boards.

Fig. 3.8 Drill Drawing Layer

This picture represents the drill drawing layer. This is a very important step in the designing the robot because it will show us here are the transitions between the two PCB’s and also the vias (it make the link between the top and the bottom boards of robot) of the robot.

We also see here in this step the drills.

Fig. 3.10 Mechanical Design

This is the physical part of the board. This represent the final shape of the board’s which will help as to know where to cut the boards.

Fig.3.11 The final view of the Nano sumo robot in the GerberLogix Program

This is the GerberLogix V.2.9.7 which I used in order to check if the Gerber file was constructed according to the rules and also to verify if I have errors.

In the left part we can see all the folders of the Gerber file and in order to check just one of them or just some of them we only need to deselect on or many of the folders.it is a very simple program which ii offer as the possibility to verify and see how the final product it will be.

After sending the GERBER files to the manufactured company this was the final product that I received:

Fig.3.12 Nano-sumo robot (top view)

Fig.3.13 Nano-sumo robot (bottom view)

After receiving the PCB’s the next step was to star to build and solder the electronic part

3.3 Electronic part description

Fig.3.16 Microcontroller AtMega 328_EAGLE_Schematic

For robots, there are important feature on a microcontroller, is the I/O ports. It’s one of the most important criteria if the microcontroller has enough I/O ports, and how much pins are analogic and how much are digital .Input ports are used for taking in the sensor data, while output is used for sending commands to external hardware such as servers. There are two types of I/O ports, analog and digital.

[6]http://www.farnell.com/datasheets/1693866.pdf

Analog Input Ports

On a microcontroller we will find both analog and digital pins.

For example in my project I used the analog ports in order to connect the sensors to the robot. Analog input ports are a continuous voltage range and they are generally used when we deal with sensors. In my project I’ve connected all the sensors to the analog ports. In the beginning, the analog signal is measured after a certain period of time. At each time period, the voltage is recorded as a number. In our days the computers only register values as ‘0’or ‘1’.In this case we need an analog to digital converter (ADC), which receives the analog signal and converts it to a digital number within a certain numerical range. This number will define a signal of 0's and 1's as shown:

Fig.3.17 Analog to Digital Conversion Signal

It has more advantages to use digital signal over analog because the digital signal is more efficient in eliminating background noise. Higher bit rates obviously mean higher quality because they better represent the analog signal. But higher bit rates also require more memory and processing power.

In the present most microcontrollers are 8 bit, meaning they have a range of 256 (2^8=256).

This bit range could also be seen as a resolution. Allows higher resolutions mean higher accuracy, but occasionally can mean slower processing and more susceptibility to noise.

Digital I/O Ports

The case of the digital ports is very similar to analog ports, but with only 1 bit (2^1=2) hence a resolution of 2 – on and off. The digital ports are rarely used for sensors; the only case when we use it is for on/off switches. The digital I/O are mostly used for is signal output. There are many cases where we can use them such as: to control motors or LED's. The digital has a very easy way to work: when we send a high voltage as 5V signal (or in my case 3.3V) something must turn on, or when we send a low voltage 0V something must to turn off.

Pin Descriptions of the microcontroller At Mega 328

VCC- The port VCC, VCC_2 and AVCC and are ports for Digital supply voltage. All this ports are connected via a junction. Also the port AREF is also connected via a junction to the VCC.

GND- The port Ground is connected to GND_2 and GND_3 via a junction.

Port B (PB7:0) XTAL1/XTAL2/TOSC1/TOSC2

“Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when

Depending on the clock selection fuse settings, PB6 can be used as input to the inverting Oscillator amplifier and input to the internal clock operating circuit.

Depending on the clock selection fuse settings, PB7 can be used as output from the inverting Oscillator amplifier.

If the Internal Calibrated RC Oscillator is used as chip clock source, PB7…6 is used as TOSC2…1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set.”[7]

On the port B I connect PB1 on in the IN4 of the driver and also I connect the distance sensor 1 and 2 through PB0 and PB2.

“Port C (PC5:0)-Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The PC5…0 output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source

current if the pull-up resistors are activated. The Port C pins are tri-stated when are set condition becomes active, even if the clock is not running”. [8]

On the port C I connect PB0, PB1 to the line sensor 1 and 2 each port for each sensor.

PC6/RESET

“If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical characteristics of PC6 differ from those of the other pins of Port C.

If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running.”[9] The minimum pulse length is given in. I connect the PC6 to the digital supply voltage (VCC).The reset input. This is a low level active.

“Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when are set condition becomes active, even if the clock is not running”.[10]

On the port D I connect the other 2 distance sensors 3 and 4 and also the other Inputs of the driver. On PD2 and PD4 I connect the distance sensor and on the ports PD3, PD6 and PD9 I connect the inputs of the motor driver.

[7] http://www.atmel.com/Images/doc8161.pdf /datasheet

[8] http://www.atmel.com/Images/doc8161.pdf /datasheet

[9] http://www.atmel.com/Images/doc8161.pdf /datasheet

[10]http://www.atmel.com/Images/doc8161.pdf /datasheet

AVCC

“AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that PC6…4 use digital supply voltage, VCC.”[11]

AREF

AREF is the analog reference pin for the A/D Converter.

This is the chip I used in the building of my Nano sumo robot

Fig.3.18 At Mega 328 chip(http://www.hobbytronics.co.uk/arduino-atmega328-pinout)

We can observe from the picture above that we have pins which are analog and pins which are digital input/output.

Besides this we have pins 30 and 31 which are for receiving (Rx) and transmitting (Tx) the information. Pin 30 and 31 form a part of UART interface (Universal Asynchronous serial Receiver/Transmitter).

Asynchronous means that the interval between data packets can be undefined. The receiver detects the start and the end of the packet. The frequency transmission bit is fixed and must be known on the both size of the transmission. The transmission and reception can be performed

simultaneously this is called full duplex transmission. Each part of the conversation can initiate a transmission.

[11] http://www.atmel.com/Images/doc8161.pdf /datasheet

PWM it stands for Pulse Width Modulation. These square waves are called PWM, short for pulse width modulation. They are most often used for controlling servos or DC motor H-Bridges.

In the description below we will see the whole description of the microcontroller At Mega 328 that I used for my nano sumo robot. The PWM signal it has an rectangular shape and it usually used in order to control the DC motors. We used this way to send a simulation of an analog signal using digital equipment, so you can simulate a voltage that's between your high and low voltage that means between (5V-0V).In my case I used the interval between 0 -3.3V.

This PWM signal is modify the ratio between how much time the signal it stays in high (3.3V) and how much in the low(0V) and we obtain a signal whose power gradually changes between this interval. This ratio is defined as fill factor. We need to take in consideration when we want to use the PWM port that not all the digital ports can generate this kind of signal.

In my project I used the PWM ports in order to control the two DC motors. When I used the PWM signal for a DC motor and apply a fill factor of 100% will run at full speed, if I will apply a fill factor of 50% the speed of the motor it will be modify accordingly to the modification (considering that only half of the time the DC motor is operated in the other half it appears the inertia).

But the PWM signal can have several applications such as:

Dimming an LED

It can generate audio signals.

Providing variable speed control for the DC motors.

Generating a modulated signal, for example: to drive an infrared LED for a remote control(in my case in the module of start/stop)

Fig3.19 Pulse Width Modulation signal(http://www.slideshare.net/guestedb041/prezentare-pwm )

When we deal with digital processor I need to take in consideration the clock cycle. On every clock cycle your processor will do something. This is way the faster the clock, the more things your processor will do.

Another important component that I used in my project was the crystal oscillator which I connected externally with the microcontroller to provide high frequency signal to the oscillator circuit in the microcontroller. The oscillator circuit provides the clock signal to the microcontroller. However I need a stable frequency and this is way I choose the crystal oscillator because is quiet accurate. For my nano sumo robot I used 2 capacitors which I place them very close to the microcontroller.

(Load_capacitance – PCB capacitance) * 2 = crystal capacitors or (12pF – 3pF) * 2 = 18pF // this is the values of the capacitors which I used for my crystal oscillator.

I would place the crystal oscillator between the pins 7 and 8 which are the XTAL 1 and XTAL 2 pins like in following picture:

Fig. 3.20 Crystal oscillator(http://www.societyofrobots.com/microcontroller_xtal.shtml )

A very important aspect is that I need to place the capacitors very close to the crystal oscillator, and the crystal also needs to be close to the microcontroller. This is necessary in order to reduce electrical noise and internal capacitance that could disturb the clock.

Motor drivers:

Another important component on my robot is the motor driver which works as an H bridge. It is necessary to have this kind of driver because it helps us to control the DC motors. The DC motors starts in the same direction with the same speed, but if we need to control them in order to obtain different speeds of each motor or if we want to reverse the direction of the one or both motors we need to use this kind of driver. “An H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards.

Most DC-to-AC converters (power inverters, most AC/AC converters, the DC-to-DC push–pull converter, most motor controllers, and many other kinds of power electronics use H bridges. In particular, a bipolar stepper motors is almost invariably driven by a motor controller containing a H- bridges”. [12]

In theory the H Bridge it can be define from the graphical representation of a circuit with four switches.

[12] http://en.wikipedia.org/wiki/H_bridge

The principal of works is very simple: when the switches S2 and S3 are open are closed (and S1 and S4 are closed) a positive voltage it will be applied to the motor. In the case, when we opening S1 and S4 switches and closing S2 and S3 switches, the voltage that is applied is reversed, allowing reverse operation of the motor. In my situation, the motors will work in the opposite direction and the robot will go back.

The last situation is the most dangerous because it can provoke an short circuit. In this case the switches S1 and S2 should never be closed at the same time and also the same rule must be applies to the switches S3 and S4. This condition is known as shoot-through.

Fig.3.21 The two states of the H Bridge(http://en.wikipedia.org/wiki/H_bridge )

A common use of the H Bridge is an inverter. The arrangement is sometimes known as a single-phase bridge inverter.

“The H Bridge with a DC supply will generate a square wave voltage waveform across the load. For a purely inductive load, the current waveform would be a triangle wave, with its peak depending on the inductance, switching frequency, and input voltage”[13].

For my project “Nano Sumo Robot” I used a motor driver whit the following specifications: the motor driver that I choose for my nano sumo is an LB1836M which is a dual low-voltage H-bridge that can be used for bidirectional control of two DC motors or one bipolar stepper motor. In my case I used this dual motor driver to control my two motors. With an operating voltage as low as 2.5 V for logic and 1.8 V for the motor(s), this controller is great for small motors powered from a single Li-based battery or 2-6 NiMH or alkaline cells. In my case I choose to power the driver with a single cell Li-based battery. “The peak current is up to 1 A per channel, but thermal dissipation usually limits the available continuous current to around 0.5 the motor driver features thermal shutdown that can help the chip withstand over-current and short-circuit situations. The IC is only available in a surface-mount package, but the 1.0 mm pitch is relatively accessible even with a standard soldering iron, making it an attractive option for those wanting to build small motion control systems”[14] .

For the project I choose the SMD version because of the small dimension of the robot.

There are many types of controlling the motor driver: the first one is the one that I used in my project: I choose an motor driver that means I choose an electrical method which implies the following concept: if you short the power and ground leads of your motor, the inductance created by your motor in one direction will power your motor in the opposite direction. Although your motor will still rotate, it will greatly resist the rotation. One of the disadvantages is that the effect of braking is determined by the motor you are using. This is a very reliable method and very easy to implement.

[13] http://www.share-pdf.com/2939b16adc574189a4f1c85fd2c41d87/PART%202.htm [point 2.6.5]

[14] http://www.pololu.com/product/399

The second method it is a mechanical one and it is used on cars today. Basically you need something with very high friction and wear resistance, and then push it as strongly as possible to your wheel or axle. A servo actuated brake works well.

I used the electrical method by using the LB1836M which is a dual low-voltage H-bridge in order to control the differential drive. This is a method of controlling a robot with only two motorized wheels.

When we speak about the motor driver we immediate think of the term 'differential' which can be defining as the robot turning speed. This is determined by the speed difference between both wheels, each one side of my robot. For example: if we keep the right wheel still and rotate the left wheel forward and the robot will turn right.

Fig.3.22 This is the case when we keep the left wheel still and rotate the right one(http://www.societyofrobots.com/images/programming_differentialdrive_example.gif )

Voltage regulator:

A very important schematic which is always used for every robot is the power source. It is not that simple and you cannot just hook up a battery directly to everything and expect it to work. There are three things that your power regulation circuit must do

– regulate at a set voltage;

-supply a minimum required amount of required power at all times;

– allow for additional special features/requirements of your application;

In the beginning, we need to take in account that we have different electronics components which require different voltages.

Graphic 3.1 Linear voltage representation

Microcontrollers (and especially sensors) are sensitive to the input voltage. When we change the voltage, a lot of things can happen. In order to avoid this kind of situation I need a device which will control the voltages. This device is called voltage regulator. This voltage regulator it works very efficient and simple: is taking any input voltage and outputs a regulated voltage. So if your battery is at 7V, then a 5V regulator will output 5V and a lot of heat to dissipate the unused energy.

To calculate wasted power, use this equation:

(input_voltage – output_voltage) * current = wasted power

(7V – 5V) * 200mA = .4W

In my project I have a battery which fully charge is at 4.7V and the voltage regulator will output a 3.3v constant.

Since microcontrollers and sensors typically do not consume a lot of current, the wasted energy isn’t that much. But in the case of the two motors, this can become a problem. A solution is to find out the total sum required power of all the components which was used and we need to keep the value below the amount your power circuit can supply. If power drops even for a second below, some components like the microcontroller could reset, or sensors would give bad readings, or motors won’t work very well.

Energy required by robot < energy battery can supply

In order to determine how much total power your robot will require by experimenting, calculating equations, and looking up datasheets on the parts you use.

Power = voltage * current

Batteries are never at a constant voltage this is why we always we choose a battery with higher voltages.

Linear regulator is a system used to maintain a steady voltage. “The resistance of the regulator varies in accordance with the load resulting in a constant output voltage. The regulating device is made to act like a variable resistor, continuously adjusting a voltage divider network to maintain a constant output voltage, and continually dissipating the difference between the input and regulated voltages as waste heat.”[15]

A voltage regulator is designed to automatically maintain a constant voltage level. The 7803 family is commonly used in electronic circuits requiring a regulated power supply due to their ease-of-use. The advantages of the 7803 series ICs do not require additional components to provide a constant, regulated source of power, making them easy to use, as well as economical and efficient uses of space. Other voltage regulators may require additional components to set the output voltage level, or to assist in the regulation process.7803 series ICs have built-in protection against a circuit drawing too much power. The disadvantages of the he input voltage must always be higher than the output voltage by some minimum amount.

Because the regulated voltage of a linear regulator must always be lower than input voltage, efficiency is limited and the input voltage must be high enough to always allow the active device to drop some voltage.

“As they are based on a linear regulator design, the input current required is always the same as the output current. As the input voltage must always be higher than the output voltage, this means that the total power (voltage multiplied by current) going into the 78xx will be more than the output power provided. The extra input power is dissipated as heat.”[16]

Fig.3.23 The pin configuration of the voltage regulator 3.3V (http://www.farnell.com/datasheets/610910.pdf )

[15] http://en.wikipedia.org/wiki/Linear_regulator

[16] http://en.wikipedia.org/wiki/78xx

In order to provide power to the voltage regulator we need a battery. Lithium polymer batteries (abbreviated Li-Po) are rechargeable (secondary cell) batteries of lithium ion technology in a pouch cell format. Li-Po batteries are usually composed of several identical secondary cells in parallel to increase the discharge current capability, and are often available in series "packs" to increase the total available voltage. In my project I used a Li-Po battery de 3, 7 V / 150 mAh (1 C)-that means it only have 1 cell. I choose this kind of battery because is a very small ((L x l x Î) 18 x 15 x 5 mm) and its weigh is around 5 g. The most important specifications are: Maximum discharge current short: 1A and has a maximum voltage: 3.7V. Due to the specifications it is a very good choice for my nano sumo robot.

When I decided what kind of battery I need I took in consideration the power and the voltage.

Battery voltages can be somewhat complicated. When fully recharged, a battery will often be 15% above its voltage rating. When fully discharged, about 15% below its rating. A fully charged battery will also immediately drop below its rating when driving heavy loads, such as a DC motor.

“Lithium (Li-ion) is the new standard for portable power. Li-ion batteries have the same high energy capacity as NiMHs, power output rates of NiCads, and weigh about 20%-35% less. They also have zero memory effect problems, meaning you can recharge whenever. “[17 ]Although lithium batteries are the most advanced for portable power, they are also usually the most expensive. Prices have been significantly dropping lately however, and I predict NiMH and NiCAD types soon becoming obsolete. They are made out of totally non-toxic material, making them safe for cute squirrels and pretty trees.Lithium ignites are large forms quantities of hydrogen when put in contact with water, so don't shoot at it or blow it up or anything of that nature. Also, fire extinguishers are usually water based, so don’t use them on lithium battery fires. Bad stuff will happen. There are also lithium polymer batteries. This battery type has extremely high current output capabilities (30A+), but less power density than lithium ion batteries.

Line sensor (IR)

“An infrared sensor is an electronic device that emits and/or detects infrared radiation in order to sense some aspect of its surroundings. Infrared sensors can measure the heat of an object, as well as detect motion. Many of these types of sensors only measure infrared radiation, rather than emitting it, and thus are known as passive infrared (PIR) sensors.”[18]

Infra-red sensors are broadly classified into two types:

Thermal infrared sensors – These use infrared energy as heat. Their photo sensitivity is independent of wavelength. Thermal detectors do not require cooling; however, they have slow response times and low detection capability.

Quantum infrared sensors – These provide higher detection performance and faster response speed. Their photo sensitivity is dependent on wavelength.

[17] http://www.societyofrobots.com/batteries.shtm l

[18] http://www.societyofrobots.com/batteries.shtml

Quantum detectors have to be cooled so as to obtain accurate measurements. The only exception is for detectors that are used in the near infrared region.

“All objects emit some form of thermal radiation, usually in the infrared spectrum. This radiation is invisible to our eyes, but can be detected by an infrared sensor that accepts and interprets it. In a typical infrared sensor like a motion detector, radiation enters the front and reaches the sensor itself at the center of the device.”[19] This part may be composed of more than one individual sensor, each of them being made from pyroelectric materials, whether natural or artificial. These are materials that generate an electrical voltage when heated or cooled.

We have already discussed how a light sensor works. IR Sensors work by using a specific light sensor to detect a select light wavelength in the Infra-Red (IR) spectrum. By using an LED which produces light at the same wavelength as what the sensor is looking for, you can look at the intensity of the received light. When an object is close to the sensor, the light from the LED bounces off the object and into the light sensor. This results in a large jump in the intensity, which we already know can be detected using a threshold.

Since the sensor works by looking for reflected light, it is possible to have a sensor that can return the value of the reflected light. This type of sensor can then be used to measure how "bright" the object it is. In the interior of the IR sensor we will find a phototransistor this is why when I make the design in EAGLE when I place the IR sensor for the line they would lock like a phototransistor.

Photo transistors are operated in their active regime, although the base connection is left open circuit or disconnected because it is not required. The base of the photo transistor would only be used to bias the transistor so that additional collector current was flowing and this would mask any current flowing as a result of the photo-action. For operation the bias conditions are quite simple. The collector of an n-p-n transistor is made positive with respect to the emitter or negative for a p-n-p transistor.

The light enters the base region of the phototransistor where it causes whole electron pairs to be generated. This mainly occurs in the reverse biased base-collector junction.

The hole-electron pairs move under the influence of the electric field and provide the base current, causing electrons to be injected into the emitter.

As already mentioned the photo transistor has a high level of gain resulting from the transistor action.

[19] http://www.wisegeek.org/what-is-an-infrared-sensor.htm

A further advantage of all phototransistors when compared to the avalanche photodiode, another device that offers gain, is that the phototransistor has a much lower level of noise.

One of the main disadvantages of the phototransistor is the fact that it does not have a particularly good high frequency response. This arises from the large capacitance associated with the base-collector junction.

The characteristics of the photo-transistor under different light intensities. They are very similar to the characteristics of a conventional bipolar transistor, but with the different levels of base current replaced by the different levels of light intensity.

“There is a small amount of current that flows in the photo transistor even when no light is present. This is called the dark current, and represents the small number of carriers that are injected into the emitter. Like the photo-generated carriers this is also subject to the amplification by the transistor action.”[20]

The circuit symbol also has the convention arrow and directions on the emitter connection. It points inwards on a PNP phototransistor circuit symbol and outwards on an NPN phototransistor symbol.

It can be seen that the phototransistor symbol shown does not give a base connection. Often the base is left disconnected as the light is used to enable the current flow through the phototransistor. In some instances the base may be biased to set the required operating point. In this case the base will be shown in the normal way on the phototransistor symbol.

Fig.3.24 Phototransistor sensor(http://learn.parallax.com/lightspectrum )

[20] http://www.radio-electronics.com/info/data/semicond/phototransistor/photo_transistor.php

I used for my nano sumo robot 2 IR sensors in order to detect the white line of the ring. One in each corner of the robot in each way that they will detect the white border of the ring. I positioned the sensors in each extremity in order to so that sensors are the first to see the white border of the ring. This IR sensor are very important in my strategy because when one of the sensor /or both of them detect the white border to the ring the robot will stop and tour around in such way he won’t leave the ring.

Proximity sensor or enemy sensor

The proximity sensor is a sensor able to detect the presence of nearby objects without any physical contact.

“A proximity sensor often emits an electromagnetic field or a beam of electromagnetic radiation (infrared, for instance), and looks for changes in the field or return signal. The object being sensed is often referred to as the proximity sensor's target. Different proximity sensor targets demand different sensors”[21]. For example, a capacitive or photoelectric sensor might be suitable for a plastic target; an inductive proximity sensor always requires a metal target.

“The maximum distance that this sensor can detect is defined "nominal range".”[22] Some sensors have adjustments of the nominal range or means to report a graduated detection distance.

Proximity sensors can have a high reliability and long functional life because of the absence of mechanical parts and lack of physical contact between sensor and the sensed object.

There are three types of proximity sensor: inductive, capacitive and magnetic. They can be either shielded or unshielded. Proximity sensors require almost no maintenance, and most are resistant to environmental contaminants and conditions.

When I select the proximity sensors, it is important to consider its operating distance and the object(s) being sensed. In many cases, the sensing distance varies with the object being sensed.

The sensing range typically listed for a sensor may not be accurate in certain environments or for certain materials, although most manufacturers can supply accurate information when the sensed material is specified. This is way before I brought them I read the information from the datasheet where I find all the information which was important for my project.

Infrared proximity switches work by sending out beams of invisible infrared light. A photo detector on the proximity switch detects any reflections of this light. These reflections allow infrared proximity switches to determine whether there is an object nearby.

[21] http://en.wikipedia.org/wiki/Proximity_sensor

[22] http://en.wikipedia.org/wiki/Proximity_sensor

As proximity switches with just a light source and photodiode are susceptible to false readings due to background light, more complex switches modulate the transmitted light at a specific frequency and have receivers which only respond to that frequency.

Even more complex proximity sensors are able to use the light reflected from an object to compute its distance from the sensor.

For my nano sumo robot I used 4 proximity IR sensors in order to detect the enemy. Two sensors I putted in front of the robot in order to detect the adversary when it is in front of him and the other two sensors I putted on each laterally face of the robot in order to detect more easily the enemy.

“The proximity IR sensor works by the process of triangulation. A pulse of light (wavelength range of 850nm +/-70nm) is emitted and then reflected back (or not reflected at all). When the light returns it comes back at an angle that is dependent on the distance of the reflecting object. Triangulation works by detecting this reflected beam angle – by knowing the angle, distance can then be determined. “[23]

The IR range finder receiver has a special precision lens that transmits the reflected light onto an enclosed linear CCD array based on the triangulation angle. The CCD array then determines the angle and causes the rangefinder to then give a corresponding *analog value to be read by your microcontroller. Additional to this, the proximity sensor circuitry applies a modulated frequency to the emitted IR beam. This ranging method is almost immune to interference from ambient light, and offers amazing indifference to the color of the object being detected. In other words, the sensor is capable of detecting a black wall in full sunlight with almost zero noise

The sensor I putted in the middle of the board in such way that they do not detect earth or different components from his body. For my robot I choose the” HSld-9100 proximity sensor which is an analog –output reflective sensor with an integrated high efficiency infrared emitter and photodiode housed in a small SMD package. I choose this model firstly for the small dimensions (Hight-2.40, width-2.75, length-7.10 mm).”[24]

Another important feature is that is has a very high efficiency emitter and high sensitivity photodiode for high signal to noise ratio and also the most important feature is that it can detect the object from near to zero to around 60mm which is more than enough for my nano sumo robot.

[23] http://www.societyofrobots.com/sensors_sharpirrange.shtml

[24] http://www.farnell.com/datasheets/1810537.pdf

Start/Stop module

Each round of Sumo match is started by an arbitrator by sending a start signal from an IR remote. When the robots get the signal round begins, it is a very efficient method because make the game more fair because it eliminates false start in comparison with compared with the old method in which the robot was turned on by the players and had a delay of 5 seconds before kickoff.

Fig.3.25 Start/stop module (http://www.robochallenge.ro/regulament-2014/106.html )

As we see in the picture above start/stop module consists of 4 pins one of the is VCC .The VCC pin it will be tie to pin of the power module, the other one is GND which will be tie to the ground, the other one is the start module which will be tie to the microcontroller. This is the pin which will give the signal which will start the module and the last pin is the Kill switch pin. This is a special pin because kill switch module is used to cut engine power as a precautionary measure. When the arbitrator sends the signal stop supplying motors must be cut. Builder’s robots are responsible for adding this robot mode. The module can provide the signal to activate the kill switch.

Fig.3.26 How to connect a kill switching module(http://www.robochallenge.ro/regulament-2014/106.html )

In my project I’ve put a start/stop module, but I didn’t use the kill switching pin because is it not mandatory.

4. Communication

4.1. Serial communication

In telecommunication and computer science, serial communication is the process of sending data one bit at a time, sequentially, over a communication channel or computer bus.

The serial communication is a digital communication type which use a very simplify protocol. “The word serial means "one after the other." Serial data transfer is when we transfer data one bit at a time, one right after the other.”[25] This is slower method than parallel communication, which allows the transmission of an entire byte at once; it is simpler and can be used over longer.

Information is passed back & forth between the computer and Arduino by, essentially, setting a pin high or low.

This type of communication it is used to transmit ASCII data. Communication is completed using 3 transmission lines: Ground, Transmit, and Receive. Since serial is asynchronous, the port is able to transmit data on one line while receiving data on another.

Another method is the Software Serial which is also a serial communication the difference being that in this case we don’t use the RX and TX pins of the microcontroller .In this method we use a specific library which will emulate the two digitals pins of the microcontroller.

A big advantage of the Software Serial method is that it can connect multiple serial devices. This kind of library is very easy to install and the only modification of the program is that we must declare the pins 10 and 11 as TX and RX and also to specific to the transmission rate (this can be found in the specification of the devices. Each device can have his specific data rate speed.

This method works very simple: any received character is written in Serial Monitor and any character that will be introduced in the serial monitor it will be sent on the emulation connection.

[25] http://www.ladyada.net/learn/arduino/lesson4.html

4.2 Bluetooth module

By using Bluetooth we can improve the performance of the robot by performing real time debugging. This debugging can be done on all sensors and in this way we can read the values and correct the errors in real time.

The name of the module was given after “Harald Bluetooth, the King of Denmark in the late 900's. He united Denmark and part of Norway.”[26]

The Bluetooth module is a “standardized protocol for sending and receiving data via a 2.4GHz wireless link. It’s a secure protocol, and it’s perfect for short-range, low-power, low-cost, wireless transmissions between electronic devices.”[27]

The Bluetooth module is a big part of that wireless revolution and it is used in mobile devices, laptops and other different types of devices.

In our days Bluetooth serves as an excellent protocol for transmitting relatively small amounts of data over a short range (<100m). It’s perfectly suited as a wireless replacement for serial communication interfaces.

Another important issue is the Bluetooth protocol which we uses. The Bluetooth protocol operates in the frequency range between 2.4-2.48 GHz in the same unlicensed ISM frequency band where RF protocols like ZigBee and Wi-Fi also exist. There is a standardized set of rules and specifications that differentiates it from other protocols. We can use the Bluetooth protocol for voice and data transmission. It is a very good choice to use the Bluetooth module for short distance (between 1-100m).

[26] http://ro.wikipedia.org/wiki/Bluetooth

[27] https://learn.sparkfun.com/tutorials/bluetooth-basics

4.2.1 Classes of Bluetooth

Bluetooth devices can be divided in three main classes. The best way to compare this kind of devices is by comparing the Output Power. A higher output power means a longer range. “This is way the Bluetooth was divvied in different categories according to the output power:

Class 1 – Long Range; Maximum Output Power of 100mW (20dBm)

It can be up to 100 meter range

Class 2 – Medium Range (the most common); Maximum Output Power of 2.5mW (4dBm)

It can be up to 10 meter range

Class 3 – Short Range (very rare); Maximum Output Power of 1mW (0dBm)

It can be up to ~1 meter range”[28]

4.2.2 Masters, Slaves, and Pico nets

The Bluetooth communication has been designed in order to connect several devices and compute a small network.

Bluetooth networks (commonly referred to as piconets) use a master/slave architecture model to control when and where devices can send data. A single master device can be connected to up to seven different slave devices. Only one connection is active while other connections are in a semi-active mode. Any slave device in the piconet can only be connected to a single master.

Fig.4.1 Master and slave architecture(https://learn.sparkfun.com/tutorials/bluetooth-basics/all )

[28] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

The master coordinates communication throughout the piconet. It can send data to any of its slaves and request data from them as well. Slaves are only allowed to transmit to and receive from their master. They can’t talk to other slaves in the piconet.

4.2.3 Bluetooth Addresses and Names

“Every single Bluetooth device has a unique 48-bit address, commonly abbreviated BD_ADDR. This will usually be presented in the form of a 12-digit hexadecimal value. The most-significant half (24 bits) of the address is an organization unique identifier (OUI), which identifies the manufacturer. The lower 24-bits are the more unique part of the address. This address should be visible on most Bluetooth devices. The “000666” portion of that address is the OUI of Roving Networks, the manufacturer of the module. Every RN module will share those upper 24-bits. The “422152” portion of the module is the more unique ID of the device.”[29]

Bluetooth devices can also have user-friendly names given to them. These are usually presented to the user, in place of the address, to help identify which device it is. The rules for device names are less stringent. They can be up to 248 bytes long, and two devices can share the same name. Sometimes the unique digits of the address might be included in the name to help differentiate devices.

4.2.4 Connection Process

Creating a Bluetooth connection between two devices is a multi-step process involving three progressive states:

Inquiry – If two Bluetooth devices know absolutely nothing about each other, one must run an inquiry to try to discover the other. One device sends out the inquiry request, and any device listening for such a request will respond with its address, and possibly its name and other information.

Paging (Connecting) – Paging is the process of forming a connection between two Bluetooth devices. Before this connection can be initiated, each device needs to know the address of the other (found in the inquiry process).

[29] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

Connection – After a device has completed the paging process, it enters the connection state. While connected, a device can either be actively participating or it can be put into a low power sleep mode.

Active Mode – This is the regular connected mode, where the device is actively transmitting or receiving data.

Sniff Mode – This is a power-saving mode, where the device is less active. It’ll sleep and only listen for transmissions at a set interval (e.g. every 100ms).

Hold Mode – Hold mode is a temporary, power-saving mode where a device sleeps for a defined period and then returns back to active mode when that interval has passed. The master can command a slave device to hold.

Park Mode – Park is the deepest of sleep modes. A master can command a slave to “park”, and that slave will become inactive until the master tells it to wake back up.

4.2.5 Bonding and Pairing

When two Bluetooth devices share a special affinity for each other, they can be bonded together. Bonded devices automatically establish a connection whenever they’re close enough. When I start up my car, for example, the phone in my pocket immediately connects to the car’s Bluetooth system because they share a bond. No UI interactions are required!

Bonds are created through one-time a process called pairing. When devices pair up, they share their addresses, names, and profiles, and usually store them in memory. The also share a common secret key, which allows them to bond whenever they’re together in the future.

Pairing usually requires an authentication process where a user must validate the connection between devices. “The flow of the authentication process varies and usually depends on the interface capabilities of one device or the other. Sometimes pairing is a simple “Just Works” operation, where the click of a button is all it takes to pair (this is common for devices with no UI, like headsets).”[30] Other times pairing involves matching 6-digit numeric codes. Older, legacy (v2.0 and earlier), pairing processes involve the entering of a common PIN code on each device. “The PIN code can range in length and complexity from four numbers (e.g. “0000” or “1234”) to a 16-character alphanumeric string.”[31]

Bluetooth profiles are additional protocols that build upon the basic Bluetooth standard to more clearly define what kind of data a Bluetooth module is transmitting. While Bluetooth specifications define how the technology works, profiles define how it’s used.

[30] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[31] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

The profile(s) a Bluetooth device supports determine(s) what application it’s geared towards. A hands-free Bluetooth headset, for example, would use headset profile (HSP), while a Nintendo Wii Controller would implement the human interface device (HID) profile. For two Bluetooth devices to be compatible, they must support the same profiles.

Serial Port Profile (SPP)

“If you’re replacing a serial communication interface (like RS-232 or a UART) with Bluetooth, SPP is the profile for you. SPP is great for sending bursts of data between two devices. It’s is one of the more fundamental Bluetooth profiles (Bluetooth’s original purpose was to replace RS-232 cables after all).”[32]

Using SPP, each connected device can send and receive data just as if there were RX and TX lines connected between them. Two Arduino, for example, could converse with each other from across rooms, instead of from across the desk.

HID is the go-to profile for Bluetooth-enabled user-input devices like mice, keyboards, and joysticks. It’s also used for a lot of modern video game controllers, like WiiMotes or PS3 controllers.

Fig. 4.2 Bluetooth connection using Arduino board(https://learn.sparkfun.com/tutorials/bluetooth-basics/all )

For my Nano sumo robot I used RN42 Bluetooth module with which I was able to do real-time debug and so I managed to check the operating parameters of the sensors.

“The RN42 is a small form factor, low power; highly economic Bluetooth radio for OEM’s adding wireless capability to their products. The RN42 supports multiple interface protocols, is simple to design in and fully certified, making it a complete embedded Bluetooth solution. The RN 42 is functionally compatible with RN 41.

With its high performance on chip antenna and support for Bluetooth® Enhanced “[33]

[32] https://learn.sparkfun.com/tutorials/bluetooth-basics/bluetooth-profiles

[33] https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf

Data Rate (EDR), the RN42 delivers up to 3 Mbps data rate for distances to 20M. The RN-42 also comes in a package with no antenna (RN-42-N).” [34]

Useful when the application requires an external antenna, the RN-42-N is shorter in length and has RF pads to route the antenna signal.

5. Programing part

The programming part is the most important and hard part when you build a robot.The programming part can be considered the process that leads from an original formulation of a computing problem to executable programs. It involves activities such as analysis, understanding, and generically solving such problems resulting using an algorithm, or different cases that lead to solving the problem.

Usually this is considered to be the easiest part in the construction of any robot, but as everyone who has ever built a robot especially a nano sumo will tell you; this is the hardest and most time consuming part. “The open-source Arduino environment makes it easy to write code and upload it to the I/O board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing, avr-gcc, and other open source software.”[35]

Because I build an autonomous I need to build a program which with the help of the sensors will take information from the environment and base on them it will be able to take he’s one own choices.

Autonomous robots can act on their own, independent of any controller. The basic idea is to program the robot to respond a certain way to outside stimuli.

When we speak about the autonomous robots we speak about artificial intelligence because the robot can compares the information and decides what the information is signifies for that specific task. Some modern robots also have the ability to learn in a limited capacity. Learning robots recognize if a certain action (moving its legs in a certain way, for instance) achieved a desired result (navigating an obstacle like the case of a line follower robot). The robot stores this information and attempts the successful action the next time it encounters the same situation.

First of all you have to declare all the pins you use, after which you have to create your own motor control functions.

[34] https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf

[35] http://arduino.cc/en/main/software

The syntax in which I declare the pins is: #define pin;

“The first step when we need to start the program is to set the data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200.In my project I need to set the data rate at the 9600 bits/per second.”[36]

The syntax is: void setup() {

Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

}

void loop() {}

After we declare the pins and set the data rate the next step is to read the sensors by using the following function “Serial1.read ()” and verify if the sensors are giving the correct values or they need calibration.

The motors are controlled by sending a command from the microcontroller to the motor driver which in turn gives you a current having a certain sense and voltage. In order to obtain this, you have to transmit a certain PWM signal to the motor driver, by using the AnalogWrite () function.

The differential drive algorithm is useful for light chasing robots. This locomotion is the most basic of all types it is also used by forklift, tanks etc.

In my project I place two motorized wheels, one on each side of the robot and the move commands to the motors are given by the motor driver.

5.1 The general algorithms which are apply in programming robots:

This is a basic pseudo- code for controlling the differential for my nano sumo robot is:

input sensor reading

make decision based on sensor reading

do one of below actions:

to drive straight both wheels move forward at same speed

to drive reverse both wheels move back at same speed

to turn left the left wheel moves in reverse and the right wheel moves forward

to turn right the right wheel moves in reverse and the left wheel moves forward

[36]http://arduino.cc/en/Serial/begin

The other part of the program is to interpret the light detecting sensors IR emitter/detectors, which are positioned two in from of the robot and the other two are positioned one on each side of the robot ,one on left side of my robot, the other located on the right side.

In my code, I have the microcontroller where I read the analog value from the 4 sensors. Then I do a comparison – the sensor that reads more light there is the direction where my robot should turn.

For example, if the left photoresistor reads more light than the right photoresistor, my robot should turn or tend towards the left. If both sensors read about the same value, meaning the both get the same amount of light, then my robot should drive straight.

Fig.5.1 Differential control using IR sensors(http://www.societyofrobots.com/images/programming_photoresistplan.jpg )

This is the following pseudo- code in order to search for the enemy in the ring:

read left_photoresistor

read right_photoresistor

if left_photoresistor detects more light than right_photoresistor

then turn robot left

if right_photoresistor detects more light than left_photoresistor

then turn robot right

if right_photoresistor detects about the same as left_photoresistor

then robot goes straight

loop

During the programming part I made some research on the internet by finding knew algorithm or knew strategies that can improve the robot. One of the algorithms was Fuzzy Logic control algorithm which is very similar with the original one, but instead of case-based it works under a more advanced and accurate information. It this type of algorithm my robot will no longer just have the three modes of turn left, turn right, and go forward. Instead will have commands like 'turn left by 10 degrees' or 'turn right really fast'.

This is the pseudo code in order to build the program:

read left_photoresistor

read right_photoresistor

left_motor = (left_photoresistor – right_photoresistor) * arbitrary_constant

right_motor = (right_photoresistor – left_photoresistor) * arbitrary_constant

loop

Photovore, Split Brain Approach

Photovore Split Brain Approach Is another type of algorithm which is not very accurate and can give I lot of errors because it works without comparison of photoresistor values. Instead, just command the right motor based on light from the left sensor, and the left motor with only data from the right sensor.

Fig. 5.2 Photovore Split Brain Approach (http://www.societyofrobots.com/images/programming_photoresistplan.jpg )

5.2. The specifics algorithms:

There are some programming algorithms which I used in my project in order to obtain a best programming code for my nano sumo robot:

The first one is the delay algorithm:

This technic it is use very offend in robotics because there are many cases where the robot must do more de two things in the same time. In this case we used the function “delay()” which will make the robot to execute only one command. Between the conditions if we put this function “delay()” that means between two consecutive condition it will be a short delay of milliseconds .

This method can be use when a sensor is activated and it is programmed to return a certain amount of time. By successive tests we can obtain the speed of the return and also we can find the position of enemy robot .This is helping us to direct the robot directly to enemy robot.

This method is very easy to be implemented, but it has a lot of disadvantages such as:

– Turnaround will not be the same because the battery will discharge. This is a problem that must be taken into account.

– It is possible that the adherence of the ring to be different in certain areas of which will rise the error-return of the robot. These adhesion problems can occur when the ring is not clean or the wheels are not clean, this is way in the competition the ring is clean after each game and also the wheels. These problems can affect a lot the behavior of the robot.

Fig.5.3 this represent “delay” method in the 3 stages

The second method that I used in my programming part is the function “millis”. It is very similar to the delay method, but it has the advantages that during the turns the robot can read with the other sensors. The output condition it is always a maximum time or if the sensors detect something it can interrupt the command. This method is very hard to implement but is more efficient then the delay method.

Fig.5.4.This represents “millis” method

3- The third method is called the PID method:

PID comes from Proportional-Integral-Derivative which is usually used in industrial control systems. It is a dynamic technique and it is used to control the power turbine of the central .This method but was adapted for the requirements of my robot. A PID controller computes an error as a difference between the measured process (the position of the line with respect to the sensor array) and a desired value (the center of the sensor array). The PID involves three variables, the proportional P which stores the present error, the integral I which is the accumulation of past errors and the derivative D which is a prediction of future errors.

The proportional, integral, and derivative terms are summed to calculate the output of the PID controller. “Defining u(t) as the controller output, the final form of the PID algorithm is:

Where:

K_p: Proportional gain, a tuning parameter

K_i: Integral gain, a tuning parameter

K_d: Derivative gain, a tuning parameter

e: Error = SP – PV

t: Time or instantaneous time “[37]

In our case it’s sufficient to use a PD controller, as the integral is an element with a very high influence on the output, and a lot of the time it has a negative impact on the output. In my project the equilibrium of the robot is the two sensors which are in front of the robot.

Fig.5.5.This represents the” PID” method

[37] http://en.wikipedia.org/wiki/PID_controller

One of the advantages of the method is that it takes all the sensor in consideration in the same time. This means that the robot it will always know where is the enemy place .If the sensors do not detect the enemy (the other robot) he can infer a possible position of the robot enemy. A very big disadvantage of this method is that is very hard to implement. Finding the constants (PID) can be very hard because every 0.1 modification of the values can completely change the behavior of the robot.

If the PID controller parameters (the gains of the proportional, integral and derivative terms) are chosen incorrectly, the controlled process input can be unstable, i.e., its output diverges, with or without oscillation, and is limited only by saturation or mechanical breakage. Instability is caused by excess gain, particularly in the presence of significant lag.

One of the heuristic tuning algorithms is formally known as the Ziegler–Nichols method and he states that in the beginning we must set the value 0 for Ki and K_d and K_p it will be increase until it will reaches the ultimate gain. When this value is found we must try to adjust the until we find the and other constants

Finding this values can take a lot of time and requires many tests in order to obtain the best values of the PID.

6. Results

During the faculty I participate at different national, international robotics competitions where I could where we could acquire knowledge but also many awards. Besides these contests I also participated in scientific communication session that took place in our faculty.

-The 2nd prize-at [anonimizat] section 12-1, Communication in English, in May 2012 with the theme "MINI SUMO ROBOT"

-Participation in [anonimizat] 12-1-Engineering section in English, in May 2013 on "LINE FOLLOWER ROBOT"

-The 2nd prize at International Robotics Contest "ROBOCHALLENGE" Issue 4 at the category “LINE FOLLOWER ENHANCED”

-Participation at the edition "ROBOCHALLANGE Vienna" 2013

-The 3rd prize at International Robotics Contest "ROBOCHALLENGE" Issue 6 at the category “MEGA SUMO” 2013

-Participation "ROBOCHALLANGE Romania" where 1st and 2nd prize at International Robotics Contest from ORADEA

-Participation at the edition "ROBOCHALLANGE Romania" 2014

7. Conclusions

The branch of robotics is a varied field and it is in a constant development. This technology will evolve and create faster and advance robots which will perform different task and in the end it will replace the hard work of the humans. The robots will also help the people to explore and improve different areas such as: medicine, military, industry etc.

The technology used to develop robots can be easily adapted to other devices or mechanisms that are not from the same area. An example is the SMT (Surface Mounted Technology) which can be found in different device such as: mobile phones, TVs, tablets, etc. This new technology because of his small packages the compounds are very small, but in the same time they are very highly preformats.

In this project I also use this kind of components which help me to improve my technical and theoretical knowledge about this new technology.

Building a Nano Sumo Robot it was complicated because I was force to appeals to all my knowledge about mechanics, electronics and programming.

In the end I was happy with the final product (the Nano Sumo Robot),but also with new knowledge that I have assimilated

References:

[1]http://definitions.uslegal.com/r/robotics/

[2] http://bowlesphysics.com/images/Robotics_-_A_historical_perspective.pdf

[3]http://www.robotchallenge.org/competition/

[4] https://solarbotics.com/download.php?file=158

[5] http://en.wikipedia.org/wiki/Microcontroller

[6]http://www.farnell.com/datasheets/1693866.pdf

[7] http://www.atmel.com/Images/doc8161.pdf /datasheet

[8] http://www.atmel.com/Images/doc8161.pdf /datasheet

[9] http://www.atmel.com/Images/doc8161.pdf /datasheet

[10]http://www.atmel.com/Images/doc8161.pdf /datasheet

[11] http://www.atmel.com/Images/doc8161.pdf /datasheet

[12] http://en.wikipedia.org/wiki/H_bridge

[13] http://www.share-pdf.com/2939b16adc574189a4f1c85fd2c41d87/PART%202.htm [point 2.6.5]

[14] http://www.pololu.com/product/399

[15] http://en.wikipedia.org/wiki/Linear_regulator

[16] http://en.wikipedia.org/wiki/78xx

[17] http://www.societyofrobots.com/batteries.shtml

[19] http://www.wisegeek.org/what-is-an-infrared-sensor.htm 18

[20] http://www.radio-electronics.com/info/data/semicond/phototransistor/photo_transistor.php

[21] http://en.wikipedia.org/wiki/Proximity_sensor

[22] http://en.wikipedia.org/wiki/Proximity_sensor

[23] http://www.societyofrobots.com/sensors_sharpirrange.shtml

[24] http://www.farnell.com/datasheets/1810537.pdf

[25] http://www.ladyada.net/learn/arduino/lesson4.html

[26] http://ro.wikipedia.org/wiki/Bluetooth

[27] https://learn.sparkfun.com/tutorials/bluetooth-basics

[28] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[29] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[30] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[31] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[32] https://learn.sparkfun.com/tutorials/bluetooth-basics/bluetooth-profiles

[33] https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf

[34] https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf

[35] http://arduino.cc/en/main/software

[36]http://arduino.cc/en/Serial/begin

[37] http://en.wikipedia.org/wiki/PID_controller

Other sources:

http://www.farnell.com/datasheets/1041607.pdf

http://www.farnell.com/datasheets/610910.pdf

http://www.farnell.com/datasheets/1825491.pdf

http://www.farnell.com/datasheets/1825492.pdf

http://www.onsemi.com/pub_link/Collateral/LB1836M-D.PDF

http://www.farnell.com/datasheets/1725706.pdf

http://www.farnell.com/datasheets/1716705.pdf

http://www.farnell.com/datasheets/1716705.pdf

http://www.farnell.com/datasheets/1810537.pdf

http://www.farnell.com/datasheets/1716705.pdf

http://www.robofun.ro/forum/

Anexa 2:

Code:

#define Dreapta 9

#define Dreaptafata 8

#define Dreaptaspate 7

#define Stanga 3

#define Stangafata 5

#define Stangaspate 4

int SLS, SLD;//SENZORI_LINIA

int SDD, SDS, SLAS, SLAD;//SENZORII_DUSMANII

int stanga = 0;

int dreapta = 0;

void set_motors(int MS, int MD){

if(MS>=0){

analogWrite(Stanga,MS);

digitalWrite(Stangafata,HIGH);

digitalWrite(Stangaspate,LOW);

}

if(MS<=0){

analogWrite(Stanga,MS*(-1));

digitalWrite(Stangafata,LOW);

digitalWrite(Stangaspate,HIGH);

}

if(MD>=0){

analogWrite(Dreapta,MD);

digitalWrite(Dreaptafata,HIGH);

digitalWrite(Dreaptaspate,LOW);

}

if(MD<=0){

analogWrite(Dreapta,MD*(-1));

digitalWrite(Dreaptafata,LOW);

digitalWrite(Dreaptaspate,HIGH);

}

}

void read_linie(){

SLS = analogRead(2);

SLD = analogRead(1);

}

void senzor_dusman(){

SDD = analogRead(0); // senzor dusman dreapta

SDS = analogRead(3); // senzor dusman stanga

SLAD = digitalRead(6); // senzor lateral dreapta

SLAS = digitalRead(12); // senzor lateral stanga

}

void setup(){

Serial.begin(9600);

pinMode(Stanga,OUTPUT);

pinMode(Stangafata,OUTPUT);

pinMode(Stangaspate,OUTPUT);

pinMode(Dreapta,OUTPUT);

pinMode(Dreaptafata,OUTPUT);

pinMode(Dreaptaspate,OUTPUT);

pinMode(2,INPUT);

pinMode(6,INPUT);

pinMode(12,INPUT);

}

void print_data(){

// Serial.print("SLS ");

// Serial.print(SLS);

// Serial.print(" ");

//

// Serial.print("SLD ");

// Serial.print(SLD);

// Serial.print(" ");

//

// Serial.print("SLAS ");

// Serial.print(SLAS);

// Serial.print(" ");

// Serial.print("SDS ");

// Serial.print(SDS);

// Serial.print(" ");

// Serial.print("SDD ");

// Serial.print(SDD);

// Serial.print(" ");

// Serial.print("SLAD ");

// Serial.print(SLAD);

// Serial.println(" ");

// delay(100);

}

void loop1(){

// while(digitalRead(2) == 0){

// senzor_dusman();

// if(SLAS == LOW)

// {stanga = 1;

// dreapta = 0;

// Serial.print("stanga ");

// Serial.print(stanga);

// Serial.print(" dreapta ");

// Serial.println(dreapta);

//

// }

// if(SLAD == LOW)

// {stanga = 0;

// dreapta = 1;

// Serial.print("stanga ");

// Serial.print(stanga);

// Serial.print(" dreapta ");

// Serial.println(dreapta);

// }

// Serial.print("stanga ");

// Serial.print(stanga);

// Serial.print(" dreapta ");

// Serial.println(dreapta);

// set_motors(0,0);

//// Serial.print("Stanga ");

Serial.print(stanga);

Serial.print(" Dreapta ");

Serial.println(dreapta);

// }

//

// read_linie();

// senzor_dusman();

// print_data();

// Serial.println(digitalRead(2));

//

//

// set_motors(0,50);

// delay(3000);

//// set_motors(0,-50);

//// delay(3000);

// set_motors(50,0);

// delay(3000);

// set_motors(-50,0);

// delay(3000);

// set_motors(50,50);

// delay(3000);

// set_motors(-50,-50);

// delay(3000);

//

//}

}

void loop(){

while(digitalRead(2) == 0){

senzor_dusman();

if(SLAS == LOW)

{stanga = 1;

dreapta = 0;}

if(SLAD == LOW)

{stanga = 0;

dreapta = 1;

}

set_motors(0,0);

// Serial.print("Stanga ");

Serial.print(stanga);

Serial.print(" Dreapta ");

Serial.println(dreapta);

}

// set_motors(70,70);

// while((SLAS == HIGH) && (SDS == HIGH) && (SDD == HIGH) && (SLAD == HIGH)){

while(digitalRead(2) == 1){

senzor_dusman();

read_linie();

// }

if((dreapta == 1) && (stanga == 0)){

// Serial.println("2");

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

// Serial.println(" verificare");

time1=millis();

set_motors(200,-200);

if((SDC == LOW) || (digitalRead(13) == LOW) || (SDS > 500) || (SDD > 500))//+linie

{dreapta=2;

break;

}

}

dreapta=2;

}

if((dreapta == 0) && (stanga == 1)){

// Serial.println("verificare");

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

// Serial.println("verificare");

time1=millis();

set_motors(-50,50);

if((SDC == LOW) || (digitalRead(13) == LOW) || (SDS > 500) || (SDD > 500))//+linie

{ stanga=2;

break;}

}

stanga=2;

}

if((SDC == HIGH) && (SDS < 200 ) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH) && (SLS < 100) && (SLD < 100)){

// Serial.println("cautare");

set_motors(70,70);

senzor_dusman();

read_linie();

}

//…………

if((SDC == LOW) && (SDS > 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 10 > time1){

read_linie();

senzor_dusman();

if((SLS > 200) || (SLD > 100) || (digitalRead(2) == LOW) || (SLAD == LOW) || (SLAS == LOW))//+linie

{break;}

// Serial.println("SDC SDS SDD");

time1=millis();

set_motors(70,70);

}

}

////…….

if((SDC == LOW) && (SDS > 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 150 > time1)

{

read_linie();

senzor_dusman();

if((SDD > 500) || (digitalRead(2) == LOW) || (SLS > 100) || (SLD > 100)|| (SLAD == LOW) || (SLAS == LOW))//+linie

{break;}

// Serial.println("SDC SDS ");

time1=millis();

set_motors(50,70);//50

}

}

////……………..

if((SDC == LOW) && (SDS < 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 150 > time1)

}

read_linie();

senzor_dusman();

if((SDS > 500) || (digitalRead(2) == LOW) || (SLS > 100) || (SLD > 100) || (SLAD == LOW) || (SLAS == LOW))//+linie

{break;}

// Serial.println(SDD");

time1=millis();

set_motors(70,50);

}

}

////……………..

if((SDC == HIGH) && (SDS > 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 10 > time1){//

read_linie();

senzor_dusman();

if((SLS > 100) || (SLD > 100) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW) || (SDC == LOW))//+linie

{break;}

// Serial.println("SDS SDD");

time1=millis();

set_motors(70,70);

}

}

////…………

if((SDC == LOW) && (SDS < 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 10 > time1){//incearca mai putine milisecunde

read_linie();

senzor_dusman();

if((SLS > 100) || (SLD > 100) || (digitalRead(2) == LOW) || (SLAD == LOW) || (SLAS == LOW) ||

(SDD > 200) || (SDS > 200))

{break;}

// Serial.println("SDS");

time1=millis();

set_motors(70,70);

}

}

////…….

if((SDC == HIGH) && (SDS > 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH))

{

//

time = time1 = millis();

while(time + 100 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (digitalRead(2) == LOW) || (SLAD == LOW) | (SLAS == LOW) || (SDD > 200) || (SLS > 200) || (SLD > 200))//+linie

{break;}

// Serial.println(" SDS ");

time1=millis();

set_motors(0,70);

}

}

//////……..

if((SDC == HIGH) && (SDS < 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 100 > time1){ // incearca mai putine milisecunde

read_linie();

senzor_dusman();

if((SDC == LOW) || (digitalRead(2) == LOW) || (SLAD == LOW) | (SLAS == LOW) || (SDS > 500) || (SLS > 100) || (SLD > 100))//+linie

{break;}

// Serial.println("SDD");

time1=millis();

set_motors(150,0);

}

}

//////………

if((SDC == HIGH) && (SDS < 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == LOW)){

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

if(((SDD > 200) && (SDC == LOW) && (SDS > 100)) || (digitalRead(2) == LOW) || (SLAD == LOW) || (SLS > 100) || (SLD > 100))//+linie

{break;}

// Serial.println("SLAS");

time1=millis();

set_motors(-200,200); //120

}

}

////………..

if((SDC == HIGH) && (SDS < 500) && (SDD < 500) && (SLAD == LOW) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

if(((SDD > 500) && (SDS > 500)) || (digitalRead(2) == LOW) || (SLAS == LOW) || (SLS >100) || (SLD > 100))//+linie

{break;}

// Serial.println("SLAD");

time1=millis();

set_motors(70,-70);//150

}

}

////…….

if((SLD > 100) && (SLS > 100)){

time = time1 = millis();

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 200) || (SDD > 200) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD SLS");

time1=millis();

set_motors(-70,-70);

}

time = time1 = millis();

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 200) || (SDD > 200) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD SLS");

time1=millis();

set_motors(70,-70);

}

}

//////………

if(SLS > 400){

time = time1 = millis()

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 500) || (SDD > 500) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLS");

time1=millis();

set_motors(-70,-70);

}

time = time1 = millis();

while(time + 150 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 500) || (SDD > 500) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLS");

time1=millis();

set_motors(70,-70);

}

}

if(SLD > 100){

time = time1 = millis();

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 200) || (SDD > 200) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD");

time1=millis();

set_motors(-70,-70);

}

time = time1 = millis();

while(time + 150 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 500) || (SDD > 500) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD");

time1=millis();

set_motors(-70,70);

}

}

}

}

unsigned long time=0;

unsigned lo

ng time1=0;

//int start = 13;

References:

[1]http://definitions.uslegal.com/r/robotics/

[2] http://bowlesphysics.com/images/Robotics_-_A_historical_perspective.pdf

[3]http://www.robotchallenge.org/competition/

[4] https://solarbotics.com/download.php?file=158

[5] http://en.wikipedia.org/wiki/Microcontroller

[6]http://www.farnell.com/datasheets/1693866.pdf

[7] http://www.atmel.com/Images/doc8161.pdf /datasheet

[8] http://www.atmel.com/Images/doc8161.pdf /datasheet

[9] http://www.atmel.com/Images/doc8161.pdf /datasheet

[10]http://www.atmel.com/Images/doc8161.pdf /datasheet

[11] http://www.atmel.com/Images/doc8161.pdf /datasheet

[12] http://en.wikipedia.org/wiki/H_bridge

[13] http://www.share-pdf.com/2939b16adc574189a4f1c85fd2c41d87/PART%202.htm [point 2.6.5]

[14] http://www.pololu.com/product/399

[15] http://en.wikipedia.org/wiki/Linear_regulator

[16] http://en.wikipedia.org/wiki/78xx

[17] http://www.societyofrobots.com/batteries.shtml

[19] http://www.wisegeek.org/what-is-an-infrared-sensor.htm 18

[20] http://www.radio-electronics.com/info/data/semicond/phototransistor/photo_transistor.php

[21] http://en.wikipedia.org/wiki/Proximity_sensor

[22] http://en.wikipedia.org/wiki/Proximity_sensor

[23] http://www.societyofrobots.com/sensors_sharpirrange.shtml

[24] http://www.farnell.com/datasheets/1810537.pdf

[25] http://www.ladyada.net/learn/arduino/lesson4.html

[26] http://ro.wikipedia.org/wiki/Bluetooth

[27] https://learn.sparkfun.com/tutorials/bluetooth-basics

[28] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[29] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[30] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[31] https://learn.sparkfun.com/tutorials/bluetooth-basics/all

[32] https://learn.sparkfun.com/tutorials/bluetooth-basics/bluetooth-profiles

[33] https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf

[34] https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf

[35] http://arduino.cc/en/main/software

[36]http://arduino.cc/en/Serial/begin

[37] http://en.wikipedia.org/wiki/PID_controller

Other sources:

http://www.farnell.com/datasheets/1041607.pdf

http://www.farnell.com/datasheets/610910.pdf

http://www.farnell.com/datasheets/1825491.pdf

http://www.farnell.com/datasheets/1825492.pdf

http://www.onsemi.com/pub_link/Collateral/LB1836M-D.PDF

http://www.farnell.com/datasheets/1725706.pdf

http://www.farnell.com/datasheets/1716705.pdf

http://www.farnell.com/datasheets/1716705.pdf

http://www.farnell.com/datasheets/1810537.pdf

http://www.farnell.com/datasheets/1716705.pdf

http://www.robofun.ro/forum/

Anexa 2:

Code:

#define Dreapta 9

#define Dreaptafata 8

#define Dreaptaspate 7

#define Stanga 3

#define Stangafata 5

#define Stangaspate 4

int SLS, SLD;//SENZORI_LINIA

int SDD, SDS, SLAS, SLAD;//SENZORII_DUSMANII

int stanga = 0;

int dreapta = 0;

void set_motors(int MS, int MD){

if(MS>=0){

analogWrite(Stanga,MS);

digitalWrite(Stangafata,HIGH);

digitalWrite(Stangaspate,LOW);

}

if(MS<=0){

analogWrite(Stanga,MS*(-1));

digitalWrite(Stangafata,LOW);

digitalWrite(Stangaspate,HIGH);

}

if(MD>=0){

analogWrite(Dreapta,MD);

digitalWrite(Dreaptafata,HIGH);

digitalWrite(Dreaptaspate,LOW);

}

if(MD<=0){

analogWrite(Dreapta,MD*(-1));

digitalWrite(Dreaptafata,LOW);

digitalWrite(Dreaptaspate,HIGH);

}

}

void read_linie(){

SLS = analogRead(2);

SLD = analogRead(1);

}

void senzor_dusman(){

SDD = analogRead(0); // senzor dusman dreapta

SDS = analogRead(3); // senzor dusman stanga

SLAD = digitalRead(6); // senzor lateral dreapta

SLAS = digitalRead(12); // senzor lateral stanga

}

void setup(){

Serial.begin(9600);

pinMode(Stanga,OUTPUT);

pinMode(Stangafata,OUTPUT);

pinMode(Stangaspate,OUTPUT);

pinMode(Dreapta,OUTPUT);

pinMode(Dreaptafata,OUTPUT);

pinMode(Dreaptaspate,OUTPUT);

pinMode(2,INPUT);

pinMode(6,INPUT);

pinMode(12,INPUT);

}

void print_data(){

// Serial.print("SLS ");

// Serial.print(SLS);

// Serial.print(" ");

//

// Serial.print("SLD ");

// Serial.print(SLD);

// Serial.print(" ");

//

// Serial.print("SLAS ");

// Serial.print(SLAS);

// Serial.print(" ");

// Serial.print("SDS ");

// Serial.print(SDS);

// Serial.print(" ");

// Serial.print("SDD ");

// Serial.print(SDD);

// Serial.print(" ");

// Serial.print("SLAD ");

// Serial.print(SLAD);

// Serial.println(" ");

// delay(100);

}

void loop1(){

// while(digitalRead(2) == 0){

// senzor_dusman();

// if(SLAS == LOW)

// {stanga = 1;

// dreapta = 0;

// Serial.print("stanga ");

// Serial.print(stanga);

// Serial.print(" dreapta ");

// Serial.println(dreapta);

//

// }

// if(SLAD == LOW)

// {stanga = 0;

// dreapta = 1;

// Serial.print("stanga ");

// Serial.print(stanga);

// Serial.print(" dreapta ");

// Serial.println(dreapta);

// }

// Serial.print("stanga ");

// Serial.print(stanga);

// Serial.print(" dreapta ");

// Serial.println(dreapta);

// set_motors(0,0);

//// Serial.print("Stanga ");

Serial.print(stanga);

Serial.print(" Dreapta ");

Serial.println(dreapta);

// }

//

// read_linie();

// senzor_dusman();

// print_data();

// Serial.println(digitalRead(2));

//

//

// set_motors(0,50);

// delay(3000);

//// set_motors(0,-50);

//// delay(3000);

// set_motors(50,0);

// delay(3000);

// set_motors(-50,0);

// delay(3000);

// set_motors(50,50);

// delay(3000);

// set_motors(-50,-50);

// delay(3000);

//

//}

}

void loop(){

while(digitalRead(2) == 0){

senzor_dusman();

if(SLAS == LOW)

{stanga = 1;

dreapta = 0;}

if(SLAD == LOW)

{stanga = 0;

dreapta = 1;

}

set_motors(0,0);

// Serial.print("Stanga ");

Serial.print(stanga);

Serial.print(" Dreapta ");

Serial.println(dreapta);

}

// set_motors(70,70);

// while((SLAS == HIGH) && (SDS == HIGH) && (SDD == HIGH) && (SLAD == HIGH)){

while(digitalRead(2) == 1){

senzor_dusman();

read_linie();

// }

if((dreapta == 1) && (stanga == 0)){

// Serial.println("2");

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

// Serial.println(" verificare");

time1=millis();

set_motors(200,-200);

if((SDC == LOW) || (digitalRead(13) == LOW) || (SDS > 500) || (SDD > 500))//+linie

{dreapta=2;

break;

}

}

dreapta=2;

}

if((dreapta == 0) && (stanga == 1)){

// Serial.println("verificare");

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

// Serial.println("verificare");

time1=millis();

set_motors(-50,50);

if((SDC == LOW) || (digitalRead(13) == LOW) || (SDS > 500) || (SDD > 500))//+linie

{ stanga=2;

break;}

}

stanga=2;

}

if((SDC == HIGH) && (SDS < 200 ) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH) && (SLS < 100) && (SLD < 100)){

// Serial.println("cautare");

set_motors(70,70);

senzor_dusman();

read_linie();

}

//…………

if((SDC == LOW) && (SDS > 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 10 > time1){

read_linie();

senzor_dusman();

if((SLS > 200) || (SLD > 100) || (digitalRead(2) == LOW) || (SLAD == LOW) || (SLAS == LOW))//+linie

{break;}

// Serial.println("SDC SDS SDD");

time1=millis();

set_motors(70,70);

}

}

////…….

if((SDC == LOW) && (SDS > 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 150 > time1)

{

read_linie();

senzor_dusman();

if((SDD > 500) || (digitalRead(2) == LOW) || (SLS > 100) || (SLD > 100)|| (SLAD == LOW) || (SLAS == LOW))//+linie

{break;}

// Serial.println("SDC SDS ");

time1=millis();

set_motors(50,70);//50

}

}

////……………..

if((SDC == LOW) && (SDS < 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 150 > time1)

}

read_linie();

senzor_dusman();

if((SDS > 500) || (digitalRead(2) == LOW) || (SLS > 100) || (SLD > 100) || (SLAD == LOW) || (SLAS == LOW))//+linie

{break;}

// Serial.println(SDD");

time1=millis();

set_motors(70,50);

}

}

////……………..

if((SDC == HIGH) && (SDS > 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 10 > time1){//

read_linie();

senzor_dusman();

if((SLS > 100) || (SLD > 100) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW) || (SDC == LOW))//+linie

{break;}

// Serial.println("SDS SDD");

time1=millis();

set_motors(70,70);

}

}

////…………

if((SDC == LOW) && (SDS < 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 10 > time1){//incearca mai putine milisecunde

read_linie();

senzor_dusman();

if((SLS > 100) || (SLD > 100) || (digitalRead(2) == LOW) || (SLAD == LOW) || (SLAS == LOW) ||

(SDD > 200) || (SDS > 200))

{break;}

// Serial.println("SDS");

time1=millis();

set_motors(70,70);

}

}

////…….

if((SDC == HIGH) && (SDS > 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == HIGH))

{

//

time = time1 = millis();

while(time + 100 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (digitalRead(2) == LOW) || (SLAD == LOW) | (SLAS == LOW) || (SDD > 200) || (SLS > 200) || (SLD > 200))//+linie

{break;}

// Serial.println(" SDS ");

time1=millis();

set_motors(0,70);

}

}

//////……..

if((SDC == HIGH) && (SDS < 200) && (SDD > 200) && (SLAD == HIGH) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 100 > time1){ // incearca mai putine milisecunde

read_linie();

senzor_dusman();

if((SDC == LOW) || (digitalRead(2) == LOW) || (SLAD == LOW) | (SLAS == LOW) || (SDS > 500) || (SLS > 100) || (SLD > 100))//+linie

{break;}

// Serial.println("SDD");

time1=millis();

set_motors(150,0);

}

}

//////………

if((SDC == HIGH) && (SDS < 200) && (SDD < 200) && (SLAD == HIGH) && (SLAS == LOW)){

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

if(((SDD > 200) && (SDC == LOW) && (SDS > 100)) || (digitalRead(2) == LOW) || (SLAD == LOW) || (SLS > 100) || (SLD > 100))//+linie

{break;}

// Serial.println("SLAS");

time1=millis();

set_motors(-200,200); //120

}

}

////………..

if((SDC == HIGH) && (SDS < 500) && (SDD < 500) && (SLAD == LOW) && (SLAS == HIGH)){

time = time1 = millis();

while(time + 300 > time1){

read_linie();

senzor_dusman();

if(((SDD > 500) && (SDS > 500)) || (digitalRead(2) == LOW) || (SLAS == LOW) || (SLS >100) || (SLD > 100))//+linie

{break;}

// Serial.println("SLAD");

time1=millis();

set_motors(70,-70);//150

}

}

////…….

if((SLD > 100) && (SLS > 100)){

time = time1 = millis();

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 200) || (SDD > 200) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD SLS");

time1=millis();

set_motors(-70,-70);

}

time = time1 = millis();

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 200) || (SDD > 200) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD SLS");

time1=millis();

set_motors(70,-70);

}

}

//////………

if(SLS > 400){

time = time1 = millis()

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 500) || (SDD > 500) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLS");

time1=millis();

set_motors(-70,-70);

}

time = time1 = millis();

while(time + 150 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 500) || (SDD > 500) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLS");

time1=millis();

set_motors(70,-70);

}

}

if(SLD > 100){

time = time1 = millis();

while(time + 200 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 200) || (SDD > 200) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD");

time1=millis();

set_motors(-70,-70);

}

time = time1 = millis();

while(time + 150 > time1){

read_linie();

senzor_dusman();

if((SDC == LOW) || (SDS > 500) || (SDD > 500) || (SLAD == LOW) || (SLAS == LOW) || (digitalRead(2) == LOW))

{break;}

// Serial.println("SLD");

time1=millis();

set_motors(-70,70);

}

}

}

}

unsigned long time=0;

unsigned lo

ng time1=0;

//int start = 13;

Similar Posts