Motor drive module
The schematic diagram of the motor drive module used is as follows. The L298N is useless because it can only control a 12V motor at the highest, and the laboratory uses a 24V motor, so I searched for it on Taobao and chose the following module.
The specific pin assignment diagram is as follows:
There are two ways to use this module:
this module can control the start, stop and forward and reverse rotation of the motor, and control the motor speed through PWM. Currently, method 1 is used for control. The actual wiring found that there is no need to provide additional 5V power supply to power the module, and the PWM pin of dSPACE will supply power to the module, so R_EN, L_EN, and VCC are short-circuited, which is equivalent to 5V, and GND is connected separately.
Simulink control model construction
The Simulink control algorithm is built as shown in the figure below, which includes multiple subsystems such as position control, forward and reverse control, duty cycle limit, PID adjustment, and position reset, which can realize independent control of wheel speed and steering.
In terms of speed, Delta Position outputs the change in the number of encoder pulses within the sampling time interval. Therefore, the actual speed of the current motor is calculated through the M-method speed measurement, and the actual speed is fed back, compared with the set speed, and adjusted by PID. So as to realize the single closed-loop control of the speed.
In terms of steering, Enc Position outputs the total number of pulses of the encoder after the motor is running, so it can calculate how many turns the motor has rotated in total, and then calculate the rotation angle of the motor, compare the actual rotation value with the set value, and determine whether the motor has rotated to When the target position is reached, it stops immediately, so as to realize the control of the rotation angle of the motor.
Hardware platform construction
The construction of the peripheral circuit is shown in the following figure:
After reading the literature and experimental verification, the corresponding relationship between the four PWM signals of the RTI PWM module and the CP18 port pins of the CLP1104 panel is as follows:
Make the SUB-D connector and the CLP1104 panel Inc1, Inc2 according to the encoder pin assignment The ports are connected, and the pin assignment of the encoder is shown in the following figure:
Control Desk experimental model construction
In terms of speed, in Control Desk, you can set the speed value, select forward and reverse rotation, adjust each PID parameter, and output the set speed curve, the actual speed curve and the speed error curve.
In terms of steering, you can set the rotation amount and rotation speed in Control Desk, output the set corner curve, the actual corner curve and the corner error curve, and you can modify the minimum allowable corner error value.