Mini Project Final-Programmable Robot with Picaxe 08M

39
Mini Project 2009 Programmable Robot Using PICAXE-08M PROGRAMMABLE ROBOT BASED ON PICAXE-08 MINI PROJECT REPORT Submitted by NITHIN KP PRAVEESH A PREETHY P THANKAPPAN PREJITH S RAFAH ABDUL GAFOOR Department of Applied Electronics & Instrumentation Engineering GOVERNMENT ENGINEERING COLLEGE KOZHIKODE-673 005 OCTOBER 2009

description

A mini project based on Picaxe 08M micro controller.This project explores the possibility of making a Programmable Robot with Picaxe 08 M micro controller.The robot doesn't require any expensive programmers to burn the program to the IC and no complex programming skills are needed as the programs are written in BASIC. Mini project report submitted by Praveesh.A,Nithin KP,Prejith V,Rafah AG &Preethy PT.

Transcript of Mini Project Final-Programmable Robot with Picaxe 08M

Page 1: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

PROGRAMMABLE ROBOT BASED ON PICAXE-08

MINI PROJECT REPORT

Submitted by

NITHIN KP

PRAVEESH A

PREETHY P THANKAPPAN

PREJITH S

RAFAH ABDUL GAFOOR

Department of Applied Electronics & Instrumentation Engineering

GOVERNMENT ENGINEERING COLLEGE

KOZHIKODE-673 005

OCTOBER 2009

Page 2: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

ACKNOWLEDGEMENTS

We would like to express my greatest gratitude to the

people who have helped and supported me throughout . First and

foremost , we would like to express my deepest appreciation to Prof.

P Reena (Head of the Dept. Applied Electronics & Instrumentation

Engineering)for her kind and valuable support and guidance.

We would like to extend our sincere thanks to Ast.Prof.

Shajahan ES for his patient and unfailing support over the successful

completion of this mini project.

We are convinced that this work would not have been

completed without the assistance and support of the lab assistants

Balan N, Sunil Kumar, Abhilash NS.

Last but not least our course mates who have provided

me with invaluable advice and help.

.

Page 3: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

GOVERNMENT ENGINEERING COLLEGE

KOZHIKODE

Department of Applied Electronics & Instrumentation Engineering

CERTIFICATE

Certified that this is the bonafide record of the mini project work titled

PROGRAMMABLE ROBOT BASED ON PICAXE-08

done by

Nithin KP, Preethy P Thankappan, Praveesh A, Prejith S & Rafah Abdul Gafoor

during the year 2009 in partial fulfillment of the requirements for the award of the degree

of Bachelor of Technology in Applied Electronics & Instrumentation Engineering of

University of Calicut.

Mini project Co-ordinator Head of Department

Ast.Prof . SHAJAHAN ES Prof. P REENA

Page 4: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

ABSTRACT

This project explores the processes and design requirements for a

programmable robot which can sense the ambient light intensity and

move towards the brightest point in a given area. The robot is

capable of detecting and avoiding any obstructions in front of it

while moving with audio indication. Instead of using the typical

microcontrollers, we have chosenPICAXE-08M microcontroller as our

robot’s brain. One of the chief advantages of using the PICAXE

microcontroller over the conventional PIC microcontroller is that, it is

easily programmable and the programmer circuit can be integrated

to the project circuitry with ease. Also, the microcontroller can be

programmed in BASIC which is much simpler compared to other

programming languages. Thus the easy reprogramming of the robot

is easily achieved. The robot senses the light intensity with the help

of a LDR and obstruction detection is done by using a bump switch

installed on the robot.

Page 5: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

CONTENTS

1. Introduction

2. The Concept

3. Functional Block Diagram

4. Component description

5. Circuit Diagram

6. PICAXE-08M

7. Motor Driver Circuit

8. List of Components

9. PCB Layout

10. Programming the PICAXE

11. Flow Chart and Program description

12. Applications

13. Conclusion

14. Future Scope

15. Bibliography

16. References

Page 6: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

1

INTRODUCTION

Robotics is the engineering science and technology of robots, and

their design, manufacture, and application. Robotics is related to

electronics, mechanics, and software. Robotics is a subject of interest

for both professionals as well as hobbyists.Basically,a robot is a

device which have some intelligence to perform a specified task. The

