You are on page 1of 17

REPORT OF INDUSTRIAL TRAINING @NEXTSAPIENS

Robotics Workshop Batch:25th29th July,2009

Report submitted by:
Rajsmita Chowdhury Assam Engineering College Guwahati-13,Assam. 22/8/2009

ACKNOWLEDGEMENT I would like to thank the entire team of NextSapiens for organizing such an innovative workshop which enabled us to expose ourselves to the world of robotics. Thanking You… . I would specially like to thank the faculty members for their dedication and support.

.OBJECTIVE To make a line follower robot using Atmega-16 microcontroller.

COMPONENTS USED • ATMEGA-16 MICROCONTROLLER • 3 COLOUR SENSORS • DC MOTORS .CASTOR .BOLTS AND SCREWS • CONNECTORS • ISP PROGRAMMER • ADAPTOR . NUTS.2 WHEELS. METAL CHASIS.

FIGURE SHOWING THE COMPONENTS USED .

.THE ATMEGA-16 MICROCONTROLLER The Atmega16 is an 8-bit Microcontroller. It has four I/O ports: Port A. C and D each of which can be configured as either input or output. Pins PA0-PA7 indicates Port A. then again continues from the right side bottom and continues upwards up till the right side of the notch. The external crystal oscillator has to be connected to XTAL1 and XTAL2. 8-bit means the Arithmetic and Logic Unit of the controller can handle 8-bit data at a time. The figure shows the pin layout of Atmega16. Both of them have to be connected to the 0V of the supply. B. It is active-low and hence to provide reset the pin has to be taken to 0V. PB0-PB7 indicate Port B and so on. There are two pins providing Ground. The numbering starts from left side of the notch goes till the bottom. The RESET pin is used to reset the Microcontroller. Note the numbering of the pins. AREF is the reference voltage for the Analog to Digital Converter. There are two pins for providing power supply: VCC & AVCC. Both of them have to be connected to a constant +5V DC supply. The ports are “Byte-addressable” as well as “Bit-addressable”.

The Atmega16 Microcontroller: .

Figure 1 .ASSEMBLAGE OF THE COMPONENTS The robot is made by assembling the components as shown in the figures below.

Figure 2 Figure 3 .

.  The sensors are placed in such a way that they distinguish between the black and white surfaces and follow the black line accordingly.  The robot will be made to self-calibrate on black and white surfaces where they will takes the respective colour values.PROBLEM DESCRIPTION To make a self-calibrating line follower robot which will be following a black track with the help of 3 colour sensors.

We write config lcd=16*2. It can be 8.  ADC defines the running mode.9 or 10.  Config statement is used to configure the various hard ware devices and other features of microcontroller.  Timer 1 is a 16bit counter.whrere 16 is the no of characters entered in a line and 2 is the no of lines. avcc or internal. its value may off.  Prescaler is a numeric constant for the clock divider.  Config lcdpin configures the pin of the microcontroller.  Reference is the additional reference options. Here we define lcd with config.ALGORITHM  $regfile instructs the compiler to use the specified register file. . The register file holds the information about the chip such as the internal registers.  Pwm stands for pulse width modulation.  $crystal defines the clock speed at which the microcontroller will run.

.  Cls clears the lcd screen.  Portd. 0&1 are the values for clock & anticlock rotation  Wires of the motor 1 will be inserted into first 2 pins of molex connector with motor1 from left side & similarly for motor in the next 2 pins of the connector.3 and portd.  Case select statement is applied.  Pwm1.6 are for the direction of the two motors.eg: DIM R as Integer.  Start adc to start device.  Compare a pwm refers to pwm compare mode .  To define a variable in bascom we use dim as variable type.a and pwm1.b represents the speed of the two motors. Prescale is the timer connected to the system clock in this case.  R stores the input. when the condition satisfies it will execute.

eg: portd.6=0.  To move in the backward direction we change the direction by changing the direction 1 to 0. To move the robot the left or right direction we decrease the motor speed 1 or 2 accordingly.3=0 and portd. The lesser the speed of the right motor. for example if the robot is to be turned right then right motor speed is decreased in comparison to the left motor and the speed of the turn inversely depends on the speed of the right motor . more is the turning speed.  To end the loop we write end. .  To stop the robot we make both the speed of the motors to 0.

Reference = Avcc Config Timer1 = Pwm . Prescale = 1 . Db7 = Portb. Cb As Integer . Prescaler = Auto . Rb As Integer .4 . Rw As Integer .PROGRAM IN BASCOM $regfile = "m16def. Lb As Integer . Db4 = Portb. Rs = Portb. R As Integer Dim Lw As Integer . Db5 = Portb. Cw As Integer .7 . Lm As Integer . Compare B Pwm = Clear Down Dim L As Integer . E = Portb.3 . Compare A Pwm = Clear Down . Db6 = Portb. C As Integer . Cm As Integer .2 Config Adc = Single . Pwm = 8 . Rm As Integer Start Adc Cls Start Timer1 Lcd "calibrate white surface" Lowerline Lcd "place the robot on white" Waitms 10000 Cls Lcd "configuring" Lw = Getadc(0) Cw = Getadc(2) Rw = Getadc(1) Waitms 1000 Cls Lcd "calibrate black surface" .5 .6 .dat" $crystal = 4000000 Config Lcd = 16 * 2 Config Lcdpin = Pin .

6 = 0 Lowerline Lcd "straight" Elseif L < Lm And C > Cm And R > Rm Then . "-" .3 = 0 Pwm1a = 200 Portd.Lowerline Lcd "place the robot on black" Waitms 10000 Cls Lcd "configuring" Lb = Getadc(0) Cb = Getadc(2) Rb = Getadc(1) Waitms 1000 Cls Lcd "calculating mean" Lm = Lw + Lb Lm = Lm / 2 Rm = Rw + Rb Rm = Rm / 2 Cm = Cw + Cb Cm = Cm / 2 Do L = Getadc(0) C = Getadc(2) R = Getadc(1) Cls Lcd L . R If L < Lm And C > Cm And R < Rm Then Pwm1b = 200 Portd. C . "-" .

6 = 0 Lowerline Lcd "right" Elseif L < Lm And C < Cm And R > Rm Then Pwm1a = 135 Portd.6 = 0 Lowerline Lcd "left" Elseif L > Lm And C > Cm And R < Rm Then Pwm1a = 200 Portd.3 = 0 Pwm1b = 150 Portd.3 = 0 Pwm1b = 200 Portd.6 = 0 Lowerline Lcd "right" Elseif L > Lm And C < Cm And R < Rm Then Pwm1a = 200 Portd.6 = 0 Lowerline Lcd "left" Loop End .3 = 0 Pwm1b = 200 Portd.Pwm1a = 135 Portd.3 = 0 Pwm1b = 150 Portd.

THANK YOU… .