Motor motion control method, motor motion controller and storage medium

By simplifying the parameter configuration and speed regulation selection of motor motion control methods, the problems of complex parameter configuration and unselectable speed regulation in the existing technology are solved, and the effect of concise parameter configuration and optional speed regulation algorithm is achieved, meeting the needs of various application scenarios.

CN119727510APending Publication Date: 2025-03-28SHENZHEN SHUMA ELECTRONICS TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411993431.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The existing motor motion control method requires the configuration of more motion parameter values, which makes it difficult for users to operate, and it is impossible to select different speed regulation rules for speed regulation, which cannot meet multiple application scenarios.

Method used

A motor motion control method is provided. By obtaining the target working mode, target speed regulation and motion parameter values, the parameter configuration is simplified, and the starting speed, acceleration parameter values, target speed, deceleration parameter values ​​and stop speed are retained. It can be used in the speed mode or displacement mode, as well as in different speed regulation rules such as trapezoidal speed regulation and S-shaped speed regulation rules.

Benefits of technology

It realizes the simplicity of parameter configuration and the optional speed regulation algorithm, which can meet a variety of application scenarios and facilitates user operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119727510A_ABST
    Figure CN119727510A_ABST
Patent Text Reader

Abstract

The invention relates to a motor motion control method, a motor motion controller and a storage medium. The method comprises the following steps: acquiring a selected target working mode; the target working mode comprises a speed mode or a displacement mode; acquiring a selected target speed regulation rule; the target speed regulation rule comprises a trapezoidal speed regulation rule and an S-shaped speed regulation rule; acquiring a motion parameter value of the motor; the motion parameter values comprise an initial speed, an acceleration parameter value, a target speed, a deceleration parameter value and a stop speed; and performing motion control on the motor based on the target speed regulation rule and the motion parameter value in the target working mode. By adopting the method, the configuration parameters are simple, the speed regulation algorithm is selectable, and various application scenes can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of motors, and in particular to a motion control method of a motor, a motion controller of a motor, and a storage medium. Background Art

[0002] The motor controls the rotation of the motor through a pulse signal, and the frequency of the pulse signal can indicate the speed of the motor. When the frequency of the pulse signal is greater than the limit starting frequency of the motor, the motor cannot start normally. In actual applications, the operating frequency of the motor is often greater than the limit starting frequency of the motor. Therefore, the frequency of the pulse signal needs to be accelerated from low speed to high speed. During the acceleration or deceleration process, if the speed change is not smooth, the load driven by the motor will be subjected to uneven force changes during the movement process, and the load will be subjected to a large impact. At the same time, the inertia of the load will also cause the motor to overshoot and lose step. Therefore, the speed, acceleration, and deceleration of the motor during acceleration and deceleration need to be controllable. At present, there are many speed control algorithms for stepper motor motion control, most of which require the configuration of more complex parameters. The current motor motion control method has the problem that there are too many parameters to be configured and cannot meet a variety of application scenarios. Summary of the invention

[0003] Based on this, it is necessary to provide a motor motion control method, a motor motion controller and a storage medium to address the above technical issues.

[0004] A motion control method for a motor, the method comprising:

[0005] Acquire a selected target operating mode; the target operating mode includes a speed mode or a displacement mode;

[0006] Obtaining a selected target speed regulation rule; the target speed regulation rule includes a trapezoidal speed regulation rule and an S-shaped speed regulation rule;

[0007] Obtaining motion parameter values ​​of the motor; the motion parameter values ​​include a starting speed, an acceleration parameter value, a target speed, a deceleration parameter value and a stop speed;

[0008] In the target working mode, the motor is motion controlled based on the target speed regulation rule and the motion parameter value.

[0009] A motion controller for a motor, the motion controller is used to implement the steps of an embodiment of a motion control method for each motor.

[0010] A computer-readable storage medium stores a computer program, which implements the steps of an embodiment of a motion control method for each motor when the computer program is executed by a processor.

[0011] The above-mentioned motor motion control method, motor motion controller and storage medium, the traditional motor motion control method needs to configure more motion parameter values, which makes user operation difficult and it is impossible to select different speed control rules for speed control; in the embodiment of the present application, by simplifying the parameters, retaining the starting speed, acceleration parameter value, target speed, deceleration parameter value and stop speed, it can be commonly used in speed mode or displacement mode, and can be commonly used in different speed control rules such as trapezoidal speed control rule and S-shaped speed control rule, so that the configuration parameters are concise and the speed control algorithm is optional, which can meet a variety of application scenarios and is convenient for user operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 A diagram showing an application environment of a motor motion control method in one embodiment;

[0013] Figure 2 is a schematic flow chart of a motion control method for a motor in one embodiment;

[0014] Figure 3 is a flow chart of a motor motion control method in another embodiment;

[0015] Figure 4 A schematic diagram of state transition in a speed mode in an embodiment;

[0016] Figure 5 A schematic diagram of state transition in a displacement mode in an embodiment;

[0017] Figure 6 A digital circuit diagram of a trapezoidal speed regulation rule in one embodiment;

[0018] Figure 7 A digital circuit diagram of an S-shaped speed regulation rule in one embodiment;

[0019] Figure 8 A digital circuit diagram of an S-shaped speed regulation rule in another embodiment;

[0020] Fig. 9 A digital circuit diagram of a trapezoidal speed regulation rule in another embodiment;

[0021] Fig.10 A digital circuit diagram of an S-shaped speed regulation rule in another embodiment;

[0022] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0023] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0025] It should be noted that all directional indications in the embodiments of the present application (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.

[0026] In addition, in this application, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0027] The terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first accumulator may be referred to as a second accumulator, and similarly, a second accumulator may be referred to as a first accumulator. Both the first accumulator and the second accumulator are accumulators, but they are not the same accumulator.

[0028] It can be understood that the “connection” in the following embodiments should be understood as “electrical connection”, “communication connection”, etc. if the connected circuits, modules, units, etc. have electrical signals or data transmission between each other.

[0029] The motor control method provided in this application can be applied to Figure 1 application environment. Figure 11 is an application environment diagram of a motor motion control method in an embodiment. It includes a motion controller 110, a motor driver 120 and a motor 130. The motor 130 can specifically be a stepping motor, etc. The speed in the signal in each embodiment of the present application can refer to the frequency of the pulse signal, in Hertz. The displacement represents the number of signals, that is, when the displacement is 1, a pulse signal needs to be sent. The motion controller 110 outputs a pulse signal (displacement) and a direction signal to the motor driver 120, and the motor driver 120 outputs a current to the motor 130.

[0030] In one embodiment, Figure 2 FIG. 1 is a flow chart of a motion control method for a motor in an embodiment, which is applied to a motion controller as an example and includes the following steps:

[0031] Step 202, obtaining a selected target operating mode; the target operating mode includes a speed mode or a displacement mode.

[0032] Specifically, in response to the operating mode selected by the user, the selected target operating mode is acquired. The target operating mode may be a speed mode or a displacement mode.

[0033] Speed ​​mode means that the motion controller starts at the starting speed v start Accelerate to target speed v targ After that, at the target speed v targ Perform uniform motion; when the target speed changes (increases or decreases), accelerate or decelerate to the new target speed. The entire process does not pay attention to the displacement change requirements, and only changes the state according to the speed requirements. The speed mode is the user's specific need to control the motor to run at a certain speed.

[0034] The displacement pattern includes the initial velocity v start Accelerate to target speed v targ The acceleration process, the speed is the target speed v targ uniform speed process (if any), by the target speed v targ To stop speed v stop The total displacement of these three processes is equal to the target displacement S targ In displacement mode, the state changes according to the displacement requirement. Displacement mode is how much displacement the motor is required to run.

[0035] Step 204, obtaining the selected target speed regulation rule; the target speed regulation rule includes a trapezoidal speed regulation rule and an S-shaped speed regulation rule.

[0036] Specifically, the target speed regulation rule may include a displacement-related speed regulation rule, a speed-related speed regulation rule, or an acceleration-related speed regulation rule, depending on the specific situation.

[0037] The trapezoidal speed regulation rule is a motor speed regulation algorithm that accelerates and decelerates at a fixed acceleration. The S-shaped speed regulation rule is a motor speed regulation algorithm that accelerates and decelerates at an unfixed acceleration. The trapezoidal speed regulation rule and the S-shaped speed regulation rule are suitable for different application scenarios. For example, in some motor processing scenarios with less demanding requirements, the trapezoidal speed regulation rule can be used; in scenarios where the motor needs to run more stably, the S-shaped speed regulation rule can be used.

[0038] Step 206, obtaining motion parameter values ​​of the motor; the motion parameter values ​​include a starting speed, an acceleration parameter value, a target speed, a deceleration parameter value and a stop speed.

[0039] Specifically, the motion parameter value can be a parameter value input by the user or a default parameter value confirmed by the user. The starting speed, acceleration parameter value, target speed, deceleration parameter value and stop speed can be applicable to different speed regulation rules of the motor, at least to trapezoidal speed regulation rule and S-shaped speed regulation rule.

[0040] Starting speed v start The initial speed at which the motion controller accelerates to the target speed. The acceleration parameter value can be the acceleration or acceleration time T incre The deceleration parameter value can be a negative acceleration or a deceleration time T decre . Stop speed v stop It is the final speed of the motion controller during deceleration, in Hertz. The stop speed can be 0 or not.

[0041] Target speed v targ It has a sign, the sign bit indicates the direction of the motor, and the absolute value indicates the target speed. When the target speed is 0, it means the motor stops, and its maximum value should be less than 1MHz (megahertz). And ensure that v targ >v start , v targ >v stop .

[0042] Step 208 : In the target working mode, the motor is motion controlled based on the target speed regulation rule and the motion parameter value.

[0043] Specifically, in the target working mode, the motion controller inputs the motion parameter value into the target speed regulation rule, and performs motion control on the motor in response to the start trigger operation of the motor.

[0044] For example, in speed mode, the motion parameter value is used to control the motion of the motor using a trapezoidal speed regulation rule or an S-shaped speed regulation rule, so that the motor can accelerate from a starting speed to a target speed and run at the target speed.

[0045] In displacement mode, the motion parameter value is used to control the motor motion with a trapezoidal speed regulation rule or an S-shaped speed regulation rule, so that the motor can accelerate from the starting speed to the target speed, and decelerate from the target speed to the stop speed to achieve the target displacement.

[0046] In this embodiment, the order of selecting the target working mode, selecting the target speed regulation rule, and obtaining the motion parameter value is not limited. For example, the motion parameter value can be selected first, then the target speed regulation rule, and then the target working mode; the target speed regulation rule can be selected first, then the motion parameter value, and then the target working mode; the target working mode can be selected first, then the motion parameter value, and then the target speed regulation rule, etc. Figure 3 As shown, it is a flow chart of the motor motion control method in another embodiment. The working mode can be selected on the motion controller, and the speed mode or the displacement mode can be selected. Then the speed regulation rule is selected, and the trapezoidal speed regulation rule or the S-shaped speed regulation rule can be selected. After the working mode and the speed regulation rule are selected, the motion parameter configuration can be performed, and the motor can be controlled in response to the start trigger operation of the motor.

[0047] In this embodiment, the traditional motor motion control method needs to configure more motion parameter values, which makes it difficult for users to operate and it is impossible to select different speed control rules for speed control. In the embodiment of the present application, by simplifying the parameters, retaining the starting speed, acceleration parameter value, target speed, deceleration parameter value and stop speed, it can be commonly used in speed mode or displacement mode, as well as in different speed control rules such as trapezoidal speed control rules and S-shaped speed control rules, so that the configuration parameters are concise and the speed control algorithm is optional, which can meet a variety of application scenarios and is convenient for user operation.

[0048] In one embodiment, the target working mode is a speed mode. The target working mode is a speed mode;

[0049] In the target working mode, the motor is controlled based on the target speed regulation rules and motion parameter values, including:

[0050] In speed mode, based on the target speed regulation rule, the system accelerates from the starting speed to the target speed according to the acceleration parameter value, and moves at a constant speed at the target speed;

[0051] When the target speed changes, in the initial state or the uniform speed state, the motor control is performed based on the target speed regulation rule with an acceleration parameter value or a deceleration parameter value in response to the changed target speed.

[0052] The initial state is a state of running at a starting speed, wherein the starting speed may be 0 or not 0.

[0053] Specifically, in the speed mode, the main change is in speed. In response to the start trigger operation of the motor, based on the target speed regulation rule, the acceleration is performed from the starting speed to the target speed according to the acceleration parameter value, and the uniform speed movement is performed at the target speed.

[0054] The motion controller responds to changes in the target speed in the initial state or uniform speed state. That is, during acceleration or deceleration, it will not immediately respond to changes in the register target speed, but will continue to run according to the original settings until it reaches the initial state or uniform speed state. In speed mode, and in the initial state or uniform speed state (i.e. a relatively stable state), in response to the change in target speed, when the changed target speed is greater than the original target speed, it will accelerate with the acceleration parameter value; when the changed target speed is less than the original target speed, it will change the speed with the deceleration parameter value to control the motor.

[0055] In this embodiment, in speed mode, based on the selected target speed regulation rule, the acceleration parameter value is used to accelerate from the starting speed to the target speed, and uniform motion is performed at the target speed; when the target speed changes, the acceleration parameter value or the deceleration parameter value is used to change the speed based on the target speed regulation rule to control the motor. The configuration parameters are simple, the motor state switching is easy, and the user operation is convenient.

[0056] In one embodiment, when the target speed changes, in the initial state or the uniform speed state, in response to the changed target speed, the motor is controlled based on the selected target speed regulation rule with an acceleration parameter value or a deceleration parameter value, including:

[0057] When the direction of the target speed changes, and in the initial state or uniform speed state, in response to the changed direction, the motor is controlled to accelerate to the target speed of the direction change at the stop speed in the original direction and then to the target speed according to the changed direction with the acceleration parameter value.

[0058] Specifically, the target speed has a direction. When the direction of the target speed changes, the motion controller can respond to the start trigger operation of the motor, such as START_TRIG, and enter the pre-stop state after the last pulse signal ends. The pre-stop state decelerates to the initial state at the stop speed according to the original direction, waits for the DIRCH_WAIT time, and then accelerates to the changed target speed according to the changed direction with the acceleration parameter value.

[0059] Optionally, in the initial state, a change in the direction of the target speed is detected, and the vehicle is accelerated to the target speed with an acceleration parameter value according to the changed direction.

[0060] In this embodiment, the response speed changes when the motor is in a steady state, so as to avoid the motor losing step due to the rapid change of torque during the motor speed change.

[0061] In one embodiment, Figure 4 The figure is a schematic diagram of state transition in speed mode in one embodiment. targ represents the target speed, v now Indicates the current speed, Di r changed indicates a change in direction, v stop Indicates the stopping speed. In the initial state of the motor, that is, the idle state, the target speed v targ Greater than the current speed v now When the acceleration parameter value is used, the current speed is accelerated until it is greater than or equal to the target speed v targ , with target speed v targ In the uniform state, the target speed v targ Make changes when the target speed v targ Greater than the current speed v now When the target speed v targ Less than the current speed v now When the speed is less than or equal to the target speed v, the vehicle will decelerate according to the deceleration parameter value until the current speed is less than or equal to the target speed v targ In the uniform speed state, it can also respond to changes in direction. When the direction changes, it enters the pre-stop state and moves at a speed less than or equal to the stop speed v stop The current speed v now Waiting, then entering the initial state, and then accelerating. It can be understood that the trapezoidal speed regulation rule and the S-shaped speed regulation rule can be applied to the speed / displacement control in the acceleration and deceleration stages.

[0062] In one embodiment, the target working mode is a displacement mode; the motion parameter value includes a total displacement;

[0063] In the target working mode, the motor is controlled based on the target speed regulation rules and motion parameter values, including:

[0064] In displacement mode, the motor is controlled to move from the starting speed to the target speed based on the target speed regulation rule and the acceleration parameter value, and the motor is controlled to move from the target speed to the stop speed based on the target speed regulation rule and the deceleration parameter value, and the displacement during the movement is equal to the total displacement.

[0065] Specifically, in the displacement mode, the total displacement is at least sufficient to achieve the acceleration process and the deceleration process. The target speed regulation rule is mainly used in the acceleration stage and the deceleration stage. Therefore, in the displacement mode, based on the acceleration parameter value and the target speed regulation rule, the movement from the starting speed to the target speed, based on the deceleration parameter value and the target speed regulation rule, the movement from the target speed to the stop speed, the displacement during the movement process is equal to the total displacement.

[0066] Optionally, in the displacement mode, based on the acceleration parameter value and the target speed control rule, the movement is from the starting speed to the target speed, and the movement is controlled at the target speed, and based on the deceleration parameter value and the target speed control rule, the movement is from the target speed to the stop speed, and the displacement of the three processes is equal to the total displacement.

