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

2.Ultrasonic servo PTZ basic use

Ultrasonic Servo PTZ Basic Use

Ultrasonic Servo PTZ Basic Use1. Software and Hardware2. Basic Principles2.1 Hardware Schematic2.2 Physical Connection Diagram2.3 Control Principle3. Project Experience3.1 Opening the Project4. Main Functions4.1 User Functions5. Experimental Phenomenon

This tutorial demonstrates: how to externally connect and use an ultrasonic servo PTZ on the expansion board and then print ultrasonic ranging data via serial port.

1. Software and Hardware

  • KEIL5

  • MSPM0G3507 Expansion Board

  • Ultrasonic Servo PTZ

  • Type-C data cable or DAP-Link

    For programming download or simulation to the development board

  • Serial Port Assistant

    Receive and print serial port data

2. Basic Principles

2.1 Hardware Schematic

upscalemedia-transformed (21)

image-20251011172219799.png

2.2 Physical Connection Diagram

未命名的设计 (35)

Servo (S1)CarSpecific Meaning
SIG(Yellow)PA28(Yellow)Signal Line
VCC(Red)VCC(Red)Power Supply
GND(Brown)GND(Black)Ground Line
Servo (S2)CarSpecific Meaning
SIG(Yellow)PA7(Yellow)Signal Line
VCC(Red)VCC(Red)Power Supply
GND(Brown)GND(Black)Ground Line

Ultrasonic Module:

Note: Using the servo PTZ requires adding jumper caps to connect 5V and choose, see the white line.

2.3 Control Principle

(Schematic Name)Control PinSpecific Meaning
TRIGPB7Trigger End
ECHOPB11Receiver End
S1PA28Servo Control Pin

Ultrasonic Module:

It is a module that uses ultrasonic waves for non-contact physical quantity measurement. It can accurately measure physical quantities such as distance, speed, and flow rate by emitting and receiving ultrasonic signals, and convert the measurement results into digital signal outputs. This article will explain the working principle and function of the ultrasonic module.

This experiment's ultrasonic module information:

ModelHC-SR04Detection Distance2-400cm
Working Voltage5VHigh PrecisionUp to 0.3cm
Working Current15mABlind Zone2cm
Working Frequency40KHzPin Wiring SequenceVCC, Trig (Control End), Echo (Receiver End), GND
Static Working Current<2mAInput Trigger Signal10uS TTL pulse
Detection AngleNot more than 15°Input Echo SignalOutput TTL level signal, proportional to range
Range Range2cm-4m (Peak)Level OutputTTL level

Ranging Principle: Input a high potential of more than 10 microseconds at the trigger end of the ultrasonic module to emit ultrasonic waves. After emitting the ultrasonic waves and before receiving the returned ultrasonic waves, the receiver end is at high potential. Therefore, the program can calculate the distance of the measured object from the high-level pulse duration of the "response" pin. Test Distance = (High Level Time * Sound Speed (340M/S)) / 2;

image-20230926100744845

Note: The above timing diagram shows that you only need to provide a pulse trigger signal of more than 10us. The module will internally emit 8 40kHz cycle levels and detect echoes. Once an echo signal is detected, it will output an echo signal. The pulse width of the echo signal is proportional to the measured distance. Therefore, the distance can be calculated from the time interval between transmitting the signal and receiving the echo signal.

PWM Control Servo Principle

Generate PWM signals using the timer/counter (TIM) peripheral and control the servo angle by adjusting the duty cycle.

image-20230926100744845

3. Project Experience

Use the project files we provide to directly experience the corresponding functions of the development board.

Later tutorials will not provide this content to avoid repetition. You can refer to 3. Development Environment Setup and Usage: 5. Project Porting for operations

3.1 Opening the Project

  • Project File Location

    Project file path: Under the corresponding course folder in the 【Program Source Code Summary】 folder

image-20251011184842078

  • Opening the Project File

    Copy the project file to the msp_sdk directory under an English path, use KEIL5 to open the project file, and select the .project file when opening

image-20251011184948004

 

  • Pin Configuration

    image-20251105185051435

    image-20251105185158149

    image-20251105185232797

    image-20251105185307647

    image-20251105185402220

    image-20251105185432493

    image-20251105185506682

4. Main Functions

Mainly introduces the functional code written by users. For detailed code, you can open the project files we provide and view the source code in the Bsp folder.

4.1 User Functions

Function: servo_init

Function Prototypevoid servo_init(void)
Function DescriptionInitialize timer simulated PWM signal output
Input ParametersNone
Output ParametersNone

Function: Set_Servo270_Angle

Function Prototypevoid Set_Servo270_Angle(unsigned int angle)
Function DescriptionControl 270-degree servo rotation
Input Parametersangle: rotation angle
Output ParametersNone

Function: Set_Servo_Angle

Function Prototypevoid Set_Servo_Angle(unsigned int angle)
Function DescriptionControl 180-degree servo rotation
Input Parametersangle: rotation angle
Output ParametersNone

Function: Hcsr04GetLength

Function Prototypefloat Hcsr04GetLength (void)
Function DescriptionCalculate and obtain ultrasonic data
Input ParametersNone
Output ParametersUltrasonic data

Function: get_servo_Printf

Function Prototypevoid get_servo_Printf ()
Function DescriptionServo rotates from 90° to 0°, then to 90° and 180°, during which ultrasonic data is obtained and respectively printf output and displayed on OLED
Input ParametersNone
Output ParametersNone

5. Experimental Phenomenon

During installation, you need to center the servo first before installation; the tutorial folder provides a 【MSPM0G_Car_Servo_ultrasonic.hex】 file for calibration. After burning this program, the servo will rotate to 90°. At this time, install the connection board between the ultrasonic and servo PTZ (physical object as shown below) on the servo. When installing the ultrasonic, it needs to face forward (slight deviation is acceptable).

image-20230926100744845

After servo calibration, we can burn the code for this chapter. Then after powering on the car, press the Reset key. We need to connect to the host computer through the Type-C interface, open the serial port assistant, set the parameters as shown in the figure below, and then we can view the measured ultrasonic distance through the serial port assistant.

After the car is powered on, the PTZ will first turn to the middle, then turn left, and then turn right. It cycles back and forth in these three directions. The serial port will print the distance between the ultrasonic measurement and obstacles.

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

Servo wiring is as follows:

image-20251011173308744

image-20230926100744845

Effect is as follows:

image-20251013113202473

Servo control
Motor PID control

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