You are on page 1of 69

1

Work Team: 1- RanaMamdouhMostafa 2- FadyNashaatAttallah 3- Peter Jimmy Samy 4- David Samir Farid 5- Amr Adel Sabry 6- George Ashraf Attia

Supervised by: Prof. Dr. Abo Bakr A. Nasr Prof. Dr. Hany El-Beblawy Prof. Dr. Abo El-Makarem A. Khalil Dr. Alaa Abdel-Hakim

Acknowledgments
Via this acknowledgement we want first to thank ALLAH who helps us usually and leads us to the best ways. Also we want to send many thanks to our supervisors for their continuously supporting and encourage us. They were the source of science and experience. Also we want to thank the engineers, our grand brothers for their time and efforts and experience and we pray to ALLAH to help them in their researches. We can't also forget our families we thanks them very much for their support along our long way from the school to the university.

Abstract
This project is one of Assiut Mechatronics section graduation projects for the year 2013. The main purpose of this project is to design mobile robot contain real time mapless control system ,obstacle avoidance module applied on labVIEW

Mobile robotics is a young field. Its roots include many engineering and science disciplines, from mechanical, electrical and electronics engineering to computer, cognitive and social sciences. In mobile robotics, we need to understand the mechanical behavior of the robot both in order to design appropriate mobile robots for tasks and to understand how to create control software for an instance of mobile robot hardware. Of course, mobile robots are not the first complex mechanical systems to require such analysis. Robot manipulators have been the subject of intensive study for more than thirty years. In some ways

Table of contents
Chapter 1: Introduction Chapter 2:Table 's mechanical structure Chapter3 Tables electric & electronic components Chapter4Tables programming & control Chapter 5:Robot's mechanical structure Chapter6 Robots electric &electronic components Chapter7Robot'sInterfacing and wiring Chapter8Robot's Navigation Chapter9 Robot 'sprogramming& control Chapter 10 Appendixes

Chapter 1 Introduction
1.1 Mechatronics Definition:
Mechatronics is the synergistic combination of mechanical engineering, electronic engineering, control engineering, systems design engineering, and computer engineering to create useful products. The purpose of this interdisciplinary engineering field is the study of automata from an engineering perspective and serves the purposes of controlling advanced hybrid systems. The word itself is a combination of 'Mechanics' and 'Electronics'. Figure 1.1 shows the Mechatronics description illustrative system.

1.2 Mechatronics Applications:


Servo-mechanics. Sensing and control systems. Automotive engineering, in the design of subsystems such as anti-lock braking systems. Computer engineering, in the design of mechanisms such as computer drives. Computer-machine controls, such as computer driven machines, IE CNC milling machines.

1.3 Aim of the Project:design the mobile robot using mechatronics approach . Objectives:1- Design mechanical body of mobile robot 2- Studying different solutions for basic motion problem 3- Build real time maples control system on LabVIEW 4- Comparing the analytical results and the experimental measurements. 5- Simulate the system using matlab software package 6- Build obstacle avoidance module to avoid dynamic, static obstacle s

Chapter 2 : Table 's mechanical structure

In this chapter we will have a look on two important parts :1st : The Design of our Project : that includes the design of the tables and the materials which were used for the implementation of there designs. 2nd : The mechanical components used in our project: we will learn about the different types of mechanical components and we'll explain the components that were used in the project. In the next pages we will discuss each part in details.

2.1 The Design of the Project:The Design Consists of two Parts: 1-Design of the tables. let's start with the Design of table no.1

Elevation:

Plan: Left Hand Side Side View: `

10

1- Another deign for table That table have different design, the table have three parts. the first be in the top ,that is the door will open and close automatic by switches in the top. when the door is open the touch screen will appear ,after you finish the order the door will close. The second part in the med ,that have the bed for the screen, the rod and his motor. the rod and his motor those can open or close the door ,as the door is connected to the rod from the 4 corners. The third part that the box that have the control circuit and the power converter. And after that the table is normal.

11

2.2How does table no.1 work ?


Table no.1 has a gate of 40 cm 40 cm which is opened manually and allows a touch screen to be put inside the table. The touch screen is to be put on a Z-mechanism which is responsible for moving the touch screen up and down form inside of the table to the outside. This mechanism is using a Power Screw which is connected to a DC Motor via Fixed Coupling. When a Push botton is pressed the DC motor starts to rotate so the power screw will also moveupwards till it hits a limit switch and the DC motor stops. Another Push botton is pressed so that the DC motor starts to rotate again but in the reverse direction and the Z-mechanism will move downwards till it hits a limit switch inside the table and the DC motor will stop.

12

2.3The Z-Mechanism "Scissor Mechanism":There are many ways to let the touch screen moves up and down as in the following : Our design:

Elevation " All Dimensions in cm " :-

13

2.4 Power Screws:A leadscrew (or lead screw), also known as a power screw or translation screw, is a screw used as a linkage in a machine, to translate turning motion into linear motion. Because of the large area of sliding contact between their threads, screws have larger frictional energy losses compared to other linkages. Leadscrews are manufactured in the same way as other thread forms. A lead screw can be used in conjunction with a split nut. there are different types of power screws like

Types of Power Screws :1-Square Thread Form: The square thread form is a common thread form for leadscrews. It gets its name from the square crosssection of the thread. The greatest disadvantage of it is the difficulty in machining such a thread.

14

2-Buttress Thread Form: The buttress thread form, also known as the breech-lock thread form, refers to two different thread profiles. However the resulting thread form has the same low friction properties as a square thread form but at about twice the shear strength due to the long thread base. 3-Acme Thread Forms: Trapezoidal thread forms are screw thread profiles with trapezoidal outlines. They are the most common forms used for leadscrews(power screws). | we use Acme types beacauseof it offers high strength and ease of manufacture. It is typically found where large loads or high accuracy are required, as in a vise or the leadscrew of a lathe.

15

Coupling:-

A coupling is a device used to connect two shafts together at their ends for the purpose of transmitting power. ` The primary purpose of couplings is to join two pieces of rotating equipment while permitting some degree of misalignment or end movement or both. By careful selection, installation and maintenance of couplings, substantial savings can be made in reduced maintenance costs and downtime. Now we will compare between most common types of coupling and we will show why we choose flange type

Types of Coupling:1-flange Coupling: A flange coupling is a unit of hardware It used to connect two separate systems, it also used to reduce shock and wear at the point where the shafts meet.

16

2-Flexible Coupling:-

Flexible couplings are used to transmit torque from one shaft to another when the two shafts are slightly misaligned. Flexible couplings can accommodate varying degrees of misalignment up to 3 and some parallel misalignment. In addition, they can also be used for vibration damping or noise reduction. `When joining shafts within a machine, mechanics can choose between flexible and rigid couplings. While flexible units offer some movement and give between the shafts, rigid couplings are the most effective choice for precise alignment and secure hold. By precisely aligning the two shafts and holding them firmly in place, rigid couplings help to maximize performance and increase the expected life of the machine. Requirements of good coupling setup:1- it should be easy to connect or disconnect the coupling. 2- it does allow some misalignment between the two adjacent shaft rotation axes. 3- it is the goal to minimise the remaining misalignment in running operation to maximise power transmission and to maximise machine runtime (coupling and bearing and sealings lifetime). 4- it should have no projecting parts.

17

Chapter3 Tables electric & electronic components

A DC motor is a mechanically commutated electric motor powered from direct current (DC). The stator is stationary in space by definition and therefore its current. The current in the rotor is switched by the commutator to also be stationary in space. This is how the relative angle between the stator and rotor magnetic flux is maintained near 90 degrees, which generates the maximum torque.

Motor Specifications

Volt: 12 Rated Current: 900 ma Reduction ratio: 1/51 Rated Torque: 3.4 kg.cm Rated RPM: 117 Output Power: 7 Watt Encoder Resolution= 7 pulse Encoder Pulses Per One Revolution= 7x 51 (gear Ratio)= 357 Weight:110gm

18

H-bridge 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. H bridges are available as integrated circuits, or can be built from discrete components.

Spicifications

Driver power supply: +5V~+46V Driver output current: 2A Max power: 25W (Temperature 75 celsus) Working temperature: -25C~+130C

19

Arduino Uno Microcontroller ATmega328 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limits) 6-20V Digital I/O Pins 14 (of which 6 provide PWM output) Analog Input Pins 6 DC Current per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA Flash Memory 32 KB of which 0.5 KB used by bootloader SRAM 2 KB EEPROM 1 KB Clock Speed 16 MHz

20

Push button A push-button (also spelled pushbutton) or simply button is a simple switch mechanism for controlling some aspect of a machine or a process. Buttons are typically made out of hard material, usually plastic or metal. The surface is usually flat or shaped to accommodate the human finger or hand, so as to be easily depressed or pushed. Buttons are most often biased switches, though even many un-biased buttons (due to their physical nature) require a spring to return to their un-pushed state. Different people use different terms for the "pushing" of the button, such as press, depress, mash, and punch.

Specifications Operating voit 24 v Current 5 A Dominion 4 X1.5 cm

21

Chapter4 Tables programming & control

FLOW CHART

22

Chapter5 Robotsmechanical structure


5.1 The Design of the Robot :Material selection :when we start selecting material we give an attention to robot weight because the motion of any moving body affected with it is weight in addition to another efforts we choose steel with thickness 3 mm to achieve hard ,non-deformable body

5.2

The Robot consists of two parts :

1- The Upper Part of the Robot. 2- The Robot's Base.

23

1st : The upper part of the Robot : " All Dimensions in cm "

Elevation:

Plan:

24

The Robot's Base : " All Dimensions in cm "

25

5.3 How does the robot work ?


After the food order is prepared, it is put on the Robot's surface and the 3`wheeled robot delivers the food order to the desired table. The movement of the robot from the kitchen to the table and vice versa depends on map less Navigation System. when the robot reaches the table a DC motor is responsible for the movement of robot's arms forward and backward so the food order is delivered. Rack and pinion are used to transport movement form the DC motor to the robot's arms which are mechanical sliders. the Rack is welded to one of the mechanical sliders. the client will have to lift the food dish from robot's surface to wherever he/she wants on the table.

