Motor control method, motor control device, electronic device, and storage medium

CN122993556APending Publication Date: 2026-10-27SHENZHEN RSPOWER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611336554.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-31
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

传统T型曲线控制方法需要对整个运行过程进行预先规划,然而,这种全局规划的方式每当目标位置、最大速度或加速度等参数发生变化时,都需要重新进行完整的曲线规划计算,响应速度慢,实时性差

Benefits of technology

[0025]本申请的电机控制方法、电机控制装置、电子设备及存储介质,通过将电机控制过程分为逐预设周期递推计算的方式,每个预设周期内仅根据目标位置、当前位置和当前速度确定该周期的给定速度和计算位置,再根据当前计算位置与目标位置的关系决定是继续计算下一周期还是停止。无需预先规划整条运动曲线,当目标位置或运动参数发生变化时,下一周期的计算即可自动适应新参数,实现了电机控制的实时性和灵活性,特别适用于目标位置频繁变化的场景。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122993556A_ABST
    Figure CN122993556A_ABST
Patent Text Reader

Abstract

The application provides a motor control method, a motor control device, an electronic device and a storage medium. The motor control method is used for controlling a motor to rotate to a target position. The motor control method comprises the following steps: obtaining a current position and a current speed of the motor. According to at least the target position, the current position and the current speed, a current given speed and a current calculated position of the motor in a current preset period are determined. According to the calculated position and the target position, a next given speed and a next calculated position of the motor in a next preset period are determined, or the motor is controlled to rotate at the current given speed at a preset time point in the current preset period, so as to control the motor to rotate to the target position. The application realizes the real-time and flexibility of motor control, and is particularly suitable for a scene in which the target position frequently changes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of motor control technology, and in particular to a motor control method, a motor control device, an electronic device, and a storage medium. Background Technology

[0002] In motor motion control, it is typically necessary to control the motor to smoothly rotate to the target position along a T-curve. Traditional T-curve control methods require pre-planning of the entire operation process. However, this global planning approach necessitates recalculating the entire curve whenever parameters such as the target position, maximum speed, or acceleration change, resulting in slow response and poor real-time performance. In applications where the target position changes frequently or motion parameters require dynamic adjustment, such as impedance matching, traditional methods struggle to quickly adapt to parameter changes, limiting the flexibility and real-time performance of motor control. Therefore, providing a motor control method that eliminates the need to replan the entire curve and can determine each control command in real-time based on the current state has become a pressing technical problem. Summary of the Invention

[0003] This application provides a motor control method, a motor control device, an electronic device, and a storage medium, which realizes the real-time and flexible nature of motor control and is particularly suitable for scenarios where the target position changes frequently.

[0004] Firstly, a motor control method is provided, the motor control method being used to control a motor to rotate to a target position, the motor control method comprising: Get the current position and speed of the motor.

[0005] Based on at least the target position, the current position, and the current speed, determine the current given speed and the current calculated position of the motor within the current preset cycle.

[0006] Based on the relationship between the current calculated position and the target position, determine the next given speed and the next calculated position of the motor in the next preset cycle, or control the motor to rotate at the current given speed at a preset time point in the current preset cycle, so as to control the motor to rotate to the target position.

[0007] In one possible implementation, determining the current given speed and current calculated position of the motor within the current preset cycle, based at least on the target position, the current position, and the current speed, includes: Based on the target location and the current location, the distance between the target location and the current location is calculated.

[0008] Based on the current speed and the interval distance, the current given speed of the motor within the current preset cycle can be calculated.

[0009] Based at least on the current given speed of the motor within the current preset cycle, the current calculated position of the motor within the current preset cycle can be obtained.

[0010] In one possible implementation, calculating the current given speed of the motor within the current preset cycle, based at least on the current speed and the interval distance, includes: Based on the current speed, calculate the deceleration distance required for the motor to decelerate from the current speed to zero speed.

[0011] The interval distance is compared with the deceleration distance, and the acceleration parameters are determined based on the comparison results.

[0012] Based on the acceleration parameters, the current given speed of the motor within the current preset cycle can be calculated.

