itrix manual

Upload: misha-vucicevic

Post on 03-Jun-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Itrix Manual

    1/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 1

    The iBot GuideAn 8051 based autonomous robotics platform

    Welcome to the world of autonomous robotics!

  • 8/13/2019 Itrix Manual

    2/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 2

    The iBot Guide

    IndexPages

    About iBot .3

    How to use this guide

    Parts descriptioniBot controller board.. 4Line sensing module.. 6IR proximity sensor8DC 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 . 281. Blinking LED. 292. Switches and LEDs 303. Sensors and Motors 324. Using the LCD module.. 335. Communicating with the PC using UART 346. Simple Line Follower 367. Obstacle Avoider... 398. Sumo Bot ...41

  • 8/13/2019 Itrix Manual

    3/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 3

    About iBotWorking with iBot is an ideal way to venture into the field of autonomous robotics. The iBotcontroller 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 bridgethe gap between concepts been taught in the classrooms and actually implementing thempractically. iBot is essentially related to a variety of fields comprising of embedded Cprogramming, microcontrollers, electronics and mechanics. And since the controller is soclosely 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 DCgeared and stepper motors, their drivers, LCD interfacing and serial communication with thePC.

    iBot follows a modular approach throughout its construction, so the user can easily add newfeatures and behaviors from line following, obstacle avoiding to swarm robotics and a basicmicromouse. 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 woulddrive you to further pursue robotics seriously.

  • 8/13/2019 Itrix Manual

    4/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 4

    The iBot Controller BoardThe 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 atime.

    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 andother peripherals.

  • 8/13/2019 Itrix Manual

    5/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 5

    Motor Enable switch: This switch is used to enable/disable the motor driver chips hence inturn 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 resetthe microcontroller during programming.MAX 232: This chip takes care of the voltage conversions needed to communicate with thePCs RS232 (Serial/ COM) port.L293D: It is a 4 channel motor driver with 600mA of current per channel and has inbuiltclamp 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 portalso 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 duringprogramming 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 audiblefeedbacks from the controller.

    Motor Connectors PORTSM4 P2.0, P2.1M3 P2.2, P2.3M2 P2.4, P2.5M1 P2.6, P2.7

    Switches (active low)Sw1 P3.2Sw2 P3.3Sw3 P3.4Sw4 P3.5

    LEDs (active low)D1 P3.0D2 P3.1D3 P3.6D4 P3.7

    LCDData P0.4 to P0.7

    Control pins P0.0 to P0.2ISP

    RXD P3.0TXD P3.1

    Sensor Connectors P1.0 to P1.7

    MiscBuzzer P0.3

    Crystal (11.0592Mhz) Pin 18 and 19Reset Switch Pin 9

  • 8/13/2019 Itrix Manual

    6/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 6

    The line sensing module is designed to detect a white line on a black surface from an idealdistance of 10mm to 20mm. The module detects the line by measuring the intensity ofreflected Infrared (IR) light. The sensor can be tuned to detect various contrasts, say whiteline 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)

    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. Referthe adjoining figure for reference.

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

  • 8/13/2019 Itrix Manual

    7/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 7

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

    Step 4: Using the screw driver, turn the potentiometer in eitherdirection. You will notice that the indicator LED lights up at aparticular point and goes off at another point. Now, in order toproperly tune to the sensor, you need to turn the pot to such apoint 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! Wenow have our Line Sensing Module all tuned up!

    Input Voltage: 5VoltsOptimum detecting distance: 10mm

  • 8/13/2019 Itrix Manual

    8/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 8

  • 8/13/2019 Itrix Manual

    9/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 9

    IR Proximity Sensor ModuleThe IR proximity sensor module is based around the TSOP sensor, commonly used in TVremote receivers. This module is able to detect objects at a distance of 5cm to 15cm. Themaximum 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 blackobject 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 ascrew driver.The sensors can be tuned so as to change the maximum detectable distance. This can bevaried by changing the intensity of the IR emitter.

    Step 1: Connect you module to one of the sensor port on the iBot controller. Refer theadjoining figure for reference.

  • 8/13/2019 Itrix Manual

    10/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 10

    Step 2: Turn on the power supply of your iBotcontroller.

    Step 3: With the help of a screw driver, turn thepotentiometer in such a way that the indicator LED justturns off. (if its already turned off, skip this step)

    Step 4: Place an object (non-black) in front of themodule at a distance of about 10cm and turn thepotentiometer such that the indicator LED justlights up. This step makes sure that the same objectwould always be detected at a maximum distanceof 10cm.

    Similarly, you could move the object and turn yourpotentiometer to achieve an optimum distance.

    Specifications:Operating Voltage: 5VoltsCurrent Consumption: xxmADetectable distance: 5cm to 15cm

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

  • 8/13/2019 Itrix Manual

    11/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 11

    The DC Power Supply and BatteryPower Supply:The DC Power supply provides 9Volts and a max current of up to 1A. It also has a provisionto safely charge the 9.6V Ni-Mh battery pack at a constant preset current. The DC SupplyOut 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, simplyconnect its plug to the charger port and turn on the supply. A full charge would take about 4to 5hrs.

  • 8/13/2019 Itrix Manual

    12/50

  • 8/13/2019 Itrix Manual

    13/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 13

    The menu flowchart:

    Program 1: Blinking LEDsNow select the first program (blinking LEDs) by pressing switch 3. You will now see all theLEDs lighting up in various sequences. To return to the main screen press the reset switch.

    Program 2: Switches and LEDsScroll dowm one step and select the second program (Switches and LEDs) on the menu. Thisprogram demonstrates the ability to use switches to trigger different events (in this case turnon/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 motorIn this program we will see how to connect and drive a dc motor in accordance with the stateof the proximity sensor. Make sure you have pressed the motor enable switch before you runthis 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, andwhen you bring an object closer to the proximity sensor, the motor will spin in the otherdirection.

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

    Reset

    START

    Program 1Blinking LEDs

    Program 2Switches and

    LEDs

    Program 3RunningMotors

    Welcome ScreenProgram Selection

  • 8/13/2019 Itrix Manual

    14/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 14

    Loading a new program into the iBOT controllerboardChecklist:

    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 haveinstalled TRIC and Flash Magic on your PCs.

    STEP 1

    To create a new project file select from the TRIC menu Project New Project . Thisopens a standard Windows dialog that asks you for the new project file name. You shouldyou 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 newproject, i.e. Project1 . TRIC creates a new project file with the name PROJECT1.trc . Youcan see this name in the Project Window .

  • 8/13/2019 Itrix Manual

    15/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 15

  • 8/13/2019 Itrix Manual

    16/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 16

    STEP 2

    You may create a new source file with the menu option File New . This opens an emptyeditor window where you can enter your source code. TRIC enables the C color syntaxhighlighting. You can save your file with the dialog File Save or Save As... under afilename with the extension *.C (by default). We are saving our example file under the nameEXAMPLE.C .

    /* Program to blink an LED */

    #include

    /*we include the necessary header file here which depends on the type ofmicrocontroller we use. There are separate header files for separatemicrocontrollers 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

  • 8/13/2019 Itrix Manual

    17/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 17

  • 8/13/2019 Itrix Manual

    18/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 18

    STEP 3

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

  • 8/13/2019 Itrix Manual

    19/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 19

    STEP 4

    Now finally you can compile your project using the Project ----Compile option, whichdisplays errors and warnings if any in the source code otherwise generates the

    EXAMPLE.ihx todownload the software intoan EPROM programmerlike FLASH.

  • 8/13/2019 Itrix Manual

    20/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 20

    STEP 5 :

    Start the Flash Magic. Select themicrocontroller and enable the followingoptions.

    1) Select the COM port2) BAUD rate3) DEVICE4) Interface5) Click on ERASE all FLASH6) Tick on the Verify after Program link7) Go to options on the top toolbar8) Select Advanced Options9) Select Hardware Config10) Untick Use DTR to control RST

    link

    11) Select OK"

  • 8/13/2019 Itrix Manual

    21/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 21

    STEP 6:

    Browse and select the HEX file that was created earlier. It can be located in the same folderwhere 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 powersupply (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 afinished 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 iBOTcontroller board. Now you can similarly load new programs of your own or try some of thesample programs given in the accompanying iBOT CD.

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

  • 8/13/2019 Itrix Manual

    22/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 22

    Assembling the iBot kit

  • 8/13/2019 Itrix Manual

    23/50

  • 8/13/2019 Itrix Manual

    24/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 24

    Step 1

    Step 2

  • 8/13/2019 Itrix Manual

    25/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 25

    Step 3

    Step 4

  • 8/13/2019 Itrix Manual

    26/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 26

    Step 5

    Step 6

  • 8/13/2019 Itrix Manual

    27/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 27

    Step 7

    Step 8

  • 8/13/2019 Itrix Manual

    28/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 28

    Step 9

    Step 10

  • 8/13/2019 Itrix Manual

    29/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 29

    Step 11

    Step 12

  • 8/13/2019 Itrix Manual

    30/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 30

    Step 13

    Step 14

  • 8/13/2019 Itrix Manual

    31/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 31

    Programming your iBot

  • 8/13/2019 Itrix Manual

    32/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 32

    1. Program to blink an LEDSince 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 LEDStep 2: Wait for sometimeStep 3: Turn OFF the LEDStep 4: Wait for sometimeStep 5: Goto Step1

    To turn ON an LED on the iBOT board, we need to send logic 0 to thatparticular pin (since LEDs are connected in the active low configuration).In order to introduce a delay, we need to eat up some processor time. Thesimplest way to achieve this is to perform a NOP (No Operation) multipletimes. And continuous looping can be achieved by either using thestatement 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 //we include the necessary header file here

    void delay(unsigned int dela) //This a simple delay function using the//nested for loop

    {unsigned int i,j;for(i=0;i

  • 8/13/2019 Itrix Manual

    33/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 33

    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 LEDsNow that we know how to turn on/off a particular pin of the

    microcontroller, as seen in the previous example, lets see how we cantake 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 theoutputs. The simplest way to know the state (is it high or low?) of aparticular 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 //we include the necessary header file here

    void main(void) //main program begins here{

    P3=0x3C; //initialize PORT 3 to 00111100 = 0x3C

    while (1) //since there is no where to return,//we put it in an infinite loop

    {if (P3_2==0) //check if Switch 1 is pressed{

    P3_0=0; //if pressed, turn ON LED 1}else P3_0=1; //else turn it OFF

    if (P3_3==0) //check if Switch 2 is pressed{

    P3_1=0; //if pressed, turn ON LED 2}else P3_1=1; //else turn it OFF

    if (P3_4==0) //check if Switch 3 is pressed{P3_6=0; //if pressed, turn ON LED 3

    }else P3_6=1; //else turn it OFF

    if (P3_5==0) //check if Switch 4 is pressed{

    P3_7=0; //if pressed, turn ON LED 4}else P3_7=1; //else turn it OFF

  • 8/13/2019 Itrix Manual

    34/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 34

    }}

    You will notice that we have written P3=0x3C at the very beginning of ourprogram. This is done to set PORT 3s pin 2, 3, 4 and 5 as inputs since wehave connected our switches to them while pin 0, 1, 6 and 7 are theoutputs 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 thatparticular pin and not logic 1.

  • 8/13/2019 Itrix Manual

    35/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 35

    3. Program using a Sensor and a DC MotorLets try and make our next program more animated. In this example, wewill control the direction of the motor based on the state of a sensor.

    Heres the algorithm:

    Step 1: Initialize the portsStep 2: Check the state of the sensor; if active, turn motor in onedirection, 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 isconnected to M4 (pin 0 and 1 of PORT 2)

    // Program using Sensor and DC Motor //

    #include //we include the necessary header file here

    void main(void) //main program begins here{

    P1=0xff; //initialize PORT 1 as inputP2=0x00; //initialize PORT 2 as output

    while (1) //since there is no where to return,//we put it in an infinite loop

    {if (P1_0==0) //check if sensor at PORT1.0 is active{ //0 active, 1 inactive

    P2=0x05; //if active, turn motor in one

    //direction (0000 00 01 )}else P2=0x0A; //else turn it in other direction (0000

    00 10 )

    }}

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

  • 8/13/2019 Itrix Manual

    36/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 36

    4. Program using the LCD moduleLCD is one of the most multipurpose modules a robot can have. It can beused to display information, check various states of the robot, see theparameters as you feed them and also as a handy debugging tool. And the

    cool factor cannot be understated as well. iBOT uses a 2x16 backlightdisplay that is compatible with the universally accepted Hitachi format.LCDs are not as easy to use as the LEDs but they are not very difficulteither.To make things simpler for you, we have written a small library for allthe 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 followsPUTLINE1 Places cursor on line1PUTLINE2 - Places cursor on line2

    To place the cursor on a particular character box it is addressed asfollows: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 1LCD_CMD(0x83);To put cursor on 5 character line 2LCD_CMD(0xC5);

    LCD_CMD(LCD_CLEAR) Clears LCD screen.

    Heres a sample program for using the LCD module with the help of theabove functions:

    // Program using the LCD module//#include //Include the necessary header files#include#include

    void main (void){

    LCD_INIT(); //Initialize the LCD moduleLCD_WRITE("TRI"); //Send a string to displayLCD_CMD(PUTLINE2); //Move the cursor to second lineLCD_WRITE("HELLO WORLD !!"); //Send a string to displaywhile(1){} //Loop Infinitely

  • 8/13/2019 Itrix Manual

    37/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 37

    }

    5. Program to communicate with the PC via UARTIn this program we will learn how to make your iBOT communicate with thePC through the UART channel. In order to do this, first refer to thedatasheet of 89V51RD2 microcontroller and have a look at the UART sectionand the SCON (serial port control) register configurations.

    In the following program, the microcontroller will send a start stringto the PC at the beginning of the execution and simultaneously accept datacoming from the PC (anything that you type on the keyboard) and display inon to the onboard LCD module.

    //Program using to communicate with the PC via UART//#include#include#include

    unsigned char RXED,TXED;

    void UART_INIT(void) //UART Initialization{

    SBUF=0x00; //Empty Serial BufferSM0=0; //Set UARTSM1=1; //in mode 1SM2=0;REN=1; //Receive EnableTMOD=0x2F; //Set baudTH1=253; //rate as 9600bpsTR1=1;ES=1; //Enable serial interruptsEA=1; //Global interrupt enable

    }

    void TX(unsigned char dat) //Transmit Data{

    SBUF=dat;DELAY(10);

    }

    void RXTX_int(void) interrupt 4 //Serial interrupt ISR{

    if(RI==1){

    RI=0; //Reset receive data bitRXED=SBUF;LCD_CHAR(RXED); //Display received character on LCD

    }

    if(TI==1){

    TI=0; //Reset transmit data bit}

    }

    void main(void) //Main program begins here{

  • 8/13/2019 Itrix Manual

    38/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 38

    LCD_INIT(); //Initialize LCDUART_INIT(); //Initialize UARTDELAY(10); //wait for a whileTX('S'); //Transmit S TX('t'); //Transmit t TX('a'); //Transmit a TX('r'); //Transmit r TX('t'); //Transmit t

    while(1){}}

    After loading the program on to your iBOT controller, open the HyperTerminal on your PC.You can find it in Start > Programs > Accessories > Communications > HyperTerminal

    Step 1: Enter a name for the connection

    Step 2: Select the COM port and configure its properties

  • 8/13/2019 Itrix Manual

    39/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 39

    6. Line Following RobotTime to actually build a robot! Lets put everything that we learned tillnow in our next program. Line following is one of the simplest task arobot can perform. There are many algorithms and sensor configurationsdesigned to do this.Heres one of the simplest and fail safe line followers algorithm:

    In this configuration we use two line sensors.

  • 8/13/2019 Itrix Manual

    40/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 40

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

    YES

    YES

    YES

    NO

    YES

    NO

    NO

    NO

    START

    InitializePorts

    Is left linesensoractive?

    Is right linesensoractive?

    Turn right

    Turn Left

    Is left linesensoractive?

    Go straight

    Is right linesensoractive?

  • 8/13/2019 Itrix Manual

    41/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 41

    // 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 //we include the necessary header file here

    #define forward 0x05 // 0000 01 01 #define right 0x01 // 0000 00 01 #define left 0x04 // 0000 01 00#define linesensor_right P1_0#define linesensor_left P1_1

    void main(void) //main program begins here{

    P1=0xff; //initialize PORT 1 as input (sensors)P2=0x00; //initialize PORT 2 as output (motors)

    while (1) //since there is no where to return,//we put it in an infinite loop

    {if (linesensor_right==0) //check if right sensor has

    detected// a line (black surface)

    {while(linesensor_left==1) //if detected, then turn right till{ //the left sensor comes on the line

    P2=right;}

    }

    if (linesensor_left==0) // check if left sensor has detected// a line

    {while(linesensor_right==1) //if detected, then turn left till{ //the right sensor comes on the line

    P2=left;

  • 8/13/2019 Itrix Manual

    42/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 42

    }}

    else{

    P2=forward; //else go forward}

    }

    }

  • 8/13/2019 Itrix Manual

    43/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 43

    7. Obstacle Avoiding robotObstacle avoiding behavior is a prerequisite in any mobile roboticapplication. In this project we will learn to add such a behavior in ouriBOT.

    Heres a simple algorithm:

    Step 1: check if right ir proximity sensor is active; if active, turn leftfor a whileStep 2: check if left ir proximity sensor is active; if active, turn rightfor a whileStep 3: else move forwardStep 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 //we include the necessary header file here#include

    #define forward 0x05 // 0000 01 01

    #define turnleft 0x06 // 0000 01 10 left motor = backwards,// right motor = forward

    #define turnright 0x09 // 0000 10 01 left motor = forward,// right motor = backwards

    #define obst_right P1_2#define obst_left P1_3

    void main(void) //main program begins here{

  • 8/13/2019 Itrix Manual

    44/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 44

    P1=0xff; //initialize PORT 1 as input (sensors)P2=0x00; //initialize PORT 2 as output (motors)

    while (1) //since there is no where to return,//we put it in an infinite loop

    {if (obst_right==0) //check if right sensor has detected an obstacle{

    P2=turnleft; //if detected, turn left for some timeDELAY(30);}

    if (obst_left==0) //check if left sensor has detected an obstacle{

    P2=turnright; //if detected, turn right for some timeDELAY(30);

    }

    else{

    P2=forward; //else go forward}

    }}By changing the delay variable we can make the robot turn for somespecific degrees after it detects an obstacle. But the turns will not beprecise since they will change as the battery drains.

    Note: In this particular case, the turning would be in place i.e., whileturning, both the motors will run in opposite direction unlike the linefollower, where the turns were turning by stopping either of the motor.

  • 8/13/2019 Itrix Manual

    45/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 45

    8. Sumo RobotIn the previous two examples welearned how to use the line sensingmodules as well as the IR proximitymodules. Now lets see how we can

    have a behavior that uses both ofthese sensors together. A sumorobot fits this bill perfectly.Inspired from the tradition humansumo competitions held in Japan,robotics enthusiasts soon startedhaving robotics sumo. Sumo roboticscompetitions are now held aroundthe world under various weight andsize classes just like the realones.In a typical sumo roboticscompetition, two robots competeagainst each other inside a sumoring. The ring is a made up of ablack surface with a white linearound its circumference as shown.The idea is to push the opponentout of the ring in the stipulatedtime frame.

    A typical sumo robot flowchart:

  • 8/13/2019 Itrix Manual

    46/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 46

    NO

    Start

    Initialize ports

    Is the opponenton the left andme not on the

    edge?

    Is the rightline sensor

    active?

    Is the opponenton the right andme on the edge?

    Is the opponentin front and me

    not on the edge?

    Is the rightline sensor

    active?

    Turn left

    Turn right

    Go forward

    Turn backwardsthen turn left

    Turn backwardsthen turn right

    Go forward

    NO

    NO

    NO

    NO

    YES

    YES

    YES

    YES

  • 8/13/2019 Itrix Manual

    47/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 47

    // 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 //we include the necessary header file here#include

    #define forward 0x05 // 0000 01 01 #define reverse 0x0A // 0000 10 10 #define turnleft 0x06 // 0000 01 10 left motor = backwards,

    // right motor = forward#define turnright 0x09 // 0000 10 01 left motor = forward,

    // right motor = backwards#define linesensor_right P1_0#define linesensor_left P1_1#define obst_right P1_2#define obst_left P1_3

    void main(void) //main program begins here{

    P1=0xff; //initialize PORT 1 as input (sensors)P2=0x00; //initialize PORT 2 as output (motors)

    while (1) //since there is no where to return,//we put it in an infinite loop

    {while ( obst_right==0 //check if right sensor has

    && obst_left==1 //detected the opponent&& linesensor_right==1 //and make sure that the robot

    is && linesensor_left==1) //not on the edge

    {P2=turnright; //if detected, turn right

    } //(i.e., towards the opponent)

    while ( obst_left==0 //check if left sensor has&& obst_right==1 //detected the opponent&& linesensor_right==1 //and make sure that the robot

    is&& linesensor_left==1) //not on the edge

    {P2=turnleft; //if detected, turn left

    } //(i.e., towards the opponent)

    while ( obst_left==0 //check if both sensors&& obst_right==0 //have detected the opponent&& linesensor_right==1&& linesensor_left==1)

    {P2=forward; //if detected, go forward

  • 8/13/2019 Itrix Manual

    48/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 48

    } //chase him and push him

    if (linesensor_right==1 ) //check if right line sensor has// detected the ring

    {

    P2=reverse; //if detected, go reverse for a whileDELAY(400);P2=turnleft; //then turn left for a whileDELAY(300);P2=forward; //and go forward

    }

    if (linesensor_left==1 ) //check if left line sensor has//detected the ring

    {P2=reverse; //if detected, go reverse for a whileDELAY(400);P2=turnright; //then turn right for a whileDELAY(300);P2=forward; //and go forward

    }

    else{

    P2=forward; //else go forward}

    }}

  • 8/13/2019 Itrix Manual

    49/50

    TRI Technosolutions Pvt. Ltd. www.triindia.co.in 49

    The iBot Component List.

    The list of components you will find in your bag.1. Controller Board2. 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.

  • 8/13/2019 Itrix Manual

    50/50

    The iBot Kit applications in Robotics.

    The iBOT kit can be used as a platform for building robots for various applications. Some ofthe possible applications are listed below

    1.

    Line Follower Robot2. 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 statement15. Collaborative Robotics

    The master Slave SPI port along with the ample program and data memory serve as agood base for communication between 2 or more bots making the iBOT platformsuitable for a study on collaborative robotics

    The rest is upto your IMAGINATION!!!!