documentation final

49
ABSTRACT The navigation and control of an autonomous vehicle is a highly complex task. Making a vehicle intelligent and able to operate “unmanned” requires extensive theoretical as well as practical knowledge. An autonomous vehicle must be able to make decisions and respond to situations completely on its own. Navigation and control serves as the major limitation of the overall performance, accuracy and robustness of an autonomous vehicle. Navigation is a key aspect when designing an autonomous vehicle. An autonomous vehicle must be able to sense its location, navigate its way toward its destination, and avoid obstacles it encounters. 1

Upload: sadaf-afzal

Post on 18-Apr-2017

252 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Documentation Final

ABSTRACT

The navigation and control of an autonomous vehicle is a highly complex task. Making a vehicle intelligent and able to operate “unmanned” requires extensive theoretical as well as practical knowledge. An autonomous vehicle must be able to make decisions and respond to situations completely on its own. Navigation and control serves as the major limitation of the overall performance, accuracy and robustness of an autonomous vehicle. Navigation is a key aspect when designing an autonomous vehicle. An autonomous vehicle must be able to sense its location, navigate its way toward its destination, and avoid obstacles it encounters.

1

Page 2: Documentation Final

CHAPTER-1

INTRODUCTION

Robotics is a very popular field of knowledge. Since many years human beings have tried to build an autonomous robot. Thanks to the development of a new technologies dreams of human beings become realistic. Robotics attracts ordinary people not only those educated in this domain. There are more and more complex robots constructed. They are equipped with built-in computers therefore they become autonomous system.

1.1 Motivation

The study of autonomous vehicles is a fairly new area of research. It can be considered a specialized branch of robotics and has only been made possible due to the most recent technological advancements. The study of robotics and autonomous vehicles emerged from humans’ interest in controlling the world around them. Humans have always sought new inventions that make their lives simpler. They have strived to explore and go where they have not gone before. From these desires the study of robotics and autonomous vehicles was born.

The birth of the microprocessor in the seventies created a technological explosion, opening numerous areas of research. One such field was sensor technology. Sensors are devices that change a physical quantity into an electrical signal, thus allowing that quantity to be measured. Scientists have created sensors that detect anything from temperature to velocity. Unfortunately, it has only been in the past few decades that the cost of the microprocessor and sensors has been affordable to anyone besides the military and government.

With the invention and advancement of these devices as well as their decreasing costs, the study of robotics is now open to anyone. New ideas and research are constantly emerging. Autonomous vehicles have the potential to make our lives simpler and in some cases protect our livelihood. Autonomous vehicles could mow our lawns, drive us around, or fight for our country. It is from these benefits that research and funding in this area will continue indefinitely for years to come.

1.2 Terminology

The definition of an autonomous vehicle is rather vague and open to much debate. It is hard to define exactly what an autonomous vehicle is because the terms used to describe it are also open-ended. This thesis will define an autonomous vehicle as a mobile robot that can intelligently navigate itself within an environment without human interaction. Unfortunately, terms such as robot, intelligence, and environment have many different meanings. Therefore, in order to understand the autonomous vehicle studied in this thesis those terms must also be defined.

2

Page 3: Documentation Final

For the context of this the term robot will describe a machine that has a perceived level of intelligence. Therefore, a robot can interpret inputs and respond to them in a useful way. For this work, a robot will collect data from its sensors, process it, and then respond to it by controlling its actuators. To an outside observer the robot appears to be making intelligent decisions based on situations it encounters in its environment.

The term environment must also be defined. With the world so complex, assumptions must be made about the environment in order for a robot to interact with it. Not every event or situation can be planned for. However, by creating a simple model of the world around the robot, hopefully, the most important situations can be planned for. Robots have been designed for numerous environments including land, air, sea, and outer space. This thesis assumes that the robot will operate on flat ground and thus will have its movement restricted to two dimensions, using an x and y coordinates system. It is also assumes that the robot will have to react to obstacles its sensors can detect.

1.3 APPLICATION

Existing Autonomous Vehicles

1.3.1 Military Applications

In the past decade, due to constant world conflict and the rapid advancement of technology, there has been a great demand for autonomous vehicle research within the U.S. military. Within the next twenty years the U.S. military hopes to have a significant percentage of its fighting force composed of autonomous vehicles.