26

5.4 The Mechanical Components :-

1st-Mechanical Slider:
Two mechanical sliders are used as robot arms for moving the food dish forward and backward using a DC motor.

2nd - Gears:
A gear or cogwheel is a rotating machine part having cut teeth, or cogs, which mesh with another toothed part in order to transmit torque, in most cases with teeth on the one gear of identical shape, and often also with that shape (or at least width) on the other gear. It used to change the speed, torque, and direction of a power source. Rack and Pinion: A rack is a toothed bar or rod that can be thought of as a sector gear with an infinitely large radius of curvature. Torque can be converted to linear force by meshing a rack with a pinion: the pinion turns; the rack moves in a straight line.

27

Such a mechanism is used in automobiles to convert the rotation of the steering wheel into the left-to-right motion of the tie rod(s).racks also feature in the theory of gear geometry, where, for instance, the tooth shape of an interchangeable set of gears may be specified for the rack (infinite radius), and the tooth shapes for gears of particular actual radii are then derived from that. The rack and pinion gear type is employed in a rack railway.

28

Chapter6 Robot 'selectric& electronic components


6.1 Sensors
Ultrasonic Sensor Module

Specifications Supply Voltage 5 V Current Consumption 15 mA Ultrasonic Frequency 40 KHZ Maximum Range 400 cm Minimum Range 3 cm Resolution 1 cm Trigger Pulse width 10 s Dimension 43x20x15mm

Limit Switch
Material: Plastic Max. Voltage: 250 V Max. Current: 20 A Dimensions: 28.0 x 15.5 x 9.5 mm

29

6.2 Actuators
Dc motor

Reduction ratio 1:24 Rated torque 10 kg .cm Rated speed 248 rpm <2300 mA Rated Current 292 rpm No Load Speed <650 mA No Load Current Built in magnetic encoder Voltage supply 3.5 -20 v Supply current 10 mA

30

DC Motor Driver
MD10C is an enhanced version of the MD10B which is designed to drive high current brushed DC motor up to 10A continuously. It offers several enhancements over the MD10B such as support for both locked-antiphase and signmagnitude PWM signal as well as using full solid state components which result in faster response time and eliminate the wear and tear of the mechanical relay. Bi-directional control for 1 brushed DC motor. Support motor voltage ranges from 3V to 25V. Maximum current up to 10A continuous and 15A peak (10 second). 3.3V and 5V logic level input. Solid state components provide faster response time and eliminate the wear and tear of mechanical relay. Dimension:75mm x 43mm

31

6.3 controller
Arduino mega
Arduinois a single-board microcontroller designed to make the process of using electronics in multidisciplinary projects more accessible. The hardware consists of a simple open source hardware board designed around an 8-bit AtmelAVR microcontroller, though a new model has been designed around a 32-bit Atmel ARM. The software consists of a standard programming language compiler and a boot loader that executes on the microcontroller.

32

Chapter7 Robot 'sInterfacing and wiring


System wiring in very important to achieve desired response Here are some remarks to achieve prefect model 1- When we connect the same components we should use the same color of wires 2- Make sure all the wires are covered to avoid short circuit 3- To avoid we must use bridges 4- Use pluggable connection is better than rigid connection ,it is simple safety because it can not reflected 5- Power wire should have large cross section however signal wire can have small cross section 6- Shortest component should welded first

