Anda di halaman 1dari 57

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 sensor…………………………………………………………8
DC Power supply and battery……………………………………………… 10

iBot controller’s 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: It’s a basic push to on - push to off type switch.


IC 7805: It’s 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
PC’s 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 PC’s 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 microcontroller’s clock frequency to 11.0592 MHz.
Beeper: Connected in the active high mode, the beeper can easily be used to get audible
feedbacks from the controller.

Motor Connectors PORTS


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

Misc
Buzzer P0.3
Crystal (11.0592Mhz) Pin 18 and 19
Reset Switch 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 controller. Refer the

adjoining figure for reference.


Step 2: Turn on the power supply of your iBOT 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 “don’t” 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) you’ll see the indicator LED glows. That’s 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 Controller’s first test run
Your iBot controller board comes preprogrammed with some sample programs to get you
started.

Here’s 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 Program 2 Program 3


Blinking LEDs Switches and Running
LEDs Motors

Reset

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 1’s 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


STEP 2
TRI Technosolutions Pvt. Ltd. www.triindia.co.in 15
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) //main program begins here

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); //wait for a short time

RXD=1; //turn the LED 1 OFF

delay(20); //wait for a short time

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
Step 1

Step 2

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


Step 3

Step 4

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


Step 5

Step 6

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


Step 7

Step 8

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


Step9:

Step 10:

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


Step11:

Step 12:

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


Step 13:

Step 14:

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


Step 15:

Step 16:

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


Step 17:

Step 18:

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


Step 19:

Step 20:

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


Step 21:

Step 22:

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


Step 23:

Step 24:

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


Step 25:

Step 26:

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


Step 27:

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


Programming your iBot

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 let’s see how we can put all of these things together in a C program.

// Program to blink an LED //

#include<P89V51RD2.h> //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<=1000;i++)
for(j=0;j<=dela;j++);
}

void main(void) //main program begins here


{

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); //wait for a short time
RXD=1; //turn the LED 1 OFF
delay(20); //wait for a short time
TRI Technosolutions Pvt. Ltd. www.triindia.co.in 37
}
}

We begin with including the header file for the microcontroller. Next we
write the delay() function using the nested for loop. Don’t 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.

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, let’s 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> //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


TRI Technosolutions Pvt. Ltd. www.triindia.co.in 38
{
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

}
}

You will notice that we have written P3=0x3C at the very beginning of our
program. This is done to set PORT 3’s 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 39


3. Program using a Sensor and a DC Motor
Let’s 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.

Here’s 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 1’s 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) //main program begins here


{
P1=0x0f; //initialize PORT 1.0 to P1.3 as input

//&& Port 1.4 to P1.7 as output


P2=0x0f; //initialize PORT 2.0 to P2.3 as input
//&& Port 2.4 to P2.7 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=0x50; //if active, turn motor M3 & M4 in one
//direction (0101 0000) }
else P2=0xA0; //else turn it in other direction (1010
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 40


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.
Let’s 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(0x82);
To put cursor on 5 character line 2
LCD_CMD(0xC4);

• LCD_CMD(LCD_CLEAR)
Clears LCD screen.

Here’s a sample program for using the LCD module with the help of the
above functions:

// Program using the LCD module//


#include<P89V51RD2.h> //Include the necessary header files
#include<delay.h>
#include<LCD.h>

void main (void)


{
LCD_INIT(); //Initialize the LCD module
LCD_WRITE("TRI"); //Send a string to display
LCD_CMD(PUTLINE2); //Move the cursor to second line
LCD_WRITE("HELLO WORLD !!"); //Send a string to display
while(1){} //Loop Infinitely
}

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


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) //UART Initialization


{
SBUF=0x00; //Empty Serial Buffer
SM0=0; //Set UART
SM1=1; //in mode 1
SM2=0;
REN=1; //Receive Enable
TMOD=0x2F; //Set baud
TH1=253; //rate as 9600bps
TR1=1;
ES=1; //Enable serial interrupts
EA=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 bit
RXED=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


{
LCD_INIT(); //Initialize LCD

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


UART_INIT(); //Initialize UART
DELAY(10); //wait for a while
TX('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 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 43


6. Line Following Robot
Time to actually build a robot! Let’s 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.
Here’s one of the simplest and fail safe line follower’s algorithm:

In this configuration we use two line sensors.

START

Initialize
Ports

Is right line YES


sensor
active?
Turn Left

NO

Is left line NO
sensor
active?

Is left line YES


YES
sensor
active?
Turn right

NO

Go straight

Is right line NO
sensor
active?

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
TRI Technosolutions Pvt. Ltd. www.triindia.co.in 44
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.

// LINE FOLLOWING ROBOT //


//Right line sensor connected to PORT1.0
//Left line sensor connected to PORT1.1
//Right motor connected at M4
//Left motor connected at M3

#include<P89V51RD2.h> //we include the necessary header file here

#define forward 0x50 // 0101 0000


#define right 0x10 // 0001 0000
#define left 0x40 // 0100 0000
#define linesensor_right P1_0
#define linesensor_left P1_1

void main(void) //main program begins here


{
P1=0x0f; //initialize PORT 1.0 to P1.3 as input

//&& Port 1.4 to P1.7 as output


P2=0x0f; //initialize PORT 2.0 to P2.3 as input
//&& Port 2.4 to P2.7 as output

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;
}
}

else
{
P2=forward; //else go forward
}
}
}

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


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.