Autonomous vehicles are the preferred method of fighting in the future due to their efficiency, data collection abilities, and protection of human life. Autonomous vehicles will be smaller, lighter, more fuel efficient, and cheaper than their currently manned counterparts. Furthermore, since it is a machine it will not get bored of mundane tasks assigned to it. Most importantly, they can enter hostile environments and safely going where humans cannot go.

Autonomous vehicles are already making their presence felt on the battlefield today. Several unmanned surveillance aircraft proved their worthiness on the battlefields of Afghanistan and Iraq. The two most prominent Unmanned Aerial Vehicles (UAVs) are the US Air Force’s Predator and Global Hawk.

Another example, the Global Hawk, is a strictly surveillance and reconnaissance UAV. It was built for High-Altitude, Long-Endurance missions. Equipped with sophisticated radar and imagery devices it can “supply responsive and sustained data from anywhere within enemy territory, day or night, regardless of weather.”

Autonomous vehicles are also being used in the sea by the Navy and on the ground by the Army. In Iraq, land mines near roads or inside buildings have killed and injuredhundreds of troops. In response, the Pentagon has deployed unmanned mine seeking vehicles. These vehicles have robotic arms that can

3

Page 4: Documentation Final

remotely disable improvised explosive devices. Several drones were damaged while disabling bombs. However, the loss of a robot is well worth the price of saving human lives.

While many of these vehicles may seem like something out of a science fiction novel, there are still many hurdles that must be overcome. First, the amount of intelligence these vehicles have is still very primitive. Vehicles such as the Predator still require much of their control to be done by humans. To some degree, they can be considered advanced remote control vehicles and not autonomous vehicles. Having unmanned vehicles accomplish more complex goals will require better navigation and control schemes.

Furthermore, different environments provide different challenges. Autonomous air vehicles are by far the most sophisticated autonomous vehicles today. However, they do not face the terrain challenges of a ground vehicle or communication and location problems of an underwater vehicle.

1.3.2 Consumer Applications

As technology advances and becomes cheaper, more applications of autonomous vehicles will become apparent. As in most cases with technology, what was once a high end, top secret military application eventually ends up in the consumer market with a completely different function. As an example, the Global Positioning System (GPS) was developed in the 1970s and had a strictly military application. However, today it is used for many other purposes, from cars’ navigation systems to mail and package tracking. Similar things will happened with autonomous vehicles and applications are already beginning to emerge today.

Another example of a consumer autonomous vehicle is Friendly Robotics’ Robomower .Friendly Robotics claims a consumer can get their lawn cut by simply pressing a button. Not only can one schedule when Robomower mows the lawn, but Robomower will also monitor its battery power and find its way back to its charging station without any assistance.

Both of these products appear to be great solutions to mundane tasks. However, there are problems with both of them. Unfortunately, in a practical setting these products underperform. They are truly not intelligent devices and make a lot of assumptions in order to simplify the world around them. For instance, both devices navigate through their environment in a random fashion. They move forward until they encounter a wall or obstacle, then they make a turn randomly and begin moving forward again until another wall or obstacle is hit. In a simple environment, such as a rectangular room or circular lawn, with very few obstacles this method may be acceptable. However, in the complex environment of the real world, this method proves to be inefficient and ineffective. Reviews of these products claim that when these products were used in a real world setting they ended up not vacuuming the whole room or leaving strips of grass unmoved. Obviously, a better system of navigation must be devised for these systems. With all the technology available today, there must bebetter, more efficient way to autonomously navigate through a house or around a lawn.

4

Page 5: Documentation Final

CHAPTER-2

COMPONENTS

