Beruflich Dokumente
Kultur Dokumente
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. I would specially like to thank the faculty members for their dedication and support. Thanking You
OBJECTIVE
To make a line follower robot using Atmega-16 microcontroller.
COMPONENTS USED
ATMEGA-16 MICROCONTROLLER 3 COLOUR SENSORS DC MOTORS ,CASTOR ,2 WHEELS, METAL CHASIS, NUTS,BOLTS AND SCREWS CONNECTORS ISP PROGRAMMER ADAPTOR
Figure 1
Figure 2
Figure 3
PROBLEM DESCRIPTION
To make a self-calibrating line follower robot which will be following a black track with the help of 3 colour sensors. The robot will be made to self-calibrate on black and white surfaces where they will takes the respective colour values. The sensors are placed in such a way that they distinguish between the black and white surfaces and follow the black line accordingly.
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. $crystal defines the clock speed at which the microcontroller will run. Config statement is used to configure the various hard ware devices and other features of microcontroller. Here we define lcd with config. We write config lcd=16*2,whrere 16 is the no of characters entered in a line and 2 is the no of lines. Config lcdpin configures the pin of the microcontroller. ADC defines the running mode. Prescaler is a numeric constant for the clock divider. Reference is the additional reference options. its value may off, avcc or internal. Timer 1 is a 16bit counter. Pwm stands for pulse width modulation. It can be 8,9 or 10.
Prescale is the timer connected to the system clock in this case. Compare a pwm refers to pwm compare mode . To define a variable in bascom we use dim as variable type.eg: DIM R as Integer. R stores the input. Cls clears the lcd screen. Case select statement is applied. when the condition satisfies it will execute. Start adc to start device. Pwm1.a and pwm1.b represents the speed of the two motors.
Portd.3 and portd.6 are for the direction of the two motors. 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.
To move the robot the left or right direction we decrease the motor speed 1 or 2 accordingly. 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 . The lesser the speed of the right motor, more is the turning speed.
To stop the robot we make both the speed of the motors to 0. To move in the backward direction we change the direction by changing the direction 1 to 0.eg: portd.3=0 and portd.6=0. To end the loop we write end.
PROGRAM IN BASCOM
$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 Dim L As Integer , C As Integer , R As Integer Dim Lw As Integer , Lb As Integer , Lm As Integer , Cw As Integer , Cb As Integer , Cm As Integer , Rw As Integer , Rb As Integer , 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"
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 ; "-" ; C ; "-" ; R If L < Lm And C > Cm And R < Rm Then Pwm1b = 200 Portd.3 = 0 Pwm1a = 200 Portd.6 = 0 Lowerline Lcd "straight" Elseif L < Lm And C > Cm And R > Rm Then
Pwm1a = 135 Portd.3 = 0 Pwm1b = 200 Portd.6 = 0 Lowerline Lcd "right" Elseif L < Lm And C < Cm And R > Rm Then Pwm1a = 135 Portd.3 = 0 Pwm1b = 200 Portd.6 = 0 Lowerline Lcd "right" Elseif L > Lm And C < Cm And R < Rm Then Pwm1a = 200 Portd.3 = 0 Pwm1b = 150 Portd.6 = 0 Lowerline Lcd "left" Elseif L > Lm And C > Cm And R < Rm Then Pwm1a = 200 Portd.3 = 0 Pwm1b = 150 Portd.6 = 0 Lowerline Lcd "left" Loop End
THANK YOU