Steering engine linear speed regulation method and system
By calculating the servo angle control total time and pulse width, a linear speed-regulating PWM waveform is generated, which solves the problem of stiff servo movement and realizes the stability and smoothness of servo movement.
Patent Information
- Application Number
- CN202510446269.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-07-11
AI Technical Summary
In the prior art, the combined action of multiple servo machines is stiff and cannot meet the precise control of the action completion time, resulting in the action being not smooth and smooth.
By obtaining the total control time required for rotation of the steering angle, calculate the time required for each rotation of 1 degree, and generate a corresponding PWM waveform to realize linear speed control of the servo, including controlling the total time acquisition module, the required time calculation module and the pulse width calculation module, generate a PWM waveform with the pulse width that needs to be increased or decreased.
The stability and smoothness of the servo movement are achieved, and the combined action of multiple servo movements is more silky, close to the effect of artificial intelligence control.
Smart Images

Figure CN120301260A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of servo motion control methods, and particularly to a servo linear speed regulation method and system. Background Art
[0002] Servos are often used in the control of the limb movement joints of robots, in radio-controlled models, ship models, and the rotation angle control of other industrial robotic arms. Most of these servo controls are implemented based on a 50 Hz PWM waveform. The difference lies in the amplitudes of the PWM waveforms, which can be as small as 3.3 V and 5 V power supplies, slightly larger ones can be 12 V and 24 V, and the control voltage (i.e., the PWM amplitude) of some servos can be customized according to requirements.
[0003] The method of controlling the rotation angle of a servo by applying a PWM wave signal with a certain duty cycle to the servo is a common method for controlling the rotation angle of a servo at present. That is, when it is known that the servo needs to rotate to a certain angle, a PWM waveform with a corresponding duty cycle is given. After applying a PWM waveform with a certain duty cycle to the servo, wait for the servo to rotate to that angle. No further control is performed during the period when the servo rotates from the current position to the target position.
[0004] Common servos can be divided into four types: 90°, 180°, 270°, and 360°. They can all control the rotation angle of the servo by the method of applying a PWM signal in the background art solution. Among them, the 360° servo rotates continuously, and only the rotation speed of the servo can be controlled by the size of the PWM duty cycle. The other three types of servos control the rotation angle of the servo by the size of the PWM duty cycle.
[0005] From the foregoing introduction, it can be seen that currently using the PMW method to control the rotation angle of a servo is a linear relationship, as Figure 1 shown (taking a 180° rotation angle servo as an example). Through Figure 1 it can be known that: taking a 180° servo as an example, using a 50 Hz PWM wave, when the high level is 0.5 ms, the servo rotates to 0°; when the high level is 1 ms, the servo rotates 45°; when the high level is 1.5 ms, the servo rotates 90°; when the high level is 2 ms, the servo rotates 135°; when the high level is 2.5 ms, the servo rotates 180°. The correspondence between the PWM duty cycle and the rotation angle is shown in Table 1. This is obviously a linear relationship. Assuming the rotation angle is A and the high level time is t, the relationship between them can be expressed by Formula 1. This is obviously a linear relationship. Assuming the rotation angle is A and the high level time is t, the relationship between them can be expressed by the following formula:
[0006] A = 45°×(t - 0.5) / 0.5
[0007] For each servo, due to different specifications, the time it takes to rotate from the current angle to the target angle is different, but its rotation time is a fixed value, assumed to be T.
[0008] Table 1 Corresponding relationship between PWM duty cycle and rotation angle of 180° servo
[0009]
[0010] Because the traditional method of controlling a servo is to give the servo a PWM waveform with a certain duty cycle and then wait for the servo to rotate to that angle (or that position) without any control during the rotation of the servo, the action completion time of a robot or robotic arm composed of multiple servos in combination is an integer multiple of T. The joint actions or action combinations are too rigid and cannot meet the requirements for accurate control such as the action completion time. Summary of the Invention
[0011] The technical problem to be solved by the present invention is how to provide a servo linear speed regulation method that can increase the stability of servo actions and make the combined actions of multiple servos smoother.
[0012] To solve the above technical problem, the technical solution adopted by the present invention is: a servo linear speed regulation method, including the following steps:
[0013] Obtain the total control time T required for the servo to rotate the angle. The minimum normal rotation time of the servo is t1, and the control time is t2, then T = t1 + t2;
[0014] Divide the difference B between the current angle of the servo and the target angle by the total control time T required for the servo to rotate the angle to obtain the time t required to rotate 1 degree within the time T;
[0015] According to the time t required to rotate 1 degree, obtain the pulse width that needs to be increased or decreased each time during the time T;
[0016] Generate a PWM waveform corresponding to the pulse width that needs to be increased or decreased and assign it to the servo controller to control the servo for linear speed regulation.
[0017] The present invention also discloses a servo linear speed regulation system, including:
[0018] Total control time acquisition module: used to obtain the total control time T required for the servo to rotate the angle. The minimum normal rotation time of the servo is t1, and the control time is t2, then T = t1 + t2;
[0019] Required time t calculation module: divide the difference B between the current angle of the servo and the target angle by the total control time T required for the servo to rotate the angle to obtain the time t required to rotate 1 degree within the time T;
[0020] Pulse width calculation module: used to obtain the pulse width that needs to be increased or decreased each time of control within the time T according to the time t required for each 1-degree rotation.
[0021] Linear speed control module: used to generate a PWM waveform corresponding to the pulse width that needs to be increased or decreased as described above and assign it to the servo controller to control the servo for linear speed regulation.
[0022] The beneficial effects produced by adopting the above technical solution are as follows: By continuously sending PWM with a continuously increasing or decreasing duty cycle to the servo from the first PWM waveform until the servo reaches the rotation angle in an arithmetic progression manner for the PWM duty cycle of the present invention, the rotation angle speed control of 90°, 180°, and 270° servos is realized, so as to achieve the purpose of changing the non-adjustable rotation speed of the current 90°, 180°, and 270° servos to linearly adjustable, increasing the stability of the servo action, making the combined action of multiple servos smoother and closer to the artificial intelligence control technology. Description of the drawings
[0023] The present invention will be further described in detail below in conjunction with the drawings and specific embodiments.
[0024] Figure 1 is a diagram showing the correspondence between the rotation angle of a 180° servo and the duty cycle of the PWM waveform in the prior art;
[0025] Figure 2 is the overall flowchart of the method described in the embodiment of the present invention;
[0026] Figure 3 is the principle block diagram of the system described in the embodiment of the present invention. Specific embodiments
[0027] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0028] Many specific details are set forth in the following description in order to provide a thorough understanding of the present invention, but the present invention may be practiced in other ways different from those described herein. Those skilled in the art can make similar generalizations without departing from the spirit of the present invention, so the present invention is not limited by the specific embodiments disclosed below.
[0029] As Figure 2 shown, the embodiment of the present invention discloses a method for linear speed regulation of a servo, including the following steps:
[0030] Obtain the total control time T (unit: millisecond, i.e., ms) required for the servo to rotate to the desired angle. Among them, the minimum normal rotation time of the servo is t1, and the control time is t2, then T = t1 + t2;
[0031] Divide the difference B (unit: degree, i.e., °) between the current angle of the servo and the target angle by the total control time T required for the servo to rotate to obtain the time t required to rotate 1 degree within the time T;
[0032] According to the time t required to rotate 1 degree, obtain the pulse width that needs to be increased or decreased for each control within the time T;
[0033] Generate the PWM waveform corresponding to the pulse width that needs to be increased or decreased above and assign it to the servo controller to control the servo for linear speed regulation. Among them, the PWM waveform is generated by a timer, with a frequency of 50 Hz (i.e., a period of 20 ms) and a duty cycle of 2.5% - 12.5%.
[0034] The pulse width is obtained by the following method:
[0035] Suppose the required total control time is T, the servo currently stops at an angle of a1, corresponding to a pulse width of p1, and the target angle at which the servo is required to stop is a2, corresponding to a pulse width of p2. If a2 > a1, it means that the rotation angle of the servo needs to increase. The first pulse width is [p1 + ((a2 - a1) / (T / 20)) * 11.11] ms, the second pulse width is [p1 + ((a2 - a1) / (T / 20)) * 11.11 * 2], the nth pulse width is calculated by formula (1), and the last pulse width is [p1 + (a2 - a1) * 11.11] = p2;
[0036]
[0037] If a1 > a2, it means that the rotation angle of the servo needs to decrease. The first pulse width is [p2 - ((a1 - a2) / (T / 20)) * 11.11] ms, the second pulse width is [p2 - ((a1 - a2) / (T / 20)) * 11.11 * 2] ms, the nth pulse width is calculated by formula (2), and the last pulse width is [p2 - (a1 - a2) * 11.11] = p1;
[0038]
[0039] The value range of n is an integer between 1 and T / 20, including 1 and T / 20. When T / 20 is a decimal, the integer is obtained by the method of rounding.
[0040] To facilitate the understanding of linear control, an example is given as follows:
[0041] Among them, a2 represents the target angle (position), a1 represents the current angle (position), T represents the time to be controlled, x represents the x-th pulse to be sent, and y represents the width of the pulse with the serial number x. Obviously, y is a linear function of x.
[0042] For example, for a PWM period of 20 ms, if the total time required to control the servo from starting to rotating to ending rotation is 600 ms, then 30 pulses need to be sent. Assuming the rotation angle is from 0° to 180°, then each pulse increases by 6°. That is, the first pulse is 0.5 ms + 66.66 μs = 0.567 ms, the second pulse is 0.5 ms + 66.66 μs × 2 = 0.633 ms, the n-th pulse is (0.5 + 0.06666 × n) ms, and the last pulse is 0.5 ms + 66.66 μs × 30 = 2.4998 ms.
[0043] For a PWM period of 20 ms, if the required total control time is 450 ms, then 23 (450 ms ÷ 20 ms) pulses need to be sent. The rotation angle is from 0° to 135°, then each pulse increases by 5.87° (135° ÷ 23). That is, the first pulse is 0.5 ms + 65.2 μs = 0.565 ms, the second pulse is 0.5 ms + 65.2 μs × 2 = 0.630 ms, the n-th pulse is (0.5 + 0.0652 × n) ms, and the last pulse is 0.5 ms + 65.2 μs × 23 = 1.996 ms.
[0044] The width increase per pulse is: the increase degree per pulse × 11.11 μs / degree. For example, in the first case: the increase per pulse is 6° × 11.11 μs / degree; in the second case: the increase per pulse is 5.87° × 11.11 μs / degree.
[0045] For a PWM period of 20 ms, if the required total control time is 550 ms, then 28 (550 ms ÷ 20 ms) pulses need to be sent. The rotation angle is from 135° to 45°, then each pulse decreases by 3.21° (90° ÷ 28). That is, the first pulse is 2 ms - 35.71 μs = 1.964 ms, the second pulse is 2 ms - 35.71 μs × 2 = 1.929 ms, the n-th pulse is (2 - 0.0357 × n) ms, and the last pulse is 2 ms - 35.71 μs × 28 = 1 ms.
[0046] Furthermore, as Figure 3 shown, corresponding to the above method, an embodiment of the present invention also discloses a servo linear speed regulation system, including:
[0047] Control total time acquisition module 101: It is used to acquire the total control time T required for the steering gear to rotate by an angle. The minimum normal rotation time of the steering gear is t1, and the control time is t2, then T = t1 + t2;
[0048] Required time t calculation module 102: Divide the difference B between the current angle of the steering gear and the target rotation angle by the total control time T required for the steering gear to rotate by an angle, to obtain the time t required for each 1-degree rotation within the time T;
[0049] Pulse width calculation module 103: It is used to obtain the pulse width that needs to be increased or decreased each time during the time T according to the time t required for each 1-degree rotation;
[0050] Linear speed control module 104: It is used to generate a PWM waveform corresponding to the pulse width that needs to be increased or decreased above and assign it to the steering gear controller to control the steering gear for linear speed regulation.
[0051] It should be noted that for the specific implementation methods of each module in the system described in the embodiments of the present application, reference can be made to the part of the steering gear linear speed regulation method of the present application, which will not be elaborated here.
[0052] The method described in the present invention uses the method of arithmetic progression to divide the rotation angle into several equal parts (the number of parts is determined by the time T required for the steering gear to rotate, that is, the number of parts = T / 20, 20 is the PWM period of 20 ms); uses the method of timer to accurately control the steering gear to increase or decrease the same angle each time by controlling the time of each rotation angle, to achieve the steering gear rotation speed control method, making the time for the steering gear to rotate to the target angle more accurate, and the combined action of multiple steering gears is no longer rigid. It is applicable to the precise control of the rotation angle speed of the steering gear or servo motor within the range of 0° to 360° (excluding).
Claims
1. A linear speed regulation method for a steering gear, characterized in that It includes the following steps: Obtain the total control time T required for the steering gear to rotate by an angle. The minimum normal rotation time of the steering gear is t1, and the control time is t2, then T = t1 + t2; Divide the difference B between the current angle of the steering gear and the target rotation angle by the total control time T required for the steering gear to rotate by an angle to obtain the time t required for each 1-degree rotation within the time T; According to the time t required for each 1-degree rotation, obtain the pulse width that needs to be increased or decreased for each control within the time T; Generate the PWM waveform corresponding to the pulse width that needs to be increased or decreased as described above and assign it to the steering gear controller to control the steering gear for linear speed regulation.
2. The servo linear speed regulation method according to claim 1, characterized in that, The PWM waveform is generated by a timer, with a frequency of 50 Hz and a duty cycle of 2.5% - 12.5%.
3. A servo linear speed regulation method according to claim 1, characterized in that, The pulse width is obtained by the following method: Suppose the required total control time is T, the steering gear currently stops at an angle of a1, corresponding to a pulse width of p1, and the target angle at which the steering gear is required to stop is a2, corresponding to a pulse width of p2. If a2 > a1, it means that the rotation angle of the steering gear needs to increase. The first pulse width is [p1 + ((a2 - a1) / (T / 20)) * 11.11] ms, the second pulse width is [p1 + ((a2 - a1) / (T / 20)) * 11.11 * 2], the nth pulse width is calculated by formula (1), and the last pulse width is [p1 + (a2 - a1) * 11.11] = p2; If a1 > a2, it means that the rotation angle of the steering gear needs to decrease. The first pulse width is [p2 - ((a1 - a2) / (T / 20)) * 11.11] ms, the second pulse width is [p2 - ((a1 - a2) / (T / 20)) * 11.11 * 2] ms, the nth pulse width is calculated by formula (2), and the last pulse width is [p2 - (a1 - a2) * 11.11] = p1; 4. The method for linearly adjusting the speed of a steering gear according to claim 3, characterized in that: The value range of n is an integer between 1 and T / 20, including 1 and T / 20. When T / 20 is a decimal, the integer can be obtained by the method of rounding.
5. The linear speed regulation method of the steering gear according to claim 1, characterized in that: The unit of the total control time T is millisecond ms.
6. The servo linear speed regulation method according to claim 1, characterized in that: The unit of the difference B between the current angle of the steering gear and the target rotation angle is degree.
7. A servo linear speed regulation system, characterized in that It includes: Total control time acquisition module: used to obtain the total control time T required for the steering gear to rotate by an angle. The minimum normal rotation time of the steering gear is t1, and the control time is t2, then T = t1 + t2; Required time t calculation module: Divide the difference B between the current angle of the steering gear and the target rotation angle by the total control time T required for the steering gear to rotate by an angle to obtain the time t required for each 1-degree rotation within the time T; Pulse width calculation module: used to obtain the pulse width that needs to be increased or decreased for each control within the time T according to the time t required for each 1-degree rotation; Linear speed regulation control module: used to generate the PWM waveform corresponding to the pulse width that needs to be increased or decreased as described above and assign it to the steering gear controller to control the steering gear for linear speed regulation.