Here’s 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 M4
//Left motor connected at M3

#include<P89V51RD2.h> //we include the necessary header file here


#include<delay.h>

#define forward 0x50 // 0101 0000

#define turnleft 0x60 // 0110 0000 left motor = backwards,


// right motor = forward

#define turnright 0x90 // 1001 0000 left motor = forward,


// right motor = backwards
#define obst_right P1_2
#define obst_left P1_3

void main(void) //main program begins here


{
P1=0x0f; //initialize PORT 1.0 to P1.3 as input

//&& Port 1.4 to P1.7 as output


P2=0x0f; //initialize PORT 2.0 to P2.3 as input
//&& Port 2.4 to P2.7 as output

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 time
DELAY(30);
}

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


{
P2=turnright; //if detected, turn right for some time
DELAY(30);

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


}

else
{
P2=forward; //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 th

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 let’s 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.

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


A typical sumo robot flowchart:

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


Start

Initialize ports

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

NO

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

NO

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

NO

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

NO

YES Is the right


Turn backwards
then turn right line sensor
active?

NO

Go forward

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


// 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 M4
//Left motor connected at M3

#include<P89V51RD2.h> //we include the necessary header file here


#include<delay.h>

#define forward 0x50 // 0101 0000

#define turnleft 0x60 // 0110 0000 left motor = backwards,


// right motor = forward

#define turnright 0x90 // 1001 0000 left motor = forward,


// right motor = backwards
#define backward 0xA0 //1010 0000

#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=0x0f; //initialize PORT 1.0 to P1.3 as input

//&& Port 1.4 to P1.7 as output


P2=0x0f; //initialize PORT 2.0 to P2.3 as input
//&& Port 2.4 to P2.7 as output

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)

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


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
} //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 while
DELAY(400);
P2=turnleft; //then turn left for a while
DELAY(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 while
DELAY(400);
P2=turnright; //then turn right for a while
DELAY(300);
P2=forward; //and go forward
}

else
{
P2=forward; //else go forward
}
}
}

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


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 52


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 53


The iBot Kit applications in Embedded Systems.
The iBOT kit is built around the very widely used 8051 architecture. The P89V51RD2
microcontroller is an In System Programmable IC which provides you with a perfect
platform for starting up with the embedded systems. The board is provided with all basic
modules like LED, Switches, motor drivers, LCD, buzzer, Serial Port Connector and
converter.

The iBot can also be used as a learning tool for the 8051 family microcontrollers.
Some experiments include
• Using ports (Input output initialization and use)
• Interrupts
• Timers
• UART
• SPI
• LCD interfacing
• Stepper motor interface

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


List of experiments which can be done by using iBOT
Automation Projects (e g : Home Automation)
The board has communication points, drivers and is powerful enough to automate a system.

Data Acquisition System


The amounts of memory and expandability options of the micro controller make it a good
choice for such systems.

Sensor Networks
This board can be used as node points in various sensor network applications. The two serial
communication points (SPI and UART) aids in such operations.

Some other minor projects/experiments that also can be implemented are as follows:
• Voting Machine
• Electronic Code Lock
• Vending Machine
• CNC Drill
• Burglar alarm
• Scrolling message display
• Motor Speed controller
• Frequency generator
• Frequency Counter
• Digital Clock
• Stop watch
• Serial to parallel converter
• Pulse width measurement
• Object counter
• Traffic signal controller
• Industrial automation and control
o Drive control
o Process automation
o Process Monitoring

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


Knowledge, support and products by TRI
Keep checking our resource section for continuous learning updates
www.triindia.co.in/resources

For new products


www.triindia.co.in/shop

For any queries


www.triindia.co.in/forums

Post your testimonials on the workshop on the testimonials section of


www.triindia.co.in/forums
.

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


Some websites for Robotics
1. www.triindia.co.in/resouces

2. www.robots-dreams.com

3. www.roboticsindia.com

4. www.seattlerobotics.org

5. www.robots.net

6. http://mobots.solarbotics.net

7. www.solarbotics.com

8. http://www.st.com/stonline/products/support/motor/tutorial/motor.swf

9. www.google.com

10. www.wikipedia.org

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

Anda mungkin juga menyukai