Monday, January 25, 2010

NextSapiens Robotics Local Contest (Basic Embedded System)

Our team (with the name DU Terminator) just participated the International Robot Contest (Bangladesh Regional). The purpose was to build a line follower robot which will reach the destination following line of colors within shortest time. The problem statement is here.

I’m doing a bit report here based on our team’s work. First of all you need a development kit which will guide through programming to work with sensors and move forward using motors.

Development Kit

We got a basic development kit from NextSapiens which includes
ü  ATMega16 Micro controller.
ü  L293D IC, LCD Screen, Sensors
ü  Relays, Switches, LEDs
ü  Power Supply
ü  And other electronic/electrical components

Collect a development kit according to your requirement and ask for manual to the manufacturer.

As I couldn’t find an online/ebook manual for the development board we have used, I’m just describing the coding has to be done for this development board. Anyway, you can get it from spellbound or nenomart. As the mcu is Atmega16 we can use AVR softwares such as BASCOM AVR.

Coding

A sample code for line follower robot with three sensors is given below.

$regfile = "m16def.dat"
$crystal = 4000000

Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7,
E = Portb.3 , Rs = Portb.2

Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down,
Compare B Pwm = Clear Down

Start Adc
Cls
Start Timer1

Dim Lw As Integer
Dim Lb As Integer
Dim Lm As Integer

Dim Cw As Integer
Dim Cb As Integer
Dim Cm As Integer

Dim Rw As Integer
Dim Rb As Integer
Dim Rm As Integer

Dim L As Integer
Dim R As Integer
Dim C As Integer

Lcd "Place on White"
Waitms 1000
Lw = Getadc(0)
Cw = Getadc(1)
Rw = Getadc(2)
Cls

Lcd "Place on Black"
Waitms 1000
Lb = Getadc(0)
Cb = Getadc(1)
Rb = Getadc(2)
Cls

Lcd "Mean"
Lm = Lw + Lb
Lm = Lm / 2

Cm = Cw + Cb
Cm = Cm / 2

Rm = Rw + Rb
Rm = Rm / 2

Do
Cls

L = Getadc(0)
C = Getadc(1)
R = Getadc(2)

Lcd L ; "-" ; C ; "-" ; R

If L < Lm And C > Cm And R < Rm Then
Lcd "FWD"
Pwm1b = 100
Portd.3 = 0
Pwm1a = 100
Portd.6 = 0
Cls

Elseif L < Lm And C < Cm And R > Rm Then
Lcd "Right"
Pwm1b = 120
Portd.3 = 0
Pwm1a = 30
Portd.6 = 0
Cls

Elseif L > Lm And C < Cm And R < Rm Then
Lcd "Left"
Pwm1b = 30
Portd.3 = 0
Pwm1a = 120
Portd.6 = 0
Cls

Elseif L < Lm And C > Cm And R > Rm Then
Lcd "90 Right"
Pwm1b = 120
Portd.3 = 0
Pwm1a = 0
Portd.6 = 0
Cls

Elseif L > Lm And C > Cm And R < Rm Then
Lcd "90 Left"
Pwm1b = 0
Portd.3 = 0
Pwm1a = 120
Portd.6 = 0
Cls


End If

Loop
End

Coding Description

ü    $regfile = "m16def.dat" includes the header file for atmega16 mcu.

ü    $crystal = 4000000 provides 4MHz clock

ü    Config routine configures devices.

ü    Getadc as initialized reads the sensor value.

ü    Waitms library routine performs the delay specified in milliseconds.

ü    Cls clears the LCD screen.

ü    Lcd routine prints provided text on LCD Screen.

There are certain factors that should be considered or as critical cases for line follower robots such as:

ü    Following acute angles correctly

ü    Distance between sensors according to track width

ü    Distance between motors for fast turning

ü    Weight of battery (better if it can be covered the voltage source with single cell of battery)

ü    Equality of readings of all sensors and similarity of speed of motors

Tricks

For first round one doesn’t need great speed to win over. Hence you can slow a bit down if you wish. Critical cases like Y-shapes, T-shapes or acute angles should be handled properly depending on the track specification.

Line Follower Robot and the Contest

A video stream of our line follower robot is embedded below.


Robot as moves following the black line track

On the contest our team acquired 4th position and the other team DU RoboIcon acquired 2nd position. A photo on the venue with Judge is attached here.


International Robotics Intelligent Systems Competition 2010 (1st robotics competition in Bangladesh) at Agargaon [DU Teams, 4 Participants of DU Terminator on Left Side and 4 Participants of DU RoboIcons on Right Side]

Related Links:

        http://www.nextsapiens.com/
        http://www.nextsapiens.com/site/edu/bes.htm
        http://www.nenowiki.com/

No comments:

Post a Comment