yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
MSPM0 Smart Robot Car📖
1.Quick Start Guide
  • 1. Assembly Videos
  • 2. Quick Start Videos
  • 3. Battery charging
  • 4. Notes
2.Introduction to the MSPM0 Car
  • 1.About MSPM0
  • 2.Development board interface description
3.Development environment setup and usage
  • 1.CCS Theia development
  • 2.MDK Arm development
  • 3.Uniflash burning
  • 4.External crystal oscillator configuration
  • 5.Project Migration
4.MSPM0 basic course
  • 1. LED light control (GPIO)
  • 2. Buzzer Control (GPIO)
  • 3. Button Control (EXTI)
  • 4. Serial Port (UART)
  • 5. Voltage Detection (ADC)
  • 6. Temperature Detection (ADC)
  • 7. Independent Watchdog (WWDG)
  • 8. Window Watchdog (WWDG)
  • 9. Timer (TIM)
  • 10. Breathing LED (PWM)
  • 11. I2C Communication (I2C)
  • 12. External Flash (SPI)
  • 13. Internal Flash (Flash)
  • 14. DMA
  • 15. FreeRTOS
5.Sensor basic course
  • 1.Servo control
  • 2.Ultrasonic servo PTZ basic use
  • 3.Motor PID control
  • 4.OLED display photosensitive value
  • 5.Infrared avoid sensor
  • 6.1 Infrared line tracking sensor-8 channel infrared tracking sensor module
  • 6.2 Infrared line tracking sensor-4 channel infrared tracking sensor module
  • 7.Infrared remote control
  • 8.Ultrasonic ranging
  • 9.RGB light drive
  • 10.MPU6050 raw data acquisition
  • 11.MPU6050 data fusion
  • 12.K210 vision recognition module
  • 13.K230 vision recognition module
6.Smart car course
  • 1.1 Car line tracking-8 channel infrared tracking sensor module
  • 1.2 Car line tracking-4 channel infrared tracking sensor module
  • 2.1 Drawing a circle-8 channel infrared tracking sensor module
  • 2.2 Drawing a circle-4 channel infrared tracking sensor module
  • 3.Ultrasonic following
  • 4.Ultrasonic avoid
  • 5.Ultrasonic avoid(Servo PTZ)
  • 6.Infrared sensor avoid
  • 7.Light following
  • 8.Gyroscope calibration straight-line walk
  • 9.Infrared remote control
  • 10.Autonomous driving car
7.Vision application course
  • 1.K210 autonomous driving
  • 2.K210 color tracking
  • 3.K210 handwritten digit action
  • 4.K210 color response
  • 5.K210 road sign indication action
  • 6.K210 following machine code
  • 7.K210 QR code command
  • 8.K230 vision line tracking
  • 9.K230 color tracking
  • 10.K230 machine code tracking
  • 11.K230 QR code command
  • 12.K230 autonomous avoid
  • 13.K230 license plate tracking
  • 14.K230 face tracking
  • 15.K230 gaze direction tracking
  • 16.K230 palm tracking
  • 17.K230 target tracking
  • 18.K230 human body tracking
  • 19.K230 OCR character recognition
8.Extended application course (Sold separately)
  • 1.Voice interaction module communication
  • 2.Voice interaction control
  • 3.K230 road sign indication action(Voice)
  • 4.K230 color response(Voice)
  • 5.K230 gesture control(Voice)
  • 6.K230 rock-paper-scissors(Voice)
  • 7.8-channel grayscale color line tracking
  • 8.Bluetooth remote control
  • 9.K210 Scenario-based autonomous driving
  • 10.K230 Scenario-based autonomous driving
Download
  • Code
  • SCH
  • 3D Model File
  • MSPM0 Data Sheet
  • Voice firmware
  • Hardware interface manual
Download ZIP

Welcome to MSPM0 Smart Robot Car repository

6.1 Infrared line tracking sensor-8 channel infrared tracking sensor module

8-Channel Line Tracking Module

2.1 Basic Parameters

PixPin_2025-11-05_12-02-52

8-Channel Module Calibration Operation Steps

  1. First, power on the module and wait at least 20s. The main purpose is to let the probe stabilize. (Need to wait every time when powering on)
  2. If it's the first time powering on and hasn't been calibrated, the module's red light will keep flashing. (At this time, you need to enter calibration mode)
  3. Long press the onboard key1 button, wait for the board's red light to stay constantly lit, and enter calibration mode. Friendly Reminder: After entering calibration mode, the lights on the probe will no longer react to black and white lines, meaning they are not effective. Wait for calibration to complete before they will react.
  4. Place the probe according to your usage height (calibrate at the height where it will run), place the entire probe on the black line, stop for 3 seconds and wait for data to stabilize (do not move the probe during this period), as shown in the figure image-2024110100002
  5. After 3s, lightly press the key1 button to record the value of the probe detecting the black line. After recording is complete, the board's red light will flash quickly, then return to constant lighting.
  6. Then, place the probe on the white line, stop for 3 seconds and wait for data to stabilize (do not move the probe during this period), as shown in the figure image-2024110100001
  7. After 3s, lightly press the key1 button to record the value of the probe detecting the white line. After recording is complete, the board's red light will flash quickly.
  8. If calibration is successful, the onboard red light will turn off and enter detection mode; if it fails, the onboard red light will keep flashing slowly, at which time you need to recalibrate.

