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

3.Motor PID control

Motor PID Control

Motor PID Control1. Software and Hardware2. Basic Principles2.1 Hardware Schematic2.2 Physical Connection Diagram2.3 Control Principle3. Project Configuration3.1 Description3.2 Pin Configuration4. Main Functions4.1 Main Functions4.2 User Functions5. Experimental Phenomenon

This tutorial demonstrates: using timer to control 2 TT encoded motors and print encoder values via serial port, where KEY buttons can control the motor rotation mode.

1. Software and Hardware

  • KEIL5

  • MSPM0G3507 Robot Development Board

  • TT Encoded Motor * 2

  • Type-C data cable or DAP-Link

    For programming download or simulation to the development board

2. Basic Principles

2.1 Hardware Schematic

upscalemedia-transformed (22)

image-20251107182104409

2.2 Physical Connection Diagram

未命名的设计 (36)

2.3 Control Principle

Motor speed and direction control: configure timer PWM output mode and change the duty cycle of PWM signal;

Motor encoder reading: configure timer to count motor encoder signals.

  • TT Encoded Motor
Motor ModelTT Encoded Motor
Motor Rated Voltage6V
Encoder Supply Voltage3.3-5V
Gearbox Reduction Ratio1:45
Magnetic Ring Line Count13 lines
Encoder TypeAB Phase Hall Encoder

Count Value

Maximum count value reduction ratio encoder line count

4: Represents encoder frequency multiplication
Based on the count value of one rotation, the car's speed can be calculated. This tutorial does not involve speed conversion
  • Motor Driver

MSPMOG3507 integrates 2 AT8236 single-channel brush DC motor driver chips.

Input pins IN1 and IN2 control the output state of the H-bridge. The following table shows the logical relationship between input and output:

IN1IN2OUT1OUT2Function
00ZZCoast, Sleep
10HLForward
01LHReverse
11LLBrake

When using PWM control to achieve speed adjustment function, the H-bridge can operate in two different states: fast decay or slow decay.

IN1IN2Function
PWM0Forward PWM, Fast Decay
1PWMForward PWM, Slow Decay
0PWMReverse PWM, Fast Decay
PWM1Reverse PWM, Slow Decay

PWM Period: T = 50us → f = 20KHz

 

  • Encoder Reading

    Obtain count value by directly reading timer CNT register value.

image-20231201152036621

The tutorial is set to count on TI1 and TI2, input signals not inverted;

image-20231201152123515

xxxxxxxxxx
Whether the counter counts up or down depends on the AB phase signals

3. Project Configuration

3.1 Description

You can refer to the basic tutorial to complete the development environment setup.

The non-omitted project configuration part is the key point that needs to be configured in this tutorial.

 

3.2 Pin Configuration

  • GPIO

image-20231024120011541

 

  • USART

  • Timer Configuration: Here demonstrates TIMA1 configuration

image-20251014114329710

 

  • PWM Configuration: Here demonstrates motor PWM configuration

 

4. Main Functions

For detailed code, you can open the project files we provide and view the source code in the Bsp folder.

4.1 Main Functions

FunctionCorresponding Tutorial
ButtonDevelopment Board Basic Tutorial: Button Control
Serial PortDevelopment Board Basic Tutorial: Serial Communication

4.2 User Functions

Function: PID_Location_Calc

Function Prototypefloat PID_Location_Calc**(PID_t *pid, float actual_val)
Function DescriptionPositional PID algorithm
Input Parameter 1PID_t *pid: structure
Input Parameter 2actual_val: PID target value
Return ValuePID output value

Function: PID_Calc_One_Motor

Function Prototypefloat PID_Calc_One_Motor(uint8_t motor_id, float now_speed)
Function DescriptionSeparately calculate one channel PID
Input Parameter 1motor_id: motor id. Use 0 and 1 to represent left and right motors respectively
Input Parameter 2now_speed: set PID target value
Return ValuePositional PID calculated output value

Function: encoder_update

Function Prototypevoid encoder_update(void)
Function DescriptionEncoder data update
Input ParametersNone
Return ValueNone

Function: Scheduler_Run

Function Prototypevoid Scheduler_Run(void)
Function DescriptionConfigure task scheduler for task scheduling
Input ParametersNone
Return Value 

5. Experimental Phenomenon

After successfully downloading the program, press the RESET button on the development board and open the serial port debugging assistant to observe the phenomenon!

xxxxxxxxxx
For program download, refer to 【3. Development Environment Setup and Usage: 3. Uniflash burning】

Phenomenon:

Press KEY1: can select mode;

Press and hold KEY1 then press KEY2: confirm the selected mode;

mode1: Display encoder values on OLED and send via serial port, then receive encoder values through serial port assistant;

mode2: Motor rotates forward and can display encoder values on OLED and send via serial port, then receive encoder values through serial port assistant;

mode3: Motor rotates in reverse and can display encoder values on OLED and send via serial port, then receive encoder values through serial port assistant;

Ultrasonic servo PTZ basic use
OLED display photosensitive value

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/中文