[0067] In this embodiment, in the displacement mode, the movement is from the starting speed to the target speed based on the acceleration parameter value and the target speed control rule, and the movement is from the target speed to the stop speed based on the deceleration parameter value and the target speed control rule, and the displacement during the movement is equal to the total displacement. The motor control can be performed by the same speed control parameters in different modes, which meets a variety of usage scenarios and simplifies user operations.

[0068] In one embodiment, the motor motion control method further includes: when the current speed of the motor is less than the stop speed, stopping deceleration, and running at a constant speed based on the stop speed until the total displacement is met.

[0069] Specifically, in the motor deceleration state, due to the errors in both the S-shaped speed regulation rule and the trapezoidal speed regulation rule, the acceleration changes faster than the ideal acceleration, resulting in the reverse increase of the speed after the speed decreases to the stop speed during the deceleration time, and the speed after the deceleration time is over will be too high. Therefore, a correction state is added. When it is detected that the current speed is less than the stop speed, the deceleration stops and the motor runs at a constant speed according to the stop speed until the total displacement is met.

[0070] In this embodiment, by detecting that the current speed is less than the stop speed, the deceleration is stopped, and the motor is operated at a constant speed based on the stop speed until the total displacement is satisfied, that is, the speed is corrected, which can accelerate the stabilization of the motor.

[0071] In one embodiment, in the target working mode, the motor is controlled based on the target speed regulation rule and the motion parameter value, including:

[0072] In the displacement mode, the displacement of the acceleration phase is determined based on the target speed regulation rule, the starting speed, the target speed and the acceleration parameter value;

[0073] Determine the deceleration phase displacement based on the target speed regulation rule, the target speed, the deceleration parameter value and the stopping speed;

[0074] When the sum of the acceleration phase displacement and the deceleration phase displacement is less than the total displacement, a motor displacement error alarm is issued.

[0075] Specifically, in the displacement mode, the motion controller substitutes the starting speed, target speed and acceleration parameter value into the target speed regulation rule to determine the displacement of the acceleration stage; substitutes the target speed, deceleration parameter value and stop speed into the target speed regulation rule to determine the displacement of the deceleration stage.

[0076] Acceleration stage displacement step incre :

[0077]

[0078] Deceleration stage displacement step dec :

[0079]

[0080] Then the uniform speed stage displacement step con :

[0081] step con =S targ -step incre -step dec

[0082] According to the above formula, the displacement of the acceleration stage and the displacement of the deceleration stage can be quickly calculated. When the sum of the displacement of the acceleration stage and the displacement of the deceleration stage is less than the total displacement, it means that the target speed cannot be reached or the acceleration time / deceleration time is too long, so the motion controller sends a motor displacement error alarm signal. In addition, information such as "the target speed setting is too large" and "the acceleration and deceleration time is too long" can be displayed on the motor. When the sum of the displacement of the acceleration stage and the displacement of the deceleration stage is greater than or equal to the total displacement, the motor motion control is performed in response to the start trigger signal of the motor.

[0083] In this embodiment, in the displacement mode, the acceleration stage displacement is determined based on the starting speed, target speed, acceleration parameter value and target speed regulation rules; the deceleration stage displacement is determined based on the target speed, deceleration parameter value, stop speed and target speed regulation rules. When the sum of the acceleration stage displacement and the deceleration stage displacement is less than the total displacement, a motor displacement error alarm is issued to enable the motor to operate normally.

[0084] In one embodiment, Figure 5 FIG. 1 is a schematic diagram of state transition in a displacement mode in an embodiment. Figure 5It includes the target displacement Starg, the current displacement Snow, the acceleration stage displacement step_incre, the deceleration stage displacement step_dec, the uniform stage displacement step_con, the current speed Vnow and the stop speed v_stop. In the displacement mode, the direction is determined only by the target displacement Starg. In the initial state, it responds to the changes in the size, direction, speed and other parameters of the target displacement. In the initial state, that is, the idle state, and when Snow is not equal to Starg, it accelerates according to the acceleration parameter value; when Starg is greater than or equal to the sum of step_incre and step_dec, and the current displacement reaches the acceleration stage displacement, it enters the uniform speed state. Move con_step in the uniform speed state and enter the deceleration state. When Snow = step_dec, it means that the target displacement is completed, and the motor enters the waiting state, and enters the initial state after waiting for a period of time. If the target displacement Starg is still the original size and direction at this time, the next movement will not be performed unless the register START_TRIG is triggered (triggering the motion controller to work or the parameters to take effect); if the direction is reversed and the size remains unchanged, it moves in the opposite direction according to the displacement (after START_TRIG is triggered).

[0085] In the deceleration state, because there is an error in the S-curve calculation (trapezoidal curve calculation), the acceleration changes faster than the ideal acceleration, resulting in the speed decreasing to the stop speed and then increasing in the opposite direction during the deceleration time, and the speed after the deceleration time is over will be too high. Therefore, a correction state is added. When it is detected that the current speed is less than the stop speed, a correction is made, that is, the deceleration is stopped and the vehicle runs at a constant speed at the stop speed until the displacement requirement Snow = Starg is met. It can be understood that the trapezoidal speed regulation rule and the S-shaped speed regulation rule can be applied to speed / displacement control in the acceleration and deceleration stages.

[0086] In this embodiment, the motor control requirements can be met by switching the state in the displacement mode with fewer parameters.

[0087] In one embodiment, the conventional speed control algorithm generally calculates the frequency of the pulse signal according to the speed formula, and the implementation method is usually to select a fixed time interval t, calculate the speed formula once every t time, and obtain the frequency f of the pulse signal at that moment. And within the time interval t, the frequency of the pulse signal is f. The accuracy of this implementation method is greatly affected by the time interval t. When the time interval t is too large, the speed may change suddenly.

[0088] Therefore, a motion control method in this embodiment is proposed. In the target working mode, the motor is controlled based on the target speed regulation rule and the motion parameter value, including:

[0089] In the target working mode, the current displacement of the motor is determined based on the target speed regulation rule and the motion parameter value at every preset time interval;

[0090] When the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent to control the motion of the motor.

[0091] The preset duration is used to indicate how often the displacement of the motor is calculated. Preferably, the displacement within the preset duration is less than one unit of displacement. Increasing the displacement by one unit means increasing by a fixed value, for example, the displacement value may be increased by one, or the displacement value may be increased by another value.

[0092] Specifically, taking the preset duration of 1 μs (microseconds) as an example, after unifying the units and converting the unit of displacement s(t) into "units", 10^6 of the duration t is moved to the left side of the equation, and one unit is 10 to the sixth power. The number of pulse signals is used to represent the displacement of the motor.

[0093] Therefore, starting from t=0, time t begins to accumulate in increments of 1μs. Every time 1us is added, a displacement calculation is performed according to the motion parameter value and the target speed control rule. When 10^6*s(t)>=10^6, it indicates that the first pulse signal such as the STEP signal can be generated, and the value of 10^6*s(t0) at the current moment is recorded. The above process is guaranteed to be completed within 1μs. Time t continues to accumulate, and the value of 10^6*s(t) continues to be calculated. When 10^6*s(t)-10^6*s(t0)>=10^6 or 10^6*s(t)=2*10^6, a second pulse signal is generated, and the value of 10^6*s(t1) at the current moment is recorded. Calculations continue in this way to generate pulse signals with speed changes (i.e., frequency changes).

[0094] In this embodiment, under the target working mode, the current displacement of the motor is determined based on the motion parameter value and the target speed control rule at preset time intervals. When the current displacement increases by one unit compared to the previous displacement, a pulse signal needs to be generated. That is, a pulse signal is generated to control the motor every time the displacement meets the requirement. Compared with the traditional method, the accuracy is not affected by the time interval, the motor speed change transition is good, and the motor control is more stable.

[0095] In one embodiment, the target working mode is a displacement mode; when the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent to control the motion of the motor, including:

[0096] When the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent to control the motor's motion until the total displacement of the motor reaches the target displacement, and then the pulse signal is stopped.

[0097] In this embodiment, in the displacement mode, the target displacement is the key to determining whether the motor stops; therefore, in the displacement mode, when the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent until the total displacement of the motor reaches the target displacement, and the pulse signal is stopped. This can effectively combine the specific working mode to send signals, so that the motor can run stably.

[0098] In one embodiment, the traditional method calculates the frequency of the pulse signal based on the displacement formula. This method requires an inverse operation on the displacement formula, solves the corresponding time according to the displacement, and then substitutes the solved time into the speed formula to finally find the frequency of the pulse signal. The displacement formula is generally a quadratic function, a quartic function, or a higher-order function of time t. When this implementation method is implemented in software, a function can be used to perform an inverse operation, but in the digital circuit implementation process, the digital circuit cannot perform an inverse operation on the displacement formula. By using the method in the present application, the target speed regulation rule can be implemented by a digital circuit.

