yahboom
HomeTutorialsProduct
Solution
Blog
Online Store
About Us
EN/中文
Store
Wheeled Chassis Kit📖
0.Chassis installation course
  • Installation Video-1
  • Installation Video-2
  • Installation Video-3
1.4-channel motor drive module tutorials
IIC communication
  • For Arduino
  • For ESP32
  • For JetsonNANO
  • For MSPM0
  • For PICO2
  • For RDK X5
  • For RPi5
  • For STM32
Motor introduction and commissioning
  • 1. Motor introduction and usage
  • 2.PC host
USART communication
  • For Arduino
  • For ESP32
  • For JetsonNANO
  • For MSPM0
  • For PICO2
  • For RDK X5
  • For RPi5
  • For STM32
2.Kinematic analysis
  • Kinematic Analysis of Two-wheel Drive Vehicles
  • Kinematic Analysis of Four-wheel Drive Vehicles
3.MSPM0 chassis tutorials(MSPM0G3507/MSPM0G3519)
CCS basic case
  • 1. Turn on the LED light
  • 2. System delay
  • 3. Button control
  • 4. External interruption
  • 5. Serial communication
  • 6. Timer
  • 7. PWM breathing light
  • 8. ADC acquisition
  • 9. DMA transfer
  • 10. Get MPU6050 data (I2C)
  • 11. LCD Display (SPI)
Development environment construction
  • 01.CCS Theia Development
  • 02.MDK Arm Development
  • 03.UniFlash Downloader
  • 04.DAP-LINK download program
  • 05.Program simulation and debugging
  • 06.Engineering transplantation
Keil basic case
  • 1. Turn on the LED light
  • 2. System delay
  • 3. Button control
  • 4. External interruption
  • 5. Serial communication
  • 6. Timer
  • 7. PWM breathing light
  • 8. ADC acquisition
  • 9. DMA transfer
  • 10. Get MPU6050 data (I2C)
  • 11. LCD Display (SPI)
MSPM0 Basic Course
  • 1. Introduction to MSPM0
MSPM0 Robot Expansion Board Example
  • 1. Introduction to MSPM0 robot expansion board
  • 2. Customize buttons
  • 3. Drive the buzzer
MSPM0 Sensor extension information
  • 01.3-channel tracking
  • 02.4-channel tracking
  • 03.8-channel tracking
  • 04.CCD tracking
  • 05.Electric PTZ control
  • 06.2.4G handle control
  • 07.Servo ultrasonic avoid
  • 08.Bluetooth remote control
  • 09.K210-Automatic Driving
  • 10.K210-Color follow
  • 11.K210-Number recognition
  • 12.K210-Color reaction
  • 13.K210-Road signs
  • 14.K210-Machine code following
  • 15.K210-QR code recognition
  • 16.K230-Visual tracking
  • 17.K230-Color tracking
  • 18.K230-Color response
  • 19.K230-Road sign recognition
  • 20.K230-Machine code tracking
  • 21.K230-QR code recognition action
  • 22.K230-Autonomous avoid
  • 23.K230-License plate tracking
  • 24.K230-Face tracking
  • 25.K230-Gaze direction tracking
  • 26.K230-Palm tracking
  • 27.K230-Target tracking
  • 28.K230-Human body tracking
  • 29.K230-OCR character recognition action
4.STM32 chassis tutorials
  • 01.3-channel tracking
  • 02.4-channel tracking
  • 03.8-channel tracking
  • 04.CCD tracking
  • 05.Electric PTZ control
  • 06.2.4G handle control
  • 07.Servo ultrasonic avoid
  • 08.Bluetooth remote control
  • 09.K210-Automatic Driving
  • 10.K210-Color follow
  • 11.K210-Number recognition
  • 12.K210-Color Reaction
  • 13.K210-Road signs
  • 14.K210-Machine code following
  • 15.K210-QR code recognition
  • 16.K230-Visual tracking
  • 17.K230-Color tracking
  • 18.K230-Color response
  • 19.K230-Road sign recognition
  • 20.K230-Machine code tracking
  • 21.K230-QR code recognition action
  • 22.K230-Autonomous avoid
  • 23.K230-License plate tracking
  • 24.K230-Face tracking
  • 25.K230-Gaze direction tracking
  • 26.K230-Palm tracking
  • 27.K230-Target tracking
  • 28.K230-Human body tracking
  • 29.K230-OCR character recognition action
