Sunteți pe pagina 1din 50

The iBot Guide

An 8051 based autonomous robotics platform

Welcome to the world of autonomous robotics!

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 1

The iBot Guide


Index
Pages About iBot .3 How to use this guide Parts description iBot controller board.. 4 Line sensing module.. 6 IR proximity sensor8 DC Power supply and battery 10 iBot controllers first test run 11 How to load your first program into iBot 13 Assembling the iBot..17 Programming your iBot . 28 1. Blinking LED. 29 2. Switches and LEDs 30 3. Sensors and Motors 32 4. Using the LCD module.. 33 5. Communicating with the PC using UART 34 6. Simple Line Follower 36 7. Obstacle Avoider... 39 8. Sumo Bot ...41

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 2

About iBot
Working with iBot is an ideal way to venture into the field of autonomous robotics. The iBot controller board is simple yet feature packed so as to cater to a wide range of applications. This kit is based around the popular 8051 microcontroller architecture and strives to bridge the gap between concepts been taught in the classrooms and actually implementing them practically. iBot is essentially related to a variety of fields comprising of embedded C programming, microcontrollers, electronics and mechanics. And since the controller is so closely related to the academic curriculum, user would find it very easy to work with. With this kit the user shall have a hands-on experience of working with different sensors, such as line sensing modules and IR proximity sensors, use of different actuators like DC geared and stepper motors, their drivers, LCD interfacing and serial communication with the PC. iBot follows a modular approach throughout its construction, so the user can easily add new features and behaviors from line following, obstacle avoiding to swarm robotics and a basic micromouse. It can also be used as a generic embedded systems development platform. We hope that building this autonomous robot will be an enriching experience and would drive you to further pursue robotics seriously.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 3

The iBot Controller Board


The iBot Controller Board is based around the Philips 89V51RD2 microcontroller. Features:

Built around the popular 89V51RD2 microcontroller with ample of program memory (64Kb) 8 channels of motor control, capable of driving 4 dc motors or 2 stepper motors at a time. Onboard detachable 16x2 LCD for enhanced interaction. 8 digital input channels for sensor interfacing. Onboard RS232 level shifter for direct communication with a computer. 4 general purpose LEDs and Switches.

Parts identification: Power On Switch: Its a basic push to on - push to off type switch. IC 7805: Its a three terminal linear 5 volt regulator used to supply the microcontroller and other peripherals. TRI Technosolutions Pvt. Ltd. www.triindia.co.in 4

Motor Enable switch: This switch is used to enable/disable the motor driver chips hence in turn enabling/disabling the motors. Reset Switch: This switch is used to reset the microcontroller. IC 555: This general purpose timer is used in the mono-stable mode to automatically reset the microcontroller during programming. MAX 232: This chip takes care of the voltage conversions needed to communicate with the PCs RS232 (Serial/ COM) port. L293D: It is a 4 channel motor driver with 600mA of current per channel and has inbuilt clamp diodes. The board contains two such chips. Potentiometer (Pot): The potentiometer is used to vary the contrast of the LCD. Sensor port: At a time, 8 individual sensor modules can be connected to this port. The port also provides a 5V supply needed drive the sensors. DB 9 connector: This is a 9 pin connector used to connect to the PCs COM port during programming or for general UART communications. Switch array: Four general purpose switches are connected in the active-low configuration. Crystal: A crystal sets the microcontrollers clock frequency to 11.0592 MHz. Beeper: Connected in the active low mode, the beeper can easily be used to get audible feedbacks from the controller.

Motor Connectors M4 M3 M2 M1 Switches Sw1 Sw2 Sw3 Sw4 LEDs D1 D2 D3 D4 LCD Data Control pins ISP RXD TXD Sensor Connectors Misc Buzzer Crystal (11.0592Mhz) Reset Switch PORTS P2.0, P2.1 P2.2, P2.3 P2.4, P2.5 P2.6, P2.7 (active low) P3.2 P3.3 P3.4 P3.5 (active low) P3.0 P3.1 P3.6 P3.7 P0.4 to P0.7 P0.0 to P0.2 P3.0 P3.1 P1.0 to P1.7

P0.3 Pin 18 and 19 Pin 9

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 5

The line sensing module