[0099] Among them, the target speed regulation rules include trapezoidal speed regulation rules and S-shaped speed regulation rules. In the trapezoidal speed regulation rule, speed and time are proportional, and the proportional coefficient is acceleration. In the trapezoidal acceleration and deceleration, after the starting speed, target speed and acceleration and deceleration parameters (taking the acceleration and deceleration time as an example) are determined, the acceleration is a fixed value.

[0100]

[0101] v(t)=kt+v0

[0102]

[0103] Where a is the acceleration, k is the slope, v1 is the target speed, v0 is the starting speed, T is the acceleration or deceleration time, v(t) is the current speed, and s(t) is the current displacement.

[0104] Taking the preset duration of 1μs as an example, after converting the displacement unit into "pieces", the formula is:

[0105]

[0106] To improve the calculation accuracy, move 10^6 to the left side of the equation

[0107]

[0108] Then every time the value on the right side of the equation increases by 10 6 (a unit), then a pulse signal is sent. The above formula can be implemented by a digital circuit to adapt to the motor. For example, the multiplication term in the above formula is implemented by a multiplier, and the addition term is implemented by an adder.

[0109] The speed change of the S-shaped speed regulation rule is an S-shaped change, and its function can be a cubic function of time t; the acceleration changes in a parabola, and its function is a quadratic function of time t, and the displacement change is a quartic function of time t. The expression of the S-shaped speed regulation rule can be:

[0110]

[0111] Among them, a(t) is acceleration, v1 is target speed, v0 is starting speed, T is single acceleration or deceleration time, v(t) is current speed, s(t) is current displacement. And when the starting speed, target speed, acceleration and deceleration parameters are determined, the characteristics of the motion process are also determined.

[0112] In the implementation of the S-shaped speed regulation algorithm, t is the time change, and 1μs is also used as the time change accuracy. After unifying the units and converting the units of displacement to "pieces", the above displacement formula becomes

[0113]

[0114] To improve the calculation accuracy, move 10^6 to the left side of the equation:

[0115]

[0116] Similarly, the above formula can be implemented by digital circuits to adapt to the motor. For example, the multiplication term in the above formula is implemented by a multiplier, and the addition term is implemented by an adder.

[0117] In this embodiment, the method of determining the current displacement of the motor based on the target speed regulation rule at preset time intervals can be implemented through a digital circuit, so that the motion controller is adapted to the motor.

[0118] In one embodiment, the division term in the target speed regulation rule is represented by a multiplication term capable of performing a shift process.

[0119] The multiplication items that can be shifted refer to the calculation items that can be simply calculated in binary form, such as approximating 0.3 to 0.25, because 0.25 is 2 to the power of -2, which allows the digital circuit to quickly calculate it.

[0120] Specifically, the expression of the trapezoidal speed regulation algorithm is:

[0121]

[0122] After converting division into multiplication and shift processing:

[0123]

[0124] Understandably, After the shift processing, we get

[0125] In addition, the expression of the S-shaped speed regulation algorithm is

[0126]

[0127] To improve computational efficiency, approximate processing is performed and the division is converted into multiplication and shift processing:

[0128]

[0129] In this embodiment, the divider in the digital circuit is difficult to implement and consumes a lot of resources. By representing the division term as a multiplication term that can be shifted, the calculation efficiency can be improved, thereby improving the motor response speed and control effect.

[0130] In one embodiment, the current displacement in the target speed regulation rule is obtained by accumulating and integrating a first-order parameter related to the speed.

[0131] Specifically, when the target speed regulation rule is a trapezoidal speed regulation rule, the first-order parameter related to the speed may be the speed. Since the acceleration in the trapezoidal speed regulation rule is a constant value and the speed is a first-order function, the displacement can be obtained by accumulating and integrating the speed.

[0132] v(t)=kt+v0

[0133] s(t)=v1+v2+v3+…+v t

[0134] Among them, v1 represents the speed obtained by the first interval, v t Represents the speed obtained at the tth interval duration.

[0135] In one embodiment, when the target speed regulation rule is an S-type speed regulation rule, since the acceleration has begun to change, the displacement is obtained by performing cumulative integration processing on at least the acceleration, as follows:

[0136]

[0137] So

[0138] v(t)=a1+a2+a3+…+a t

[0139] s(t)=v1+v2+v3+…+v t

[0140] Therefore, each term in the displacement is a multiplication, and is the product of the change t and the constant. In digital circuits, the product of the constant and the change can be realized by a shift register instead of a multiplier, which can ensure that the resource usage is minimized under the premise of a certain calculation accuracy.

[0141] In one embodiment, the addition term in the target speed regulation rule is implemented by an adder, and the multiplication term is implemented by a shift register.

[0142] Specifically, the adder can be an accumulator for accumulating values. A single multiplication of time and constant terms is not a true multiplication in a digital circuit, but is implemented through addition and shifting. For example, x*6 is decomposed into x*4+x*2, which is a shift. Since the power is uncertain, it cannot be calculated through shifting and accumulation. If a real multiplier is used, a large amount of resources will be occupied, resulting in a slow response speed.

[0143] Then, since the current displacement in the target speed control rule is obtained by cumulative integration of a first-order parameter related to the speed, and cumulative integration is a method of calculating the integral value by accumulation, the addition term in the target speed control rule can be implemented by an adder, and the multiplication term can be implemented by a shift register, thereby minimizing the resource usage of the motion controller.

[0144] In one embodiment, the target speed regulation rule includes a trapezoidal speed regulation rule; the target speed regulation rule is implemented by a shift register for determining the speed and an accumulator for accumulating the speed, and the output end of the shift register is connected to the input end of the accumulator.

[0145] Specifically, in the trapezoidal speed regulation rule, the speed is a first-order parameter related to the speed, and the first-order speed can be realized by a shift register. The multiplication of a variable and a constant can be realized by a shift register. When the starting speed is 0, the speed is determined only by the shift register; when the starting speed is not 0, the speed can be determined by combining the shift register and the adder. It can be understood that the output end of the shift register used to determine the speed outputs the speed, which is used to input the accumulator for speed accumulation, and the output of the accumulator is the displacement. The formula is as follows:

[0146] Shift register and adder: v(t)=at+v0

[0147] Accumulator: s(t) = v t +s t-1

[0148] like Figure 6As shown in FIG. 1 , a digital circuit diagram of a trapezoidal speed regulation rule in an embodiment is shown. The “×” in the figure represents a shift register, and the “+” represents an adder. It can be understood that the accumulator is a special adder. Figure 6 It includes a shift register 602, an adder 604 and an accumulator 606 for determining the speed, and the three are connected in sequence. Taking the calculation of displacement every 1 microsecond as an example, the first time t is 1μs, the trigger calculation obtains v1=a*1+v0, and the displacement s1=v1; the second time t is 2μs, the trigger calculation obtains v2=a*2+v0, and the displacement s2=s1+v2... and so on to obtain the current displacement of the motor. And when the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent. And when some parameters in the target speed regulation rule change, it can also respond based on the digital circuit.

[0149] It can be understood that in displacement mode, when s(t) reaches the target displacement, the motor stops rotating. In speed mode, speed-related parameters change, which can also be controlled by the digital circuit.

[0150] In this embodiment, the target speed regulation rule is implemented by a shift register for determining the speed and an accumulator for accumulating the speed, which can be adapted to the motor, and since no multiplier is required, the resources consumed in calculation are greatly reduced.

[0151] In one embodiment, the target speed regulation rule includes an S-shaped speed regulation rule. The target speed regulation rule is implemented by a shift register for determining a first-order parameter related to speed, a first accumulator for accumulating acceleration, and a second accumulator for accumulating speed, wherein the shift register, the first accumulator, and the second accumulator are connected in sequence.

[0152] Specifically, in the S-shaped speed regulation rule, the acceleration is variable, and may be a linear change related to time t, or a quadratic or cubic change related to time t, etc. Therefore, the shift register is used to determine the linear parameters related to the speed, and the subsequent calculations involving quadratic and cubic calculations are implemented through the accumulator.

[0153] Optionally, when the acceleration calculation method is a first power, the first power parameter related to the speed is the acceleration, which can be realized by a shift register. Taking a(t)=2t as an example, Figure 7 FIG. 1 is a schematic diagram of a digital circuit for an S-shaped speed regulation rule in one embodiment. Figure 7The shift register 702 for determining acceleration, the first accumulator 704 for accumulating acceleration, and the second accumulator 706 for accumulating velocity are connected in sequence. It can be understood that the output of the shift register 702 for determining acceleration is acceleration a(t), the output of the first accumulator for accumulating acceleration is velocity v(t), and the output of the second accumulator for accumulating velocity is current displacement s(t). Then the representation on the accumulator is

