yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
8-channel Grayscale Tracking Module📖
0. Precautions for use
  • Identifying Defective Solutions
1.About 8-channel tracking module
  • 8-channel grayscale module introduction
2.MCU data reading
  • 1.MSPM0G3507
  • 2.MSPM0G3519new
  • 3.STM32F103C8T6
  • 4.ESP32
  • 5.Arduino
  • 6. Raspberry Pi Pico
3.Car gray line tracking
  • 1. MSPM0 Smart Car
  • 2. STM32 development board for small car
  • 3. ESP32 wheeled car chassis V1
  • 4. Arduino Wheeled Car Chassis V2
  • 5. Raspberry Pi Pico Wheel Car Chassis V2
Download
  • Code
  • 3D Model File
  • Serial Port Assistant
Download ZIP

Welcome to 8-channel Grayscale Tracking Module repository

2.MSPM0G3519

Data Reading

Data Reading1. Quick Start2. Hardware Wiring3. Usage Instructions4. Phenomenon and Results5. Code Explanation

1. Quick Start

This tutorial explains how to use the MSPM0G3519 motherboard to read the digital information from an eight-channel grayscale tracking module and view the print results using a serial port assistant.

The hardware used in this tutorial is the MSPM0G3519 core board and eight-channel grayscale tracking module sold by Yabo. After connecting the wires according to the wiring diagram below, you can then program the motherboard to obtain the data. Modules other than Yabo's are for reference only.

2. Hardware Wiring

The MSPM0G3519's USB port needs to be connected to the computer's USB port using a Type-C port.

image-20251110141418715

Eight-channel grayscale line-following moduleMSPM0G3519
5V5V
GNDGND
AD0PA14
AD1PA15
AD2PA16
OUTPA17

The 8-channel grayscale module sold by Yabo uses an XH2.54 to 6-pin DuPont cable for connection:

image-20251108181811636

3. Usage Instructions

  1. Open the UniFlash programming tool, search for MSPM0G3519, and click the third result. If this software is not available, you need to refer to the MSPM0G3507 core board documentation to learn the basic usage and programming of the motherboard.

image-20251110141933497

  1. In the Program navigation page, select the hex file in the source code.

image-20251110142328418

  1. Select the COM port and baud rate.

image-20251110142604496

  1. Press and hold the BSL button, then press and hold the RST button for about 1 second. Release the RST button, then release the BSL button. You are now in burning mode.

image-20241116142931986

After entering the burning mode, click "Load image" to download.

Note: The download must be performed within 10 seconds of the development board entering burning mode; otherwise, the download will fail.

image-20241116121631693

If you encounter the same error message as shown in the image below, "Image loading falled: Try manual Bootloader invocation...", the download has actually been successful. This is a bug in the download software.

img

  1. Press the reset button (NRST) to restart the motherboard and run the program. Open the serial port assistant and view the printed information.

4. Phenomenon and Results

In the serial port assistant, you can see the continuously printed digital values ​​of the eight-channel grayscale tracking module. X1 corresponds to the X1 indicator on the module; when the X1 indicator is lit, the corresponding value is 1.

image-20251108171858515

5. Code Explanation

​x
// empty.c
int main(void)
{
    SYSCFG_DL_init();
    USART_Init();

    while(1)
    {       
        Grayscale_Sensor_Read_All(g_sensor_data);
        
        for (i = 0; i < GRAYSCALE_SENSOR_CHANNELS; i++)
        {
            printf("[ %s:%d ]", sensor_labels[i], g_sensor_data[i]);
        }
        printf("\n");
        delay_ms(30);
    }    
}
  • main: The main entry point of the program. First, SYSCFG_DL_init() is called. This function, generated by TI's SysConfig tool, initializes all hardware peripherals, including GPIO and UART. Then, USART_Init() is called to enable serial port interrupts. Within an infinite loop, the program continuously calls Grayscale_Sensor_Read_All() to acquire sensor data and prints it out using printf. The printf function has been redirected to the UART, so the data is sent via the serial port.

xxxxxxxxxx
// grayscale_sensor.c
void Grayscale_Sensor_Read_All(uint16_t* sensor_values)
{
    uint8_t i;
    for (i = 0; i < GRAYSCALE_SENSOR_CHANNELS; i++)
    {
        _select_channel(i);
        _delay_us(50);
        sensor_values[i] = Read_OUT_value();
    }
}
static void _select_channel(uint8_t channel)
{
    SENSOR_AD0_WRITE((channel >> 0) & 0x01);
    SENSOR_AD1_WRITE((channel >> 1) & 0x01);
    SENSOR_AD2_WRITE((channel >> 2) & 0x01);
}
  • Grayscale_Sensor_Read_All: Traverse all 8 sensor channels, passing The _select_channel function selects a channel, reads its value, and stores it in an array.

  • _select_channel: The SENSOR_ADx_WRITE macro controls the GPIO level to select the corresponding sensor. These macros ultimately call the DL_GPIO_setPins and DL_GPIO_clearPins functions in the TI DriverLib library.

MSPM0G3507
STM32F103C8T6

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

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文