• 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: ESP32 P4 Development Board WIFI6 4 inch LCD Round Display 4inch TouchScreen 720×720 Dual Microphones Spotpear ESP32-S3 Luckfox Pico RJ45 ESP32 S3 Development Board 1.47 inch LCD Touch Screen 1.47inch Display 172×320 SD AXS5106L JD9853 TTL UART To CAN Raspberry Pi 18.5inch FHD LCD 1920x1080 Capacitive TouchScreen Display For Raspberry Pi/Jetson Nano/ Solar Raspberry Pi 5 PCIe FFC Connector to Standard PCIe x1 Slot (C) Expansion Board Code Raspberry Pi Real time clock Raspberry Pi RP2040 Long-Rang Thermal imaging camera ESP32-S3FH4R2 Matrix 8x8 RGB-LED-WiFi Bluetooth QST Attitude Gyro Sensor QMI8658C Arduino Python 3.5inch RPi LCD (A) Manual Configuration DeepSeek XiaoZhi AI Voice Chat Robot BOX ESP32-S3 Development Board 1.28 inch Round LCD 1.28inch TouchScreen N16R8 D-Robotics RDK X3 Development Board Horizon Sunrise Pi ARM Cortex-A53 5Tops 2GB/4GB RAM X1002 Raspberry Pi 5 PCIe to M.2 NVMe SSD Adapter Board HAT Pi5 2280 Raspberry Pi PICO Long-Range Communication spotpear