intelligence of the robot is realized with the help of a microcontroller

and the program in it.This project aims at building a light following

robot which can be easily programmed.

Page 7: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

2

THE CONCEPT

The project aims at building a microcontroller based programmable

robot that can act as a light follower and can detect and avoid

obstructions while moving. The robot can sense light intensities at

various points in a given space and is capable of moving towards the

point where the light intensity is maximum. The robot is

programmable, therefore, the drive circuit is merely a slave to the

software and is of a relatively simple design. The circuit is based on a

PICAXE-08 micro. Although more limited than a ‘raw’

microcontroller, it is a little marvel nonetheless – both cutting out

the need for a programmer and for placing respectable power at the

service of the constructor with great simplicity. The programmer and

the project circuit are one and the same and there is no need of

removing the microcontroller from the main circuit for programming

it.

Page 8: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

3

FUNCTIONAL BLOCK DIAGRAM

The functional block diagram shows the interrelationship between

different blocks of the robot.The center of the robot’s control system

is PICAXE-08M microcontroller.The microcontroller listens to inputs

from the light sensing circuit and the obstruction detection circuit.

The microcontroller triggers the motor driving circuit according to

the inputs from light sensing circuit and obstruction detection circuit.

LIGHT SENSING

PICAXE-08M

OBSTRUCTION

DETECTION

SOUND

OUTPUT

MOTOR DRIVER

L

MOTOR

R

MOTOR

Page 9: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

4

The motor driving circuit is based on high current half H bridge IC

LN293D.Under normal operation ,the robot checks for any

obstructions in the path of it through the bump switch. On detecting

any obstruction, the microcontroller commands the motor driving

circuit to turn both motors backwards so that the robot moves

backwards. Once the obstruction has been avoided, the light sensing

circuit compares the light intensities on both sides of the robot as

well as directly in front and moves to the direction where light

intensity is maximum.The comparison of light intensities is done with

the help of microcontroller’s built in ADC and the light sensing

circuit. This repeats until the robot reaches the point with maximum

intensity.

Page 10: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

5

COMPONENT DESCRIPTION

PICAXE-08M MICROCONTROLLER

A PICAXE microcontroller is a standard Microchip PICmicro™

microcontroller that has been pre-programmed with the PICAXE

bootstrap code. The bootstrap code enables the PICAXE

microcontroller to be re-programmed directly via a simple serial

connection. This eliminates the need for an (expensive)conventional

programmer, making the whole download system a very low-cost

simple serial cable. The pre-programmed bootstrap code also

contains common routines (such as how to generate a pause delay or

a sound output), so that each download does not have to waste time

downloading this commonly required data. This makesthe download

time much quicker.

The PICAXE system exploits the unique characteristics of the new

generation of low-cost ‘FLASH’ memory based microcontrollers.

These microcontrollers can be programmed over and over again

Page 11: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

6

(typically 100 000 times) without the needfor an expensive

programmer. The PICAXE uses a simple BASIC language (or graphical

flowcharts) that younger students can start generating programs

with within an hour of first use. It is much easier to learn and debug

than industrial programming languages (C or assembler code). The

power of the PICAXE system is its simplicity. No programmer, eraser

or complicated electronic system is required - the microcontroller is

programmed via a 3-wire connection to the computers serial port.

L393D-MOTOR DRIVING IC

The bidirectional rotation of motors is achieved with the help of the

motor driving IC. The motor driving IC also acts as a high current

source for the DC motors. The Device is a monolithic integrated high

voltage, high current four channel driver designed to accept standard

DTL or TTL logic levels and drive inductive loads (such as relays

solenoids, DC and stepping motors) and switching power transistors.

To simplify use as two bridges each pair of channels is equipped with

an enable input. A separate supply input is provided for the logic,

allowing operation at a lower voltage and internal clamp diodes are

included.This device is suitable for use in switching applications at

frequencies up to 5 kHz.

Page 12: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

7

BC 547

BC547 is NPN Silicon Epitaxial Planar Transistor used in AF small

signal amplifier stages and direct coupled circuits. The BC 547 acts as

a part of the Inverter circuit.

7805 VOLTAGE REGULATOR

A voltage regulator maintains the supply voltage at a constant

level. IC 7805 was used to regulate the supply voltage to 5V,which is