[0154] a(t)=2*t

[0155] v(t)=a t +v t-1

[0156] s(t)=v t +s t-1

[0157] Optionally, when the acceleration calculation method is quadratic, the first-order parameter related to the velocity is the jerk, which can be realized by a shift register. For example, the calculation method is as follows:

[0158]

[0159] The only velocity-related parameter that contains a first-order term is the acceleration a ′ (t). The cumulative expression is as follows:

[0160] a t =a ′ 1+a ′ 2+a ′ 3+…+a ′ t

[0161] v t =a1+a2+a3+…+a t +v0

[0162] s t =v1+v2+v3+…+v t

[0163] Specifically, it is represented on the accumulator as

[0164] a(t)=a ′ t +a t-1

[0165] v(t)=a t +v t-1

[0166] s(t)=v t +s t-1

[0167] It is understandable that the initial speed may be 0 or not. Taking the above calculation formula as an example, Figure 8 FIG. 2 is a schematic diagram of a digital circuit for an S-shaped speed regulation rule in another embodiment. Figure 8 The coefficient in is Figure 8 The shift register 802 and 806 for determining the jerk, and the adder 804, the third accumulator 808 for jerk accumulation, the first accumulator 810 for acceleration accumulation, and the second accumulator 812 for velocity accumulation are included, and the shift register 802, the adder 804, the shift register 806, the third accumulator 808, the first accumulator 810, and the second accumulator 812 are connected in sequence. It can be understood that, Figure 8 The output of the shift register 806 is the acceleration a ′ (t), the output of the third accumulator 808 for jerk accumulation is acceleration a(t), the output of the first accumulator for acceleration accumulation is velocity v(t), and the output of the second accumulator for velocity accumulation is current displacement s(t).

[0168] In this embodiment, in the S-shaped speed regulation rule, acceleration is a time-related change. Therefore, the acceleration can be calculated first through a shift register, and then the current displacement is determined by a first accumulator for acceleration accumulation and a second accumulator for velocity accumulation. In this way, when the speed regulation rule is implemented by a digital circuit, high-order calculations are converted into first-order accumulation calculations, thereby ensuring that resource usage is minimized under the premise of a certain calculation accuracy.

[0169] In one embodiment, the target speed regulation rule is a trapezoidal speed regulation rule, and is implemented by a digital circuit as an example. In a trapezoidal slope, the speed is proportional to the time. In the trapezoidal acceleration and deceleration, after the starting speed v0 (hz), the target speed v1 (hz) and the acceleration and deceleration time T (ms) are determined, the acceleration is a constant value.

[0170]

[0171] v(t)=kt+v0

[0172]

[0173] Where a is the acceleration, k is the slope, v1 is the target speed, v0 is the starting speed, T is the acceleration or deceleration time, v(t) is the current speed, and s(t) is the current displacement.

[0174] Taking the preset duration of 1 μs as an example, the unit of t is μs, and the unit of displacement is converted into "pieces", the formula is

[0175]

[0176] To improve the calculation accuracy, move 10^6 to the left side of the equation

[0177]

[0178] After converting division into multiplication and shift processing:

[0179]

[0180] Then every time the value on the right side of the equation increases by 10 6 , a pulse signal is sent. In order to reduce resource consumption, the displacement formula calculation is also implemented by cumulative integration, starting with the velocity formula.

[0181] Let D1p0=t, D2p0=v0, and calculate the two items separately. Then the integral term of t is D1p1=D1p1+D1p0, which is equal to the integral term of t last time plus the value of t this time. The integral term of v0 is D2p1=D2p1+D2p0, which is equal to the integral term of v0 last time plus the value of v0 this time.

[0182] The cumulative calculation formula is:

[0183]

[0184] like Fig. 9 FIG. 1 is a schematic diagram of a digital circuit of a trapezoidal speed regulation rule in another embodiment. Fig. 9 represents the above formula. vk1 is the sk1 is the Then t is accumulated, multiplied by sk1 to get the intermediate value s_1, and then multiplied by a for unit conversion to get the intermediate value sa; in another item, the starting speed v0 is accumulated in the D2p1 item, and then added to the intermediate value Sa to get the current displacement s(t). t and k are calculated through the shift register to get v_1, and then multiplied by a for unit conversion to get va=kt, and the sum of it and the starting speed v0 is the current speed v(t) of the motor.

[0185] In this embodiment, by converting the division of the trapezoidal speed regulation rule into multiplication and shift, and realizing the calculation of the motor speed and displacement through a shift register and an adder, resource occupation can be greatly reduced and the motor response speed can be improved.

[0186] In one embodiment, the target speed regulation rule is an S-shaped speed regulation rule, the acceleration is a quadratic function of time t, and is implemented by a digital circuit as an example. Then, the speed changes in an S-shaped manner, and its function is a cubic function of time t, the acceleration changes in a parabolic manner, and its function is a quadratic function of time t, and the displacement changes in a quartic function of time t.

[0187]

[0188] Among them, a(t) is acceleration, v1 is target speed, v0 is starting speed, T is single acceleration or deceleration time, v(t) is current speed, s(t) is current displacement. And when the starting speed, target speed, acceleration and deceleration parameters are determined, the characteristics of the motion process are also determined.

[0189] In the implementation of the S-shaped speed regulation algorithm, t is the time change, and 1μs is also used as the time change accuracy. After unifying the units and converting the units of displacement to "pieces", the above displacement formula becomes

[0190]

[0191] To improve the calculation accuracy, move 10^6 to the left side of the equation:

[0192]

[0193] To improve computational efficiency, approximate processing is performed and the division is converted into multiplication and shift processing:

[0194]

[0195] The displacement formula includes the fourth power of time. The longer the time, the more registers are required for multiplication, which consumes resources. Therefore, in the algorithm implementation, the displacement formula is solved by accumulating integrals. Starting from the derivative jerk of acceleration, accumulation is performed every 1μs.

[0196] The function of acceleration (deceleration) is as follows:

[0197]

[0198] The formula is as follows