[0013] In one possible implementation, the acceleration parameter includes at least one of the acceleration direction and acceleration value. The step of comparing the interval distance with the deceleration distance and determining the acceleration parameter based on the comparison result includes: When the interval distance is greater than the deceleration distance, the acceleration direction is determined as the first direction, and the acceleration value is the preset acceleration.

[0014] When the interval distance is less than the deceleration distance, the acceleration direction is determined to be the second direction, and the acceleration value is the preset acceleration.

[0015] When the interval distance is equal to the deceleration distance, the acceleration value is determined to be zero.

[0016] In one possible implementation, calculating the current given speed of the motor within the current preset cycle, at least based on acceleration parameters, includes: Based on the direction of acceleration and the preset acceleration, the calculated speed of the motor within the current preset cycle is obtained.

[0017] When the calculated speed is less than the threshold speed, the current given speed of the motor within the current preset cycle is determined as the calculated speed.

[0018] When the calculated speed is greater than or equal to the threshold speed, the current given speed of the motor within the current preset cycle is determined as the threshold speed.

[0019] In one possible implementation, calculating the current position of the motor within the current preset period based at least on the current given speed of the motor within the current preset period includes: Based on the current position, the current given speed of the motor within the current preset cycle, and the time length of the preset cycle, the current calculated position of the motor within the current preset cycle is obtained.

[0020] In one possible implementation, determining the next given speed and the next calculated position of the motor within the next preset cycle based on the relationship between the current calculated position and the target position, or controlling the motor to rotate at the current given speed at a preset time point within the current preset cycle to control the motor to rotate to the target position, includes: When the calculated position does not coincide with the target position, the next given speed and the next calculated position of the motor in the next preset cycle are determined based on the target position, the calculated position in the previous preset cycle, and the given speed.

[0021] When the calculated position coincides with the target position, the control motor rotates at the currently given speed at a preset time point within the current preset cycle, so as to control the motor to rotate to the target position.

[0022] Secondly, a motor control device is also provided, comprising an acquisition unit and a control unit. The acquisition unit is used to acquire the current position and current speed of a motor. The control unit is used to determine, at least based on a target position, the current position, and the current speed, the current given speed and the current calculated position of the motor within a current preset period, and, based on the calculated position and the target position, the next given speed and the next calculated position of the motor within a next preset period; or, to control the motor to rotate at the current given speed at a preset time point within the current preset period, thereby controlling the motor to rotate to the target position.

[0023] Thirdly, an electronic device is also provided, comprising a motor and a motor control device. The motor control device includes an acquisition unit and a control unit. The acquisition unit is used to acquire the current position and current speed of a motor. The control unit is used to determine, at least based on a target position, the current position, and the current speed, the current given speed and the current calculated position of the motor within a current preset period, and, based on the calculated position and the target position, the next given speed and the next calculated position of the motor within a next preset period, or to control the motor to rotate at the current given speed at a preset time point within the current preset period, so as to control the motor to rotate to the target position.

[0024] Fourthly, a computer-readable storage medium is also provided, which stores computer program instructions that, when executed, implement the above-described motor control method.

[0025] The motor control method, motor control device, electronic device, and storage medium of this application divide the motor control process into a recursive calculation method based on preset cycles. Within each preset cycle, the given speed and calculation position for that cycle are determined only based on the target position, current position, and current speed. Then, the relationship between the current calculation position and the target position determines whether to continue calculating for the next cycle or stop. There is no need to pre-plan the entire motion curve. When the target position or motion parameters change, the calculation for the next cycle can automatically adapt to the new parameters, achieving real-time performance and flexibility in motor control. This is particularly suitable for scenarios where the target position changes frequently. Attached Figure Description

[0026] To more clearly illustrate the technical solutions in the embodiments of this application or the background art, the accompanying drawings used in the embodiments of this application or the background art will be described below.

[0027] Figure 1 This is a flowchart of a motor control method in some embodiments of this application.

[0028] Figure 2 for Figure 1 The sub-flowchart of step S200 is shown.

[0029] Figure 3 for Figure 2 The sub-flowchart of step S220 is shown.

[0030] Figure 4 for Figure 3 The sub-flowchart of step S222 is shown.

[0031] Figure 5 for Figure 3 The sub-flowchart of step S223 is shown.