the optimum voltage for the PICAXE microcontroller.The 3 terminal

device can source upto 1A current.

Page 13: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

8

9V BATTERY

To ensure smooth and continuous operation of the robot, 9V dc

battery was used.The supply voltage was regulated to 5V with the

regulator circuit.

LDR

The light sensing circuit of the robot consists of mainly an LDR.Its

resistance varies with the variations in the light intensity falling on it.

MOTORS

The Robot is designed to move on wheels. Two motor-powered

wheels and a castor wheel are provided for this. Two geared dc-

motors of the following specifications were used.

• 6 Volts DC motors

Page 14: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

9

• Weight = 90gms

• Rated Voltage = DC 6V

• No-load current < 60mA

• Load current < 300mA

BUZZER

A 6V buzzer was used to give audio indication of an obstruction being

detected by the robot.

Page 15: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

10

CIRCUIT DIAGRAM

The circuit diagram of the robot is given below.

CIRCUIT DESCRIPTION

The circuit is built around a PICAXE-08M microcontroller.The Vcc for the

microcontroller is given from a 7805 voltage regulator which regulates

the supply voltage to 5V.Picaxe is operated at 4MHz frequency and the

built in oscillator generates this. The programming circuit consists of a

3.5 mm stereo socket, a 10k resistor and a 22 k resistor. The

microcontroller communicates with the PC via pin 2(serial in ) and pin

7(serial out). The 22k resistor clamps the serial voltage to 5V to prevent

damage to the chip. Serial in or pin 2 of the PICAXE should never be left

floating and the 10k resistor is used to ground it whenever it is not

connected to PC for programming. Pin 1 and Pin 8 are connected to the

positive power supply and the ground respectively.

Page 16: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

11

Pinout diagram of PICAXE-08M

Pin 7 (P0) is designated by the manufacturers for output only and

is used to switch both of the motors on or off at the same time. It

may also be used to pulse the motors on and off (pulse-width

modulation) for speed control or special effects. When it is ‘high’,

the motors are on; when it is ‘low’ they are off.Pin 5 (P2) is

designated for input or output. In this circuit, it is used for output

only and controls the direction (forward or reverse) of the lefthand

motor, as seen from the rear of the robot. Pin 3 (P4) is likewise

designated for input or output and is used here to control the

direction (forward or reverse) of the right hand motor. Neither pin 5

nor pin 3 will accomplish anything unless both motors are switched

on frst via pin 7 (P0). Both pins 5 and 3 cause a wheel to roll forwards

when it is ‘low’ and backwards when it is ‘high’. Pins 7, 5 and 3

together may be used not only to make the robot drive forwards or

reverse but also to turnPin 4 (P3) is designated for input only and is

used to sense collisions through the robot’s bumper bar. The robot

need not only do a simple reverse-and-turn, but it may also be

programmed to respond in various ways. Pin 6 (P1) is designated for

output, input or analogue input. In this circuit, it is used only for

output and analogue input. In ‘output’ mode, it is used to drive a

piezo sounder for programmable sound. In ‘analogue’ mode, pin 6

reads the light level at the front of the robot. Note that this first

requires the correct adjustment of VR1 with the help of the LDR

Page 17: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

12

ADJUST program. The robot is capable of detecting sixteen levels of

light which may be used for light-seeking (or light-avoidance), line

tracking and day-night sensing. Pin 7 (P0) activates both motors

simultaneously via the L293D’S enable inputs. Pin 6 (P1), used in

‘output’ mode, drives piezo sounder X1. Since VR1 and LDR1 are

connected to the same pin, two 330Ω resistors are included as

protection for these components. In analogue mode, pin 6 monitors

LDR1 and the PICAXE-08 interprets the voltage as 16 discrete levels,

between <0.22V (level 1) and >3.38V (level 16).

Transistors Q1 and Q8 are used as inverters, so that when the

‘forward motion’ of motors is disabled, the ‘reverse motion’ of

motors is activated. Pin 4 is normally held low by its 47kΩ resistor.

When bump-and-respond switch S1 (the bumper bar) is closed,

pin 4 is pulled high. The 10µF capacitor and the 47kΩ resistor

determine how long a bump will be ‘remembered’ and the values of

these components may be modifed as desired. These components