5.Expand course
  • 1.Autonomous driving car
  • 2.Vehicle-mounted balance ball motion control systemnew
Download
  • Code
  • 3D_Model_File
Download ZIP

Welcome to Wheeled Chassis Kit repository

06.2.4G handle control

ps2 wireless controller control

ps2 wireless controller control1. Introduction2. Experimental preparationThe relationship between the 4 motor interfaces and the car is as follows:Hardware wiring:Wiring using MSPM0 robot expansion boardWiring using MSPM0G3507 core board (Yahboom)Wiring pins3. Key code analysis4. Experimental phenomenon

1. Introduction

Please read the "Introduction to Motors and Usage" in the four-way motor driver board information first to understand the motor parameters, wiring methods, and power supply voltage you are currently using. To avoid burning the motherboard or motor.

2. Experimental preparation

National Race chassis V2 four-wheel drive version, 4*L520 motors, 12V lithium battery, PS2 wireless controller, MSPM0 robot expansion board (optional), MSPM0G3507 core board (Yahboom).

The relationship between the 4 motor interfaces and the car is as follows:

M1 -> upper left motor (left front wheel of the car)

M2 -> lower left motor (left rear wheel of the car)

M3 -> upper right motor (right front wheel of the car)

M4 -> lower right motor (right rear wheel of the car)

Hardware wiring:

Wiring using MSPM0 robot expansion board

Note: The wire used to connect the MSPM0 robot expansion board to the four-way motor drive module is: XPH2.0-4pin cable, double-ended all black, reverse (200mm), the direction of the reverse cable holder is shown in the figure below

扩展板接线

Wiring using MSPM0G3507 core board (Yahboom)

mspban

Wiring pins

Four-way motor driver boardMSPM0G3507 core board (Yahboom)
RX2PB6
TX2PB7
GNDGND
5V5V

Take M1 motor as an example below, and other motors are similar

MotorFour-way motor driver board (Motor)
M+M1+
M-M1-
GNDGND
VCC3V3
BH1A
AH1B
PS2 wireless controllerMSPM0G3507 core board (Yahboom)
VCC3V3
SCKPA24
ACKNo connection
CSPA25
GNDGND
MISOPA26
MOSIPA27

3. Key code analysis

  • pstwo.c

​x

//判断是否为红灯模式 Judge whether it is red light mode
//返回值;0,红灯模式    Return value: 0, red light mode
//其他,其他模式       Others, other modes
u8 PS2_RedLight(void)
{
    CS_L;
    PS2_Cmd(Comd[0]);  //开始命令   Start Command
    PS2_Cmd(Comd[1]);  //请求数据   Request data
    CS_H;
    if( Data[1] == 0X73)   return 0 ;
    else return 1;

}
...
void Get_PS2data(void)
{
    PS2_LX=PS2_AnologData(PSS_LX);
    PS2_LY=PS2_AnologData(PSS_LY);
    PS2_RX=PS2_AnologData(PSS_RX);
    PS2_RY=PS2_AnologData(PSS_RY);
    PS2_KEY=PS2_DataKey();
    
//  printf("PS2_LX=%d    ",PS2_LX);
//  printf("PS2_LY=%d    ",PS2_LY);
//  printf("PS2_RX=%d    ",PS2_RX);
//  printf("PS2_RY=%d    ",PS2_RY);
//  printf("PS2_KEY=%d    \r\n",PS2_KEY);
    
}
...

void PS2_CarControl(void)
{
    //----摇杆直向控制---//
    //----Joystick vertical control---//
    if(PS2_LX == 128 && PS2_LY == 127)
    {
        Contrl_Pwm(0,0,0,0);
    }

    if(PS2_LY>=0&&PS2_LY<70)//直走    Go straight
    {
        Contrl_Pwm(1500,1500,1500,1500);
    }
    
    if(PS2_LY<=255 && PS2_LY>200 &&PS2_LX == 128)//后退   Back
    {
        Contrl_Pwm(-1500,-1500,-1500,-1500);
    }
    
    if(PS2_LX>=0&&PS2_LX<70)//左旋    Rotate Left
    {
        Contrl_Pwm(-1500,-1500,1500,1500);
    }
    
    if(PS2_LX<=255 && PS2_LX>200 && PS2_LY == 127)//右旋  Rotate Right
    {
        Contrl_Pwm(1500,1500,-1500,-1500);
    }
    
    //----摇杆斜向控制---//
    //----Joystick tilt control---//
    if(PS2_LX >= 0&&PS2_LX <= 90 && PS2_LY >= 0&&PS2_LY <= 70)//左前旋转    Left front rotation
    {
        Contrl_Pwm(0,0,1500,1500);
    }
    if(PS2_LX >= 165&&PS2_LX <= 255 && PS2_LY >= 0&&PS2_LY <= 70)//右前旋转 Right front rotation
    {
        Contrl_Pwm(1500,1500,0,0);
    }
    if(PS2_LX >= 0&&PS2_LX <= 90 && PS2_LY >= 165&&PS2_LY <= 255)//左后旋转 Left rear rotation
    {
        Contrl_Pwm(0,0,-1500,-1500);
    }
    if(PS2_LX >= 165&&PS2_LX <= 255 && PS2_LY >= 165&&PS2_LY <= 255)//右后旋转  Right rear rotation
    {
        Contrl_Pwm(-1500,-1500,0,0);
    }
    
    //---方向按键控制---//
    //---Direction button control---//
    switch(PS2_KEY){
        case KEY_FORWARD:
            Contrl_Pwm(1500,1500,1500,1500);
        break;
        
        case KEY_BACK:
            Contrl_Pwm(-1500,-1500,-1500,-1500);
        break;
        
        case KEY_SPINRIGHT:
            Contrl_Pwm(1500,1500,-1500,-1500);
        break;
        
        case KEY_SPINLEFT:
            Contrl_Pwm(-1500,-1500,1500,1500);
        break;
        
        defalut:
        break;
    }
}

PS2_RedLight: Determine whether it is in red light mode; return value: 0, red light mode; return value: other, other modes.

Get_PS2data: Get the key value of the handle

PS2_CarControl: The key value of the handle button is bound to the car's motion status

  • app_motor_usart.c

xxxxxxxxxx
//控制pwm Control PWM
void Contrl_Pwm(int16_t M1_pwm,int16_t M2_pwm,int16_t M3_pwm,int16_t M4_pwm)
{
    sprintf((char*)send_buff,"$pwm:%d,%d,%d,%d#",M1_pwm,M2_pwm,M3_pwm,M4_pwm);
    Send_Motor_ArrayU8(send_buff, strlen((char*)send_buff));
}

Controlling 4 motors via PWM

  • empty.c

xxxxxxxxxx
int main(void)
{
    USART_Init();
    while(1)
    {       
        Get_PS2data();
        if(!PS2_RedLight())//切换为模拟量输入模式时,开始控制小车 When switching to analog input mode, start controlling the car
        {
            PS2_CarControl();
        } 
        delay_ms(2);
    }    
}

USART_Init: Initialize the serial port for communication with the four-way motor driver board

Get_PS2data: Get the key value of the handle button

PS2_RedLight: Red light mode judgment

PS2_CarControl: Get the key value of the handle button and then control the car

4. Experimental phenomenon

After connecting the car, burning the program to MSPM0, put the car on the ground and connect the car power supply. At this time, the red light of the receiver is always on and the green light is flashing. It is waiting for pairing. Then turn on the handle switch. At this time, when the red and green lights on the receiver are always on, it means the matching is successful. If the matching is not successful, please check the wiring again. Press and hold the handle mode key to switch the mode. The mode in which the red and green lights on the top of the handle are always on is the analog value mode. At this time, you can press the direction key on the left side of the handle or push the left joystick; the direction key up and down controls the car to move forward and backward, and the direction key left and right controls the car to rotate left and right; the control effect of the left joystick is similar to the direction key.

Electric PTZ control
Servo ultrasonic avoid

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