[0032] Figure 6 for Figure 2 The sub-flowchart of step S230 is shown.

[0033] Figure 7 for Figure 1 The sub-flowchart of step S300 is shown.

[0034] Figure 8 This is a schematic diagram of a motor control device in some embodiments of this application.

[0035] Figure 9 This is a schematic diagram of an electronic device in some embodiments of this application.

[0036] Explanation of reference numerals in the attached drawings: 10, motor control device; 100, acquisition unit; 200, control unit; 20, motor; 1, electronic device. Detailed Implementation

[0037] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0038] In the description of the embodiments of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.

[0039] In the description of the embodiments of this application, it should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein.

[0040] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products, or devices.

[0041] Please see Figure 1 , Figure 1 This is a flowchart of a motor control method in some embodiments of this application. For example... Figure 1 As shown, this application provides a motor control method for controlling a motor to rotate to a target position. The motor control method includes: Step S100: Obtain the current position and current speed of the motor.

[0042] Step S200: Determine the current given speed and calculated position of the motor within the current preset cycle, based at least on the target position, the current position, and the current speed.

[0043] Step S300: Based on the relationship between the current calculated position and the target position, determine the next given speed and the next calculated position of the motor in the next preset cycle, or control the motor to rotate at the current given speed at a preset time point in the current preset cycle, so as to control the motor to rotate to the target position.

[0044] Therefore, the motor control method described in this application divides the motor control process into a recursive calculation method based on preset cycles. Within each preset cycle, the given speed and calculation position for that cycle are determined only based on the target position, the current position, and the current speed. Then, the relationship between the current calculation position and the target position determines whether to continue calculating for the next cycle or stop. There is no need to pre-plan the entire motion curve. When the target position or motion parameters change, the calculation for the next cycle can automatically adapt to the new parameters, achieving real-time performance and flexibility in motor control. This method is particularly suitable for scenarios where the target position changes frequently.

[0045] In some embodiments, the current position can be obtained through a position sensor, such as an encoder, Hall sensor, resolver, or photoelectric encoder. The encoder can be mounted on the motor shaft, and the current angular position of the motor rotor can be obtained by reading the pulse count of the encoder.

[0046] Specifically, the target position is the position of the motor after completing the target stroke, and can be an integer multiple of a certain position on the outer circumference of the motor shaft.

[0047] In some embodiments, the current speed can be obtained directly by a speed sensor, or by differential calculation of the current position, or by integral calculation of a given speed within the previous preset period. For example, the current speed can be obtained by differential calculation of the encoder position signal to avoid the need for an additional speed sensor.

[0048] In some embodiments, the preset period is the control cycle of the motor control system, and its duration is determined based on the controller's computing power and the dynamic characteristics of the motor. For example, the preset period can range from tens of microseconds to milliseconds. The shorter the preset period, the higher the control accuracy, but the higher the requirements for the controller's real-time computing power.

[0049] In some embodiments, when the next given speed and the next calculated position of the motor in the next preset cycle are determined, the motor is controlled to rotate at the corresponding given speed at a preset time point in each preset cycle, so as to control the motor to rotate to the target position.

[0050] In some embodiments, the preset time point can be the start time point of a preset period.

[0051] Please refer to the following: Figure 2 , Figure 2 for Figure 1The sub-flowchart of step S200 is shown below. Figure 1 , Figure 2 As shown, step S200: Based at least on the target position, the current position, and the current speed, determine the current given speed and the current calculated position of the motor within the current preset cycle, including: Step S210: Calculate the distance between the target location and the current location based on the target location and the current location.

[0052] Step S220: Calculate the current given speed of the motor within the current preset cycle, based at least on the current speed and the interval distance.

[0053] Step S230: Calculate the current position of the motor within the current preset cycle based at least on the current given speed of the motor within the current preset cycle.

[0054] Therefore, the motor control method described in this application decomposes the calculation process within each preset cycle into three steps: interval distance calculation, given speed calculation, and position calculation. The interval distance reflects the distance and direction between the current position and the target position; the given speed calculation determines the speed command to be used in this cycle based on the interval distance; and the position calculation converts the speed command into a position increment.

