Line Follower.(Worksheet 10)
There are (currently) 3 files needed to run the line follower
- BASIC_LF.py
See text
- UKMARS.py updated 7/3/2022
See text
- params.py
Basic_LF.py needs to be saved on the Pico, and the "main.py" should be edited as just:
import Basic_LFso that it runs on power-up.
UKMARS.py contains definitions of the switches, sensors LEDs,
and Motor control objects, in order to simplify the line-follower program.
params.py contains values for the speed, and line follower tuning,
to improve the performance. - See the tuning section below.
Basic instructions:
( Set the speed on the switches (see below) before you switch on.)Switch on, and you will see the line sensor illumination LED come on,
and the two line sensor LEDs will show which of the two sensors
are seeing white.
Move the sensors sideways over the line, to calibrate them.
Do this until the LED stops flashing as you move it back and forth.
The robot will try to spin to centralise the sensor,
(as long as the efactor parameter is large enough).
To start it running, press the push button.
It has no mechanism for stopping.
Tuning. :
The params file lets you set up values for:- basespeed, which is the speed at which it will run if sucessfully following the line.
Its values must be in the range 0-100
- efactor, which controls the sharpness of the steering,
if too low, it will swing wide on the corners, and may fall off the line.
Too high, will make it over-reactive and sensitive to the slightest
variation of position over the line.
-dfactor, which controls how much it takes into account the speed at which
its sensor is crossing the line.
A reasonable value can reduce the swinging back and forth across the line, whereas too high,
can also make it over-reactive.
Switches: The 4 switches can be used to override the "basespeed" setting in file params.py
The combinations are:
| 0000 | Use basespeed from params.py |
| 1000 | Speed 10 |
| 0100 | Speed 20 |
| 1100 | Speed 30 |
| 0010 | Speed 40 |
| 1010 | Speed 50 |
| 0110 | Speed 60 |
| 1110 | Speed 70 |
| 0001 | Speed 80 |
where 1 is ON and 0 is OFF