DC motor control method, system and automobile based on H-bridge drive
Through the H-bridge driven DC motor control method, PWM self-learning and position feedback are used to dynamically adjust the PWM signal, which solves the problems of fixed speed and inaccurate control, improves applicability and accuracy, reduces costs and saves manpower. .
Patent Information
- Application Number
- CN202210989306.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-17
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-08-17
AI Technical Summary
In existing DC motor drive control systems, fixed speed and lack of position feedback lead to inaccurate control problems, and existing solutions require separate calibration for different application scenarios, which is cumbersome to operate and not universally applicable.
The DC motor control method based on H-bridge drive is used to obtain the appropriate duty cycle through PWM self-learning, combined with the position feedback voltage for control, and the PWM signal is dynamically adjusted to achieve speed control and avoid the DC motor swinging back and forth at the target position.
It is possible to improve the applicability and accuracy of DC motor control while reducing costs, avoiding the problem of the DC motor swinging back and forth at the target position, and saving manpower. It obtains a suitable PWM signal duty cycle through self-learning, which is suitable for different applications. Application scenarios.
Smart Images

Figure CN115378312B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of direct current motor control, and in particular relates to a direct current motor control method, system and automobile based on H-bridge drive. Background Art
[0002] At present, the drive control of DC motors is often achieved through H-bridge drive circuits, and the speed of DC motors is controlled by speed control circuits combined with PWM. The speed control circuit increases the cost of DC motors. For control systems without speed control circuits, the DC motors are directly driven by H-bridges with fixed speeds. When the same DC motor with fixed speed and without position feedback is used as an actuator in different scenarios (such as air-conditioning outlet angle adjustment, three-way valve opening adjustment, etc.), in some scenarios, after the control module stops controlling due to excessive speed of the DC motor, the DC motor still moves forward for a certain angle before stopping, resulting in inaccurate position control. When the same DC motor with fixed speed but with position feedback is used as an actuator in different scenarios, in some scenarios, after the control module detects that its rotation position exceeds its preset control error range, it will drive the DC motor to rotate in the opposite direction, resulting in the DC motor swinging back and forth at the target position. In order to solve this problem, the commonly used means are to conduct offline calibration tests for different application scenarios separately, and store the calibrated PWM duty cycle back into the control module, which is cumbersome to operate and not universally applicable. Summary of the invention
[0003] The object of the present invention is to provide a direct current motor control method, system and automobile based on H-bridge drive, so as to improve applicability while reducing cost.
[0004] The DC motor control method based on H-bridge driving of the present invention comprises:
[0005] When the PWM self-learning state is waiting for self-learning, PWM self-learning is performed to obtain a PWM self-learning duty cycle A.
[0006] When the PWM self-learning state is that the self-learning has been completed, the DC motor is driven to work based on the PWM self-learning duty cycle A.
[0007] Based on the PWM self-learning duty cycle A, the methods of driving the DC motor include:
[0008] S11, obtain the current position feedback voltage of the DC motor, and then execute S12.
[0009] S12, calculating the difference δ between the DC motor control target voltage and the current position feedback voltage, and then executing S13.
[0010] S13, determine whether δ is greater than 0, and |δ| is greater than a preset control error, if so, execute S14, otherwise execute S15.
[0011] S14, make the first port output a PWM signal with a duty cycle of A, make the fourth port output a PWM signal with a duty cycle of A or 100%, make the second port output a PWM signal with a duty cycle of 0 (i.e., continuously output a low level), make the third port output a PWM signal with a duty cycle of 0, drive the DC motor to rotate forward, and then return to execute S11.
[0012] S15. Determine whether δ is less than 0 and |δ| is greater than a preset control error. If so, execute S16; otherwise, execute S17.
[0013] S16, make the first port output a PWM signal with a duty cycle of 0, make the fourth port output a PWM signal with a duty cycle of 0, make the third port output a PWM signal with a duty cycle of A, make the second port output a PWM signal with a duty cycle of A or 100%, drive the DC motor to reverse, and then return to execute S11.
[0014] S17, make the first port output a PWM signal with a duty cycle of 0 (i.e., continuously output a low level), make the third port output a PWM signal with a duty cycle of 0, make the second port output a PWM signal with a duty cycle of 100% (i.e., continuously output a high level), make the fourth port output a PWM signal with a duty cycle of 100%, the DC motor stops rotating, and then ends.
[0015] Preferably, the method of performing PWM self-learning to obtain the PWM self-learning duty cycle A includes:
[0016] S21, determine that the PWM duty cycle B=100%, the count value Counter0=0, and then execute S22.
[0017] S22, obtain the current position feedback voltage of the DC motor, and then execute S23.
[0018] S23, calculate the difference δ1 between the DC motor control target voltage and the current position feedback voltage, and then execute S24.
[0019] S24, determine whether δ1 is greater than 0, and |δ1| is greater than a preset control error, if so, execute S25, otherwise execute S26.
[0020] S25, make the first port output a PWM signal with a duty cycle of B, make the fourth port output a PWM signal with a duty cycle of B or 100%, make the second port output a PWM signal with a duty cycle of 0, make the third port output a PWM signal with a duty cycle of 0, drive the DC motor to rotate forward, and then return to execute S22.
[0021] S26, determine whether δ1 is less than 0, and |δ1| is greater than a preset control error, if so, execute S27, otherwise execute S28.
[0022] S27, the first port outputs a PWM signal with a duty cycle of 0, the fourth port outputs a PWM signal with a duty cycle of 0, the third port outputs a PWM signal with a duty cycle of B, the second port outputs a PWM signal with a duty cycle of B or 100%, and the DC motor is driven to reverse, and then S210 is executed;
[0023] S28, make the first port output a PWM signal with a duty cycle of 0, make the third port output a PWM signal with a duty cycle of 0, make the second port output a PWM signal with a duty cycle of 100%, make the fourth port output a PWM signal with a duty cycle of 100%, the DC motor stops rotating, and then execute S29.
[0024] S29, taking B as the PWM self-learning duty cycle A, and storing it, and then ending.
[0025] S210, obtaining the current position feedback voltage of the DC motor, calculating the difference δ2 between the current position feedback voltage and the initial position voltage of the DC motor, and then executing S211.
[0026] S211. Determine whether δ2 is greater than 0 and |δ2| is greater than a preset control error. If so, return to execute S27; otherwise (that is, δ2 is equal to 0, or |δ2| is less than or equal to the preset control error), execute S212.
[0027] S212, make the first port output a PWM signal with a duty cycle of 0, make the third port output a PWM signal with a duty cycle of 0, make the second port output a PWM signal with a duty cycle of 100%, make the fourth port output a PWM signal with a duty cycle of 100%, the DC motor stops rotating, and the count value Counter0 is accumulated by 1 (that is, let Counter0= Counter0+1), and then execute S213.
[0028] S213, set B=100%- Counter0*C, and then return to execute S22; wherein C is a preset duty cycle threshold.
[0029] The speed of the DC motor is positively correlated with the duty cycle of PWM. The larger the duty cycle of PWM, the faster the speed of the DC motor, and the smaller the duty cycle of PWM, the slower the speed of the DC motor. The duty cycle B of PWM is gradually reduced from 100% to C as the gradient, and then the DC motor is tested to see whether there will be a reversal when it moves from the initial position to the target position. If so, the value of the duty cycle B of PWM is further reduced until there is no reversal. The duty cycle B of PWM when there is no reversal is used as the self-learning duty cycle A of PWM. The self-learning is fast, accurate, and meets actual needs.
[0030] Preferably, the preset duty cycle threshold C=10%. 10% is a relatively suitable value, which will not affect the accuracy of self-learning and can also reduce the number of self-learning times.
[0031] Preferably, the method of making the first port output a PWM signal with a duty cycle of A and making the fourth port output a PWM signal with a duty cycle of A in S14 includes:
[0032] P11, set the count value Counter1 = 0, and then execute P12.
[0033] P12. Determine whether the count value Counter1 is equal to 100. If so, return to execute P11, otherwise execute P13.
[0034] P13, determine whether the count value Counter1 is less than 100*A, if so, execute P14, otherwise execute P15.
[0035] P14, make the first port output a high level, make the fourth port output a high level, start timing, and then execute P16.
[0036] P15, make the first port output a low level, make the fourth port output a low level, start timing, and then execute P16.
[0037] P16. When the timing reaches the preset time t, the count value Counter1 is incremented by 1 (i.e., Counter1 = Counter1 + 1), and then the process returns to execute P12.
[0038] The first port outputs a PWM signal with a duty cycle of A, and the fourth port outputs a PWM signal with a duty cycle of A by counting and judging, which is simple and fast.
[0039] Preferably, the method of causing the third port to output a PWM signal with a duty cycle of A and causing the second port to output a PWM signal with a duty cycle of A in S16 includes:
[0040] P21, set the count value Counter2 = 0, and then execute P22.
[0041] P22. Determine whether the count value Counter2 is equal to 100. If so, return to execute P21, otherwise execute P23.
[0042] P23. Determine whether the count value Counter2 is less than 100*A. If so, execute P24; otherwise, execute P25.
[0043] P24, make the second port output a high level, make the third port output a high level, start timing, and then execute P26.
[0044] P25, make the second port output a low level, make the third port output a low level, start timing, and then execute P26.
[0045] P26. When the timing reaches the preset time t, the count value Counter2 is incremented by 1 (i.e., Counter2 = Counter2 + 1), and then the process returns to execute P22.
[0046] The third port outputs a PWM signal with a duty cycle of A, and the second port outputs a PWM signal with a duty cycle of A by counting judgment, which is simple and fast.
[0047] Preferably, the method of making the first port output a PWM signal with a duty cycle of B and making the fourth port output a PWM signal with a duty cycle of B in S25 includes:
[0048] P31, set the count value Counter1 = 0, and then execute P32.
[0049] P32. Determine whether the count value Counter1 is equal to 100. If so, return to execute P31, otherwise execute P33.
[0050] P33. Determine whether the count value Counter1 is less than 100*B. If so, execute P34; otherwise, execute P35.
[0051] P34, make the first port output a high level, make the fourth port output a high level, start timing, and then execute P36.
[0052] P35, make the first port output a low level, make the fourth port output a low level, start timing, and then execute P36.
[0053] P36. When the timing reaches the preset time t, the count value Counter1 is incremented by 1 (i.e., Counter1 = Counter1 + 1), and then the process returns to execute P32.
[0054] By counting and judging, the first port outputs a PWM signal with a duty cycle of B, and the fourth port outputs a PWM signal with a duty cycle of B, which is simple and fast.
[0055] Preferably, the method of making the third port output a PWM signal with a duty cycle of B and making the second port output a PWM signal with a duty cycle of B in S27 includes:
[0056] P41, set the count value Counter2 = 0, and then execute P42.
[0057] P42. Determine whether the count value Counter2 is equal to 100. If so, return to execute P41, otherwise execute P43.
[0058] P43. Determine whether the count value Counter2 is less than 100*B. If so, execute P44; otherwise, execute P45.
[0059] P44, make the second port output a high level, make the third port output a high level, start timing, and then execute P46.
[0060] P45, make the second port output a low level, make the third port output a low level, start timing, and then execute P46.
[0061] P46. When the timing reaches the preset time t, the count value Counter2 is incremented by 1 (i.e., Counter2 = Counter2 + 1), and then the process returns to execute P42.
[0062] The third port outputs a PWM signal with a duty cycle of B, and the second port outputs a PWM signal with a duty cycle of B by counting judgment, which is simple and fast.
[0063] Preferably, the preset time t=1 ms. Then the period of the PWM signal is: 100*1 ms=100 ms.
[0064] The DC motor control system of the present invention comprises an H-bridge driving circuit, a position detection circuit and a control module, wherein the H-bridge driving circuit comprises a first controllable switch S1 and a second controllable switch S2 located at the left half bridge and a third controllable switch S3 and a fourth controllable switch S4 located at the right half bridge, the DC motor is connected between the left half bridge and the right half bridge, the first controllable switch S1 and the third controllable switch S3 are connected to a driving power supply VCC, the second controllable switch S2 and the fourth controllable switch S4 are grounded, the first port of the control module is connected to the control end of the first controllable switch S1, the second port of the control module is connected to the control end of the second controllable switch S2, the third port of the control module is connected to the control end of the third controllable switch S3, the fourth port of the control module is connected to the control end of the fourth controllable switch S4, the position detection circuit is connected to the control module, and the detected current position feedback voltage of the DC motor is sent to the control module. The control module is programmed to execute the above-mentioned DC motor control method based on H-bridge driving.
[0065] The automobile of the present invention comprises the above-mentioned DC motor control system.
[0066] The present invention eliminates the speed control module (hardware) and directly uses the PWM signal to act on the H-bridge drive circuit to achieve speed regulation, thereby preventing the DC motor from swinging back and forth at the target position and reducing costs. The PWM signal duty cycle for realizing the speed control of the DC motor is obtained by self-learning, and there is no need to conduct offline calibration tests separately for different application scenarios, thereby improving applicability and saving manpower. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 This is a schematic diagram of the architecture of the DC motor control system in Example 1.
[0068] Figure 2 This is a flow chart of the DC motor control method based on H-bridge drive in Example 1.
[0069] Figure 3 This is a flow chart of performing PWM self-learning in Example 1 to obtain the PWM self-learning duty cycle A.
[0070] Figure 4 This is a flow chart of driving a DC motor based on PWM self-learning duty cycle A in Example 1.
[0071] Figure 5 This is a flow chart of making the first port and the fourth port output a PWM signal with a duty cycle of A in Example 1.
[0072] Figure 6 This is a flow chart for causing the third port and the second port to output a PWM signal with a duty cycle of A in Example 1.
[0073] Figure 7This is a flow chart of making the first port and the fourth port output a PWM signal with a duty cycle of B in Example 1.
[0074] Figure 8 This is a flow chart for causing the third port and the second port to output a PWM signal with a duty cycle of B in Example 1. DETAILED DESCRIPTION
[0075] Example 1: Figure 1 As shown, the DC motor control system in this embodiment includes an H-bridge driving circuit, a position detection circuit and a control module. The H-bridge driving circuit includes a first controllable switch S1 and a second controllable switch S2 located in the left half bridge and a third controllable switch S3 and a fourth controllable switch S4 located in the right half bridge. The DC motor is connected between the left half bridge and the right half bridge. The first controllable switch S1 and the third controllable switch S3 are connected to the driving power supply VCC, and the second controllable switch S2 and the fourth controllable switch S4 are grounded. The first port of the control module is connected to the control end of the first controllable switch S1, the second port is connected to the control end of the second controllable switch S2, the third port is connected to the control end of the third controllable switch S3, and the fourth port is connected to the control end of the fourth controllable switch S4. The position detection circuit is connected to the control module, and the feedback voltage of the current position of the detected DC motor is sent to the control module. Different positions have different feedback voltages. The control module is programmed to execute the DC motor control method based on H-bridge driving in this embodiment.
[0076] like Figure 2 As shown, the DC motor control method based on H-bridge driving in this embodiment is executed by a control module, and the method specifically includes:
[0077] Step 1: Determine whether the PWM self-learning state is waiting for self-learning. If yes, execute step 2; otherwise (i.e., when the PWM self-learning state is completed self-learning), execute step 4.
[0078] Step 2: Perform PWM self-learning to obtain the PWM self-learning duty cycle A, store it, and then execute step 3.
[0079] like Figure 3 As shown, the method of performing PWM self-learning and obtaining the PWM self-learning duty cycle A includes:
[0080] S21, determine that the PWM duty cycle B=100%, the count value Counter0=0, and then execute S22.
[0081] S22, obtain the current position feedback voltage of the DC motor, and then execute S23.
[0082] S23, calculate the difference δ1 between the DC motor control target voltage and the current position feedback voltage, and then execute S24.
[0083] S24, determine whether δ1 is greater than 0, and |δ1| is greater than a preset control error, if so, execute S25, otherwise execute S26.
[0084] S25, make the first port and the fourth port output PWM signals with a duty cycle of B, make the second port and the third port output PWM signals with a duty cycle of 0, drive the DC motor to rotate forward, and then return to execute S22.
[0085] S26, determine whether δ1 is less than 0, and |δ1| is greater than a preset control error, if so, execute S27, otherwise execute S28.
[0086] S27, making the first port and the fourth port output PWM signals with a duty cycle of 0, making the third port and the second port output PWM signals with a duty cycle of B, driving the DC motor to reverse, and then executing S210.
[0087] S28, make the first port and the third port output PWM signals with a duty cycle of 0, make the second port and the fourth port output PWM signals with a duty cycle of 100%, the DC motor stops rotating, and then execute S29.
[0088] S29, taking B as the PWM self-learning duty cycle A, and storing it, and then ending.
[0089] S210, obtaining the current position feedback voltage of the DC motor, calculating the difference δ2 between the current position feedback voltage and the initial position voltage of the DC motor, and then executing S211.
[0090] S211. Determine whether δ2 is greater than 0 and |δ2| is greater than a preset control error. If so, return to execute S27; otherwise (that is, δ2 is equal to 0, or |δ2| is less than or equal to the preset control error), execute S212.
[0091] S212, make the first port and the third port output PWM signals with a duty cycle of 0, make the second port and the fourth port output PWM signals with a duty cycle of 100%, the DC motor stops rotating, the count value Counter0 is accumulated by 1, and then execute S213.
[0092] S213, set B=100%-Counter0*C, and then return to execute S22; wherein C is a preset duty cycle threshold (in this embodiment, C=10%).
[0093] Step 3: Change the PWM self-learning status to completed self-learning, and then end.
[0094] Step 4: Based on the PWM self-learning duty cycle A, drive the DC motor to work, and then end.
[0095] like Figure 4 As shown in the figure, based on the PWM self-learning duty cycle A, the specific methods of driving the DC motor include:
[0096] S11, obtain the current position feedback voltage of the DC motor, and then execute S12.
[0097] S12, calculating the difference δ between the DC motor control target voltage and the current position feedback voltage, and then executing S13.
[0098] S13, determine whether δ is greater than 0, and |δ| is greater than a preset control error, if so, execute S14, otherwise execute S15.
[0099] S14, make the first port and the fourth port output PWM signals with a duty cycle of A, make the second port and the third port output PWM signals with a duty cycle of 0, drive the DC motor to rotate forward, and then return to execute S11.
[0100] S15, determine whether δ is less than zero and |δ| is greater than a preset control error, if yes, execute S16, otherwise execute S17.
[0101] S16, make the first port and the fourth port output PWM signals with a duty cycle of 0, make the third port and the second port output PWM signals with a duty cycle of A, drive the DC motor to reverse, and then return to execute S11.
[0102] S17, the first port and the third port output PWM signals with a duty cycle of 0, and the second port and the fourth port output PWM signals with a duty cycle of 100%, the DC motor stops rotating, and then the process ends.
[0103] like Figure 5 As shown, the method of making the first port output a PWM signal with a duty cycle of A and making the fourth port output a PWM signal with a duty cycle of A in S14 includes:
[0104] P11, set the count value Counter1 = 0, and then execute P12.
[0105] P12. Determine whether the count value Counter1 is equal to 100. If so, return to execute P11, otherwise execute P13.
[0106] P13, determine whether the count value Counter1 is less than 100*A, if so, execute P14, otherwise execute P15.
[0107] P14, make the first port and the fourth port output high level, start timing, and then execute P16.
[0108] P15, make the first port and the fourth port output low level, start timing, and then execute P16.
[0109] P16. After the timing reaches the preset time t (the value is 1 ms in this embodiment), the count value Counter1 is incremented by 1, and then the process returns to execute P12.
[0110] like Figure 6 As shown, the method of making the third port output a PWM signal with a duty cycle of A and making the second port output a PWM signal with a duty cycle of A in S16 includes:
[0111] P21, set the count value Counter2 = 0, and then execute P22.
[0112] P22. Determine whether the count value Counter2 is equal to 100. If so, return to execute P21, otherwise execute P23.
[0113] P23. Determine whether the count value Counter2 is less than 100*A. If so, execute P24; otherwise, execute P25.
[0114] P24, make the second port and the third port output high level, start timing, and then execute P26.
[0115] P25, make the second port and the third port output low level, start timing, and then execute P26.
[0116] P26. When the timing reaches the preset time t, the count value Counter2 is incremented by 1, and then the process returns to execute P22.
[0117] like Figure 7 As shown, the method of making the first port output a PWM signal with a duty cycle of B and making the fourth port output a PWM signal with a duty cycle of B in S25 includes:
[0118] P31, set the count value Counter1 = 0, and then execute P32.
[0119] P32. Determine whether the count value Counter1 is equal to 100. If so, return to execute P31, otherwise execute P33.
[0120] P33. Determine whether the count value Counter1 is less than 100*B. If so, execute P34; otherwise, execute P35.
[0121] P34, make the first port and the fourth port output high level, start timing, and then execute P36.
[0122] P35, make the first port and the fourth port output low level, start timing, and then execute P36.
[0123] P36. When the timing reaches the preset time t, the count value Counter1 is incremented by 1, and then the process returns to execute P32.
[0124] like Figure 8 As shown, the method of making the third port output a PWM signal with a duty cycle of B and making the second port output a PWM signal with a duty cycle of B in S27 includes:
[0125] P41, set the count value Counter2 = 0, and then execute P42.
[0126] P42. Determine whether the count value Counter2 is equal to 100. If so, return to execute P41, otherwise execute P43.
[0127] P43. Determine whether the count value Counter2 is less than 100*B. If so, execute P44; otherwise, execute P45.
[0128] P44, make the second port and the third port output high level, start timing, and then execute P46.
[0129] P45, make the second port and the third port output low level, start timing, and then execute P46.
[0130] P46. When the timing reaches the preset time t, the count value Counter2 is incremented by 1, and then the process returns to execute P42.
[0131] This embodiment also provides a car, which includes Figure 1 The DC motor control system shown.
[0132] Embodiment 2: The DC motor control system and the automobile in this embodiment are the same as those in Embodiment 1. Most steps of the DC motor control method based on H-bridge drive in this embodiment are the same as those in Embodiment 1, except that:
[0133] In S14, the first port outputs a PWM signal with a duty cycle of A, the fourth port outputs a PWM signal with a duty cycle of 100%, and the second port and the third port output PWM signals with a duty cycle of 0, thereby driving the DC motor to rotate forward.
[0134] In S16, the first port and the fourth port are made to output a PWM signal with a duty cycle of 0, the third port is made to output a PWM signal with a duty cycle of A, and the second port is made to output a PWM signal with a duty cycle of 100%, so as to drive the DC motor to reverse.
[0135] In S25, the first port outputs a PWM signal with a duty cycle of B, the fourth port outputs a PWM signal with a duty cycle of 100%, and the second port and the third port output a PWM signal with a duty cycle of 0, thereby driving the DC motor to rotate forward.
[0136] In S27, the first port and the fourth port are made to output a PWM signal with a duty cycle of 0, the third port is made to output a PWM signal with a duty cycle of B, and the second port is made to output a PWM signal with a duty cycle of 100%, so as to drive the DC motor to reverse.
Claims
1. A DC motor control method based on H-bridge drive, characterized in that: include: When the PWM self-learning state is in the waiting state, PWM self-learning is performed to obtain the PWM self-learning duty cycle A; When the PWM self-learning state is that the self-learning has been completed, the DC motor is driven to work based on the PWM self-learning duty cycle A; specifically, the following steps are included: S11, obtaining the current position feedback voltage of the DC motor, and then executing S12; S12, calculating the difference δ between the DC motor control target voltage and the current position feedback voltage, and then executing S13; S13, determine whether δ is greater than 0, and |δ| is greater than a preset control error, if yes, execute S14, otherwise execute S15; S14, making the first port output a PWM signal with a duty cycle of A, making the fourth port output a PWM signal with a duty cycle of A or 100%, making the second port and the third port output a PWM signal with a duty cycle of 0, driving the DC motor to rotate forward, and then returning to execute S11; S15, determine whether δ is less than 0, and |δ| is greater than a preset control error, if yes, execute S16, otherwise execute S17; S16, making the first port and the fourth port output a PWM signal with a duty cycle of 0, making the third port output a PWM signal with a duty cycle of A, making the second port output a PWM signal with a duty cycle of A or 100%, driving the DC motor to reverse, and then returning to execute S11; S17, the first port and the third port are made to output PWM signals with a duty cycle of 0, and the second port and the fourth port are made to output PWM signals with a duty cycle of 100%, and the DC motor stops rotating, and then the process ends; Among them, the method of performing PWM self-learning and obtaining the PWM self-learning duty cycle A includes: S21, determine that the PWM duty cycle B=100%, the count value Counter0=0, and then execute S22; S22, obtaining the current position feedback voltage of the DC motor, and then executing S23; S23, calculating the difference δ1 between the DC motor control target voltage and the current position feedback voltage, and then executing S24; S24, determine whether δ1 is greater than 0, and |δ1| is greater than a preset control error, if yes, execute S25, otherwise execute S26; S25, making the first port output a PWM signal with a duty cycle of B, making the fourth port output a PWM signal with a duty cycle of B or 100%, making the second port and the third port output a PWM signal with a duty cycle of 0, driving the DC motor to rotate forward, and then returning to execute S22; S26, determine whether δ1 is less than 0, and |δ1| is greater than a preset control error, if yes, execute S27, otherwise execute S28; S27, making the first port and the fourth port output a PWM signal with a duty cycle of 0, making the third port output a PWM signal with a duty cycle of B, making the second port output a PWM signal with a duty cycle of B or 100%, driving the DC motor to reverse, and then executing S210; S28, making the first port and the third port output PWM signals with a duty cycle of 0, making the second port and the fourth port output PWM signals with a duty cycle of 100%, the DC motor stops rotating, and then executing S29; S29, taking B as the PWM self-learning duty cycle A, and storing it, and then ending; S210, obtaining the current position feedback voltage of the DC motor, calculating the difference δ2 between the current position feedback voltage and the initial position voltage of the DC motor, and then executing S211; S211, determine whether δ2 is greater than 0, and |δ2| is greater than a preset control error, if yes, return to execute S27, otherwise execute S212; S212, the first port and the third port are made to output PWM signals with a duty cycle of 0, and the second port and the fourth port are made to output PWM signals with a duty cycle of 100%, the DC motor stops rotating, the count value Counter0 is accumulated by 1, and then S213 is executed; S213, set B=100%- Counter0*C, and then return to execute S22; wherein C is a preset duty cycle threshold.
2. The DC motor control method based on H-bridge drive according to claim 1, characterized in that: The preset duty cycle threshold C=10%.
3. The DC motor control method based on H-bridge drive according to claim 1 or 2, characterized in that: The method of causing the first port to output a PWM signal with a duty cycle of A and causing the fourth port to output a PWM signal with a duty cycle of A in S14 includes: P11, set the count value Counter1 = 0, and then execute P12; P12, determine whether the count value Counter1 is equal to 100, if yes, return to execute P11, otherwise execute P13; P13, determine whether the count value Counter1 is less than 100*A, if yes, execute P14, otherwise execute P15; P14, make the first port and the fourth port output high level, start timing, and then execute P16; P15, make the first port and the fourth port output low level, start timing, and then execute P16; P16. When the timing reaches the preset time t, the count value Counter1 is incremented by 1, and then the process returns to execute P12.
4. The DC motor control method based on H-bridge drive according to claim 1 or 2, characterized in that: The method of causing the third port to output a PWM signal with a duty cycle of A and causing the second port to output a PWM signal with a duty cycle of A in S16 includes: P21, set the count value Counter2 = 0, and then execute P22; P22, determine whether the count value Counter2 is equal to 100, if yes, return to execute P21, otherwise execute P23; P23, determine whether the count value Counter2 is less than 100*A, if yes, execute P24, otherwise execute P25; P24, make the second port and the third port output high level, start timing, and then execute P26; P25, make the second port and the third port output low level, start timing, and then execute P26; P26. When the timing reaches the preset time t, the count value Counter2 is incremented by 1, and then the process returns to execute P22.
5. The DC motor control method based on H-bridge drive according to claim 1 or 2, characterized in that: The method of causing the first port to output a PWM signal with a duty cycle of B and causing the fourth port to output a PWM signal with a duty cycle of B in S25 includes: P31, set the count value Counter1 = 0, and then execute P32; P32, determine whether the count value Counter1 is equal to 100, if yes, return to execute P31, otherwise execute P33; P33, determine whether the count value Counter1 is less than 100*B, if so, execute P34, otherwise execute P35; P34, make the first port and the fourth port output high level, start timing, and then execute P36; P35, make the first port and the fourth port output low level, start timing, and then execute P36; P36. When the timing reaches the preset time t, the count value Counter1 is incremented by 1, and then the process returns to execute P32.
6. The DC motor control method based on H-bridge drive according to claim 1 or 2, characterized in that: The method of causing the third port to output a PWM signal with a duty cycle of B and causing the second port to output a PWM signal with a duty cycle of B in S27 includes: P41, set the count value Counter2 = 0, and then execute P42; P42, determine whether the count value Counter2 is equal to 100, if yes, return to execute P41, otherwise execute P43; P43, determine whether the count value Counter2 is less than 100*B, if so, execute P44, otherwise execute P45; P44, make the second port and the third port output high level, start timing, and then execute P46; P45, make the second port and the third port output low level, start timing, and then execute P46; P46. When the timing reaches the preset time t, the count value Counter2 is incremented by 1, and then the process returns to execute P42.
7. The DC motor control method based on H-bridge driving according to claim 3 is characterized in that: The preset time t=1ms.
8. A DC motor control system, comprising an H-bridge drive circuit, a position detection circuit and a control module, wherein the H-bridge drive circuit comprises a first controllable switch S1 and a second controllable switch S2 located at the left half bridge and a third controllable switch S3 and a fourth controllable switch S4 located at the right half bridge, the DC motor is connected between the left half bridge and the right half bridge, the first controllable switch S1 and the third controllable switch S3 are connected to a drive power supply VCC, the second controllable switch S2 and the fourth controllable switch S4 are grounded, the first port of the control module is connected to the control end of the first controllable switch S1, the second port is connected to the control end of the second controllable switch S2, the third port is connected to the control end of the third controllable switch S3, and the fourth port is connected to the control end of the fourth controllable switch S4, the position detection circuit is connected to the control module, and the detected current position feedback voltage of the DC motor is sent to the control module; it is characterized in that: The control module is programmed to execute the DC motor control method according to any one of claims 1 to 7.
9. A car, characterized in that: Comprising the DC motor control system as described in claim 8.
