• sales

    +86-0755-88291180

Chapter 11 of KitiBot-Microbit User Guide

Chapter 11 of KitiBot-Microbit

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.


Blocks

 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.

  Get original data (five data) from infrared tracking sensor

  Get the maximum value which every sensor able to detect after calibrating

  Get the minimum value which every sensor able to detect after calibrating

  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.

https://cdn.static.spotpear.com/uploads/picture/learn/micro-bit/micro-bit-kit/chapter-11-of-kitibot-microbit/chapter-11-of-kitibot-microbit-07.gif

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.


Section 2

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



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.


Section 3

We calibrate the output data in this section

https://cdn.static.spotpear.com/uploads/picture/learn/micro-bit/micro-bit-kit/chapter-11-of-kitibot-microbit/chapter-11-of-kitibot-microbit-13.gif

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.


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.

https://cdn.static.spotpear.com/uploads/picture/learn/micro-bit/micro-bit-kit/chapter-11-of-kitibot-microbit/chapter-11-of-kitibot-microbit-16.gif


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

TAG: ESP-IDF download and installation Industrial USB TO RS485 Isolated Bidirectional Converter Original FT232RNL 1200m Long Distance Raspberry Pi Prism Raspberry Pi DSI Scr spotpear Raspberry Pi IR Thermal Imagi ESP32-S3 Development Board 4 inch LCD TouchScreen Display 480x480 RS485 /SHT20 /Relay For Arduino LVGL 86 TVbox ESP32-S3 3.49-inch Development Board DeepSeek AI Chat Box 3.49inch LCD Capacitive TouchScreen Display 172×640 N16R8 ESP32 1.9inch LCD ESP32 C3 Round LCD Development Board Electronic EYE 0.71 inch Display Watch Screen GC9A01 160x160 Raspberry Pi 5 Raspberry Pi Triple Screen HAT Raspberry Pi Pico RP2040 1.69 inch TouchScreen Round LCD Display With QMI8658/Buzzer/RTC For Arduino MP2.5GD Raspberry Pi 5 PCIe to Dual 2.5G Double Ethernet HAT Pi5 RTL8125 Raspberry Pi Pico Buzzer RP2350B-MINI-A picotool Tutorial HDMI to RGB D-Robotics RDK X3 Module Core MD Module Horizon Sunrise Pi ARM Cortex-A53 5Tops Size Compatible With Raspberry Pi CM4 Size ESP32-S3 A7670E 4G development board supports LTE Cat-1/2G/GNSS positioning/WiFi/Bluetooth Raspberry Pi Camera