[0055] Specifically, the interval distance is calculated using the following formula: Pos_err = pos_tar - Pos_cur, where Pos_err is the interval distance, pos_tar is the target position, and Pos_cur is the current position. The sign of the interval distance indicates the direction of the target position relative to the current position. The absolute value of the interval distance reflects the remaining distance between the current and target positions, while the sign indicates the direction (positive or negative) of the target position relative to the current position, providing directional information for subsequent acceleration direction determination.

[0056] Please refer to the following: Figure 3 , Figure 3 for Figure 2 The sub-flowchart of step S220 is shown below. Figure 2 , Figure 3 As shown, step S220: Calculate the current given speed of the motor within the current preset cycle based at least on the current speed and the interval distance, including: Step S221: Calculate the deceleration distance required for the motor to decelerate from the current speed to zero speed based on the current speed.

[0057] Step S222: Compare the interval distance with the deceleration distance, and determine the acceleration parameters based on the comparison results.

[0058] Step S223: Calculate the current given speed of the motor within the current preset cycle based at least on the acceleration parameters.

[0059] Therefore, the motor control method described in this application first calculates the deceleration distance based on the current speed when determining a given speed, then compares the deceleration distance with the interval distance, and determines the acceleration parameter based on the comparison result. The deceleration distance, as a critical threshold, reflects the distance required for the motor to decelerate from the current speed to a stop. By comparing it with the interval distance, it can be determined in real time whether the motor should continue accelerating, maintain a constant speed, or begin deceleration, thus forming the acceleration segment, constant speed segment, and deceleration segment in a T-shaped curve without the need for pre-planning time segments.

[0060] Specifically, the deceleration distance is calculated using the following formula: Pos_0 = V_cur² / (2×acc), where Pos_0 is the deceleration distance, V_cur is the current speed, and acc is the preset acceleration value. When the motor decelerates from the current speed V_cur to zero speed with the preset acceleration, the distance traveled is V_cur² / (2×acc). Here, the deceleration distance is a critical threshold; its magnitude is directly proportional to the square of the current speed and inversely proportional to the preset acceleration. When the interval distance equals the deceleration distance, the motor can just decelerate to zero at the target position with the preset deceleration.

[0061] In some embodiments, the preset acceleration is the maximum allowable acceleration value of the motor, which is a pre-set positive scalar parameter. The magnitude of the preset acceleration is determined based on the motor's output torque, load inertia, and the mechanical structure's tolerance. The direction of acceleration is determined by comparison results, with the positive or negative direction corresponding to acceleration or deceleration, respectively.

[0062] Please refer to the following: Figure 4 , Figure 4 for Figure 3 The sub-flowchart for step S222 is shown. The acceleration parameters include at least one of the acceleration direction and acceleration value. For example, Figure 3 , Figure 4 As shown, step S222: Compare the interval distance with the deceleration distance, and determine the acceleration parameters based on the comparison result, including: Step S224: When the interval distance is greater than the deceleration distance, determine the acceleration direction as the first direction and the acceleration value as the preset acceleration.

[0063] Step S225: When the interval distance is less than the deceleration distance, determine the acceleration direction as the second direction and the acceleration value as the preset acceleration.

[0064] Step S226: When the interval distance is equal to the deceleration distance, determine that the acceleration value is zero.

[0065] Therefore, the motor control method described in this application divides the relationship between the interval distance and the deceleration distance into three mutually exclusive cases, corresponding to positive acceleration, negative acceleration, and zero acceleration, respectively. This makes the judgment condition for the acceleration direction simple, clear, and unambiguous. When the interval distance is greater than the deceleration distance, the motor still has sufficient deceleration margin and can continue to accelerate; when the interval distance is less than the deceleration distance, it indicates that the deceleration range has been entered, and deceleration must be carried out with negative acceleration; when the interval distance is equal to the deceleration distance, the current speed remains unchanged.