Simple wiring diagram

33

Actual wiring diagram

34

Chapter8 : Robot's Navigation


8.1 Mobile Robot Workspace
A mobile robots workspace is important because it defines the range of possible poses that the mobile robot can achieve in its environment. The mobile robot controllability defines the manner in which active engagement of motors can be used to move from pose to pose in the workspace. In ather words controllability defines possible paths and trajectories in its workspace. Robot dynamics places additional constraints on workspace and trajectory due to mass and force considerations. the mobile robot is also limited by dynamics; for instance, a high center of gravity limits the practical turning radius of a fast, car-like robot because of the danger of rolling.

8.2Locomotion
A mobile robot needs locomotion mechanisms that enable it to move unbounded throughoutits environment. But there are a large variety of possible ways to move, and so the selectionof a robots approach to locomotion is an important aspect of mobile robot design. In the laboratory, there are research robots that can walk, jump, run, slide, skate, swim, fly,and, of course, roll. Most of these locomotion mechanisms have been inspired by their biologicalcounterparts (jumping ,running ,crawl ,sliding )

35

Owing to these limitations, mobile robots generally loco mote either using wheeled mechanisms, a well-known human technology for vehicles, or using a small number of articulated legs, our robot is simple differential wheeled robot

36

8.3 Basic motion problem


There are two different methods used to solve motion problem 1- Mapping For a robot, an animal, and even for man, to be able to use an internal representation of the spatial layout of its environment to position itself is a very complex task, which raises numerous issues of perception, categorization and motor control that must all be solved in an integrated manner to promote survival.so we use the other method 2- Maples Using this method mobile robot follow a trajectory described by its position or velocity profile as a function of time. This is often done by dividing the trajectory (path) The control problem is thus to recomputed a smooth trajectory which drives the robot from the initial position to the final position We can divide maples method into 3 subsystems according to elementary motion task

In our project we apply two of three sub_systems ,point to _point motion ,trajectory tracking

37

8.4 Requirements for Motion Control


1- Kinematic model of the robot 2- dynamic model of the robot 3- Model of the interaction between the wheel and the ground 4- Definition of required motion and speed control, position control 5- Control law that satisfies the requirements

38

1-

Kinematic model of the robot

Deriving a model for the whole robots motion is a bottom-up process. Each individual wheel contributes to the robots motion and, at the same time, imposes constraints on robot motion. Wheels are tied together based on robot chassis geometry, and therefore their constraints combine to form constraints on the overall motion of the robot chassis But the forces and constraints of each wheel must be expressed with respect to a clear and consistent reference frame. This is particularly important in mobile robotics because of its self-contained and mobile nature; a clear mapping between global and local frames of reference is required. Representing robot position Throughout this analysis we model the robot as a rigid body on wheels, operating on a horizontal plane. The total dimensionality of this robot chassis on the plane is three, two for position in the plane and one for orientation along the vertical axis, which is orthogonal to the plane. In order to specify the position of the robot on the plane we establish a relationship between the global reference frame of the plane and the local reference frame of the robot,

39

To describe robot motion in terms of component motions, it will be necessary to map motion along the axes of the global reference frame to motion along the axes of the robots local reference frame. Of course, the mapping is a function of the current pose of the robot. This mapping is accomplished using the orthogonal rotation matrix:

This matrix can be used to map motion in the global reference frame to motion in terms of the local reference frame . This operation is denoted by because the computation of this operation depends on the value of

In another term establish the robot speed the wheel speeds , steering angles parameters of the robot (configuration coordinates). , steering speeds

as a function of and the geometric

40

Mathematical modeling The actuating machines most used in mechatronics motion control systems are DC machines (motors). The mobile platform motion control can be simplified to a DC motor motion control. In modeling DC motors and in order to obtain a linear model, the hysteresis and the voltage drop across the motor brushes is neglected, the motor input voltage, Vin maybe applied to the field or armature terminals . Considering that system dynamics and disturbance torques depends on platform shape and dimensions, as well as, environment and the road conditions.

I.

Basic electric motor modeling

The PMDC motor open loop transfer function without any load attached relating the input voltage, Vin(s), to the output angular velocity, (s), is given by Eq(1). The total equivalent inertia, Jequiv and total equivalent damping, bequiv at the armature of the motor , for simplicity, the mobile robot can be considered to be of cuboide shape, with the inertia calculated ,correspondingly, the equivalent mobile robot system transfer function with gear ratio, n,

41

42