are required because the software, as it executes, may need a

moment to reach the pro-gram line which monitors the status of S1

and because there is bound to be some switch-bounce too.

Motor control with Picaxe.

Page 18: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

13

PICAXE-08M MICROCONTROLLER

A PICAXE microcontroller is a standard Microchip PICmicro™

microcontroller that has been pre-programmed with the PICAXE

bootstrap code. A PIC microcontroller is a single integrated circuit

small enough to fit in the palm of a hand. ‘Traditional’

microprocessor circuits contain four or five separate integrated

circuits - the microprocessor (CPU) itself, an EPROM program

memory chip, some RAM memory and an input/output interface.

With PIC microcontrollers all these functions are included within one

single package, making them cost effective and easyto use.PIC

microcontrollers can be used as the ‘brain’ to control a large variety

of products. In order to control devices, it is necessary to interface

(or ‘connect’) them to the PIC microcontroller. This section will help

to enable those with limited electronics experience to successfully

complete these interfacing tasks.The bootstrap code enables the

PICAXE microcontroller to be re-programmed directly via a simple

serial connection. The PICAXE-08M IS based on PIC12F683 .The

monitor program uses all of the flash memory and the program is

stored in EEPROM (256 bytes).

The PICAXE-08M offers:

80 lines memory

1-4 inputs (configurable)

1-4 outputs (configurable)

2 8/10-bit Analog-to-Digital converters (ADC)

8MHz maximum operation speed (4MHz normally)

Supports o Interrupts

o Digital temperature sensors

Page 19: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

14

o Servo control o IR transmit/receive o Plays user-defined musical tones o PWM Motor control

The PICAXE Memory

The PICAXE memory consists of three different areas. The amount of memory varies between PICAXE types.

Program Memory.

Program memory is where the program is stored after a new download. This is ‘FLASH’ rewritable memory that can be reprogrammed up to (typically) 100,000times. The program is not lost when power is removed, so the program will start running again as soon as the power is re connected. It is not generally required to erase a program, as each download automatically over-writes the whole of the last program. However if you want to stop a program running you can use the PICAXE>Clear Hardware Memory menu to download an ‘empty’ program into the PICAXE.The PICAXE-08M supports 80 lines or 256 bytes of BASIC program code.

Data Memory

Data memory is additional storage space within the microcontroller. The data is also not lost when power is removed. Each download resets all data bytes to 0, unless the EEPROM command has been used to ‘preload’ data into the data memory. See the EEPROM, read and write command descriptions for more details. On the PICAXE-08M the data memory is ‘shared’ with the program memory Therefore larger programs will result is a smaller available data memory area.

Page 20: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

15

RAM (Variables)

The RAM memory is used to store temporary data in variables as the program runs. It loses all data when the power is removed. There are four types of variable general purpose, storage, scratchpad and special function. Variables are memory locations within the PICAXE microcontroller that store data whilst the program is running. All this information is lost when the microcontroller is reset.

General Purpose Variables.

There are 14 or more general purpose byte variables. These byte variables are labeled b0, b1 etc. Byte variables can store integer numbers between 0 and 255.Byte variables cannot use negative numbers or fractions, and will ‘overflow’ without warning if you exceed the 0 or 255 boundary values (e.g. 254 + 3 = 1),(2 - 3 = 255)

Storage Variables.

Storage variables are additional memory locations allocated for temporary storage of byte data. They cannot be used in mathematical calculations, but can be used to temporarily store byte values by use of the peek and poke commands.PICAXE-08M uses 48variables, 80 to 127 ($50 to $7F).

Special Function Variables (SFR)

The special function variables available for use depend on the PICAXE type.

PICAXE-08M SFR

pins = the input / output port

dirs = the data direction register (sets whether pins are inputs or outputs)

infra = another term for variable b13, used within the infrain2 command

Page 21: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

16

FUNCTIONAL BLOCK DIAGRAM OF PICAXE-08M

Page 22: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

17

THE MOTOR DRIVER CIRCUIT

The motor driver circuit is built around the high current half H-Bridge

IC LN 293D. For each motor connected, if the Enable is kept high and

DIR1 is made high, then the motor will rotate in the clockwise

direction. If Enable and DIR2 is made high, then the motor will rotate

