Stop the robot after the third line

From cod3v
Other languages:
English • ‎suomi

Introduction

How to stop the robot after passing the third (or nth) line? This problem is very often encountered in FIRST Lego League (FLL) or in Rescue competitions. The problem is that the sensor reads continuous data, and the simplest solutions wont work.

StopAt3rdLine.png

This page gives two different solutions: (i) using timer or rotation angle to pass the lines and (ii) using flip-flop algorithm to count the black lines. The flip flop is a robust method which works with a variable width lines.


Robot

Almost any robot will do. We use Asimov 2/ Verne robot.

Sensors

One color sensor is needed.

Example Videos

The video is about the second method, only.

Theory

The two different methods are described below. The color sensor reads the reflected light intensity continuously, but the reading frequency is rather large. Thus, during passing the black line, the sensor reads hundreds of close to zero, or black, values. See, the image.

Sensor readings while the robot passes black lines.

The calibrated color sensor reads about 100 at white, and while passing the black line the sensor values are about 0.

Using the timer/ rotation angle

By using the timer we can drive past the black line, and again look for the next black line. After finding the third one, we stop. This can be done in a loop, also. Usually, if you need to repeat the code, use a loop instead of copying the same script again.


Using flip flop circuit

The idea of the flip flop is that first we flip the state to black, and then after finding white we flop the state back to white. Note that the sensor continuously measures the reflectance.


Example Code

The example codes with two different algorithms are shown.

Using the timer

The timer based code is rather reliable and works perfectly even on difficult environments. The timer can be replaced by the rotation angle.

The timer code.

Using the flip flop algorithm

The flip flop algorithm is simple and reliable, if the ground floor is easy enough.

The flip flop algorithm is easy to implement.

Exercises

  • How fast can you make the robot to pass exactly three lines? Measure the time, and the extra passage (slippage), which the root makes after passing the last line.
  • Make the robot work with two sensors, and assign other sensor to follow a line, and the other to stop after to stop the robot after 3rd line. See the image.
  • Use the line follower algorithm with other sensor, and the other sensor is used to stop after three perpendicular black lines.


This course is supported by Meet and Code. The course is made in collaboration with Robotiikka- ja tiedekasvatus ry.

MeetAndcodeLogo.png
Back to Meet and Code 2020 I: Ev3-G front page