An autonomous vehicle is a complex mechanical and electrical system. Designing an autonomous vehicle requires knowledge from many disciples of engineering, including mechanical, aerospace, electrical, and computer engineering. Usually, mechanical and aerospace engineers study the dynamics of the system. They create mathematical models to analyze the physical characteristics of the system. Modeling a system is a difficult task and can be infinitely complex. Being able to model a system in a simple yet concise way is highly dependent on the system being modeled. System modeling is still a large area of research today.Electrical engineering is also important when designing and studying autonomous vehicles. Electrical engineers interface the electronics onto the system and design ways to control the system. Once a mathematical model of the system is generated, control techniques can be employed to get the system to act as desired. This again is difficult because many constraints come into play. Not only must a system abide by the laws of physics but it must also meet performance and financial constraints. An autonomous vehicle is laden with expensive sensors and controllers. Getting these devices to work with one another is also complicated. A thorough knowledge of electronics, sensors, and microcontrollers is definitely required.Finally, autonomous vehicles require knowledge from computer engineering and computer science. Giving autonomous vehicles intelligence requires complex software. A computer engineer must understand the system they are working with and then translate it into code. Acquiring sensor data, processing that data, and controlling actuators are all done via software. Making this software robust, reliable, and user friendly is a huge design task.

2.1 Atmega 16 Development Board

2.1.1 Specifications and Features

The atmega 16 Development Board Features are:

40 Pin Atmel ATmega16/32 microcontroller with internal system clock upto 8 MHz and

externally upto 16 MHz

16/32 KB Flash RAM memory for programs

1/2 KB of SRAM

512/1024 Bytes of EEPROM

One 6x1 Pin SPI Relimate Header

Eight 3x1 Pin Relimate header inputs for 8 analog sensors

5

Page 6: Documentation Final

One 16 Pin header to connect 16*2 alphanumeric LCD

Two onboard L293D drivers for motors (upto 600 mA per channel)

Dual 7805 Voltage regulator

Dual power input options (Through molex connector or through DC Jack)

Two programmable Micro-Switches

Two programmable LEDs

Two DPDT switches (one for power on/off and one for reset)

MAX 232 Level shifter for RS232 communication

One 3x1 Pin relimate header for RS2332 communication

Four 8 Pin bergistick headers (male) from each port of ATmega16/32

Wide input power range from 7 volts to 24 volts at 1.5-2 Amps

Board size of 6 x 3 inches, on high quality PCB

2.1.2 Ports and Connectors Details

Here is the detailed information of the atmega 16 Development Board –

Power Unit:

IC 7805 :

It is a voltage Regulator IC Which Regulates the voltage to +5v DC minimum voltage must be +7V DC Input to as to convert the output .

7805 and Power Connector :

Power Switch is used to turn on the power supply of the board. Power will flow to voltage regulators only when the power switch is in down position.

Power supply can be given either through the Power Connector or through

the DC Jack. Be sure to use ONLY ONE power source.

6

Page 7: Documentation Final

Regulated 5 Volts Power Output:

This connector can be used to provide power to any external device. Taking into consideration,

that the board can only withdraw power up to 2 Amps, power output from this jack may vary.

Reset Switch:

This switch is used to reset the program counter to zero and restart the program execution.

When execution is done, Reset switch is needed to be kept in down position.

While writing the program to the chip, reset switch should be kept in up position

LEDs:

Four LEDs are provided on the board for the testing purpose. These LEDs can be programmed

to glow. Connection details of the LEDs and microcontroller pins are given below –

LED 1 : PortC.1

LED 2 : PortC.2

LED 3 : PortC.3

LED 4 : PortD.2

Each individual LED can be programmed to glow or to blink by programming the corresponding microcontroller pin.

40 Pin Base for microcontroller:

This base is provided to install and remove microcontroller chip easily. This board supports

ONLY two microcontrollers – ATmega16 and Atmel ATmega32. Both microcontrollers have

7

Page 8: Documentation Final

exactly same pin configuration but they differ in terms of the memory. For more information

on microcontroller, refer to the respective datasheet.

16 Pin Base for L293D Driver ICs:

There are two bases provided onboard to use L293D H-Bridge with microcontroller. This board supports ONLY L293D Driver. No other H-Bridge IC can be installed instead of L293D. For more information on L293D, refer to its datasheet.

L293D IC:

It is H Bridge Circuit used to control the Direction of the motor.

It is used basically as we cannot withdraw much power from the microcontroller and as we merely give +5 volts to the microcontroller but Motor have a rating of 12v, 1Amp so the need of L293D is essential

Motor Connectors:

The Development Board’s four DC motor outputs are located bottom left side of the board by means of motor connectors. These connectors can also be used to drive two stepper motors. These connectors have following configuration –

8

Page 9: Documentation Final

MOTOR1

For Connector 1 –

PWM Channel = PWM1B

Direction Bit = PortD.3

For Connector 2 –

PWM Channel = PWM1A

Direction Bit = PortD.6

MOTOR2

For Connector 1 –

PWM Channel= PortC.6

Direction Bit = PortC.7

For Connector 2 –

PWM Channel= PortC.4

Direction Bit = PortC.5

Eight 3 Pin Headers for Sensors:

This board provides capability to connect up to eight sensors directly to ADC port of the ATmega16/32. ADC need to be configured and started while working with Analog sensors whereas ADC need to kept off while working with Digital sensor with same Port A. However types of sensors can be used at a time but they both should be different ports, i.e. analog sensors should be on Port A (with ADC started) and digital sensors should be on any other port (with that port in input mode).

Given below is the connection details of all eight headers with corresponding microcontroller pin –

J12 = PortA.7 (or) ADC(7)

J13 = PortA.5 (or) ADC(5)

9

Page 10: Documentation Final

J14 = PortA.3 (or) ADC(3)

J15 = PortA.1 (or) ADC(1)

J17 = PortA.6 (or) ADC(6)

J16 = PortA.4 (or) ADC(4)

J18 = PortA.2 (or) ADC(2)

J19 = PortA.0 (or) ADC(0)

RS232 Connector:

This connector is provided for RS232 communication. Pin configuration of RS232 is given below –

RX = PortD.0

TX = PortD.1

16 Pin LCD Headers:

A 16 Pin header is provided to interface one 16 * 2 Alphanumeric LCD. Given below are the pin configuration details –

Lcdpin = Pin

Db4 = Portb.4

Db5 = Portb.5

Db6 = Portb.6

Db7 = Portb.7

E = Portb.3

10

Page 11: Documentation Final

Rs = Portb.2

DB4 to DB7: Data Buses of LCD

E: Enable pin of LCD

Rs: Register Select of LCD

These pin configuration are only for the LCD which is 16 * 2 alphanumeric display. For other type of LCD this may vary. Refer to related datasheet of the LCD incase if you are using a different one.

2.2 Wheels

Wheeled robots are robots that navigate around the ground using motorized wheels to propel themselves. This design is simpler than using treads or legs and by using wheels they are easier to design, build, and program for movement in flat, not-so-rugged terrain. They are also more well controlled than other types of robots. Disadvantages of wheeled robots are that they can not navigate well over obstacles, such as rocky terrain, sharp declines, or areas with low friction. Wheeled robots are most popular among the consumer market, their differential steering provides low cost and simplicity. Robots can have any number of wheels, but three wheels are sufficient for static and dynamic balance. Additional wheels can add to balance; however, additional mechanisms will be required to keep all the wheels in the ground, when the terrain is not flat.

2.3 Actuator

An actuator is a mechanism for activating process control equipment by use of pneumatic, hydraulic, or electronic signals. Actuators have been used in robotics since the field's invention in the early 1950s; however those original robots were created for research and industrial applications. It has only been in the last few decades that the technology has advanced far enough to put the power of robotics into the hands of home users. The most common actuator in Robotics is DC Motors. DC Motors converts electrical into mechanical energy. DC Motors are best at high speed and low torque.

2.3.1 Motor Control

11

Page 12: Documentation Final

The final AUTONOMOUS ROBOT subsystem controls the motors onboard the AUTONOMOUS ROBOT. The inputs of the path following and global coordinate model were the vehicle’s linear and rotational velocities. Based on the vehicle’s wheel radius and half wheel base, r and b, there is a one to one mapping between the vehicle’s linear and rotational velocity, v and ω, and the vehicle’s wheel velocities, ωL and ωR.

The kinematic models and controllers used to derived the path following and trajectory tracking controllers assumed that the motors of the actual system were ideal. Based on this assumption, it is implied that the motors have an infinite resolution and can instantaneously change to any desired speed. However in actuality, these assumptions are not true. If a controller is implemented digitally, a motor only has a discrete number of speeds it can be set to. Furthermore, there is always a delay in the amount of time it takes for a motor to achieve a certain speed. Not taking these practical constraints into account in the actual implementation of the AUTONOMOUS ROBOT could lead to undesired and unpredictable results.

The most common actuator in Robotics is DC Motors. DC Motors converts electrical into mechanical energy. DC Motors are best at high speed and low torque.