II. Sensor modeling encoder is a sensor used to measure the actual output angular position , in which of position derivative is angular velocity , Dynamics of encoder and the transfer function can be represented using the following equation:

III.

Ultrasonic modeling

The basic principle of an ultrasonic sensor is to transmit a packet of (ultrasonic) pressure waves and to measure the time it takes for this wave packet to reflect and return to the receiver. Vout = K * d

43

2.Dynamics modeling of mobile robot


When deriving an accurate mathematical model for mobile system it is important to study and analyze dynamics between the road, wheel and platform considering all the forces applied upon the mobile platform system. (Farhan A. Salem , 2013) introduce accurate modeling and simulation of mobile robotic platform dynamics, including most acting forces that is categorized into road-load and tractive force. The road-load force consists of the gravitational force, hill-climbing force, rolling resistance of the tires , the aerodynamic drag force and the aerodynamics lift force, Equations derived by (Farhan A. Salem , 2013), that describes DC motor system dynamics and sensor modeling, the next open loop transfer function, relating the armature input terminal voltage, Vin(s) to the output terminal voltage of the encoder Vencoder (s), with most load torques applied are considered

To characterize the current localization of the mobile robot in its operational space of evolution a 2D plane (x,y), we must define first its position and its orientation. Assuming the angular orientation (direction) of a wheel is defined by angle , between the instant linear velocity of the mobile robot v and the local vertical axis . The linear instant velocity of the mobile robot v , is a result of the linear velocities of the left driven wheel vL and respectively the right driven wheel vR . These two drive velocities vL and vR are permanently two parallel vectors and, in the same time, they are permanently perpendicular on the common mechanical axis of these two driven wheels. When a wheel movement is restricted to a 2D plane (x,y), and the wheel is free to rotate about its axis (x axis), the robot exhibits preferential rolling motion in one direction (y axis) and a certain amount of lateral slip , the
44

wheelmovement ( speed) is the product of wheel's radius and angular speed and is directly proportional by the angular velocity of the wheel, and given by : while the wheel is following a path and having no slippery conditions, the velocity of the wheel at a given time, has two velocity components with respect to coordinate axes X and Y.

Assuming the mobile robot follows a circular trajectory shown in Figure 3, and s , and R are the arc distance traveled by the wheel, and its respective orientation with respect to the global coordinates, and R is the circumference radius of the wheel, then the linear and angular velocities of the mobile robot are given by in time equal to , is given by invcrsc of the radius R is given by then we have the arc distance traveled

and the curvature ,that is the assuming the time is so small

45

The instantaneous center of curvature (ICC ) is the point the robot must rotate around it to avoid slippage and have only apure rolling motion .ICC lied on the common axis of the two driving wheels .In case of differential drive by changing the velocities VL VR of the two left and right wheels . the ICC of rotation will move and different trajectories will be followed at each time left and right wheels ,moves around the ICC with the same angular speed rate

Where R is distance between ICC point and to midpiont P between the two wheels

Because the vectors for linear speed of wheels L and R are orthogonal on the common axis of the driven wheels, we can write an equation to represent the angular velocity of the robot

the instant linear velocity of the mobile robot Vmob is attached and defined relative to the characteristic point P , this velocity is a result of the linear
46

velocities of the left driven wheel VL and respectively the right driven wheel VR these two drive velocities VLVVR are permanently two parallel vectors and in the same time they are permanently perpendicular on the common mechanical axis of these two driven wheels

A differential drive mobile robot is very sensitive to the relative velocity of the two wheels where for VRVL then the radius R is infinite and the robot moves in a straight line if VRVL then the radius R is zero and the robot rotates around robot center point P .If VRVL the robot follows a curved trajectory around an ICC Point located at a distance R from robot center point P the curvature which is the inverse of the radius R is given by

The arc length ,distance ,traveled by the mobile robot (point P ) is the average of arces lengths traveled by the two driven wheels and given by

Correspondingly ,the center oriention angle of the trajectory is given by

47

3-Model of the interaction between the wheel and the ground

Our robot move on a horizontal plane in which there is only one point contact also our robot wheels are not deformable which mean Pure rolling (vc = 0 at contact point ) There is no slipping, skidding or sliding also there is no friction for rotation around contact point the Steering axes orthogonal to the surface Wheels connected by rigid frame (chassis)

48

4- Definition of required motion and speed control, position control


We have two levels of control high level one is real time control applied on labVIEW which purely kinematic_ based with velocity commands and low level one is microprocessor based controller arduino which digital at high frequency ,so we can draw two different block diagrams

49

50

5- (Potential Fields and Model Predictive Control)


