Sports chassis is an important part of the mobile robot, unlike laser radar, IMU, microphone, audio, camera these general components can be bought, it is difficult to buy a general chassis. On the one hand, because the size of the chassis is to match the specific robot; on the other hand, the chassis contains a hardware and software complete set of solutions, which is the core technology of many robots, generally not disclosed. For strong currency and learning enthusiasm, I want to DIY a set of two rounds of differential chassis and open a complete design process for everyone to learn. Dry, do it, this chapter main content:
1.STM32 master hardware design
2.STM32 master software design
3. Chassis Communication Agreement
4. Chassis ROS driver development
5. Chassis PID control parameter tuning
6. Chassis mileage bill
1.STM32 Master Hardware Design Complete STM32 Master Hardware Includes: DC speed reducer with Hall encoder, motor drive, STM32 single chip development board and other accessories.
1.1. DC speed reducer with Hall encoder
(Figure 1) DC speed reducer with Hall encoder
To make a robot chassis, you need a complete motor component, just as seen in Figure 1, there is a need for tires, couplings, gearboxes, motors, and encoders, specific selection can refer to these aspects. the elements of:
Tire: The larger the diameter, the better the cars, but will reduce the horsepower of the car climbing;
Coupling: Select the model that matches the tire and the motor output shaft size;
Gasket: Decentralization ratio determines the torque of the motor output shaft, the larger the reduction ratio, the larger the output shaft torque, but the output shaft speed is slower;
Motor: Generally 12V motor, DC brush is easy to control;
Encoder: Generally, an incremental orthogonal encoder, the number of coding lines is selected according to the actual needs accuracy.
(Figure 2) Motor terminal port
As shown in Figure 2, you can clearly see the wiring port of the motor, and there is also a wire printing on the board. Wiring is divided into two categories, one is motor control (motor line +, motor line -), and the other is an encoder (encoder 5V, encoder A phase, encoder B phase, encoder GND).
1.2. Motor drive circuit
(Figure 3) TB6612FNG motor drive
Be
After understanding the motor constructive knowledge, let's introduce how to drive the motor. As shown in Figure 3, TB6612FNG is a very popular motor drive chip, which is much higher than the conventional L298N efficiency, and the volume is greatly reduced. TB6612FNG is a double drive, that is, two motors can be driven; TB6612FNG outputs a continuous drive current of up to 1.2 A per channel, activates peak current to 2A / 3.2 A (continuous pulse / single pulse); 4 motor control mode: forward / Reverse / braking / stop; PWM supports up to 100 kHz.
(Figure 4) TB6612FNG pin definition
The pin definition of TB6612FNG, as shown in Figure 4, the pin is divided into power pins, controls the input pin, and control the output foot.
VM: For the motor drive voltage, according to the actual motor rated voltage selection, it is recommended to use 12V power supply;
VCC: Logic power supply, recommended 5V power supply;
STBY: Standby / Working status switch, low level standby, high level work;
PWMA: A port motor PWM speed control signal input;
AIN1 and AIN2: A motor steering control signal input;
PWMB: B port motor PWM speed control signal input;
BIN1 and BIN2: B Motor Steering Control Signal Input;
AO1 and AO2: A port motor drive signal output;
BO1 and BO2: B port motor drive signal output.
(Figure 5) TB6612FNG control signal authenticity table
Be
Finally, let's take a look at the logical truth table of the control signal, as shown in Figure 5, input from the microcontroller IO port, then combined with the PWM signal, you can implement the positive / reverse and speed control of the motor. Since the two motor control is exactly the same, the logical truth table of the other control signal is not repeated.
1.3. Hall orthogonal encoder principle
(Figure 6) Hall orthogonal encoder principle
Be
If the two signal phase differs from 90 degrees, the two signals are called orthogonal. Since the two signal phase differs from 90 degrees, it can be judged in the direction according to the two signals. It is easy to obtain the speed and steering of the motor by capturing the A and B of the microcontroller. Hall is orthogonal encoder principle, as shown in Figure 6.
1.4.STM32 single-chip minimum system
STM32 MCU is common models of STM32F103, based on the specific demand, the RAM capacity, the number of IO ports are selected, and some of the commonly used model parameters are compared, as shown in Figure 7.
(Figure 7) STM32F103 series single-chip parameter comparison
Considering that the STM32 master is only used for the control of the two motors, the resource overhead is not large, the IO port you need to use is not much, the timer resources are not much, for the cost-effective consideration, STM32F103C8T6 models.
(Figure 8) STM32F103F103C8T6 minimum system board
Be
As shown in Figure 8, the STM32F103C8T6 minimum system board is relatively simple, controlling two electric motors, only need to use two IO port output 2 PWM to two motor speed, respectively, respectively, the direction of the two motors, respectively, In addition, four IO ports are connected to the orthogonal encoder input of two motors, and the UART1 and the UART2 are used for program DEBUG and the upper instruction control.
1.5.STM32 Master Hardware Overall Box Chart
The first version of the hardware circuit is a variety of modules connected to the flying line, and the stability of the circuit is very poor, and the appearance is extremely ugly. Painful thinking, determined to design the circuit board, integrate each module into a plate, after two modes of change, finally succeeded. As shown in Figure 9, the board is simple and beautiful, and the connection terminal is reasonable, which is in line with the standard of me.
(Figure 9) STM32 Master Circuit Board
Be
Ok, I have this circuit board. Tell my design ideas for this circuit board. Firstly, a power supply system is required for a single-chip power supply, motor power supply, and external equipment power supply. It is also necessary to consider the power supply reverse, overvoltage, short circuit and other protection; then need to design a STM32 single-chip minimum system circuit; finally surround STM32 minimum system, It is necessary to design a motor drive, UART to USB, encoder signal capture these peripheral circuits, while also considering the motor blocking protection, motor to system power supply interference. After picking pits one by one, it is almost designed. STM32 master hardware overall block diagram, as shown in Figure 10.
(Figure 10) STM32 master hardware overall block diagram
Our other product: