Chapter 11 of KitiBot-Microbit

From Waveshare Wiki
Jump to: navigation, search

KitiBot, after seen a high-speed rail moving fast along the track, he hopes to have same track to move along, like a high-speed train. In this chapter we will learn about the “tracing function” of kitiBot. The aim of this chapter is to learn about the tracking sensor, and how to use it to implement the robot patrolling function.

Tracking sensor: the tracking sensor helps the robot move along the black line on the ground. There are five detectors at the bottom of the sensor, and the infrared LED light is used to project infrared light to the ground to detect the deviation of the module relative to the black line.



Kitibor for microbit manual 11-1.png The detection range of different sensors are different, so we need to calibrate sensors to get their min and max values, then calibrate original data. To use this block, you need to put the robot on center of black line, move left and right to get dozens of data for calibrating.

Kitibor for microbit manual 11-2.png Get original data (five data) from infrared tracking sensor

Kitibor for microbit manual 11-3.png Get the maximum value which every sensor able to detect after calibrating

Kitibor for microbit manual 11-4.png Get the minimum value which every sensor able to detect after calibrating

kitibor for microbit manual 11-5.png Read the position of black line, range of data is 0~4000, 0 stands for left side, 4000 stand for right side, 2000 means center.

Section 1

This section, we read original data of tracking sensor from serial port. Let's see how will these data change.

We read the data and save it to various item, then send the data to serial port.

Kitibor for microbit manual 11-6.gif

Kitibor for microbit manual 11-7.png

Connect the micro:bit to PC, and search the COM port on Device Mangaer. Download the code to micro:bit. Open serial assistant software, set baudrate to 115200. Five data will be printed to software. If you higher the robot, the data will turn small to about 0~10. If you put the robot to white ground, the data will rise to 500~700, on black line, the output are about 100.

Kitibor for microbit manual 11-8.png

Section 2

We let the script to output the position of black line base on previous section

Kitibor for microbit manual 11-9.gif

Kitibor for microbit manual 11-10.png

Download the code to micr:bit, you can see that data are output as below. When black line is under tracking sensor, the data are smaller, about 80~10. The right data is the position of black line. Note that these data are not be calibrated.

Kitibor for microbit manual 11-11.png

Section 3

We calibrate the output data in this section

Kitibor for microbit manual 11-12.gif

Kitibor for microbit manual 11-13.png

Put the robot on ground, and make sure the black lines is on the center. After 3s (run the code), robot begin to calibrate, turn left first, then turn right, finally turn back to original place. During calibrating, the min and max values of every sensor will be printed, and data calibrated.

Kitibor for microbit manual 11-14.png

Section 4

In previous sections we learned about how to read the data of tracking sensor, here let's make robot to move along the black line. That is make robot turn right to back to black line when the data show that black line is on the right by slowing down the right motor, and turn left if the black line is on the left by slowing down the left motor.

Kitibor for microbit manual 11-14.gif

Kitibor for microbit manual 11-15.png

The P on the code is position tolerance, if it is positive, means robot deviation to right, and robot deviation to left if it is negative.

D is the difference between current P and last P, bigger the D, faster the robot response.

dif is the value which motor need to change, this value is based on P and D

Related Pages