A DC motor is a mechanically commutated electric motor powered from direct current (DC). The stator is stationary in space by definition and therefore it’s 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.

DC motors have a rotating armature winding (winding in which a voltage is induced) but non-rotating armature magnetic field and a static field winding (winding that produce the main magnetic flux) or permanent magnet. Different connections of the field and armature winding provide different inherent speed/torque regulation characteristics. The speed of a DC motor can be controlled by changing the voltage applied to the armature or by changing the field current. The introduction of variable resistance in the armature circuit or field circuit allowed speed control. Modern DC motors are often controlled by power electronics systems called DC drives.

DC motors are widely used in robotics because of their small size and high energy output. They are excellent for powering the drive wheels of a mobile robot as well as powering other mechanical assemblies. Speed reduction is often required because many actuators are suited to high speeds and low torques. Also, weight/inertia of actuators affects the dynamics, so the actuators are placed at or near the robot base. Thus, a transmission system must be used.

DC Motors are easy to control. One DC Motor requires only two signals to perform operations. If we want to change its direction just reverse the polarity of power supply across it. We can vary the speed of motor by varying the supply across it. This simplifies controller design immensely, and there are a number of known techniques to meet motor performance criteria such as rise time, settling time, peak overshoot and steady state error.

12

Page 13: Documentation Final

2.3 Power supply System:

It is the system which supplies power to the motors and other electronic devices fitted on the robot.

2.4 Sensory devices for feedback

Sensory devices are the sensors. A sensor is a type of transducer.A Transducer is a device (usually, electrical, electronic, or electro-mechanical), that converts one type of energy to another for various purposes including measurement or information transfer. The IR Sensor Set consists of an IR transmitter and an IR receiver mounted side by side on a tiny PCB. With minimum interface and 5VDC power, it can be used as a reflective type IR sensor for mobile robot or low cost object detection sensor.

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 result in a large jump in the intensity, which we already know can be detected using a threshold.

2 types of sensors have been used:

IR sensor

LED sensor

13

Page 14: Documentation Final

Principles Of Operation

14

Page 15: Documentation Final

2.5 Serial Communication By RS232 And MAX 232

2.5.1 Serial Communication By RS232

For serial communication, ATMEGA16 is provided with two pins D.0 and D.1 which are working as Receiver and Transmitter

D.0- RXD ( receiver)

D.1- TXD (transmitter)

So, using RXD and TXD, we can receive and send data from the microcontroller using serial communication port called as RS232. These pins are also called as UART.

Now,RS232 helps in serial communication with other devices e.g. personal computers, RFID, Sim module etc.

2.5.2 MAX 232

15

Page 16: Documentation Final

MAX232 is an IC that operates on single 5V supply and it is integrated with two drivers and two receivers .All receivers can be used to convert RS232 levels to TTL/CMOS levels and all drivers can be used to convert TTL/CMOS level inputs to RS232 levels.

MAX 232

2.6 GSM Module

Plug and play GSM Modem to interface serial interface.Use it to send SMS by controlling it through simple AT commands from micro controller. The modem consists of all the required external circuitry required to start experimenting with the SIM300 module like the power regulation, external antenna, SIM Holder, etc.

Features:

Uses the extremely popular SIM300 module

Provides serial TTL interface for easy and direct interface to microcontrollers

Can be controlled through standard AT commands

Onboard wire antenna for better reception.

The SIM300 allows an adjustable serial baud rate from 1200 to 115200 bps (9600 default)

Low power consumption of 0.25 A during normal operations and around 1 A during transmission

Operating Voltage: 7 - 15V AC or DC

16

Page 17: Documentation Final

GSM 300 Module

2.7 In-System-Programmer

To burn program in ATmega16, we directly connect the USB programmer with the microcontroller. Only 5 pins of microcontroller are need to be connected to the programmer. They are:

MOSI,MISO, SCK, RESET, GROUND.

These pins are present at 6,7,8,9 and 11 th pin of the microcontroller.

17

Page 18: Documentation Final

CHAPTER 3

INTERFACING

L293d With Motors

18

Page 19: Documentation Final

CHAPTER-3

PROGRAMMING IN BASIC LANGUAGE USING BASCOM-AVR

3.1 Overview