OussamaKhatib, 1986. robot moves in a field of forces. ,The position to be reached is aattractive pole for robot and obstacles are repulsive surfaces for robot

Potential field methods are rapidly gaining popularity in obstacle avoidance applications for mobile robots and manipulators. While the potential field principle is particularly attractive because of its elegance and simplicity, substantial shortcomings have been identified as problems that are inherent to this principle. Based upon mathematical analysis,

During the past few years, potential field methods (PFM) for obstacle avoidance have gained increased popularity among researchers in the field of robots and mobile robots. The idea of imaginary forces acting on a robot has been suggested by Andrews and Hogan [1983] and Khatib [1985]. In these approaches obstacles exert repulsive forces onto the robot, while the target applies an attractive force to the robot. The sum of all forces, the resultant force R, determines the subsequent direction and speed of travel

51

. Robot-Environment Mathematical Analysis To analyze the behavior of the mobile robot in the presence of obstacles, first we introduce a differential equation that describes the robot's motions as affected by the environment. This equation is based on combining the steering system model with environmental parameters. The basic model for the robot's steering motor is a first-order differential equation

This sets up a goal as a circle with radius r. When the agent reaches the goal no forces from the goal act upon it, whence when d < r both x and y are set to zero. The field has a spread of s and the agent reaches the extent of this field when d = s + r. Outside of this circle of extent, the vector magnitude is set to the maximum possible value. Within this circle of extent but outside of the goal's radius, the vector magnitude is set proportional to the distance between the agent and the goal. I include the constant >0 so that the strength of the field can be easily scaled. For the development of the robot environment model, we assume that the robot travels on one side of a long obstacle, with the objective to reach a target located on the other side of the obstacle, Since the object is long, the repulsive force has only a lateral component in the direction of X

52

Vector field of actuator values computed from the potential field in Fig. 1. Black circles represent obstacles

Potential Field disadvantages We faced the following 4 significant problems that are inherent to PFMs and independent of the particular implementation: 1. Trap situations due to local minima (cyclic behavior). Perhaps the best-known and most often-cited problem with PFMs is the problem of local minima or trapsituations [Andrew and Hogan, 1983; Tilove, 1989]. A trap-situation may occur when the robot runs into a dead end (e.g., inside a U-shaped obstacle). Traps can be created by a variety of different obstacle configurations, and different types of traps can be distinguished. However, trap-situations can be resolved by heuristic or global recovery.

53

2. No passage between closely spaced obstacles. a mobile robot at an attempt to pass among two closely spaced obstacles (e.g., passing through a door frame). With PFMs, the repulsive forces from obstacle 1 and 2 are combined into the two lumped repulsive forces F' and F' , respectively. The sum of all repulsive forces (F =F' +F' ) points straight away r1 r2 r r1 r2 from the opening between the two obstacles. Depending on the relative magnitude of the targetdirected force F, the robot will either approach the opening further, or it will turn away

3. Oscillations in the presence of obstacles. One of the most significant limitations of potential field methods is their tendency to causeunstable motion in the presence of obstacles. When the robot travels alongside the obstacleunder steady state conditions, the sum of the lateral forces is zero 4_ Oscillations in narrow passages. A similar yet more severe problem with PFMs occurs when the robot travels in narrow corridors, in which the robot experiences repulsive forces simultaneously from opposite sides.

54

Chapter 9 Robot 'sprogramming &control


Here we will discuss control of each part in our system

9.1

Dc motor