If you accidentally enter calibration mode, you can press the reset button to reset the module or quickly double-click the key1 button to exit calibration.

The calibrated values are saved after power-off each time, and can be used directly next time you power on, without needing to calibrate every time you power on. Unless you change to a different environment and height, at which time you need to recalibrate.

2.2 Hardware Wiring

Eight-Channel Line Tracking ModuleMSPM0G3507
5V5V
GNDGND
TXRX0
RXTX0

启动小车 (17)

upscalemedia-transformed (upscalemedia-transformed (1).png)

image-20251028214030899

2.3 Environment Setup

Open sysconfig tool and configure the following

PixPin_2025-11-05_17-07-40

Open receive interrupt pin configuration as follows

PixPin_2025-11-05_17-09-00

2.4 Partial Code Analysis

bsp_ir.c

​x
void IRDataAnalysis(void)
{
    ...
    // If no data received or data reception not complete, do not process
    if (IR_recv_complete_flag == 0) return;
​
    // Disable interrupt to prevent receiving new data during parsing
    __disable_irq();
​
    // Find the first '$' of the format header
    while ((IR_recv_buff[head] != '$') && (head < IR_recv_length))
    {
        head++;
    }
    if (head == IR_recv_length)
    {
        // Data header not found, clear receive flag, wait for next reception
        IR_recv_complete_flag = 0;
        IR_recv_length = 0;
        __enable_irq();
        return;
    }
     // Set valid data start address 
    buff = &IR_recv_buff[head]; 
​
    // Find the end '#'
    while ((buff[end] != '#') && (end < IR_recv_length))
    {
        end++;
    }
    if ((head + end) == IR_recv_length)
    {
        // Data end not found, clear receive flag, wait for next reception
        IR_recv_complete_flag = 0;
        IR_recv_length = 0;
        __enable_irq();
        return;
    }
​
    // Copy data to temp buffer
    if (end + 1 < sizeof(temp))
    {
        strncpy(temp, buff, end + 1);
        temp[end + 1] = '\0';  // Ensure string termination 
​
        // Check if data format is correct ($D,...)
        if (temp[0] == '$' && temp[1] == 'D')
        {
            char *token = strtok(temp, ","); 
            int index = 0;
​
            while (token != NULL && index < IR_Num)
            {
                // Parse x1:1, x2:1, ..., x8:1 format data
                if (strstr(token, "x") != NULL)
                {
                    char *colon = strchr(token, ':');  
                    if (colon != NULL)
                    {
                        // Extract numeric characters after ':' and convert to value
                        IR_Data_number[index] = (colon[1] - '0'); 
                        index++;
                    }
                }
                token = strtok(NULL, ",");  
            }
        }
    }
​
    // Clear receive complete flag, reset buffer, wait for next reception
    IR_recv_complete_flag = 0;
    IR_recv_length = 0;
    memset(IR_recv_buff, 0, USART_RECEIVE_LENGTH);
    __enable_irq(); 
}
// Continuously receive sensor returned data in serial port interrupt, then determine every 20ms in timer interrupt whether frame end is received, close interrupt to process new data when frame end is received
void UART_0_INST_IRQHandler(void)
{
    uint8_t RecvDATA = 0;  
    // Check interrupt source
    switch (DL_UART_getPendingInterrupt(UART_0_INST))
    {
        case DL_UART_IIDX_RX: 
            RecvDATA = DL_UART_Main_receiveData(UART_0_INST);  
​
            // Check if buffer is full
            if (IR_recv_length >= USART_RECEIVE_LENGTH - 1)
            {
                // Buffer full, reset receive state (discard data)
                IR_recv_complete_flag = 0;
                IR_recv_length = 0;
                break;
            }
​
            // Store received data to buffer
            IR_recv_buff[IR_recv_length++] = RecvDATA;
            IR_recv_buff[IR_recv_length] = '\0';  
​
            // Mark reception complete when '#' is received
            if (RecvDATA == '#')
            {
                IR_recv_complete_flag = 1;
            }
            break;
​
        default:
            break;
    }
}

2.5 Main Functions

IRDataAnalysis

Function Prototypevoid IRDataAnalysis(void)
Function DescriptionInfrared data parsing function, used to parse received infrared sensor data. The process includes: checking data reception complete flag, finding data header ('$') and data tail ('#'), verifying data format (must start with "$D"), parsing "x1:1,x2:1,...x8:1" format 8-channel sensor data and storing to IR_Data_number array, finally resetting receive state to wait for next data
Input ParametersNone
Return ValueNone

2.6 Experimental Phenomenon

Connect the car wires, connect the OLED module, after burning the program to MSPM0, sensor data is displayed on the OLED

image-20251028191614823

Infrared avoid sensor
Infrared line tracking sensor-4 channel infrared tracking sensor module

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文