in the ant-clockwise direction. If both DIR1 and DIR2 are kept at high,

then the motor will remain static. If enable is low, then the motor

remains static. The inputs DIR1 and DIR2 of each motor are driven by

outputs from the Pin 3(P4) and Pin 5(P2) of the PICAXE.

The IC L293D is a quadruple high-current half h-Drive. The L293D is

designed to provide bidirectional drive currents of up to 600-mA at

voltages from 4.5 V to 36 V. It is designed to drive inductive loads

such as relays, solenoids, dc and bipolar stepping motors, as well as

other high-current/high-voltage loads in positive-supply applications.

All inputs are TTL compatible. Each output is a complete totem-pole

drive circuit, with a Darlington transistor sink and a pseudo-

Darlington source. Drivers are enabled in pairs, with drivers 1 and 2

enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an

Page 23: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

18

enable input is high the associated drivers are enabled and their

outputs are active and in phase with their inputs. When the enable

input is low, those drivers are disabled and their outputs are off and

in the high-impedance state. With the proper data inputs, each pair

of drivers forms a full-H (or bridge) reversible drive suitable for

solenoid or motor applications. A VCC1 terminal, separate from

VCC2, is provided for the logic inputs to minimize device power

dissipation. The L293D is characterized for operation from 0°C to

70°C.

Page 24: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

19

Absolute maximum ratings

Supply voltage, VCC1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 36 V

Output supply voltage, VCC2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 V

Input voltage, VI . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . 7 V

Output voltage range, VO. . . . . . . . . . . . . . . . . . . . –3 V to VCC2 + 3 V

Peak output current, IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ±1.2 A

Continuous output current, IO: L293 . . . .….... . . . .. . . . . . . . . . . ±1 A

Continuous output current, IO: L293D. . . . . . . . . . . . . . . . . . ±600 mA

Continuous total dissipation at (or below) 25°C free-air temperature

…………………………………………………………………. . . . . . …………….2075 mW

Continuous total dissipation at 80°C case temperature . . . 5000 mW

Maximum junction temperature, TJ. . . . . . . . . . …. . . . . . 150°C

Lead temperature………………… . .. . . . . . . . . . . . .. . . . . … . 260°C

Storage temperature range, Tstg . . . . . . . . . . –65°C to 150°C

Page 25: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

20

LIST OF COMPONENTS

COMPONENT DESCRIPTION QUANTITY

PICAXE-08M MICROCONTROLLER 1

L293D MOTOR DRVER IC 1

BC 547 2

VOLTAGE

REGULATOR

L7805,5V 1

RESISTORS R1",22k, R2",10k, R5",10k, R6",10k, R3",1k, R4",1k,

R7",330, R8",330, R9",47k, 10K POT

¼ WATT

CAPACITORS C1",100n, C2",100n, C3",100u, C4",100u, C5",10u,

LDR 1

SPEAKER 1

CONNECTOR 1

DIODE 1N4001 1

BUMP SWITCH 1

Page 26: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

21

PCB LAYOUT

Page 27: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

22

PROGRAMMING THE PICAXE

The serial download circuit is identical for all PICAXE chips. It consists

of 3 wires from the PICAXE chip to the AXE026 serial cable. One wire

sends data from the computer to the serial input of the PICAXE, one

wire transmits data from the serial output of the PICAXE to the

computer, and the third wire provides a common ground. See the

USB adapter section for details on how to use the USB port adapter.

The minimum download circuit is shown here. This circuit is

appropriate for most educational and hobbyist work.

Picaxe Programming Editor

The programs are edited and compiled in Picaxe Programming

editor,which is provided by the manufacturer.It also have a built in

simulator to debug the programs created by the user.The programs

are written and compiled in BASIC and saved with .bas

extension.They are then downloaded to the Microcontroller with the

help of the serial download cable.

Page 28: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

23

Picaxe programming editor

Serial Download Cable

Page 29: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

24

FLOWCHART AND PROGRAM DESCRIPTION The program used three variable memory spaces b0,b1 and b2 to

store the adc reading corresponding to light intensities at front,left

side and right side of the robot. The direction of motion was then

determined by comparing these variables.

MAIN PROGRAM:

Page 30: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

25

SUBROUTINES

Page 31: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

26

PROGRAM MAIN PROGRAM