there are different ways to control dc motor parameters ,in our project we use digital controller to achieve speed and direction control /* speed control (PWM) */ int motor1 = 8; void setup() {Serial.begin(9600); int motor2=9 ; // run once, when the sketch starts // set up Serial library at 9600 bps

pinMode(motor1, OUTPUT); pinMode(motor2, OUTPUT);} void loop () { digitalWrite(motor2, LOW); delay (50); // ton digitalWrite(motor1, HIGH); delay (150); // T -ton } /

55

/*direction control (PWM) */ int motor1 = 8; void setup() { Serial.begin(9600); int motor2=9 ; // run once, when the sketch starts // set up Serial library at 9600 bps

pinMode(motor1, OUTPUT); pinMode(motor2, OUTPUT); } void loop () { digitalWrite(motor2, LOW); digitalWrite(motor1, HIGH); delay (2000); digitalWrite(motor2, HIGH); digitalWrite(motor1, LOW); }

/*direction control (PWM) */ int motor1speed = 8; int motor1dir=9 ; void setup() { Serial.begin(9600); // set up Serial library at 9600 bps // pwm

pinMode(motor1speed, OUTPUT); pinMode(motor1dir, OUTPUT); void loop() // run over and over again

{ analogWrite(motor1speed, 200); digitalWrite(motor1dir, HIGH); // forward}

56

9.2Encoder
We use half resolution method to read encoder pulses so that we can measure the angular position ,the approaches measure angular velocity in counts per second.

#define ENCODER_OPTIMIZE_INTERRUPTS // to void interrupts priority volatileint encoder0Pos1 = 0; volatileint encoder0Pos2 = 0; #define encoder1 2 #define encoder2 4 void setup() { digitalWrite(encoder1, HIGH); digitalWrite(encoder2, HIGH); digitalWrite(encoder3, HIGH); digitalWrite(encoder4, HIGH); Serial.begin (9600); attachInterrupt(0, doEncoder1,FALLING); }
57

// pull up resistance

void loop () { Serial.print (encoder0Pos1); void doEncoder1(){

if (digitalRead(encoder1) == HIGH) { // found a low-to-high on channel A if (digitalRead(encoder2) == LOW) // check channel B to see which way encoder is turning { encoder0Pos1 = encoder0Pos1 - 1; } // CCW

else { encoder0Pos1 = encoder0Pos1 + 1; } } // CW else // found a high-to-low on channel A

{ if (digitalRead(encoder2) == LOW) { // check channel B to see which wayencoder is turning encoder0Pos1 = encoder0Pos1 + 1; } else { // CW

encoder0Pos1 = encoder0Pos1 - 1; } } } // CCW

58

9.3Ultrasonic
A short ultrasonic pulse is transmitted at the time 0, reflected by an object. The senor receives this signal and converts it to an electric signal. The next pulse can be transmitted when the echo is faded away. This time period is called cycle period. The recommend cycle period should be no less than 50ms. If a 10s width trigger pulse is sent to the signal pin, the Ultrasonic module will output eight 40kHz ultrasonic signal and detect the echo back. The measured distance is proportional to the echo pulse width and can be calculated by the formula above. If no obstacle is detected, the output pin will give a 38ms high level signal. /* print how far obstacle is */ intpingPin = A7; long duration, cm; void setup() { Serial.begin(9600); } // set up Serial library at 9600 bps

void ping (){ pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); cm = duration / 29 / 2; Serial.print(cm); Serial.print("cm"); Serial.println(); } void loop() { ping(); } // run over and over again

59

9.4Serial communication
/* program receive byte array from labVIEW and transmitted it again */ charBuf[4] = {0,0,0,0}; char z1; char z2; signedint x1 ; signedint x2; int wreal1 ; unionserial_super_data { signed long int_2_bytes; signed char read_byte[2]; } super_data;

void setup() { Serial.begin (9600); } void loop(){ while(Serial.available() <=0); // wait for incoming serial data if (Serial.available() >= 2) // wait for four bytes { for(int a=0; a <=1; a++) super_data.read_byte[a]=Serial.read(); } z1= super_data.read_byte[0]; z2= super_data.read_byte[1]; x1 =int ( z1/4) ; x2 = int( z2 /4); // convert char to int delay (1000); wreal1 =x1 -20000; Buf[0] = z1 ; Buf[1] = z2 ; if (wreal1 > 0) { Buf[2] = 'a';} else Buf[2] = 'b'; if (wreal1 > 0) {Buf[3] = 'a'; } else Buf[3] = 'b'; for (inti = 0; i<=3; i++) {Serial.write (Buf [i]);} }

60

9.5Whole program of arduino


#define ENCODER_OPTIMIZE_INTERRUPTS #include <Encoder.h> volatileint encoder0Pos1 = 0; volatileint encoder0Pos2 = 0; #define encoder1 2 #define encoder2 4 #define encoder3 3 #define encoder4 5 int motor1 =8 ; intmotorE =9 ; int mator1 =11 ; intmatorE =10 ; intpingPin = A0; int duration, cm; int pingPin2 = A1; int duration2, cm2; int pingPin3 = A2; int duration3, cm3; char Buf[8] = {0,0,0,0,0,0,0,0}; char z1; char z2; char z3; char z4; unsignedint x1=0 ; unsignedint x2=0 ; unionserial_super_data { long int_4_bytes; charread_byte[4];

} super_data;

61

unsigned long currentTime ; unsigned long loopTime ; unsignedint p11 ; unsignedint p22 ; void setup() { pinMode(encoder1, INPUT); pinMode(encoder2, INPUT); pinMode(encoder3, INPUT); pinMode(encoder4, INPUT); pinMode(motor1, OUTPUT); pinMode(motorE, OUTPUT); pinMode(mator1, OUTPUT); pinMode(matorE, OUTPUT); digitalWrite(encoder1, HIGH); digitalWrite(encoder2, HIGH); digitalWrite(encoder3, HIGH); digitalWrite(encoder4, HIGH);

attachInterrupt(0, doEncoder1,FALLING); attachInterrupt(1, doEncoder2,FALLING);

Serial.begin (9600); currentTime = millis(); loopTime = currentTime; }

62

void ping1 (){ pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); pinMode(pingPin, INPUT); duration2 = pulseIn(pingPin2, HIGH); cm = duration / 29 / 2; delay(50); } void ping2 (){ pinMode(pingPin2, OUTPUT); digitalWrite(pingPin2, LOW); delayMicroseconds(2); digitalWrite(pingPin2, HIGH); delayMicroseconds(5); digitalWrite(pingPin2, LOW); pinMode(pingPin2, INPUT); duration2 = pulseIn(pingPin2, HIGH); cm2 = duration2 / 29 / 2; delay(50); } void ping3 (){ pinMode(pingPin3, OUTPUT); digitalWrite(pingPin3, LOW); delayMicroseconds(2); digitalWrite(pingPin3, HIGH); delayMicroseconds(5); digitalWrite(pingPin3, LOW); pinMode(pingPin3, INPUT); duration3 = pulseIn(pingPin3, HIGH); cm3 = duration3 / 29 / 2; delay(50); }
63

void loop () { currentTime = millis(); if (Serial.available() >= 4) // wait for four bytes

{ for(int a=0; a <=3; a++) super_data.read_byte[a]=Serial.read(); z1= super_data.read_byte[0]; z2= super_data.read_byte[1]; z3= super_data.read_byte[2]; z4= super_data.read_byte[3]; x1 =int ( z1) ; // angular velocity to linear x2 = int( z2); //duty = 1 * x1 ; }

analogWrite(motor1, abs(x1)); //values from 0 to 255 represent 0% - 100% if (int(z3)==0 ) { digitalWrite (motorE, LOW ); } if (int(z3)!=0 ) { digitalWrite (motorE, HIGH ); }

analogWrite(mator1, abs(x2)); //values from 0 to 255 represent 0% - 100% if (int(z4)==0 ) { digitalWrite (matorE, LOW ); } if (int(z4)!=0 ) { digitalWrite (matorE, HIGH ); }

ping1(); ping2(); ping3();

64

if(currentTime>= (loopTime + 200)){ // get counter value each .5 ms cli(); // Disable Interrupts p11 = abs(encoder0Pos1) ; p22 = abs(encoder0Pos2) ;

Buf[0] = 'b'; Buf[1] = 's'; Buf[2] =char (p11 ) ; Buf[3] = 'a'; Buf[4] =char(p22 ) ; Buf [5]= char (cm); Buf [6]= char (cm2); Buf [7]= char (cm3); for (inti = 0; i<=7; i++) { Serial.write(Buf[i]); }

encoder0Pos1=0; encoder0Pos2=0; loopTime = currentTime; sei(); // enable global interrupts } }

void doEncoder1(){ if (digitalRead(encoder1) == HIGH) { // found a low-to-high on channel A if (digitalRead(encoder2) == LOW) { // check channel B to see which way // encoder is turning encoder0Pos1 = encoder0Pos1 - 1; } // CCW else { encoder0Pos1 = encoder0Pos1 + 1; } } // CW

else // found a high-to-low on channel A { if (digitalRead(encoder2) == LOW) { // check channel B to see which way // encoder is turning encoder0Pos1 = encoder0Pos1 + 1; } // CW

65

else {

encoder0Pos1 = encoder0Pos1 - 1;

// CCW

void doEncoder2(){ if (digitalRead(encoder3) == HIGH) { // found a low-to-high on channel A if (digitalRead(encoder4) == LOW) { // check channel B to see which way // encoder is turning encoder0Pos2 = encoder0Pos2 - 1; } // CCW else { encoder0Pos2 = encoder0Pos2 + 1; } } // CW else // found a high-to-low on channel A { if (digitalRead(encoder4) == LOW) { // check channel B to see which way // encoder is turning encoder0Pos2 = encoder0Pos2+ 1; } // CW else { encoder0Pos2 = encoder0Pos2 - 1; } } } // CCW

66

9.6 labVIEW

67

Chapter10 Appendixes

68

69

You might also like