BASCOM – AVR is an IDE based development platform and is developed by MCS Electronics. BASCOM uses BASIC programming language. It is very easy to write,compile and download the program with BASCOM.

3.2 Basics

To write program with Basic language for AVR, start with following sentences –

1. Define $regfile – instruct the compiler to use the specified register file.

19

Page 20: Documentation Final

Syntax$REGFILE = "name_of_file"

“Name_of_file” - It refers to the name of register file. The register files are stored in the BASCOM-AVR application directory with .DAT extension.

The register file holds information about the chip such as the internal registers and interrupts addresses.

Since we are using Atmega16 Microcontroller, we will define

$regfile= “m16def.dat” ‘this file is loaded for Atmel atmega16

Note: For Atmega32, we will define $regfile= “m32def.dat”

2 . $crystal – It defines the clock speed at which you want to run your microcontroller.

Syntax

$CRYSTAL = ValueValue - A numeric constant defining the Frequency of the crystal.

Example –

$crystal = 4000000 ‘ it set the clock speed at 4MHz3. Config - The CONFIG statement is used to configure the various hardware devices and other features

of microcontroller. We are required to configure the following hardware and features:

a) LCDb) ADCc) Timer

(a) Configuring LCD

20

Page 21: Documentation Final

BASCOM allows us to configure LCD with ease. You can configure various types of LCDs with BASCOM like 16*2, 16*4, 20*2, 20*4 OR 40*4 alphanumeric LCDs.

The Lcd provided on NEXTSAPIENS Controller Board is of size 16*2 i.e. 16 char in one line and total of 2 lines of display. Syntax for Configuring LCD:

CONFIG LCD = LCD_type

LCD_type – It is the type of LCD you want to configure. It can be:

40 * 4,16 * 1, 16 * 2, 16 * 4, 16 * 4, 20 * 2 or 20 * 4 or 16 * 1a or 20*4A.

For Example : 16*2 means : 16 Character in one line and a total of 2 lines

CONFIG LCDPIN = PIN , DB4= PN,DB5=PN, DB6=PN, DB7=PN, E=PN, RS=PN

To configure a 16*2 alphanumeric LCD of NextSapiens Development Board, the command is –

Config LCD = 16*2

Config lcdpin = pin, Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2

21

Page 22: Documentation Final

(b) Configuring ADC

Syntax

CONFIG ADC = single, PRESCALER = AUTO, REFERENCE = opt

ADC –

It defines the Running mode of ADC. Its value is SINGLE.We use SINGLE to enable getadc() command , if we use Free , the values are freely taken by the Microcontroller

PRESCALER –

A numeric constant for the clock divider. Use AUTO to let the compiler generate the best value depending on the XTAL.

For ADC to work a clock of 50 to 200 KHZ , so we use auto to select Maximum possible Clock Frequency available .

REFERENCE –

it simply means to whom adc must compare to give a value i.e. as the maximum resolution of the ADC is 10 bits . meaning it can maximum convert values from 0 to 1023(2^10-1) , so if we are reffering Avcc(i.e +5 V) that meams on giving an input to the microcontroller’s ADC pin +5V the digital value we will get at the controller will be 1023.

Configuring ADC in BASCOM is also very easy. To configure ADC in BASCOM for NEXTSAPIENS Development Board, the statement is –

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Start ADC

22

Page 23: Documentation Final

(C) Configuring Timers to generate PWM

Syntax

CONFIG TIMER1 = COUNTER | TIMER | PWM, PRESCALE= 1|8|64|256|1024, PWM = 8 | 9 |10, COMPARE A PWM = CLEAR UP| CLEAR DOWN | DISCONNECT COMPARE B PWM = CLEAR UP| CLEAR DOWN | DISCONNECT

TIMER1: It is a 16 bit counter.

PRESCALE - The TIMER is connected to the system clock in this case. You can select the division of the system clock with this parameter.Valid values are 1, 8, 64, 256 or 1024, This command divides the Internal Clock to a value , to increase the time duration .

PWM - Can be 8, 9 or 10.This is the resolution of the PWM if selecting 8 (Default) maximum variation which can be optained will be 0 to 255 (2^8-1), so the registor pwm1a/pwm1b could withstand a maximum value of 0 to 255.