[0066] Specifically, when the interval distance is greater than the deceleration distance, it indicates that the current position is still far from the target position. Even if acceleration continues, there is still enough distance for subsequent deceleration. Therefore, the acceleration direction is the first direction (i.e., towards the target position), and the motor is in the acceleration or constant speed phase. When the interval distance is less than the deceleration distance, it indicates that the current position is too close to the target position. If the current speed is maintained, the motor will overshoot the target position. Therefore, the acceleration direction is the second direction (i.e., opposite to the current direction of movement), and the motor enters the deceleration phase. When the interval distance is equal to the deceleration distance, it indicates that the motor is in a critical state. At this time, maintaining the current speed will allow the motor to decelerate to zero at the target position. The acceleration is zero, and the motor is in the constant speed phase.

[0067] Furthermore, in actual control processes, since both the interval distance and deceleration distance are continuously changing quantities, the moment when they are strictly equal is only a single instant. However, in a digital control system, when the difference between the interval distance and the deceleration distance changes by less than a preset small threshold within a preset period, the sign of the acceleration alternates, and the speed fluctuates within the range of the product of the preset acceleration and the period time, thus forming a uniform motion segment from an overall perspective.

[0068] Please refer to the following: Figure 5 , Figure 5 for Figure 3 The sub-flowchart of step S223 is shown below. Figure 3 , Figure 5 As shown, step S223: Calculate the current given speed of the motor within the current preset cycle based at least on the acceleration parameters, including: Step S227: Calculate the motor speed within the current preset cycle based on the acceleration direction and preset acceleration.

[0069] Step S228: When the calculated speed is less than the threshold speed, determine the current given speed of the motor in the current preset cycle as the calculated speed.

[0070] Step S229: When the calculated speed is greater than or equal to the threshold speed, determine the current given speed of the motor in the current preset cycle as the threshold speed.

[0071] Therefore, the motor control method described in this application, after calculating the speed for the current cycle based on the acceleration direction and preset acceleration, compares the calculated speed with a threshold speed. When the calculated speed exceeds the threshold speed, it is limited to the threshold speed. This limiting process prevents the motor speed from exceeding the maximum permissible speed, protecting the motor and mechanical structure from overspeed impacts. Furthermore, after the motor reaches its maximum speed, the speed no longer increases, automatically forming a uniform speed segment in the T-curve, resulting in a natural and smooth transition between the acceleration and deceleration segments.

[0072] Specifically, the calculation speed is obtained by the following formula: V_cal = V_cur + a × T, where V_cal is the calculation speed, V_cur is the current speed, a is the signed acceleration value (its sign is determined by the direction of acceleration, and its absolute value is the preset acceleration), and T is the time length of the preset period.

[0073] The threshold speed is the maximum speed at which the motor is allowed to operate, i.e., the preset maximum speed V_max. The threshold speed is a positive scalar value, and the absolute value of the motor speed is not allowed to exceed this value.

[0074] Furthermore, when the absolute value of the calculation speed is greater than or equal to the threshold speed, the absolute value of the given speed is restricted to the threshold speed, while maintaining the direction of the calculation speed. Specifically, if the calculation speed is positive and exceeds the threshold speed, the given speed is the speed plus the threshold speed; if the calculation speed is negative and its absolute value exceeds the threshold speed, the given speed is the speed minus the threshold speed. Through this limiting process, a uniform speed segment of the T-shaped curve is formed.

[0075] Please refer to the following: Figure 6 , Figure 6 for Figure 2 The sub-flowchart of step S230 is shown below. Figure 2 , Figure 6 As shown, step S230: Calculate the calculated position of the motor within the current preset cycle based at least on the current given speed of the motor within the current preset cycle, including: Step S231: Calculate the current position of the motor within the current preset cycle based on the current position, the current given speed of the motor within the current preset cycle, and the time length of the preset cycle.

[0076] Therefore, the motor control method described in this application calculates the position update directly based on the current position, the given speed for the current cycle, and the preset cycle length. The position increment is obtained by multiplying the given speed by the time length, and then added to the current position to obtain the calculated position. The position estimate is obtained by integrating the speed command, requiring no global curve parameters, and the computational load for each cycle is extremely small, ensuring the feasibility of real-time control.

[0077] Wherein, the current position is the position at the start of each preset cycle, and the current given speed is the speed given at the start of each preset cycle.

