Documente Academic
Documente Profesional
Documente Cultură
www.triindia.co.in 1
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.
www.triindia.co.in 3
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
www.triindia.co.in 5
Step 2: Turn on the power supply of your iBOT proV 2.1 controller.
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
www.triindia.co.in 7
www.triindia.co.in 8
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.
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.
www.triindia.co.in 10
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.
www.triindia.co.in 11
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
www.triindia.co.in 12
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.
www.triindia.co.in 13
www.triindia.co.in 14
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 */
www.triindia.co.in 16
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.
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.
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"
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.
www.triindia.co.in 21
www.triindia.co.in 22
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
www.triindia.co.in 24
Step 3
Step 4
www.triindia.co.in 25
Step 5
Step 6
www.triindia.co.in 26
Step 7
Step 8
www.triindia.co.in 27
Step 9
Step 10
www.triindia.co.in 28
Step 11
Step 12
www.triindia.co.in 29
Step 13
Step 14
www.triindia.co.in 30
www.triindia.co.in 31
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.
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.
www.triindia.co.in 34
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.
www.triindia.co.in 35
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){}
//Initialize the LCD module //Send a string to display //Move the cursor to second line //Send a string to display //Loop Infinitely
www.triindia.co.in 36
//Transmit Data
www.triindia.co.in 37
//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
www.triindia.co.in 38
www.triindia.co.in 39
START
Initialize Ports
YES
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.
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
//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)
//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
www.triindia.co.in 41
} } else { P2=forward; } } }
//else go forward
www.triindia.co.in 42
// 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
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.
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.
www.triindia.co.in 45
Start
Initialize ports
Turn left
NO YES Turn backwards then turn left Is the right line sensor active?
NO Go forward
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
// // // // // //
0000 01 01 0000 10 10 0000 01 10 left motor = backwards, right motor = forward 0000 10 01 left motor = forward, right motor = backwards
//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
while (
//check if left sensor has //detected the opponent //and make sure that the robot //not on the edge
is
while (
www.triindia.co.in 47
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
www.triindia.co.in 48
www.triindia.co.in 49
www.triindia.co.in 50