pwm 1,21,30 'start-up beep

'PWM is used here to circumvent a

' potential SOUND/READADC conflict

main:

if pin3=1 then reverseout 'reverse if S1 bumper bar closes

pause 2000 'pause for two seconds

readadc 1,b1 'check light level directly in front

gosub checkleft 'turn left, using subroutine

readadc 1,b0 'check light level to the left

gosub checkright 'turn right, using subroutine

readadc 1,b2 'check light level to the right

if b0<b2 then left 'if the left is brighter than the right,

' turn left, using subroutine

if b1<b0 then left 'if directly in front is brighter than

' the left, provisionally use subroutine

goto main 'repeat the process

reverseout:

pwm 1,21,20 'beep

high 2 'left motor backwards

high 4 'right motor backwards

high 0 'turn both motors on

for b0=0 to 40 'add a sound effect while reversing

pwm 1,b0,10 ' by varying the PWM duty cycle

Page 32: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

27

next b0 ' from 0 to 40

low 2 'left motor forwards (and right

backwards)

pause 1800 ' for 1.8 seconds

low 0 'turn both motors off

goto main

checkleft:

high 2 'left motor backwards

low 4 'right motor forwards

high 0 'turn both motors on

pause 600 ' for 0.6 seconds

low 0 'turn both motors off

return 'return to where the main program

left off

checkright:

low 2 'left motor forwards

high 4 'right motor backwards

high 0 'turn both motors on

pause 1200 ' for 1.2 seconds

low 0 'turn both motors off

return

left:

if b1<b0 then middle 'skip this if directly in front is

brighter

' than the left, using subroutine middle

high 2 'left motor backwards

low 4 'right motor forwards

Page 33: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

28

high 0 'turn both motors on

pause 1200 ' for 1.2 seconds

low 0 'turn both motors off

goto straight 'drive straight ahead, using subroutine

goto main

middle:

high 2 'left motor backwards

low 4 'right motor forwards

high 0 'turn both motors on

pause 600 ' for 0.6 seconds

low 0 'turn both motors off

goto straight 'drive straight ahead, using subroutine

goto main

straight:

low 2 'left motor forwards

low 4 'right motor forwards

high 0 'turn both motors on

pause 1200 ' for 1.2 seconds

low 0 'turn both motors off

goto main

LDR ADJUST PROGRAM

;LDR TEST

;this adjusts VR1 to suit LDR1 and lighting conditions

;b3=160 when the LDR is directed at the darkest areas of a

room

;aim for the widest variation in b3 as the LDR surveys a scene

;keep the jack plug inserted in the robot while taking readings

Page 34: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

29

main:

readadc 1,b3 ;read the light level

debug b3 ;display the light level on screen (watch b3)

pause 100 ;pause 0.1 seconds

goto main ;repeat the procedure

Page 35: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

30

APPLICATION

The circuit could operate a pulley system, serve as a line-tracker

or rotate motors in response to broken beams of varying intensity

without modification to the PC board.

Page 36: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

31

CONCLUSION

The Programmable Robot was constructed successfully, yielding

satisfactory results. The robot is capable of moving towards areas

having a higher light intensities and avoids obstructions in its path.

Page 37: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

32

FUTURE SCOPE

The Programmable robot has a tremendous scope for improvement .

Some of the possible improvements are listed below.

Instead of using a single LDR, three LDR s can be used so that

the robot needn’t turn every time to read the light intensities

on its sides.

With effective programming, the robot can be configured to do

multitasks.

With a more advanced Microcontroller like Picaxe 14M or

28M,more sensors and output modules can be integrated to

the robot.

Page 38: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

33

BIBLIOGRAPHY

1. Ramakanth A.Gayakwad : Op-Amps and Linear Integrated

Circuits

2. R S Sedha: Applied Electronics

3. Paul Horowitz and Winfield Hill: The Art of Electronics

Page 39: Mini Project Final-Programmable Robot with Picaxe 08M

Mini Project 2009 Programmable Robot Using PICAXE-08M

34

REFERENCES

1. www.microchip.com

2. www.wikipedia.com

3. www.roboticsindia.com

4. www.electro-tech-online.com

5. www.howstuffworks.com

6. www.picaxe.co.uk

7. http://www.picaxeforum.co.uk