ailable at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode Program Line Follower in Autonomous Mode
Jan 02, 2016
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program Line Follower in Autonomous Mode
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program Line Follower in Autonomous Mode
Performance Objective: Given the components of a VEX robotics design system program a line follower in autonomous mode to have the robot move forward and follow a white line on a gray mat.
Enabling Objectives: explain the purpose of a line follower explain how a line follower operates draw a flow chart for using a line follower program a line follower
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Line follower A line tracker mostly consists of an infrared light
sensor and an infrared LED The line follow functions by illuminating a surface with
infrared light; the sensor then picks up the reflected infrared radiation and, based on its intensity, determines the reflectivity of the surface in question
Lightly colored surfaces will reflect more light than dark surfaces; therefore, lightly colored surfaces will appear brighter to the sensor
This allows the sensor to detect a dark line on a light surface, or a light line on a dark surface
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Line follower
An efficient way to follow a line is using three sensors
The three sensors are lined up beside each other
The center line follower is designed to be on the line being followed, while the outside sensors are detecting the surface beside the line
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
1 2 3
Line follower logic
The logic behind using three sensors is this: if sensors 1 and 3 are dark and sensor 2 is light, then go straight; if sensors 1 and 2 are dark while sensor 3 is light, turn right; if sensors 2 and 3 are dark, and sensor 1 is light, turn left
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Line follower logic
Three sensors are best when there are crossing lines
All three sensors will be reading the same color, you know to turn a direction when this happens
Using this logic, two sensors will work to follow a line that does not cross another line
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Verify the sensor
Plug the three sensors into analog ports Open easyC and download the line follower test code The test code is only written for one sensor, you can
add the two additional get blocks to be able to read the other two sensors, you also need to define two new variables
Place the robot on a gray mat and notice the value of the sensors (> 700)
Place the robot on a white surface and notice the value of the sensors (< 500)
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program the line follower
Program a VEX robot equipped with a line following kit to move forward and follow a white line on a gray mat
Draw the flow chart of a program that can complete the above task according to the logic explained earlier
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program the line follower
Open a new competition project and configure the microcontroller for the three line following sensors
Add a variable for each line following sensor
Insert an appropriate driving mode block into the operator tab
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program the line follower
Insert a while loop where 1==1
Insert the get analog input block for each line follower
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program the line follower
Insert an If statement to move the robot forward if both outside sensors are dark and the middle sensor is lightNOTE: When using the line follower kit, you will want to move slower, therefore insert a user value of 60 or -60 when programming the motors
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program the line follower
Insert an Else-If statement to correct the robot if it starts to veer off the line towards the right
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Program the line follower
For correction when the robot veers off of the line, insert an Else-If statement to correct the positioning
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Test your code
Build and download your code Run the code with the Competition
Switch Simulator The robot should slowly move forward
following a line, correcting itself if it starts to veer to one side or the other
Available at: www.etcurr.com Lesson 3.6 – Program Line Follower in Autonomous Mode
Show it off!
If your code works, show it to your instructor If the robot does not run correctly, go back
through the lesson and double check your code
For more technical data on the line follower visit: http://www.vexforum.com/wiki/index.php/Line_Follower