The line sensing module is designed to detect a white line on a black surface from an ideal distance of 10mm to 20mm. The module detects the line by measuring the intensity of reflected Infrared (IR) light. The sensor can be tuned to detect various contrasts, say white line on a green surface or a white line on a black surface. The red indicator led lights up whenever in encounters a reflecting surface (white line)

Tuning the line sensing module:


You need the power supply/battery, controller board, sensor module and a screw driver. Step 1: Connect you module to one of the sensor port on the iBOT proV 2.1 controller. Refer the adjoining figure for reference.

Step 2: Turn on the power supply of your iBOT proV 2.1 controller.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 6

Step 3: Place your sensor at a distance of approximately 2cm above the surface that you dont want to detect, eg., a black surface.

Step 4: Using the screw driver, turn the potentiometer in either direction. You will notice that the indicator LED lights up at a particular point and goes off at another point. Now, in order to properly tune to the sensor, you need to turn the pot to such a point that the LED just turns off.

Step 5: Now when you place you sensor on a reflective surface (such as white) youll see the indicator LED glows. Thats it! We now have our Line Sensing Module all tuned up!

Specifications
Input Voltage: 5Volts Optimum detecting distance: 10mm

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 7

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 8

IR Proximity Sensor Module


The IR proximity sensor module is based around the TSOP sensor, commonly used in TV remote receivers. This module is able to detect objects at a distance of 5cm to 15cm. The maximum detectable distance varies in accordance with the color and texture of the object. For example, a white object can be easily detected from a distance of 15cm while a black object would be detectable from a maximum distance of 5cm.

Tuning the obstacle detection module: You need the power supply/battery, controller board, IR proximity sensor module and a screw driver. The sensors can be tuned so as to change the maximum detectable distance. This can be varied by changing the intensity of the IR emitter. Step 1: Connect you module to one of the sensor port on the iBot controller. Refer the adjoining figure for reference.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 9

Step 2: Turn on the power supply of your iBot controller. Step 3: With the help of a screw driver, turn the potentiometer in such a way that the indicator LED just turns off. (if its already turned off, skip this step)

Step 4: Place an object (non-black) in front of the module at a distance of about 10cm and turn the potentiometer such that the indicator LED just lights up. This step makes sure that the same object would always be detected at a maximum distance of 10cm. Similarly, you could move the object and turn your potentiometer to achieve an optimum distance.

Specifications: Operating Voltage: 5Volts Current Consumption: xxmA Detectable distance: 5cm to 15cm

NOTE: IR light is invisible to the human eye but digital cameras like webcams or cell-phone cameras are capable of detecting it. Point your camera towards the IR emitter (while turned on) and see for yourself! This is a very handy debugging tool.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 10

The DC Power Supply and Battery


Power Supply: The DC Power supply provides 9Volts and a max current of up to 1A. It also has a provision to safely charge the 9.6V Ni-Mh battery pack at a constant preset current. The DC Supply Out and the Battery Pack have negative polarity on the outside and positive inside. (Photo of the power supply) Add schematic.

The Battery Pack: The battery pack consists of 8 AA Ni-Mh Cells of 1.2V each, rated at 1300mAh. Thus, the total voltage rating of the battery pack is of 9.6Volts. In order to charge the pack, simply connect its plug to the charger port and turn on the supply. A full charge would take about 4 to 5hrs.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 11

iBot Controllers first test run


Your iBot controller board comes preprogrammed with some sample programs to get you started. Heres what you need for your boards first test run: The iBot Controller Board LCD module The Power Supply One iBot DC motor Line sensing module IR Proximity sensor Screwdriver

Step 1: Connect the LCD module to the iBot controller board as shown in the figure. The connector would plug in with a small amount of force.

Step2: Connect the power supply connector to the board. Turn on the power supply and then press the power switch on the controller. The blue power LED will now light up and a welcome message will appear on the LCD. Adjust the contrast pot for optimum text viewing. Step 3: Now, you shall see the program list, two at a time. Use the switches to scroll up and down the menu and select the respective programs. Switch 1: scroll up Switch 2: scroll down Switch 3: select

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 12

The menu flowchart: START

Welcome Screen Program Selection

Program 1 Blinking LEDs

Program 2 Switches and LEDs Reset

Program 3 Running Motors