[0078] Specifically, the calculated position is obtained using the following formula: Pos_cal = Pos_cur + V_given × T, where Pos_cal is the calculated position, Pos_cur is the current position, V_given is the given speed within the current preset cycle, and T is the duration of the preset cycle. The calculated position is not the final target position, but rather the intermediate transition position that the motor is expected to reach after the current preset cycle ends. The calculated position is used to replace the current position as the new current state in the next preset cycle, forming a cycle-by-cycle recursive calculation.

[0079] Please refer to the following: Figure 7 , Figure 7 for Figure 1 The sub-flowchart of step S300 is shown below. Figure 1 , Figure 7 As shown, step S300: Based on the relationship between the current calculated position and the target position, determine the next given speed and the next calculated position of the motor in the next preset cycle, or control the motor to rotate at the current given speed at a preset time point in the current preset cycle, so as to control the motor to rotate to the target position, including: Step S310: When the calculated position does not coincide with the target position, determine the next given speed and the next calculated position of the motor in the next preset cycle based on the target position, the calculated position in the previous preset cycle, and the given speed.

[0080] Step S320: When the calculated position coincides with the target position, control the motor to rotate at the currently given speed at a preset time point within the current preset cycle, so as to control the motor to rotate to the target position.

[0081] Therefore, the motor control method described in this application uses whether the calculated position coincides with the target position as the criterion for terminating the iteration. When the calculated position has not yet reached the target position, the calculated position and given speed of the previous cycle are used as the new current state, and the calculation for the next cycle continues. When the calculated position coincides with the target position, the iteration stops, and the motor rotates at the corresponding given speed in each cycle until it reaches the target position. This ensures that the motor can accurately stop at the target position without overshoot.

[0082] In some embodiments, a position error threshold (such as the position value corresponding to an encoder resolution) can be set. When the absolute value of the difference between the calculated position and the target position is less than the position error threshold, it is determined that the two coincide. When it is determined that the calculated position coincides with the target position, the recursive calculation stops. The motor has rotated at the corresponding given speed in each previous preset cycle, eventually reaching the vicinity of the target position and stopping. At this time, the motor controller can output a zero-speed command or a control command to maintain the current position to ensure that the motor stops accurately at the target position. When it is determined that the calculated position does not coincide with the target position, the calculated position in the current preset cycle is used as the current position in the next preset cycle, and the given speed in the current preset cycle is used as the current speed in the next preset cycle. The calculation process is repeated until the calculated position coincides with the target position.

[0083] The motor control method of this application, through the above steps and a recursive calculation in preset cycles, can achieve real-time position control of the motor without the need for pre-planning a complete T-curve. Within each cycle, it performs interval distance calculation, deceleration distance calculation, acceleration direction determination, given speed calculation and limiting, and position update. By comparing the deceleration distance as a critical threshold with the interval distance, it determines in real time whether the motor should be in an acceleration, constant speed, or deceleration state, naturally forming the three motion stages of the T-curve. When parameters such as target position, maximum speed, or acceleration change, the next cycle can automatically adapt without replanning the entire curve, effectively improving the real-time performance and flexibility of the control. Simultaneously, speed limiting ensures smooth motion, and position overlap determination ensures positioning accuracy. With low computational load and simple implementation, it is particularly suitable for motor control scenarios where the target position changes frequently.

[0084] Please see Figure 8 , Figure 8 This is a schematic diagram of a motor control device in some embodiments of this application. For example... Figure 8 As shown, this application also provides a motor control device 10, which includes an acquisition unit 100 and a control unit 200. The acquisition unit 100 is used to acquire the current position and current speed of a motor 20. The control unit 200 is used to determine, at least based on the target position, the current position, and the current speed, the current given speed and the current calculated position of the motor 20 within the current preset period, and, based on the relationship between the current calculated position and the target position, determine the next given speed and the next calculated position of the motor 20 within the next preset period, or control the motor 20 to rotate at the current given speed at a preset time point within the current preset period, so as to control the motor 20 to rotate to the target position.

[0085] The operations performed by the motor control device 10 or the control unit 200 correspond to the steps in the motor control method of any of the foregoing embodiments. Further operations that the motor control device 10 or the control unit 200 can perform are detailed in the relevant content of the motor control method of any of the foregoing embodiments, and will not be repeated here.