[0199] Acceleration a`(t) D1p0=2*t D2p0=T D3p0=0 Acceleration a(t) D1p1=D1p1+D1p0 D2p1=D2p1+D2p0 D3p1=0 Speed ​​v(t) D1p2=D1p2+D1p1 D2p2=D2p2+D2p1 <![CDATA[D3p2=v0 <!-- 13 -->]]> Displacement s(t) D1p3=D1p3+D1p2 D2p3=D2p3+D2p2 D3p3=D3p3+D3p2

[0200] The calculation of the jerk is divided into two items, D1p0 and D2p0, where D1p0=2*t, D1p0=2*t. Since the starting velocity does not need to be added at this time, D3p0=0.

[0201] Then the acceleration is calculated by accumulating the jerk, that is, the previous acceleration value (accumulated jerk value) plus the current jerk value, which is also divided into two items for accumulation calculation: D1p1=D1p1+D1p0; D2p1=D2p1+D2p0.

[0202] The calculation of velocity is realized by accumulating acceleration, that is, the last velocity value (accumulated acceleration value) plus the current acceleration value, where the accumulation of two items is calculated: D1 p2 = D1 p2 + D1 p1; D2p2 = D2p2 + D2p1. Since the initial velocity may not be 0, there is a third item D3p2 = v0 added to the calculation.

[0203] The displacement is calculated by accumulating the velocity, that is, the last displacement value (accumulated velocity value) plus the current velocity value. Due to the existence of the initial velocity, it is divided into three items for cumulative calculation: D1p3=D1p3+D1p2; D2p3=D2p3+D2p2; D3p3=D3p3+D3p2.

[0204] Then, by adding up the above formula, we can get

[0205]

[0206] like Fig.10 FIG. 2 is a schematic diagram of a digital circuit for an S-shaped speed regulation rule in another embodiment. Fig.10 K is a fixed value ak1 is the vk1 is the value in v(t) vk2 is the value in v(t) sk1 is the sk2 is the number of The outputs in the figure include acceleration a(t), velocity v(t) and displacement s(t). For the first term D1 p0 = 2*t, the acceleration without coefficient is output after being accumulated with D1 p1, and then multiplied with ak1 to obtain the intermediate value a_1. For the second term T, the intermediate value a_de l is obtained by subtracting the value obtained by accumulating D2p0 from the intermediate value a_1, and then multiplying it by the unit conversion coefficient K to obtain the current acceleration a(t) of the motor.

[0207] D1p2 is added to D1 p1 and multiplied by vk1 to obtain part of the speed expression v_1; D2p1 is added to D2p2 and multiplied by vk2 to obtain part of the speed expression v_2, v_1 ​​plus v_2 obtains the intermediate value v_de l, the intermediate value v_de l is multiplied by K to obtain the intermediate value vK, and the sum of the intermediate value vK and the starting speed v0 obtains the current speed v(t).

[0208] Furthermore, D1p2 and D1p3 are accumulated and multiplied by sk1 to obtain a part of the displacement expression s_1; D2p2 and D2p3 are accumulated and multiplied by sk2 to obtain a part of the displacement expression s_2. After s_1 plus s_2, the intermediate value s_de l is obtained, which is then multiplied by K to obtain the intermediate value sK, and the sum of the accumulated value of D3p3 is obtained to obtain the current displacement s(t).

[0209] In this embodiment, by converting the division of the S-shaped speed regulation rule into multiplication and shifting, and realizing the calculation of the motor speed and displacement through a shift register and an adder, resource occupation can be greatly reduced and the motor response speed can be improved.

[0210] In one embodiment, the motor motion control method further includes: obtaining an update parameter value;

[0211] In response to a trigger operation on the register, when the value of the register is a first value, storing an updated parameter value until the motor reaches a target speed or an initial state, and then performing motion control on the motor based on the updated parameter value;

[0212] When the value of the register is the second value, updating the parameter value is ignored.

[0213] The updated parameter value refers to the value of the updated parameter, which may be a starting speed, an acceleration parameter, a target speed, a deceleration parameter, a stop speed, etc.

[0214] Specifically, in speed mode, during acceleration or deceleration, the register is updated and the register START_TRIG is triggered. If the register buff_en=1 (the value of the register is the first value) at this time, the parameter change will not be responded to immediately in this scenario, and the motor motion control will be automatically responded to based on the updated parameter value after reaching the target speed or initial state. If the register buff_en=0 (the value of the register is the second value) at this time, the parameter change (updated parameter value) and START_TRIG trigger during this acceleration or deceleration process are ignored, and only the trigger after reaching the target speed or initial state next time is responded.

[0215] In displacement mode, if the register is updated during the movement and the register START_TRIG is triggered, if the register buff_en=1 (the value of the register is the first value) at this time, the parameter change will not be responded to immediately in this scenario, and it will automatically respond to the trigger in the initial state after reaching the target displacement; if the register buff_en=0 (the value of the register is the second value) at this time, the parameter changes and START_TRIG trigger during this movement are ignored, and only the next initial state trigger is responded to.

[0216] Optionally, in displacement mode, when the target displacement is reached, upon receiving a START_TRIG signal (or a START_TRIG signal maintained during movement in buff_en=1 mode), the register Snow is automatically cleared, and then the movement is repeated again according to the target displacement.

[0217] In this embodiment, in response to the trigger operation of the register, when the value of the register is the first value, the updated parameter value is stored until the motor reaches the target speed or initial state, and the motor is motion controlled based on the updated parameter value; when the value of the register is the second value, the updated parameter value is ignored, and it is possible to configure whether the updated parameter value needs to be retained, thereby improving the flexibility of motor control.

[0218] In one embodiment, a traditional stepper motor motion controller requires too many parameters to be configured. In particular, when a segmented S-shaped speed curve algorithm is used, the user needs to configure the speed, acceleration (deceleration), jerk or acceleration / deceleration of each segment, which is a cumbersome process. In addition, the motion controller is generally started immediately after the target speed parameters or target displacement parameters are configured, which can easily lead to errors in the motion controller during application. Some motion controllers only have a single speed regulation algorithm to choose from, which cannot meet multiple application scenarios at the same time.

[0219] In the implementation process of traditional speed regulation algorithms, when the frequency of the pulse signal is calculated according to the speed formula, the implementation method is usually to select a fixed time interval t, calculate the speed formula once every t time, and obtain the frequency f of the pulse signal at that moment. Within the time interval t, the frequency of the pulse signal is f. In this implementation method, the accuracy is affected by the time interval t. When the time interval t is too large, the speed changes too quickly.

[0220] In addition, the frequency of the pulse signal can also be calculated based on the displacement formula. This method requires an inverse operation on the displacement formula. The time corresponding to the displacement is solved, and the solved time is substituted into the speed formula to finally find the frequency of the pulse signal. The displacement formula is generally a quadratic function, a quartic function, or a higher-order function of time t. When this implementation method is implemented in software, a function can be used to perform an inverse operation. However, in the process of digital circuit implementation, the digital circuit cannot perform an inverse operation on the displacement formula. Therefore, a motion control method for a motor in this implementation is proposed.

[0221] The present invention provides a stepper motor motion controller with simple configuration parameters, controllable startup mode, and selectable speed regulation algorithm. The motion controller can select trapezoidal speed curve algorithm and polynomial S-type speed curve algorithm according to different application scenarios, and the required motion parameters are consistent. During the operation of the controller, it can also alarm for acceleration errors and displacement errors, and prohibit the motion controller from working, so as to prevent the motor from rotating incorrectly and causing unnecessary losses.

[0222] Under the premise of realizing the speed regulation algorithm by digital circuit, a method for realizing a trapezoidal speed curve algorithm and a polynomial S-type speed curve algorithm is provided, and the resource occupation is minimized under the premise of ensuring a certain calculation accuracy.

[0223] 1. Configuration parameters

[0224] Taking the pulse signal as STEP signal as an example, before the motion controller works, the user needs to set the following parameters. Based on the following parameters, the digital internal will calculate the acceleration, deceleration, displacement of each process and other parameters.

[0225] (1)v targ : Target speed (frequency of STEP signal), unit: hz, signed number (complement code), the sign bit indicates the direction of the motor (only in speed mode), and the absolute value indicates the target speed. |v targ When | is 0, it means the motor stops, and its maximum value should be less than 1MHZ. And ensure v targ >v start , v targ >v stop .

[0226] (2)v start : Starting speed (frequency of STEP signal), the initial speed at which the motion controller accelerates to the target speed, in hz, with a default value of 350hz.

[0227] (3)v stop : Stop speed (frequency of STEP signal), the final speed of the motion controller during deceleration after the stop signal is triggered, in hz, with a default value of 350hz.

[0228] (4)S targ : Target displacement, a signed number (complement code), the sign bit indicates the direction (only in displacement mode), and the absolute value indicates the number of STEP signals under the corresponding subdivision number.

[0229] (5) T_incre: acceleration time, the time of a single acceleration process, in ms, with a default value of 200 ms.

[0230] (6) T_dec: Deceleration time, the time of a single deceleration process, in ms, with a default value of 200 ms.

[0231] (7) Amax_l im: Maximum acceleration limit, the maximum absolute value of acceleration allowed by the user. If the absolute value of acceleration is greater than this value, an alarm signal is generated and the motion controller is prohibited from working. The unit is hz / ms.

[0232] The above 7 parameters are the parameters required for calculation. After the calculation parameter configuration is completed, the user also needs to configure the enabling parameters.

[0233] Motion_mode: Motion control mode selection, including speed mode and displacement mode.

[0234] Ramp_mode: acceleration / deceleration ramp type, including polynomial S-shaped speed regulation rule and trapezoidal speed regulation rule.

[0235] En_motion: Motion controller is always enabled.

[0236] Buff_en: START_TRIG trigger signal buffer enable.

[0237] Stop_mode: In motion controller mode, the stop mode triggered by pin FORCE_STOP (DRV_ENn).

[0238] Force_stop: motion controller stop control signal, only hard stop.

[0239] START_TRIG: Triggers the motion controller to work or parameters to take effect. Hard stop and pin-triggered soft stop do not require this trigger signal.

[0240] 2. Working Mode

[0241] Includes velocity mode and displacement mode.

[0242] Speed ​​mode: The motion controller starts with a starting speed v start Accelerate to target speed v targ Then, at the target speed v targ Perform uniform motion; when the target speed changes (increases or decreases), accelerate or decelerate to the new target speed. The entire process does not pay attention to the change requirements of displacement, but only changes the state according to the speed requirements.

[0243] Displacement mode: starting speed v start Accelerate to target speed v targ The acceleration process, the speed is the target speed v targ uniform speed process (if any), by the target speed v targ To stop speed v stop The total displacement of these three processes is equal to the target displacement S targ In displacement mode, the state changes according to the displacement requirements.

[0244] 1. Speed ​​mode

[0245] v targ It is a signed number. The user configures it through registers. Its sign bit indicates the direction of the motor. Its absolute value indicates the target speed. During the acceleration and deceleration calculation process, only its absolute value is calculated. Vnow is the current actual speed.

[0246] In the initial state or uniform speed state (velocity_reach=1), it will respond to v targ During the change, acceleration or deceleration process, the register v will not respond immediately targ If the machine is changed, it still runs according to the original settings until it reaches the initial state or uniform speed state.

[0247] During the motor rotation, when v targ After the sign bit of G changes (i.e. the direction changes), wait until the state is uniform or initial. In the uniform state, when the direction change is detected and START_TRIG is triggered, after the last STEP signal ends, it enters the pre-stop state. This state follows the original direction and the set stop speed v stop (can be 0) decelerates to the initial waiting state, waits for the DIRCH_WAIT time, and then accelerates to the target speed according to the newly set direction; in the initial state, a steering change is detected and the steering is accelerated to the target speed according to the newly set direction.

[0248] In speed mode, the integral value of acceleration is detected to be greater than or equal to v targ To decide whether to end the acceleration process, the same applies to the deceleration process.

[0249] 2. Displacement mode

[0250] In displacement mode, the direction is determined only by S targ The target displacement S will be responded only in the initial state. targ The size, direction, speed and other parameters of the change. After completing a movement and returning to the initial state, if the target displacement S targ It still has the original size and direction, and will not move next time unless the register START_TRIG is triggered (triggering the motion controller to work or parameters to take effect); if the direction is reversed and the size remains unchanged, the reverse movement is performed according to the displacement (after START_TRIG is triggered).

[0251] In the deceleration state, because there is an error in the S-curve calculation (trapezoidal curve calculation), the acceleration changes faster than the ideal acceleration, resulting in the speed decreasing to the stop speed and then increasing in the reverse direction during the deceleration time, and the speed after the deceleration time is over will be too high. Therefore, a correction state is added. When it is detected that the current speed is less than the stop speed, the deceleration is stopped and the machine runs at a constant speed at the stop speed until the displacement requirement is met.

[0252] In displacement mode, state transfer is performed by detecting whether the displacement meets the requirements under acceleration, uniform speed and deceleration states. The following formula is the displacement size of each state.

[0253] Acceleration stage displacement step incre :

[0254]

[0255] Deceleration stage displacement step dec :

[0256]

[0257] Then the uniform speed stage displacement step con :

[0258] step con =S targ -step incre -step dec

[0259] In displacement mode, according to the set v start 、v stop , acceleration time T_incre, deceleration time T_dec and v targ The size of the acceleration and deceleration phase displacement is calculated according to the above formula. If the target displacement S is set targ If it is greater than or equal to the sum of the acceleration and deceleration displacements, it works normally. Otherwise, a displacement error alarm is issued, indicating that the parameter setting is abnormal (the speed setting is too large or the acceleration and deceleration time is too long), and the displacement mode does not work at this time.

[0260] 3. Startup Confirmation

[0261] After the motion controller is enabled, the motion control parameters (speed, displacement, time), ramp type and working mode are configured, the motion controller will start working only after writing 1 to the register START_TRIG.

[0262] In speed mode, the register is updated during acceleration or deceleration and the register START_TRIG is triggered. If the register buff_en=1 at this time, the parameter change will not be responded immediately in this scenario, and the trigger will be automatically responded after reaching the target speed or initial state; if the register buff_en=0 at this time, the parameter change and START_TRIG trigger during acceleration or deceleration are ignored, and only the trigger after reaching the target speed or initial state is responded.

[0263] In displacement mode, if the register is updated during the movement and the register START_TRIG is triggered, if the register buff_en=1 at this time, the parameter change will not be responded immediately in this scenario, and it will automatically respond to the trigger in the initial state after reaching the target displacement; if the register buff_en=0 at this time, the parameter change and START_TRIG trigger during the movement are ignored, and only the trigger of the initial state is responded.

[0264] In displacement mode, when the target displacement is reached, after receiving the START_TRIG signal (or the START_TRIG maintained during the movement in buff_en=1 mode), the register Snow is automatically cleared, and then the movement is repeated again according to the target displacement.

[0265] Hard stop and pin-triggered soft stop do not require register START_TRIG trigger.

[0266] 4. Stop method

[0267] 1. Soft stop

[0268] In velocity mode (no soft stop in displacement mode), the register v targ = 0 to stop the motion controller. When the value in the register takes effect, the motion controller decelerates to stop, that is, soft stop.

[0269] In speed mode, soft stop can also be achieved by using the pin FORCE_STOP (DRV_ENn) and configuring the register stop_mode = 1.

[0270] There is no soft stop in displacement mode.

[0271] In this mode, the motor still has a holding current after it stops.

[0272] 2. Hard stop

[0273] In speed or displacement mode, you can achieve a hard stop by configuring the register stop_mode = 0 through the pin FORCE_STOP (DRV_ENn); or by configuring the register force_stop = 0 to turn off the motion controller function to achieve a hard stop. Once the above hard stop conditions are triggered, the motion controller will stop immediately regardless of which stage it is in. In this mode, the motor still has a holding current after stopping.

[0274] 5. Fault alarm

[0275] (1) Displacement error

[0276] The target displacement STARG is smaller than the sum of the acceleration and deceleration displacements, and a displacement error alarm is issued, indicating that the parameter setting is abnormal and the displacement mode does not work at this time.

[0277] (2) Acceleration error

[0278] According to the setting v start 、v stop, T_incre, and T_dec can calculate the maximum value of acceleration a_max. Users can limit the acceleration during motion control by configuring the AMAX register. When a_max is greater than the value set in the AMAX register, an acceleration error warning is issued, indicating that the set parameters are unreasonable (the difference between the initial velocity and the final velocity is large or the acceleration and deceleration time is too small), and the acceleration exceeds the limit. At this time, both the velocity mode and the displacement mode do not work.

[0279] 6. Speed ​​Regulation Rules Implementation

[0280] The speed regulation rules include S-shaped speed regulation rules and trapezoidal speed regulation rules, which means that the speed changes in an S shape or trapezoidal shape.

[0281] 1. Polynomial S-shaped speed regulation rule

[0282] The speed change of the S-shaped speed regulation rule is an S-shaped change, and its function can be a cubic function of time t; the acceleration changes in a parabola, and its function is a quadratic function of time t, and the displacement change is a quartic function of time t. The expression of the S-shaped speed regulation rule can be:

[0283]

[0284] Among them, a(t) is acceleration, v1 is target speed, v0 is starting speed, T is single acceleration or deceleration time, v(t) is current speed, s(t) is current displacement. And when the starting speed, target speed, acceleration and deceleration parameters are determined, the characteristics of the motion process are also determined.

[0285] In the implementation of the S-shaped speed regulation algorithm, t is the time change, and 1μs is also used as the time change accuracy. After unifying the units and converting the units of displacement to "pieces", the above displacement formula becomes

[0286]

[0287] To improve the calculation accuracy, move 10^6 to the left side of the equation:

[0288]

[0289] Starting from t=0, time t starts to accumulate in increments of 1μs. Every time 1us is added, a displacement calculation is performed according to the motion parameter value and the target speed control rule. When 10^6*s(t)>=10^6, it indicates that the first STEP signal can be generated, and the value of 10^6*s(t0) at the current moment is recorded. The above process is guaranteed to be completed within 1μs. Time t continues to accumulate, and the value of 10^6*s(t) continues to be calculated. When 10^6*s(t)-10^6*s(t0)>=10^6 or 10^6*s(t)=2*10^6, a second pulse signal is generated, and the value of 10^6*s(t1) at the current moment is recorded. The calculation continues in this way to generate a pulse signal of speed change (i.e. frequency change). In displacement mode, until the total displacement reaches the target displacement, it indicates that the motion process is over.

[0290] The displacement formula contains the fourth power of time. The longer the time, the more registers are required for multiplication, which consumes resources. Therefore, in the algorithm implementation, the displacement formula is solved by accumulating integrals. Starting from the derivative of acceleration, the jerk, the accumulation is performed every 1us.

[0291] The function of acceleration (deceleration) is as follows

[0292]

[0293] Fig.10 This is a digital circuit diagram for solving the acceleration, velocity and displacement changes by using the S-shaped speed regulation rule. By accumulating the above formula, we can finally get

[0294]

[0295]

[0296] 2. Implementation of trapezoidal speed regulation rules

[0297] In a trapezoidal ramp, the speed is proportional to the time. In trapezoidal acceleration and deceleration, after the starting speed v0 (hz), target speed v1 (hz) and acceleration and deceleration time T (ms) are determined, the acceleration is a constant.

[0298]

[0299] v(t)=kt+v0

[0300]

[0301] Where a is the acceleration, k is the slope, v1 is the target speed, v0 is the starting speed, T is the acceleration or deceleration time, v(t) is the current speed, and s(t) is the current displacement.

[0302] Taking the preset duration of 1 μs as an example, the unit of t is μs, and the unit of displacement is converted into "pieces", the formula is

[0303]

[0304] To improve the calculation accuracy, move 10^6 to the left side of the equation

[0305]

[0306] After converting division into multiplication and shift processing:

[0307]

[0308] The method of determining whether to send a pulse signal is the same as the above S-shaped method. In order to reduce resource consumption, the displacement formula calculation is also implemented by cumulative integration, starting with the velocity formula.

[0309] Fig. 9 It is a digital circuit schematic diagram for solving the changes of acceleration, speed and displacement through trapezoidal speed regulation rules. Fig. 9 The expression in is as follows:

[0310]

[0311] The specific steps include:

[0312] Step (a1), obtaining a selected target operating mode; the target operating mode includes a speed mode or a displacement mode.

[0313] Step (a2), obtaining a selected target speed regulation rule; the target speed regulation rule includes a trapezoidal speed regulation rule and an S-shaped speed regulation rule.

[0314] Step (a3), obtaining motion parameter values ​​of the motor; the motion parameter values ​​include a starting speed, an acceleration parameter value, a target speed, a deceleration parameter value and a stop speed.

[0315] Step (a4), in the speed mode, based on the selected target speed regulation rule, accelerate from the starting speed to the target speed according to the acceleration parameter value, and move at a uniform speed at the target speed.

[0316] Step (a5), when the target speed changes, in the initial state or the uniform speed state, in response to the changed target speed, the motor is controlled based on the target speed regulation rule with an acceleration parameter value or a deceleration parameter value.

[0317] Step (a6), when the direction of the target speed changes, and in the initial state or the uniform speed state, in response to the changed direction, decelerate to the initial state at the stop speed in the original direction, and then control the motor to accelerate to the target speed of the direction change according to the changed direction with the acceleration parameter value.

[0318] Step (a7), in the displacement mode, the motor is controlled to move from the starting speed to the target speed based on the target speed regulation rule and the acceleration parameter value, and the motor is controlled to move from the target speed to the stop speed based on the target speed regulation rule and the deceleration parameter value, and the displacement during the movement is equal to the total displacement.

[0319] Step (a8), when the current speed of the motor is less than the stop speed, stop deceleration and run at a constant speed based on the stop speed until the total displacement is met.

[0320] Step (a9), during the motion process in the speed mode and the displacement mode, determining the current displacement of the motor based on the target speed regulation rule and the motion parameter value.

[0321] Step (a10), when the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent to control the motion of the motor.

[0322] Step (a11), in the displacement mode, the acceleration phase displacement is determined based on the target speed regulation rule, the starting speed, the target speed and the acceleration parameter value.

[0323] Step (a12), determining the deceleration phase displacement based on the target speed regulation rule, the target speed, the deceleration parameter value and the stopping speed.

[0324] Step (a13), when the sum of the displacement in the acceleration phase and the displacement in the deceleration phase is less than the total displacement, a motor displacement error alarm is issued.

[0325] Step (a14), obtaining updated parameter values.

[0326] Step (a15), in response to a trigger operation on the register, when the value of the register is the first value, the updated parameter value is stored until the motor reaches the target speed or the initial state, and the motor is motion controlled based on the updated parameter value.

[0327] Step (a16), when the value of the register is the second value, ignore updating the parameter value.

[0328] In this embodiment, a stepper motor motion controller with simple configuration parameters, controllable startup mode, and selectable speed control algorithm is provided. The motion controller can select a trapezoidal speed curve algorithm and a polynomial S-type speed curve algorithm according to different application scenarios, and the required motion parameters are consistent. During the operation of the controller, it can also alarm for acceleration errors and displacement errors, and prohibit the motion controller from working to prevent the motor from rotating incorrectly and causing unnecessary losses; under the premise of realizing the speed control algorithm in a digital circuit, a trapezoidal speed curve algorithm and a polynomial S-type speed curve algorithm are provided, and under the premise of ensuring a certain calculation accuracy, the resource occupation is minimized.

[0329] It should be understood that although the above Figure 2 and Figure 3 In the flowchart, each step is shown in sequence according to the arrows, and each step in step (a1) to step (a16) is shown in sequence according to the numbers, but these steps are not necessarily performed in the order indicated by the arrows or numbers. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be performed in other orders. Moreover, Figure 2 and Figure 3 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0330] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WI FI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for controlling the motion of a motor is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0331] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0332] In one embodiment, a motion controller of a motor is provided, and the motion controller is used to implement the steps of the motion control method embodiment of each motor.

[0333] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned method embodiments when executing the computer program.

[0334] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method embodiments are implemented.

[0335] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.

[0336] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes in the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0337] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A motion control method for a motor, characterized in that: The method comprises: Acquire a selected target operating mode; the target operating mode includes a speed mode or a displacement mode; Obtaining a selected target speed regulation rule; the target speed regulation rule includes a trapezoidal speed regulation rule and an S-shaped speed regulation rule; Obtaining motion parameter values ​​of the motor; the motion parameter values ​​include a starting speed, an acceleration parameter value, a target speed, a deceleration parameter value and a stop speed; In the target working mode, the motor is motion controlled based on the target speed regulation rule and the motion parameter value.

2. The method according to claim 1, characterized in that The target working mode is a speed mode; The step of controlling the motion of the motor based on the target speed regulation rule and the motion parameter value in the target working mode includes: In the speed mode, based on the target speed regulation rule, the acceleration is performed from the starting speed to the target speed according to the acceleration parameter value, and the uniform speed movement is performed at the target speed; When the target speed changes, in an initial state or a constant speed state, the motor control is performed based on the target speed regulation rule with the acceleration parameter value or the deceleration parameter value in response to the changed target speed.

3. The method according to claim 2, characterized in that When the target speed changes, in an initial state or a uniform speed state, in response to the changed target speed, the motor is controlled based on the target speed regulation rule with the acceleration parameter value or the deceleration parameter value, including: When the direction of the target speed changes, and in the initial state or the uniform speed state, in response to the changed direction, after decelerating to the initial state at the stop speed in the original direction, the motor is controlled to accelerate to the target speed of the direction change according to the changed direction with the acceleration parameter value.

4. The method according to claim 1, characterized in that: The target working mode is a displacement mode; the motion parameter value includes a total displacement; The step of controlling the motion of the motor based on the target speed regulation rule and the motion parameter value in the target working mode includes: In the displacement mode, the motor is controlled to move from the starting speed to the target speed based on the target speed regulation rule and the acceleration parameter value, and the motor is controlled to move from the target speed to the stop speed based on the target speed regulation rule and the deceleration parameter value, and the displacement during the movement is equal to the total displacement.

5. The method according to claim 4, characterized in that The method further comprises: When the current speed of the motor is less than the stop speed, the motor stops decelerating and runs at a constant speed based on the stop speed until the total displacement is satisfied.

6. The method according to claim 1, characterized in that The step of controlling the motion of the motor based on the target speed regulation rule and the motion parameter value in the target working mode includes: In the displacement mode, based on the target speed regulation rule, the starting speed, the target speed and the acceleration parameter value, the acceleration phase displacement is determined; Determining a deceleration phase displacement based on the target speed regulation rule, the target speed, the deceleration parameter value and the stop speed; When the sum of the acceleration phase displacement and the deceleration phase displacement is less than the total displacement, a motor displacement error alarm is issued.

7. The method according to claim 1, characterized in that The step of controlling the motion of the motor based on the target speed regulation rule and the motion parameter value in the target working mode includes: In the target working mode, determining the current displacement of the motor based on the target speed regulation rule and the motion parameter value at every preset time interval; When the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent to control the motion of the motor.

8. The method according to claim 7, characterized in that The target working mode is a displacement mode; When the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent to control the motion of the motor, including: When the current displacement increases by one unit compared to the previous displacement, a pulse signal is sent once to control the motion of the motor until the total displacement of the motor reaches the target displacement, and the pulse signal is stopped from being sent.

9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: Get updated parameter values; In response to a trigger operation on a register, when the value of the register is a first value, storing the updated parameter value until the motor reaches the target speed or an initial state, and then performing motion control on the motor based on the updated parameter value; When the value of the register is the second value, the update parameter value is ignored.

10. A motion controller for a motor, characterized in that: The motion controller of the motor is used to implement the steps of the method according to any one of claims 1 to 9.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

Citation Information

Cited By

  • Device, control method and parameter setting method of switchgear motor operating mechanism

    CN120183935A