Program 1: Blinking LEDs Now select the first program (blinking LEDs) by pressing switch 3. You will now see all the LEDs lighting up in various sequences. To return to the main screen press the reset switch. Program 2: Switches and LEDs Scroll dowm one step and select the second program (Switches and LEDs) on the menu. This program demonstrates the ability to use switches to trigger different events (in this case turn on/off respective LEDs). Try pressing one of the four switches and observe what happens. Press reset to return to the main window. Program 3: Running the motor In this program we will see how to connect and drive a dc motor in accordance with the state of the proximity sensor. Make sure you have pressed the motor enable switch before you run this program. One IR proximity sensor is connected to PORT 1s pin 0 and one motor is connected to M1 (pin 0 and 1 of PORT 2) The motor shall run in one direction under normal conditions, and when you bring an object closer to the proximity sensor, the motor will spin in the other direction.

Note: All of the above programs are explained in detail in the programming section.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 13

Loading a new program into the iBOT controller board


Checklist: iBot controller board Serial Cable Power Supply TRI C Flash Magic Some patience Ok so you have collected all the tools and are ready for some coding. I assume that you have installed TRIC and Flash Magic on your PCs. STEP 1 To create a new project file select from the TRIC menu Project New Project. This opens a standard Windows dialog that asks you for the new project file name. You should you use a separate folder for each project. You can simply use the icon Create New Folder in this dialog to get a new empty folder.Select this folder and enter the file name for the new project, i.e. Project1. TRIC creates a new project file with the name PROJECT1.trc. You can see this name in the Project Window.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 14

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 15

STEP 2 You may create a new source file with the menu option File New. This opens an empty editor window where you can enter your source code. TRIC enables the C color syntax highlighting. You can save your file with the dialog File Save or Save As... under a filename with the extension *.C (by default). We are saving our example file under the name EXAMPLE.C.
/* Program to blink an LED */ #include<p89v51rd2.h> /*we include the necessary header file here which depends on the type of microcontroller we use. There are separate header files for separate microcontrollers in SDCC.*/ void delay(unsigned int dela) /*This a simple delay function using the nested for loop { unsigned int i,j; for(i=0;i<=1000;i++) for(j=0;j<=dela;j++); } void main(void) { while (1) //since there is no where to return //we put it in an infinite loop { RXD=0; //LED 1 is on pin RXD at PORT 3_1, we //turn it ON delay (20); RXD=1; delay(20); } } //wait for a short time //turn the LED 1 OFF //wait for a short time //main program begins here */

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 16

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 17

STEP 3 Once you have created your source file you can add this file to your project. TRIC enables you to add source files to a project from Project menu-----Add Main File. The option Add Main Files opens the standard files dialog. Select the file EXAMPLE.C you have just created. If your main file has more than one file then you add more files using the option Add Sub File. The name of the added files can be seen in the Project workspace.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 18

STEP 4 Now finally you can compile your project using the Project ----Compile option, which displays errors and warnings if any in the source code otherwise generates the EXAMPLE.ihx to download the software into an EPROM programmer like FLASH.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 19

STEP 5: Start the Flash Magic. Select the microcontroller and enable the following options. 1) Select the COM port 2) BAUD rate 3) DEVICE 4) Interface 5) Click on ERASE all FLASH 6) Tick on the Verify after Program link 7) Go to options on the top toolbar 8) Select Advanced Options 9) Select Hardware Config 10) Untick Use DTR to control RST link 11) Select OK"

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 20

STEP 6: Browse and select the HEX file that was created earlier. It can be located in the same folder where you saved your project file. (in this case, the file would be itrix.hex and not led.hex) STEP 7: Connect the serial cable between the PC and your controller board and then plug in the power supply (battery or separate). Turn ON the board.

STEP 8: Click the start button on Flash Magic and wait till it programs the uC and displays a finished sign at the bottom. Press the reset button on the board. In this section we learned how to write a program in C and then run it on your iBOT controller board. Now you can similarly load new programs of your own or try some of the sample programs given in the accompanying iBOT CD.

Note: 89V51RD2 has an inbuilt bootloader and therefore no separate hardware is required to program it.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 21

Assembling the iBot kit

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 22

Assembling the iBot kit


Parts Checklist:

Sr. No. Parts 1 2 - Tyres 2 2 - Wheels 3 13 - 3mm nuts 4 10 - 15mm spacers 5 Hinge 6 Caster-ball wheel 7 Front plate 8 Top plate 9 Bottom plate 10 2 - Side plates 11 4 - Lugs 12 2 - DC Geared Motors 13 16 - M4x6 screws 14 4 - M3x50 screws 15 2 - M3x20 screws 16 2 - M4x12 screws 17 8 - M3x6 screws 18 2 - 12mm nuts TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 23

Step 1

Step 2

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 24

Step 3

Step 4

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 25

Step 5

Step 6

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 26

Step 7

Step 8

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 27

Step 9

Step 10

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 28

Step 11

Step 12

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 29

Step 13

Step 14

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 30

Programming your iBot

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 31

1. Program to blink an LED


Since this is our first program, we will try to keep things simple. The following program will blink an LED on the board at a particular rate. A generic algorithm for such a program will be something like this: Step 1: Turn ON the LED Step 2: Wait for sometime Step 3: Turn OFF the LED Step 4: Wait for sometime Step 5: Goto Step1 To turn ON an LED on the iBOT board, we need to send logic 0 to that particular pin (since LEDs are connected in the active low configuration). In order to introduce a delay, we need to eat up some processor time. The simplest way to achieve this is to perform a NOP (No Operation) multiple times. And continuous looping can be achieved by either using the statement goto or more appropriately by using the while() loop. Now lets see how we can put all of these things together in a C program. // Program to blink an LED // #include<P89V51RD2.h> void delay(unsigned int dela) { unsigned int i,j; for(i=0;i<=1000;i++) for(j=0;j<=dela;j++); } void main(void) { while (1) { RXD=0; delay (20); RXD=1; delay(20); } } We begin with including the header file for the microcontroller. Next we write the delay() function using the nested for loop. Dont worry about the exact time of delay over here, you can experiment with different values and see what difference it makes. For example, replacing delay(20) with delay(60) will reduce the frequency while delay(10) would increase the frequency. You could also try and use all the LEDs and generate different patterns. //LED 1 is on pin RXD at PORT 3_1, we //turn it ON //wait for a short time //turn the LED 1 OFF //wait for a short time //main program begins here //we include the necessary header file here //This a simple delay function using the //nested for loop

//since there is no where to return //we put it in an infinite loop

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 32

Note: The LEDs are connected in an active-low configuration. Therefore, to turn ON an LED, we need to send logic 0 and logic 1.

2. Program using Switches and LEDs


Now that we know how to turn on/off a particular pin of the microcontroller, as seen in the previous example, lets see how we can take inputs from a particular pin and execute actions based on its state. In this example, we will be using switches as our inputs and LEDs as the outputs. The simplest way to know the state (is it high or low?) of a particular pin is to poll it continuously. The algorithm would go something like this: Step 1: Check if Switch 1 is pressed; if pressed, turn ON LED 1, else, turn it OFF. Step 2: Check if Switch 2 is pressed; if pressed, turn ON LED 2, else, turn it OFF. . . . Step n: goto step 1. Lets see how a C program based on this algorithm would look like: // Program using Switches and LEDs // #include<P89V51RD2.h> void main(void) { P3=0x3C; while (1) { if (P3_2==0) { P3_0=0; } else P3_0=1; if (P3_3==0) { P3_1=0; } else P3_1=1; if (P3_4==0) { P3_6=0; } else P3_6=1; if (P3_5==0) { P3_7=0; } else P3_7=1; //check if Switch 1 is pressed //if pressed, turn ON LED 1 //else turn it OFF //check if Switch 2 is pressed //if pressed, turn ON LED 2 //else turn it OFF //check if Switch 3 is pressed //if pressed, turn ON LED 3 //else turn it OFF //check if Switch 4 is pressed //if pressed, turn ON LED 4 //else turn it OFF //we include the necessary header file here //main program begins here //initialize PORT 3 to 00111100 = 0x3C //since there is no where to return, //we put it in an infinite loop

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 33

} } You will notice that we have written P3=0x3C at the very beginning of our program. This is done to set PORT 3s pin 2, 3, 4 and 5 as inputs since we have connected our switches to them while pin 0, 1, 6 and 7 are the outputs where LEDs are connected. (1 Input, 0 Output) Note: The switches are connected in an active-low configuration. Therefore, whenever a switch is pressed, we will receive logic 0 on that particular pin and not logic 1.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 34

3. Program using a Sensor and a DC Motor