[0086] The acquisition unit 100 is mainly used to execute the steps of acquiring the current position and current speed of the motor 20 in the above-described motor control method. For example, the acquisition unit 100 may include a position sensor interface and a speed calculation circuit. The position sensor interface is used to receive signals output by position sensors such as encoders and convert them into digital position values; the speed calculation circuit is used to perform differential or integral operations on the position values ​​to obtain the current speed.

[0087] The control unit 200 is mainly used to execute other specific steps of the above-mentioned motor control method. The control unit 200 can be a general-purpose processor such as a central processing unit (CPU), or a digital signal processor (DSP), application specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate logic devices, transistor logic devices, etc. It can also be a microprocessor such as a micro control unit (MCU).

[0088] In some embodiments, the motor 20 can be used to adjust the adjustable components of the impedance matching circuit, such as capacitors, inductors, etc.

[0089] The motor control method and motor control device 10 of this application, through the aforementioned steps and structure, achieve real-time position control of the motor 20 by recursively calculating in preset cycles, without the need for pre-planning a complete T-shaped curve. Within each cycle, interval distance calculation, deceleration distance calculation, acceleration direction determination, given speed calculation and limiting, and position update are performed. By comparing the deceleration distance as a critical threshold with the interval distance, it is determined in real time whether the motor 20 should be in an accelerating, constant speed, or decelerating state, naturally forming the three motion stages of the T-shaped curve. When parameters such as target position, maximum speed, or acceleration change, the next cycle can automatically adapt without replanning the entire curve, effectively improving the real-time performance and flexibility of the control. Simultaneously, speed limiting ensures smooth motion, and position overlap determination ensures positioning accuracy. The calculation is small and the implementation is simple, making it particularly suitable for motor 20 control scenarios where the target position changes frequently.

[0090] Please see Figure 9 , Figure 9 This is a schematic diagram of an electronic device in some embodiments of this application. For example... Figure 9 As shown, this application also provides an electronic device 1, which includes a motor 20 and a motor control device 10.

[0091] Please refer to it again. Figure 8 .like Figure 8 As shown, the motor control device 10 includes an acquisition unit 100 and a control unit 200. The acquisition unit 100 is used to acquire the current position and current speed of a motor 20. The control unit 200 is used to determine, at least based on the target position, the current position, and the current speed, the current given speed and the current calculated position of the motor 20 within the current preset period, and, based on the relationship between the current calculated position and the target position, determine the next given speed and the next calculated position of the motor 20 within the next preset period, or control the motor 20 to rotate at the current given speed at a preset time point within the current preset period, so as to control the motor 20 to rotate to the target position.

[0092] For a more specific description of the structure of the motor control device 10, please refer to the relevant content of the motor control device 10 in any of the foregoing embodiments, which will not be repeated here.

[0093] In some embodiments, electronic device 1 may be an impedance matching device or an radio frequency power supply device.

[0094] In some embodiments, the motor control device 10 can be connected to the motor 20 via a motor driver. The motor control device 10 outputs a given speed command, and the motor driver controls the current in the windings of the motor 20 according to the command, thereby controlling the speed and direction of the motor 20.

[0095] The motor control method, motor control device 10, and electronic device 1 of this application, through the aforementioned steps and structure, achieve real-time position control of the motor 20 by recursively calculating in preset cycles, without the need for pre-planning a complete T-shaped curve. Within each cycle, interval distance calculation, deceleration distance calculation, acceleration direction determination, given speed calculation and limiting, and position update are performed. By comparing the deceleration distance as a critical threshold with the interval distance, it is determined in real time whether the motor 20 should be in an accelerating, constant speed, or decelerating state, naturally forming the three motion stages of the T-shaped curve. When parameters such as target position, maximum speed, or acceleration change, the next cycle can automatically adapt without replanning the entire curve, effectively improving the real-time performance and flexibility of the control. Simultaneously, speed limiting ensures smooth motion, and position overlap determination ensures positioning accuracy. The calculation is small and the implementation is simple, making it particularly suitable for motor 20 control scenarios where the target position changes frequently.

[0096] This application also provides a computer-readable storage medium storing a computer program that, when run on a computer or processor, implements the motor control method of any of the foregoing embodiments.

