Car line patrol based on four-way line patrol module

Car line patrol based on four-way line patrol module1. 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 "Motor Introduction and Usage" in the four-way motor driver board information first to understand the motor parameters, wiring method, and power supply voltage you are currently using. To avoid burning the motherboard or motor.

2. Experimental preparation

Wheeled car chassis V1 four-wheel drive version, 4*310 motors, 7.4V lithium battery, four-way line patrol module, 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 for the four-way patrol module is: XH2.54 cable (6pin double-headed-all black-reverse 25cm), and the direction of the reverse cable holder is as shown in the following figure

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

扩展板接线

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)
M2M1-
VCC3V3
AH1A
BH1B
GNDGND
M1M1+
Four-way line patrol moduleMSPM0G3507 core board (Yahboom)
GNDGND
X4PA27
X3PA26
X2PA25
X1PA24
VCC5V

3. Key code analysis

APP_IR_PID_Calc: Use PID algorithm to calculate. If the line patrol effect is not good, you can set KP and KD to 0 first, then slowly increase KP, and finally try to increase the value of KD

Four_GetLineWalking: Get the status of the four-way line patrol module sensor

Four_LineWalking: Adjust the driving state of the car by obtaining the status of the four-way line patrol module

 

Configure the motor parameters of the 4-way motor driver board

Contrl_Speed: Control the speed of the 4 motors separately

 

 

 

4. Experimental phenomenon

Connect the car and burn the program to MSPM0, then place the car on the map with white background and black lines, and unplug the serial line that communicates with the four-way motor module. Adjust the four-way patrol module and adjust the module knob so that the module indicator light is on when encountering a black line, and the indicator light is off when it is not a black line. After the adjustment is completed, disconnect the power supply and plug the serial line back in. Put the car in the middle, let the two middle probes of the four-way patrol module be on the black line, then plug in the power supply, and the car will patrol the black line. The map adapted for this project is the high-difficulty map sold in this store, and it is adapted to the chassis of the four-wheel drive 310. If the patrol effect of other chassis is not good, you need to modify the motor PID and patrol PID in the code yourself.