Lets try and make our next program more animated. In this example, we will control the direction of the motor based on the state of a sensor. Heres the algorithm: Step 1: Initialize the ports Step 2: Check the state of the sensor; if active, turn motor in one direction, else, turn it in other direction. Step 3: goto step 2 One IR proximity sensor is connected to PORT 1s pin 0 and one motor is connected to M4 (pin 0 and 1 of PORT 2) // Program using Sensor and DC Motor // #include<P89V51RD2.h> //we include the necessary header file here

void main(void) { P1=0xff; P2=0x00; while (1) { if (P1_0==0) { P2=0x05; } else P2=0x0A; 0010) } }

//main program begins here //initialize PORT 1 as input //initialize PORT 2 as output //since there is no where to return, //we put it in an infinite loop //check if sensor at PORT1.0 is active //0 active, 1 inactive //if active, turn motor in one //direction (0000 0001) //else turn it in other direction (0000

Similarly, you can write a code to turn both the motors and use both sensors together.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 35

4. Program using the LCD module


LCD is one of the most multipurpose modules a robot can have. It can be used to display information, check various states of the robot, see the parameters as you feed them and also as a handy debugging tool. And the cool factor cannot be understated as well. iBOT uses a 2x16 backlight display that is compatible with the universally accepted Hitachi format. LCDs are not as easy to use as the LEDs but they are not very difficult either. To make things simpler for you, we have written a small library for all the LCD functions. Lets look at the LCD functions that we have at our disposal: LCD_INIT() Initializes the LCD in 2 line 4 bit mode with blinking cursor. LCD_CHAR(T) Used to write any character T to the LCD. LCD_WRITE(Xplore Robotics) Used to write a string on the LCD (max 16 characters in length) LCD_CMD(X) To give commands to the LCD. X can be as follows PUTLINE1 Places cursor on line1 PUTLINE2 - Places cursor on line2

To place the cursor on a particular character box it is addressed as follows: Command = LCD_CMD(0b1XXX XXXX); where xxx xxxx is the address of character in binary. Note: LCD row 1 address starts at 0x00 and row 2 starts at 0x40 Eg: To put cursor on 3 character line 1 LCD_CMD(0x83); To put cursor on 5 character line 2 LCD_CMD(0xC5); LCD_CMD(LCD_CLEAR) Clears LCD screen.

Heres a sample program for using the LCD module with the help of the above functions: // Program using the LCD module// #include<P89V51RD2.h> #include<delay.h> #include<LCD.h> void main (void) { LCD_INIT(); LCD_WRITE("TRI"); LCD_CMD(PUTLINE2); LCD_WRITE("HELLO WORLD !!"); while(1){}

//Include the necessary header files

//Initialize the LCD module //Send a string to display //Move the cursor to second line //Send a string to display //Loop Infinitely

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 36

5. Program to communicate with the PC via UART


In this program we will learn how to make your iBOT communicate with the PC through the UART channel. In order to do this, first refer to the datasheet of 89V51RD2 microcontroller and have a look at the UART section and the SCON (serial port control) register configurations. In the following program, the microcontroller will send a start string to the PC at the beginning of the execution and simultaneously accept data coming from the PC (anything that you type on the keyboard) and display in on to the onboard LCD module. //Program using to communicate with the PC via UART// #include<P89V51RD2.h> #include<delay.h> #include<LCD.h> unsigned char RXED,TXED; void UART_INIT(void) { SBUF=0x00; SM0=0; SM1=1; SM2=0; REN=1; TMOD=0x2F; TH1=253; TR1=1; ES=1; EA=1; } void TX(unsigned char dat) { SBUF=dat; DELAY(10); } void RXTX_int(void) interrupt 4 //Serial interrupt ISR { if(RI==1) { RI=0; //Reset receive data bit RXED=SBUF; LCD_CHAR(RXED); //Display received character on LCD } if(TI==1) { TI=0; } } void main(void) { //Main program begins here //UART Initialization //Empty Serial Buffer //Set UART //in mode 1 //Receive Enable //Set baud //rate as 9600bps //Enable serial interrupts //Global interrupt enable

//Transmit Data

//Reset transmit data bit

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 37

LCD_INIT(); UART_INIT(); DELAY(10); TX('S'); TX('t'); TX('a'); TX('r'); TX('t'); while(1){} }

//Initialize LCD //Initialize UART //wait for a while //Transmit S //Transmit t //Transmit a //Transmit r //Transmit t

After loading the program on to your iBOT controller, open the Hyper Terminal on your PC. You can find it in Start > Programs > Accessories > Communications > Hyper Terminal Step 1: Enter a name for the connection

Step 2: Select the COM port and configure its properties

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 38

6. Line Following Robot


Time to actually build a robot! Lets put everything that we learned till now in our next program. Line following is one of the simplest task a robot can perform. There are many algorithms and sensor configurations designed to do this. Heres one of the simplest and fail safe line followers algorithm: In this configuration we use two line sensors.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 39

START

Initialize Ports

Is right line sensor active?

YES Turn Left

NO Is left line sensor active? YES NO

Is left line sensor active?

YES

Turn right NO Go straight Is right line sensor active? NO

YES
Basically, the robot will always try to get the sensors on the line alternately, thus moving in a zig-zag path and eventually follow the line. The following code is written to follow a black line on a white surface but it can be easily modified to follow a white line on a black surface.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 40

// LINE FOLLOWING ROBOT // //Right line sensor connected to PORT1.0 //Left line sensor connected to PORT1.1 //Right motor connected at M2 //Left motor connected at M1 #include<P89V51RD2.h> #define #define #define #define #define forward right left linesensor_right linesensor_left //we include the necessary header file here 0x05 0x01 0x04 P1_0 P1_1 // 0000 01 01 // 0000 00 01 // 0000 01 00

void main(void) { P1=0xff; P2=0x00; while (1) { if (linesensor_right==0) detected {

//main program begins here //initialize PORT 1 as input (sensors) //initialize PORT 2 as output (motors) //since there is no where to return, //we put it in an infinite loop //check if right sensor has // a line (black surface)

while(linesensor_left==1) { P2=right; } } if (linesensor_left==0) { while(linesensor_right==1) { P2=left;

//if detected, then turn right till //the left sensor comes on the line

// check if left sensor has detected // a line //if detected, then turn left till //the right sensor comes on the line

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 41

} } else { P2=forward; } } }

//else go forward

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 42

7. Obstacle Avoiding robot


Obstacle avoiding behavior is a prerequisite in any mobile robotic application. In this project we will learn to add such a behavior in our iBOT. Heres a simple algorithm: Step 1: check if right ir proximity sensor is active; if active, turn left for a while Step 2: check if left ir proximity sensor is active; if active, turn right for a while Step 3: else move forward Step 4: goto step 1

// OBSTACLE AVOIDING ROBOT // //Right proximity sensor connected to PORT1.2 //Left proximity sensor connected to PORT1.3 //Right motor connected at M2 //Left motor connected at M1 #include<P89V51RD2.h> #include<delay.h> #define forward #define turnleft 0x05 0x06 //we include the necessary header file here

// 0000 01 01 // 0000 01 10 left motor = backwards, // right motor = forward // 0000 10 01 left motor = forward, // right motor = backwards

#define turnright 0x09 #define obst_right #define obst_left void main(void) { P1_2 P1_3

//main program begins here

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 43

P1=0xff; P2=0x00; while (1) { if (obst_right==0) { P2=turnleft; DELAY(30); } if (obst_left==0) { P2=turnright; DELAY(30); } else { P2=forward; }

//initialize PORT 1 as input (sensors) //initialize PORT 2 as output (motors) //since there is no where to return, //we put it in an infinite loop //check if right sensor has detected an obstacle //if detected, turn left for some time

//check if left sensor has detected an obstacle //if detected, turn right for some time

//else go forward

} } By changing the delay variable we can make the robot turn for some specific degrees after it detects an obstacle. But the turns will not be precise since they will change as the battery drains. Note: In this particular case, the turning would be in place i.e., while turning, both the motors will run in opposite direction unlike the line follower, where the turns were turning by stopping either of the motor.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 44

8. Sumo Robot
In the previous two examples we learned how to use the line sensing modules as well as the IR proximity modules. Now lets see how we can have a behavior that uses both of these sensors together. A sumo robot fits this bill perfectly. Inspired from the tradition human sumo competitions held in Japan, robotics enthusiasts soon started having robotics sumo. Sumo robotics competitions are now held around the world under various weight and size classes just like the real ones. In a typical sumo robotics competition, two robots compete against each other inside a sumo ring. The ring is a made up of a black surface with a white line around its circumference as shown. The idea is to push the opponent out of the ring in the stipulated time frame.