[0097] In the various embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, and devices can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and there may be other division methods in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0098] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0099] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can be physically comprised separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or in the form of hardware plus software functional units.

[0100] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute some steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0101] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Where there is no conflict, the embodiments and features in the embodiments of this application can be combined with each other. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A motor control method for controlling a motor to rotate to a target position, characterized in that, The motor control method includes: Get the current position and speed of the motor; Based on at least the target position, the current position, and the current speed, determine the current given speed and the current calculated position of the motor within the current preset cycle; Based on the relationship between the current calculated position and the target position, determine the next given speed and the next calculated position of the motor in the next preset cycle, or control the motor to rotate at the current given speed at a preset time point in the current preset cycle, so as to control the motor to rotate to the target position.

2. The motor control method according to claim 1, characterized in that, The process of determining the current given speed and current calculated position of the motor within the current preset cycle, based at least on the target position, the current position, and the current speed, includes: Based on the target location and the current location, the distance between the target location and the current location is calculated; Based at least on the current speed and the interval distance, the current given speed of the motor within the current preset cycle can be calculated; Based at least on the current given speed of the motor within the current preset cycle, the current calculated position of the motor within the current preset cycle can be obtained.

3. The motor control method according to claim 2, characterized in that, The step of calculating the current given speed of the motor within the current preset cycle, based at least on the current speed and the interval distance, includes: Based on the current speed, calculate the deceleration distance required for the motor to decelerate from the current speed to zero speed; Compare the interval distance with the deceleration distance, and determine the acceleration parameters based on the comparison results; Based on the acceleration parameters, the current given speed of the motor within the current preset cycle can be calculated.

4. The motor control method according to claim 3, characterized in that, The acceleration parameters include at least one of the acceleration direction and acceleration value; The step of comparing the interval distance with the deceleration distance and determining the acceleration parameters based on the comparison result includes: When the interval distance is greater than the deceleration distance, the acceleration direction is determined as the first direction, and the acceleration value is the preset acceleration. When the interval distance is less than the deceleration distance, the acceleration direction is determined to be the second direction, and the acceleration value is the preset acceleration. When the interval distance is equal to the deceleration distance, the acceleration value is determined to be zero.

5. The motor control method according to claim 4, characterized in that, The step of calculating the current given speed of the motor within the current preset cycle based at least on acceleration parameters includes: Based on the direction of acceleration and the preset acceleration, the calculated speed of the motor in the current preset cycle is obtained; When the calculated speed is less than the threshold speed, the current given speed of the motor within the current preset cycle is determined as the calculated speed; When the calculated speed is greater than or equal to the threshold speed, the current given speed of the motor within the current preset cycle is determined as the threshold speed.

6. The motor control method according to claim 2, characterized in that, The step of calculating the current position of the motor within the current preset period based at least on the current given speed of the motor within the current preset period includes: Based on the current position, the current given speed of the motor within the current preset cycle, and the time length of the preset cycle, the current calculated position of the motor within the current preset cycle is obtained.

7. The motor control method according to claim 1, characterized in that, The step of determining the next given speed and next calculated position of the motor in the next preset cycle based on the relationship between the current calculated position and the target position, or controlling the motor to rotate at the current given speed at a preset time point in the current preset cycle to control the motor to rotate to the target position, includes: When the calculated position does not coincide with the target position, the next given speed and the next calculated position of the motor in the next preset cycle are determined based on the target position, the calculated position in the previous preset cycle, and the given speed. When the calculated position coincides with the target position, the control motor rotates at the currently given speed at a preset time point within the current preset cycle, so as to control the motor to rotate to the target position.

8. A motor control device, characterized in that, include: The acquisition unit is used to acquire the current position and current speed of a motor; The control unit is configured to determine, based at least on the target position, the current position, and the current speed, the current given speed and the current calculated position of the motor within the current preset period, and based on the calculated position and the target position, the next given speed and the next calculated position of the motor within the next preset period, or to control the motor to rotate at the current given speed at a preset time point within the current preset period, so as to control the motor to rotate to the target position.

9. An electronic device, characterized in that, The electronic device includes a motor and a motor control device as described in claim 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed, implement the motor control method as described in any one of claims 1-7.