COMPARE A(B) PWM – It refers to PWM compare mode.It compairs the value to the reference to get that weather motor should rotate clockwise /counter clockwise. It can be CLEAR UP (Anti-Clockwise) or CLEAR DOWN(Clockwise)

With BASCOM, again it is very easy task. To generate PWM, the statement is –

Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down

Start Timer1

Timer1 is a 16 bit timer which actually works in two parts, each one of 8 bit, simultaneously. So the above statement is actually generating two PWMs, PWM 1A and PWM 1B. Same way timer 2 can be

23

Page 24: Documentation Final

configured. Refer ATmega16/32 datasheet and BASCOM help for more information regarding timers and PWM generation.

CHAPTER-4

PROGRAM CODES

4.1-LCD interface and display

$regfile = "m16def.dat" '

$crystal = 4000000

Config Lcd = 16 * 2

Config Lcdpin = Pin, Db4 = Portb.4, Db5 = Portb.5, Db6 = Portb.6, Db7 = Portb.7, E = Portb.3, Rs = Portb.2

Config Adc = Single, Prescaler = Auto, Reference = Avcc

24

Page 25: Documentation Final

Config Timer1 = Pwm, Pwm = 8, Prescale = 1, Compare A Pwm = Clear Down, Compare B Pwm = Clear Down

Start Adc //Starts ADC

Cls // Clears the Screen

Start Timer1

Lcd "NExtsapiens" //Displays the text on the screen

Lowerline //Next line

Lcd "welcome"

End

4.2-Metro Train Prototype

$regfile = "m16def.dat"

$crystal = 1000000

Config Lcd = 16 * 2

Config Lcdpin = Pin, Db4 = Portb.4, Db5 = Portb.5, Db6 = Portb.6, Db7 = Portb.7, E = Portb.3, Rs = Portb.2

Config Timer1 = Pwm , Prescale = 1 , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down

Start Timer1

25

Page 26: Documentation Final

Do

Cls

Lcd "forward"

Pwm1a = 200

Portd.6 = 0

Pwm1b = 200

Portd.3 = 0

Waitms 2000

Cls

Lcd "left"

Pwm1a = 200

Portd.6 = 0

Pwm1b = 50

Portd.3 = 0

Waitms 1000

Cls

Lcd "right"

Pwm1a = 50

Portd.6 = 0

Pwm1b = 200

Portd.3 = 0

Waitms 1000

Cls

26

Page 27: Documentation Final

Lcd "stop"

Pwm1a = 0

Portd.6 = 0

Pwm1b = 0

Portd.3 = 0

Waitms 1000

Cls

Lcd "backward"

Pwm1a = 50

Portd.6 = 1

Pwm1b = 50

Portd.3 = 1

Waitms 2000

Cls

Lcd "stop"

Pwm1a = 255

Portd.6 = 1

Pwm1b = 255

Portd.3 = 1

Waitms 1000

Cls

Loop

27

Page 28: Documentation Final

End

4.3- Analog Sensor Calibration

$regfile = "m16def.dat" $crystal = 4000000

Config Lcd = 16 * 2 Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2

Config Adc = Single , Prescaler = Auto , Reference = Avcc Start ADCConfig Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down Start Timer1

Dim A As integer // declaring variable “A” of type integer

Cls // Clear screen

Do // Start the loop

A= GetADC (0) // The input of sensor connected to Pin 0 of port A will be

stored in variable A. Here, in this case, Pin 0 refers to J19 connector of Development Board. Please refer to Page 6 for pin connection details.

LCD A // Display the value of variable A on LCD

Loop // End of Loop

End // to end the program

28

Page 29: Documentation Final

4.4- Fire Avoidance

$regfile = "m16def.dat" '

$crystal = 1000000

Config Lcd = 16 * 2

Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down

Start Adc

Cls

Start Timer1

Dim R As Integer

Do

Cls

R = Getadc(0)

If R > 700 Then

Pwm1b = 0

29

Page 30: Documentation Final

Portd.3 = 0

Pwm1a = 0

Portd.6 = 0

Lcd "obstacle found"

Lowerline

Lcd "stop"

Elseif R < 700 Then

Pwm1b = 255

Portd.3 = 0

Pwm1a = 255

Portd.6 = 0

Lcd "no obstacle found"

Lowerline

Lcd "move"