A typical sumo robot flowchart:

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 45

Start

Initialize ports

Turn left

Is the opponent on the left and me not on the edge?

NO YES Turn right

Is the opponent on the right and me on the edge?

NO YES Go forward Is the opponent in front and me not on the edge?

NO YES Turn backwards then turn left Is the right line sensor active?

NO YES Is the right line sensor active?

Turn backwards then turn right

NO Go forward

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 46

// SUMO ROBOT // //Right line sensor connected to PORT1.0 //Left line sensor connected to PORT1.1 //Right proximity sensor connected to PORT1.2 //Left proximity sensor connected to PORT1.3 //Right motor connected at M2 //Left motor connected at M1 #include<P89V51RD2.h> #include<delay.h> #define forward #define reverse #define turnleft #define turnright #define #define #define #define linesensor_right linesensor_left obst_right obst_left //we include the necessary header file here

0x05 0x0A 0x06 0x09 P1_0 P1_1 P1_2 P1_3

// // // // // //

0000 01 01 0000 10 10 0000 01 10 left motor = backwards, right motor = forward 0000 10 01 left motor = forward, right motor = backwards

void main(void) { P1=0xff; P2=0x00; while (1) { while (

//main program begins here //initialize PORT 1 as input (sensors) //initialize PORT 2 as output (motors) //since there is no where to return, //we put it in an infinite loop obst_right==0 && obst_left==1 && linesensor_right==1 && linesensor_left==1) //check if right sensor has //detected the opponent //and make sure that the robot //not on the edge

is

{ P2=turnright; } //if detected, turn right //(i.e., towards the opponent)

while (

obst_left==0 && obst_right==1 && linesensor_right==1 && linesensor_left==1) { P2=turnleft; }

//check if left sensor has //detected the opponent //and make sure that the robot //not on the edge

is

//if detected, turn left //(i.e., towards the opponent)

while (

obst_left==0 && obst_right==0 && linesensor_right==1 && linesensor_left==1) { P2=forward;

//check if both sensors //have detected the opponent

//if detected, go forward

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 47

//chase him and push him

if (linesensor_right==1 ) { P2=reverse; DELAY(400); P2=turnleft; DELAY(300); P2=forward; } if (linesensor_left==1 ) { P2=reverse; DELAY(400); P2=turnright; DELAY(300); P2=forward; } else { P2=forward; } } }

//check if right line sensor has // detected the ring //if detected, go reverse for a while //then turn left for a while //and go forward

//check if left line sensor has //detected the ring //if detected, go reverse for a while //then turn right for a while //and go forward

//else go forward

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 48

The iBot Component List.


The list of components you will find in your bag.
1. Controller Board 2. Laser cut, powder coated MS Chassis. 3. 2 geared motors. 4. 8 x 1.2V rechargeable NiMH battery pack. 5. DC power supply with built-in NiMH battery charger. 6. Two Infrared line detecting modules. 7. Two Infrared obstacle detecting modules. 8. 16x2 LCD module. 9. Pair of Tyres with wheels. 10. Screw Driver. 11. Packet consisting of nut, bolt, spacer, hinge, lugs and omni-directional Caster wheel. 12. Manual and CD including starter guide, assembly guide and utilities. 13. Serial Port Connector.

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 49

The iBot Kit applications in Robotics.


The iBOT kit can be used as a platform for building robots for various applications. Some of the possible applications are listed below 1. Line Follower Robot 2. Obstacle avoider / follower. 3. Wall follower. 4. SUMO robot. 5. Non-autonomous / semi-autonomous robot. 6. RF controlled robot. 7. Robotic Arm using RC servos (provided required current rating is not exceeded) 8. Micro-mouse. 9. Distance measurement robot. 10. Edge avoiding robot. 11. Soccer Playing robot. 12. Grid Solving robot. 13. PC controlled robots 14. Autonomous robot to solve a problem statement 15. Collaborative Robotics The master Slave SPI port along with the ample program and data memory serve as a good base for communication between 2 or more bots making the iBOT platform suitable for a study on collaborative robotics

The rest is upto your IMAGINATION!!!!

TRI Technosolutions Pvt. Ltd.

www.triindia.co.in 50

S-ar putea să vă placă și