End If

Loop

End

30

Page 31: Documentation Final

CHAPTER 5

LINE FOLLOWER

5.1 IntroductionLine follower is an autonomous robot which follows either black line in white are or white line in black area. Robot must be able to detect particular line and keep following it.

31

Page 32: Documentation Final

 

Block Diagram

An array of sensor is used to detect the line. Based on the status of sensors, special circuit or controller decides the position of line and also the required direction of motion required to follow the line. Motor driver circuit is used to ON/OFF the LEFT/RIGHT motors of the robot to provide desired motion.

5.2 SensorsSensors are required to detect position of the line to be followed with respect to the robot’s position. Most widely used sensors for the line follower robot are PHOTOSENSERS. They are based on the basic observation that “the white surface reflects the light and the black surface absorbs it”.  Sensor circuit contains emitter, detector and comparator assembly.

Photosensors

IR or VISIBLE light is emitted from the emitter (IR light is mostly preferred to avoid interference from the visible light which is generally around the robot. However IR light is also present in atmosphere but its intensity is much less than that of visible light, so IR light can give much reliable output. For better accuracy of the sensors, they must be covered properly for the isolation from the surrounding.) This emitted light strikes the surface and gets reflected back. If the surface is white, more intensity of light gets reflected and for black surface very less intensity of light is reflected.  Photo detector is used to detect the intensity of light reflected. The corresponding analog voltage is induced based on the intensity of reflected light. This voltage is compared with the fixed reference voltage in comparator circuit and hence it is converted into logic 0 or logic 1 which can be used by the controller.

32

Page 33: Documentation Final

Principle of line follower sensor

33

Page 34: Documentation Final

Working principle

5.3 Program code of line follower

$regfile = "m16def.dat" '

$crystal = 4000000

Config Lcd = 16 * 2

Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down

Start Adc

Cls

Start Timer1

Dim Ob As Integer

Dim Nob As Integer

Dim M As Integer

Dim A As Integer

Lcd "object case"

Waitms 500

34

Page 35: Documentation Final

Ob = Getadc(0)

Waitms 500

Cls

Lcd "no object case"

Waitms 500

Nob = Getadc(0)

Waitms 500

Cls

Lcd "calculate mean"

M = Ob + Nob

M = M / 2

Do

Cls

A = Getadc(0)

If A > M Then

Pwm1b = 0

Portd.3 = 0

Pwm1a = 0

Portd.6 = 0

Lcd "no object"

Lowerline

35

Page 36: Documentation Final

Lcd "stop"

Cls

Elseif A < M Then

Pwm1b = 255

Portd.3 = 0

Pwm1a = 255

Portd.6 = 0

Lcd "object found"

Lowerline

Lcd "move"

Cls

End If

Loop

End

36

Page 37: Documentation Final

CONCLUSION

37

Page 38: Documentation Final

REFERENCES

[1] W.P. Aung, ”Analysis on Modeling and Simulink of DC Motor and its Driving System Used for Wheeled Mobile Robot”, Proceedings Of World Academy Of Science, Engineering And Technology, vol. 26, pp.299-306, December 2007

[2] T. Bräunl,” Research relevance of mobile robot competitions,” IEEE Robotics and Automation Magazine, vol. 6, no. 4, pp. 32–37 , December 1999 (6)

[3] Borenstein, J., “Mobile Robot Positioning: Sensors and Techniques,” Journal of Robotic Systems, Vol. 14, Issue 4 (1997), pp. 231-249.

[4] Brown, Jim, “Brief H-bridge Theory of Operation,” http://www.dprg.org/tutorials/1998-04a/, (Dallas, TX: Dallas Personal Robotics Group. April, 1998).

[5] Yuan, Jing, Yalou Huang and Qiang Han, “A Strategy of Path Following Control for Wheeled Mobile Robots,” Proceedings of the 5th World Congress on Intelligent Control and Automation, (15-19 June 2004), IEEE, Vol. 6, pp. 4991–4995.

38

Page 39: Documentation Final

[6] Cao, Zuo Liang, Yuyu Huang, and Ernest L. Hall, “Region Filling Operations with Random Obstacle Avoidance for Mobile Robots,” Journal of RoboticSystems, Vol. 5 Issue 2 (1988), pp. 87-102.

39