Stepping motor control method, device and system and storage medium

文档序号:1641237 发布日期:2019-12-20 浏览:24次 中文

阅读说明:本技术 步进电机控制方法、装置、系统及存储介质 (Stepping motor control method, device and system and storage medium ) 是由 刘元江 赵云峰 王子铭 贺子和 周忠厚 于 2019-09-02 设计创作,主要内容包括:本发明涉及电机驱动技术领域,公开了一种步进电机控制方法、装置、系统及存储介质,所述方法包括:提供一种正弦S曲线加速算法,根据目标位移和目标速度由所述算法计算和规划步进电机在运动过程中的的速度方程,根据所述速度方程,由驱动器内置的高性能处理器及驱动模块控制所述步进电机运转,由于其速度方程的二阶导数为正弦函数,即加速度、加加速度方程均连续可导,不存在突变,较好地符合了步进电机力矩随速度升高而减小的特点,充分利用了电机的有效转矩,同时能够减弱机械冲击,使得步进电机运行更加平稳可靠。(The invention relates to the technical field of motor driving, and discloses a stepping motor control method, a stepping motor control device, a stepping motor control system and a stepping motor control storage medium, wherein the stepping motor control method comprises the following steps: the speed equation of the stepping motor in the motion process is calculated and planned by the algorithm according to the target displacement and the target speed, the stepping motor is controlled to operate by a high-performance processor and a driving module which are arranged in a driver according to the speed equation, and the second derivative of the speed equation is a sine function, namely, the acceleration equation and the jerk equation are continuously conductive and have no sudden change, so that the characteristic that the moment of the stepping motor is reduced along with the increase of the speed is better met, the effective torque of the motor is fully utilized, and the mechanical impact can be weakened, so that the stepping motor operates more stably and reliably.)

1. A stepping motor control method, characterized in that the stepping motor control comprises the steps of:

receiving a data instruction of an upper computer, wherein the data instruction comprises target displacement and target speed;

calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed through a preset sine S-curve acceleration algorithm;

and controlling the stepping motor to operate according to the time speed.

2. The stepping motor control method according to claim 1, wherein said operation phase includes an acceleration phase, a smooth acceleration phase, and a deceleration phase;

calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed by a preset sine S-curve acceleration algorithm, and specifically comprises the following steps:

calculating the acceleration and the acceleration time of the acceleration stage according to the target displacement and the target speed;

determining uniform acceleration time of the uniform acceleration stage according to the acceleration time;

and calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement, the target speed, the accelerated acceleration time and the uniform acceleration time.

3. The stepping motor control method according to claim 2, wherein the calculating a time velocity of the stepping motor at each time in the operation phase based on the target displacement, the target velocity, the jerk, and the jerk time includes:

respectively calculating a first maximum speed of the acceleration stage and a second maximum speed of the uniform acceleration stage according to the target displacement, the target speed, the acceleration time and the uniform acceleration time;

calculating the maximum acceleration according to the jerk and the jerk time;

and calculating the speed of the stepping motor at each moment in the operation stage according to the accelerated speed, the accelerated speed adding time, the uniform accelerated time, the first maximum speed, the second maximum speed and the maximum acceleration.

4. The stepping motor control method according to claim 3, wherein said calculating a first maximum speed of said jerk phase and a second maximum speed of said jerk phase from said target displacement, said target speed, said jerk time, and said jerk time, respectively, comprises:

calculating a first maximum speed of the jerk phase from the jerk and the jerk time;

and calculating a second maximum speed of the uniform acceleration stage according to the accelerated speed, the accelerated time and the uniform acceleration time.

5. The method of controlling a stepping motor according to claim 3, wherein the calculating the time velocity of the stepping motor at each time in the operation phase based on the jerk, the jerk time, the first maximum velocity, the second maximum velocity, and the maximum acceleration comprises:

determining a first operation time when the uniform acceleration stage starts and a second operation time when the deceleration stage starts according to the jerk time, the first operation time and the uniform acceleration time;

and calculating the speed of the stepping motor at each moment in the operation stage according to the jerk value, the jerk time, the first operation moment, the second operation moment, the first maximum speed and the second maximum speed and the maximum acceleration.

6. The stepping motor control method according to claim 5, wherein said determining a first operating time at which said uniform acceleration phase starts and a second operating time at which said deceleration phase starts based on said jerk time, said first operating time, and said uniform acceleration time, comprises:

determining a first running time when the uniform acceleration stage starts according to the acceleration time;

and determining a second operation time when the deceleration and acceleration stage starts according to the first operation time and the uniform acceleration time.

7. The stepping motor control method according to claim 5, wherein said calculating a time velocity of the stepping motor at each time of the operation stage based on the jerk value, the jerk time, the first operation time, the second operation time, the first maximum velocity, the second maximum velocity, and the maximum acceleration specifically comprises:

calculating a first integral constant according to the jerk and the jerk time;

calculating a second integral constant from the first integral constant and the second maximum speed;

and calculating the time speed of the stepping motor at each time in the operation stage according to the accelerated speed, the accelerated time, the first operation time, the second operation time, the first maximum speed, the first integral constant and the second integral constant.

8. A stepping motor control apparatus, characterized by comprising:

the data communication module is used for receiving a data instruction of the upper computer, and the data instruction comprises target displacement and target speed;

the speed calculation module is used for calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed through a preset sine S-curve acceleration algorithm;

and the motor control module is used for controlling the stepping motor to operate according to the time speed.

9. A stepper motor control system, comprising: a control module, a power module, a data storage module, a communication module, a drive module, an upper computer, a stepper motor and a stepper motor control program stored on the data storage module and operable on the control module, the stepper motor control program being configured to implement the steps of the stepper motor control method as claimed in any of claims 1 to 7.

10. A storage medium having a stepping motor control program stored thereon, the storage medium having the stepping motor control program stored thereon, the stepping motor control program when executed by a processor implementing the steps of the stepping motor control method according to any one of claims 1 to 7.

Technical Field

The invention relates to the technical field of motor driving, in particular to a stepping motor control method, a stepping motor control device, a stepping motor control system and a storage medium.

Background

The stepping motor is an electromechanical actuator for converting an electric pulse signal into linear displacement or angular displacement, is a main execution unit in a modern digital program control system, is widely applied, but cannot be used conventionally like a common direct current motor and an alternating current motor, and a control system consisting of a double-loop pulse signal, a power drive circuit and the like can be used.

The stepping motor has an idle-load starting frequency, i.e. a pulse frequency at which the stepping motor can be normally started under the idle-load condition, so that in practical application, if the starting pulse frequency is higher than the value, the motor may be out of step or locked, and thus the motor cannot be normally started. The key point for solving the problems lies in speed control when the motor is started, an acceleration curve algorithm is generally adopted in the prior art to control the speed, the acceleration curve algorithm generally has a linear type and a parabolic type, wherein the linear type acceleration curve has the characteristics of optimal time, simple operation and the like, but the acceleration mode does not consider the characteristic of improving the torque change of the motor. Meanwhile, when the acceleration is started and finished, the acceleration has sudden change, mechanical shock can be generated to induce vibration, and adverse effects are brought to the stable operation of the system.

Therefore, the technical problem of how to make the stepping motor operate more stably to meet the requirements of higher application occasions exists.

The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.

Disclosure of Invention

The invention mainly aims to provide a method, a device and a system for controlling a stepping motor and a storage medium, and aims to solve the technical problem of how to enable the stepping motor to run more stably so as to meet the requirements of higher application occasions.

In order to achieve the above object, the present invention provides a stepping motor control method, including the steps of:

receiving a data instruction of an upper computer, wherein the data instruction comprises target displacement and target speed;

calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed through a preset sine S-curve acceleration algorithm;

and controlling the stepping motor to operate according to the time speed.

Preferably, the calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed by using a preset sine S-curve acceleration algorithm specifically includes:

calculating the acceleration and the acceleration time of the acceleration stage according to the target displacement and the target speed;

determining uniform acceleration time of the uniform acceleration stage according to the acceleration time;

and calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement, the target speed, the accelerated acceleration time and the uniform acceleration time.

Preferably, the calculating the time velocity of the stepping motor at each time in the operation stage according to the target displacement, the target velocity, the jerk, and the uniform acceleration time specifically includes:

respectively calculating a first maximum speed of the acceleration stage and a second maximum speed of the uniform acceleration stage according to the target displacement, the target speed, the acceleration time and the uniform acceleration time;

calculating the maximum acceleration according to the jerk and the jerk time;

and calculating the speed of the stepping motor at each moment in the operation stage according to the accelerated speed, the accelerated speed adding time, the uniform accelerated time, the first maximum speed, the second maximum speed and the maximum acceleration.

Preferably, the calculating a first maximum speed of the acceleration stage and a second maximum speed of the uniform acceleration stage according to the target displacement, the target speed, the jerk, the acceleration time, and the uniform acceleration time includes:

calculating a first maximum speed of the jerk phase from the jerk and the jerk time;

and calculating a second maximum speed of the uniform acceleration stage according to the accelerated speed, the accelerated time and the uniform acceleration time.

Preferably, the calculating the time speed of the stepping motor at each time in the operation stage according to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration specifically includes:

determining a first operation time when the uniform acceleration stage starts and a second operation time when the deceleration stage starts according to the jerk time, the first operation time and the uniform acceleration time;

and calculating the speed of the stepping motor at each moment in the operation stage according to the jerk value, the jerk time, the first operation moment, the second operation moment, the first maximum speed and the second maximum speed and the maximum acceleration.

Preferably, the determining a first operation time when the uniform acceleration phase starts and a second operation time when the deceleration phase starts according to the jerk time, the first operation time, and the uniform acceleration time specifically includes:

determining a first running time when the uniform acceleration stage starts according to the acceleration time;

and determining a second operation time when the deceleration and acceleration stage starts according to the first operation time and the uniform acceleration time.

Preferably, the calculating the time velocity of the stepping motor at each time of the operation stage according to the jerk value, the jerk time, the first operation time, the second operation time, the first maximum velocity, the second maximum velocity, and the maximum acceleration specifically includes:

calculating a first integral constant according to the jerk and the jerk time;

calculating a second integral constant from the first integral constant and the second maximum speed;

and calculating the time speed of the stepping motor at each time in the operation stage according to the accelerated speed, the accelerated time, the first operation time, the second operation time, the first maximum speed, the first integral constant and the second integral constant.

In addition, in order to achieve the above object, the present invention also provides a stepping motor control device including:

the data communication module is used for receiving a data instruction of the upper computer, and the data instruction comprises target displacement and target speed;

the speed calculation module is used for calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed;

and the motor control module is used for controlling the stepping motor to operate according to the time speed.

Further, to achieve the above object, the present invention also proposes a stepping motor control apparatus comprising: a memory, a processor, and a stepper motor control program stored on the memory and executable on the processor, the stepper motor control program configured with steps to implement a stepper motor control method as described above.

In addition, to achieve the above object, the present invention further provides a storage medium having a stepping motor control program stored thereon, which when executed by a processor implements the steps of the stepping motor control method as described above.

According to the control method of the stepping motor, the data instruction of the upper computer is received, the data instruction comprises target displacement and target speed, the time speed of the stepping motor at each moment in the operation stage is calculated through a preset sine S-curve acceleration algorithm according to the target displacement and the target speed, the stepping motor is controlled to operate according to the time speed, the time speed is calculated through the obtained target displacement and the target speed, the stepping motor is controlled to operate according to the time speed, the stepping motor is enabled to operate more stably, and the technical problem of how to enable the stepping motor to operate stably is solved.

Drawings

FIG. 1 is a schematic diagram of a stepper motor control system in a hardware operating environment according to an embodiment of the present invention;

FIG. 2 is a schematic flowchart of a control method for a stepping motor according to a first embodiment of the present invention;

FIG. 3 is a diagram illustrating a first embodiment of a method for controlling a stepping motor according to the present invention;

FIG. 4 is a flowchart illustrating a step motor control method according to a second embodiment of the present invention;

FIG. 5 is a flowchart illustrating a stepping motor control method according to a third embodiment of the present invention;

fig. 6 is a functional block diagram of a stepping motor control device according to a first embodiment of the present invention.

The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.

Detailed Description

It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

Referring to fig. 1, fig. 1 is a schematic structural diagram of a stepping motor control system in a hardware operating environment according to an embodiment of the present invention.

As shown in fig. 1, the stepping motor control system may include: the device comprises a control module 1001, a driving module 1002, a stepping motor 1003, an upper computer 1004, a data storage module 1005, a power supply module 1006 and a communication module 1007.

The control module takes a 32-bit high-performance embedded processor as a control core, and a sine speed curve algorithm is built in firmware of the control module, so that the stability and reliability of acceleration and deceleration of the motor are realized; the on-chip SPI peripheral of the processor is communicated with the motor driving chip to read and write the register of the driving chip, so that the aim of configuring the parameters of the driving chip is fulfilled; the on-chip IIC peripheral of the processor is used for communicating with the memory chip AT24C16C, and the parameter data can be stored after power failure.

The power supply module converts the externally input 24V voltage into 3.3V through the power supply chip AOZ1282CI, and can supply power to the control module, the driving module, the communication module and the data storage module.

The data storage module stores parameters of the driver, such as subdivision, current, S-curve acceleration step number, target speed, driver CAN.ID and the like, through an external storage chip AT24C16C, so that the important parameters are not lost when power is lost, and the driver can be normally used after being electrified again without resetting the parameters.

The communication module CAN realize CAN communication through the on-chip CAN peripheral of the high-performance embedded processor and the cooperation of a CAN transceiver chip SN65HVD 230; the communication interface can receive control commands and data of a control card or a PLC, and also can receive commands and data sent by an upper computer, so that the control function of the driver and the reading and writing of parameters are realized.

The driving module adopts a high-performance stepping driving chip TMC2660, the direction and the pulse interface of the driving chip are controlled through the IO port of the main control chip, the direction and the speed control of the motor are realized, and the parameter reading and writing of the driving chip are realized through the SPI peripheral of the main control chip.

Furthermore, the power module comprises a voltage division circuit, the voltage of a power interface is connected to the AD peripheral interface of the high-performance main control chip through the voltage division circuit, so that the main control chip can read the current voltage value, a power management mechanism is arranged in the main control chip, and when the external access voltage is too low or too high, the driver can throw out corresponding alarm information.

Furthermore, the communication module is in CAN bus communication, CAN peripheral equipment of a high-performance main control chip is adopted, and an external CAN transceiving chip SN65HVD230 is matched, so that the communication rate of 1Mbps at most CAN be realized; and the firmware of the main control chip is internally provided with communication overtime retransmission, heartbeat monitoring and other mechanisms, so that the CAN communication is more reliable and stable.

Furthermore, the acceleration of the sine acceleration curve is a sine function and can be continuously derived, the acceleration of the trapezoidal acceleration curve and the parabolic acceleration curve is a step function, step transformation exists, the speed change of the motor is not stable enough, the sine curve can avoid the problem, the sine curve better conforms to the characteristic that the torque of the stepping motor is reduced along with the rise of the speed, the effective torque of the motor is fully utilized, and meanwhile, the mechanical impact can be weakened.

Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 1 does not constitute a limitation of a stepper motor control system, and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.

As shown in fig. 1, the data storage module 1005, which is a kind of storage medium, may include therein an operating system, a communication module, a user interface module, parameters of a driver, and a stepping motor control program.

In the stepping motor control device shown in fig. 1, the communication module 1007 is mainly used for connecting an upper computer or a control card and receiving a control command or data; the present invention calls a stepping motor control program stored in the data storage module 1005 through the control module 1001, and executes the following operations:

receiving a data instruction of an upper computer, wherein the data instruction comprises target displacement and target speed;

calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed through a preset sine S-curve acceleration algorithm;

and controlling the stepping motor to operate according to the time speed.

Further, the control module 1001 may call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:

calculating the acceleration and the acceleration time of the acceleration stage according to the target displacement and the target speed;

determining uniform acceleration time of the uniform acceleration stage according to the acceleration time;

and calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement, the target speed, the accelerated acceleration time and the uniform acceleration time.

Further, the control module 1001 may call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:

respectively calculating a first maximum speed of the acceleration stage and a second maximum speed of the uniform acceleration stage according to the target displacement, the target speed, the acceleration time and the uniform acceleration time;

calculating the maximum acceleration according to the jerk and the jerk time;

and calculating the speed of the stepping motor at each moment in the operation stage according to the accelerated speed, the accelerated speed adding time, the uniform accelerated time, the first maximum speed, the second maximum speed and the maximum acceleration.

Further, the control module 1001 may call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:

calculating a first maximum speed of the jerk phase from the jerk and the jerk time;

and calculating a second maximum speed of the uniform acceleration stage according to the accelerated speed, the accelerated time and the uniform acceleration time.

Further, the control module 1001 may call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:

determining a first operation time when the uniform acceleration stage starts and a second operation time when the deceleration stage starts according to the jerk time, the first operation time and the uniform acceleration time;

and calculating the speed of the stepping motor at each moment in the operation stage according to the jerk value, the jerk time, the first operation moment, the second operation moment, the first maximum speed and the second maximum speed and the maximum acceleration.

Further, the control module 1001 may call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:

determining a first running time when the uniform acceleration stage starts according to the acceleration time;

and determining a second operation time when the deceleration and acceleration stage starts according to the first operation time and the uniform acceleration time.

Further, the control module 1001 may call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:

calculating a first integral constant according to the jerk and the jerk time;

calculating a second integral constant from the first integral constant and the second maximum speed;

and calculating the time speed of the stepping motor at each time in the operation stage according to the accelerated speed, the accelerated time, the first operation time, the second operation time, the first maximum speed, the first integral constant and the second integral constant.

In this embodiment, by receiving a data instruction of the upper computer, where the data instruction includes a target displacement and a target speed, the time speed of the stepping motor at each time in the operation stage is calculated by a preset sine S-curve acceleration algorithm according to the target displacement and the target speed, and the operation of the stepping motor is controlled according to the time speed, so that the time speed is calculated by the obtained target displacement and the target speed, and the operation of the stepping motor is controlled according to the time speed, so that the operation of the stepping motor is more stable, and the technical problem of how to stably operate the stepping motor is solved.

Based on the hardware structure, the embodiment of the stepping motor control method is provided.

Referring to fig. 2, fig. 2 is a flowchart illustrating a step motor control method according to a first embodiment of the present invention.

In a first embodiment, the stepping motor control method includes the steps of:

and step S10, receiving a data instruction of the upper computer, wherein the data instruction comprises target displacement and target speed.

It should be noted that the execution main body of the embodiment may be a control module of a stepping motor control system, and may also be other devices that can achieve the same or similar functions.

It should be understood that the user inputs the target displacement and the target speed, which are two values set by the user according to the requirement, the target speed is the maximum speed reached by the stepping motor in the operation stage, and the present embodiment does not limit the range of the target displacement and the target speed.

And step S20, calculating the time speed of the stepping motor at each moment in the operation stage through a preset sine S-curve acceleration algorithm according to the target displacement and the target speed.

It should be noted that, the control module of the stepping motor control system uses a high-performance embedded processor as a control core, a preset sine S-curve acceleration algorithm is built in firmware of the control module, so as to realize stable and reliable acceleration and deceleration of the motor, and the on-chip SPI peripheral of the processor is used for communicating with the motor driver chip to read and write the register of the driver chip, thereby achieving the purpose of configuring the parameters of the driver chip.

It should be understood that, the acceleration of the preset sine S curve acceleration algorithm is a sine function, which can be derived continuously, while the acceleration of the trapezoidal or parabolic acceleration curve is a step function, which has step change, so that the speed change of the motor is not stable enough, and the sine curve can avoid this problem.

It can be understood that, after the target displacement and the target speed are obtained, the stepping motor control device calculates the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm built in the stepping motor control device to obtain a time speed of the stepping motor in the operation stage, where the time speed is an operation speed at each time.

It should be understood that the operation phase of the stepping motor includes an acceleration phase and a constant speed phase, the acceleration phase includes an acceleration phase, a uniform acceleration phase and an acceleration reduction phase, the acceleration phase is a phase in which the acceleration is increasing continuously, the uniform acceleration phase is a phase in which the acceleration is not changing, and the acceleration reduction phase is a phase in which the acceleration is decreasing continuously.

It can be understood that, in this embodiment, the operation stages of the stepping motor are in the order of an acceleration increasing stage, an acceleration uniforming stage, an acceleration decreasing stage and a constant speed stage, that is, the stepping motor is continuously accelerated when it starts to operate, and when the maximum speed is reached (the maximum speed of the acceleration decreasing stage), the acceleration is not continued, but the maximum speed is kept to operate at a constant speed. The speed variation of the stepper motor is shown in FIG. 3, t0To t1The section is an acceleration stage, t1To t2The section is a uniform acceleration stage t2To t3To reduce the acceleration phase, t3Followed by a constant velocity phase.

And step S30, controlling the stepper motor to operate according to the time speed.

It should be noted that the acceleration stage of the stepping motor in the prior art is not stable, but in this embodiment, the acceleration stage is divided into an acceleration increasing stage, an acceleration uniforming stage and an acceleration decreasing stage, the time speed is calculated by a preset sine S-curve acceleration algorithm, and the stepping motor is controlled to operate according to the time speed, so that the speed of the stepping motor is increased according to the optimal speed to maintain the stability of the stepping motor.

In this embodiment, by receiving a data instruction of the upper computer, where the data instruction includes a target displacement and a target speed, the time speed of the stepping motor at each time in the operation stage is calculated by a preset sine S-curve acceleration algorithm according to the target displacement and the target speed, and the operation of the stepping motor is controlled according to the time speed, so that the time speed is calculated by the obtained target displacement and the target speed, and the operation of the stepping motor is controlled according to the time speed, so that the operation of the stepping motor is more stable, and the technical problem of how to stably operate the stepping motor is solved.

In an embodiment, as shown in fig. 4, a second embodiment of the stepping motor control method according to the present invention is proposed based on the first embodiment, and the step S20 includes:

step S201, calculating the acceleration rate and acceleration time of the acceleration stage according to the target displacement and the target speed.

It should be noted that the jerk in the jerk phase may be calculated according to the following formula, and the jerk may be accurately calculated according to the formula.

Wherein, JPFor jerk of jerk phase, VPIs a target speed, SPIs the target displacement.

The acceleration time of the acceleration phase can be calculated according to the following formula, and the acceleration time can be accurately calculated according to the formula.

Wherein, tJAcceleration time, V, for acceleration phasePIs a target speed, SPIs the target displacement.

And step S202, determining the uniform acceleration time of the uniform acceleration stage according to the acceleration adding time.

Note that the uniform acceleration time is denoted by tCIn the present algorithm, t is setJ=tCThat is, the acceleration time is the same as the uniform acceleration time, which is the operation time of the uniform acceleration stage, even though the operation times of the acceleration stage and the uniform acceleration stage are the same.

And step S203, calculating the time speed of the running stage of the stepping motor according to the target displacement, the target speed, the acceleration rate, the acceleration time and the uniform acceleration time.

It can be understood that the acceleration time t is calculated by the above steps in the present embodimentJAcceleration JPUniform acceleration time tCAnd the target speed VPAnd a target displacement SPIs a known quantity, and therefore, can be based on the target speed VPTarget displacement SPPlus acceleration time tJAcceleration JPTime of acceleration tCThe speed at the moment of the operating phase of the stepping motor is calculated.

In the embodiment, the jerk and the jerk time in the jerk stage are calculated according to the target displacement and the target speed, and the jerk time in the uniform acceleration stage is determined according to the jerk time, so that the time speed in the operation stage of the stepping motor is calculated according to the target speed, the jerk time, the uniform acceleration time, the target displacement and the target speed obtained through calculation.

In an embodiment, as shown in fig. 5, a third embodiment of the stepping motor control method according to the present invention is proposed based on the first embodiment or the second embodiment, and in this embodiment, the step S203 includes:

step S2031, calculating a first maximum speed in the acceleration stage and a second maximum speed in the uniform acceleration stage according to the target displacement, the target speed, the acceleration rate, the acceleration time, and the uniform acceleration time.

It should be noted that a first maximum speed in the jerk phase is calculated from the jerk and the jerk time, and a second maximum speed in the jerk phase is calculated from the jerk, the jerk time, and the jerk time, where the first maximum speed is the maximum speed in the jerk phase and the second maximum speed is the maximum speed in the jerk phase.

It should be appreciated that the formula for calculating the first maximum velocity for the jerk phase from the jerk and jerk time is as follows, from which the first maximum velocity can be accurately calculated.

Wherein, V1Is the first maximum speed of the acceleration phase, tJTo increase the acceleration time, JPIs a jerk.

The formula for calculating the second maximum speed in the uniform acceleration stage according to the jerk, the jerk time, and the uniform acceleration time is as follows, and the second maximum speed can be accurately calculated according to the formula.

Wherein, V2Second maximum speed, t, of the uniform acceleration phaseJTo increase the acceleration time, JPIs a jerk.

Step S2032, calculating the maximum acceleration according to the jerk and the jerk time.

It should be appreciated that the formula for calculating the maximum acceleration from jerk and jerk time is as follows, from which the maximum acceleration can be accurately calculated.

Wherein, aPAt maximum acceleration, tJTo increase the acceleration time, JPIs a jerk.

Step S2033, calculating the time speed of the running stage of the stepping motor according to the accelerated speed, the accelerated speed adding time, the uniform accelerated time, the first maximum speed, the second maximum speed and the maximum accelerated speed.

It should be noted that a first operation time at the start of the uniform acceleration phase is determined according to the jerk time, a second operation time at the start of the deceleration phase is determined according to the first operation time and the uniform acceleration time, a first integral constant is calculated according to the jerk and the jerk time, a second integral constant is calculated according to the first integral constant and the second maximum speed, and a time speed is calculated according to the jerk, the jerk time, the first operation time, the second operation time, the first maximum speed, the first integral constant, and the second integral constant.

Determining the first running time at the beginning of the uniform acceleration phase according to the acceleration time, wherein the initial time is 0, the acceleration time is calculated by the steps, the acceleration phase is the first phase of the running phase and is followed by the uniform acceleration phase, therefore, the first running time at the beginning of the uniform acceleration phase can be obtained according to the acceleration time, and the first running time is recorded as t1For example, the acceleration time is 2S, that is, the acceleration phase continues for 2S and then shifts to the uniform acceleration phase, that is, the uniform acceleration phase and 2S start, that is, the first operation time is 2S.

Determining a second operation time at the beginning of the deceleration and acceleration phase according to the first operation time and the uniform acceleration time, and it can be understood that, as shown in fig. 3, the first operation time and the uniform acceleration time are calculated by the above steps, the uniform acceleration phase is the second phase, and the deceleration and acceleration phase is the third phase, so that the second operation time at the beginning of the deceleration and acceleration phase can be obtained according to the first operation time and the uniform acceleration time, and the second operation time is recorded as t2For example, since the acceleration time is 2S and the smooth acceleration time is 2S in the same manner as the acceleration time, the first operation time is the 2 nd S and the second operation time is the 4 th S.

The formula for calculating the first integral constant from the jerk and the jerk time is as follows, and the first integral constant can be accurately calculated from the formula.

Wherein, C0Is a first integral constant, tJTo increase the acceleration time, JPIs a jerk.

The formula for calculating the second integral constant from the first integral constant and the second maximum speed is as follows, from which the second integral constant can be accurately calculated.

C1=V2-C0

Wherein, C1Is a second integral constant, C0Is a first integral constant, V2The second maximum speed.

It should be noted that the algorithm further includes a jerk equation during acceleration, and the jerk can be accurately calculated according to the jerk equation.

Wherein, tJTo increase the acceleration time, JPFor jerking, t1Is a first operating time, t2Is the second operating time, t3And the third operation time is the time when the deceleration and acceleration stage is finished, and t is the current time.

Further, an acceleration equation during acceleration is also included, and the acceleration can be accurately calculated according to the equation as follows.

Wherein, tJTo increase the acceleration time, JPFor jerking, t1Is a first operating time, t2Is the second operating time, t3Is the third operating time, aPAnd t is the maximum acceleration and the current moment.

Further, a speed equation for accelerating the process is also included, and the speed can be accurately calculated according to the equation as follows.

Wherein, tJTo increase the acceleration time, JPFor jerking, t1Is a first operating time, t2Is the second operating time, t3Is the third operating time, aPMaximum acceleration, t current time, V1At a first maximum speed, C0Is a first integral constant, C1Is a second integral constant.

Therefore, a second integral constant is calculated according to the first integral constant and the second maximum speed obtained in the above steps, the moment speed, namely the speed which the stepping motor should keep at each moment, can be calculated by substituting the acceleration rate, the acceleration time, the first operation moment, the second operation moment, the first maximum speed, the first integral constant and the second integral constant into a speed equation of an acceleration process, and the operation of the stepping motor can be controlled according to the moment speed, so that the stepping motor can operate more stably.

It can be understood that the operation stage of the stepping motor further includes a deceleration stage, the acceleration stage and the deceleration stage are symmetrical, the corresponding deceleration stage corresponds to the acceleration stage, the speed at the moment can be calculated through the speed equation, and the deceleration operation of the stepping motor is controlled according to the speed at the moment, so that the operation of the stepping motor is more stable.

In the embodiment, a first maximum speed of the acceleration stage and a second maximum speed of the uniform acceleration stage are respectively calculated according to the target displacement, the target speed, the acceleration rate, the acceleration time and the uniform acceleration time; calculating the maximum acceleration according to the jerk and the jerk time; and calculating the time speed of the running stage of the stepping motor according to the accelerated speed, the uniform accelerated time, the first maximum speed, the second maximum speed and the maximum accelerated speed, substituting the numerical values calculated in the steps into a speed equation to calculate the time speed, and controlling the running of the stepping motor according to the time speed to ensure that the stepping motor runs more stably.

In addition, an embodiment of the present invention further provides a storage medium, where the storage medium stores a stepping motor control program, and the stepping motor control program, when executed by a processor, implements the following operations:

receiving a data instruction of an upper computer, wherein the data instruction comprises target displacement and target speed;

calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed through a preset sine S-curve acceleration algorithm;

and controlling the stepping motor to operate according to the time speed.

Further, the stepper motor control program when executed by the processor further performs the following operations:

calculating the time speed of the running stage of the stepping motor according to the target displacement and the target speed, and specifically comprises the following steps:

calculating the acceleration and the acceleration time of the acceleration stage according to the target displacement and the target speed;

determining uniform acceleration time of the uniform acceleration stage according to the acceleration time;

and calculating the time speed of the running stage of the stepping motor according to the target displacement, the target speed, the accelerated time and the uniform acceleration time.

Further, the stepper motor control program when executed by the processor further performs the following operations:

respectively calculating a first maximum speed of the acceleration stage and a second maximum speed of the uniform acceleration stage according to the target displacement, the target speed, the acceleration time and the uniform acceleration time;

calculating the maximum acceleration according to the jerk and the jerk time;

and calculating the time speed of the running stage of the stepping motor according to the accelerated speed, the accelerated speed adding time, the uniform accelerated time, the first maximum speed, the second maximum speed and the maximum accelerated speed.

Further, the stepper motor control program when executed by the processor further performs the following operations:

calculating a first maximum speed of the jerk phase from the jerk and the jerk time;

and calculating a second maximum speed of the uniform acceleration stage according to the accelerated speed, the accelerated time and the uniform acceleration time.

Further, the stepper motor control program when executed by the processor further performs the following operations:

determining a first operation time when the uniform acceleration stage starts and a second operation time when the deceleration stage starts according to the jerk time, the first operation time and the uniform acceleration time;

and calculating the time speed of the running stage of the stepping motor according to the accelerated speed value, the accelerated speed time, the first running time, the second running time, the first maximum speed and the second maximum speed and the maximum acceleration.

Further, the stepper motor control program when executed by the processor further performs the following operations:

determining a first running time when the uniform acceleration stage starts according to the acceleration time;

and determining a second operation time when the deceleration and acceleration stage starts according to the first operation time and the uniform acceleration time.

Further, the stepper motor control program when executed by the processor further performs the following operations:

calculating a first integral constant according to the jerk and the jerk time;

calculating a second integral constant from the first integral constant and the second maximum speed;

and calculating the moment speed according to the jerk, the jerk time, the first operation moment, the second operation moment, the first maximum speed, the first integral constant and the second integral constant.

In the embodiment, a data instruction of an upper computer is received, wherein the data instruction comprises target displacement and target speed; calculating the time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed through a preset sine S-curve acceleration algorithm; and controlling the stepping motor to operate according to the time speed, so that the time speed is calculated through the acquired target displacement and the target speed, and the stepping motor is controlled to operate according to the time speed, so that the stepping motor operates more stably, and the technical problem of how to stably operate the stepping motor is solved.

In addition, referring to fig. 6, an embodiment of the present invention further provides a stepping motor control apparatus, including:

the data communication module 10 is used for receiving a data instruction of an upper computer, wherein the data instruction comprises target displacement and target speed;

it should be noted that the executing main body of the embodiment may be a control module of a stepping motor control system, and may also be other devices that can implement the same or similar functions, which is not limited in the embodiment.

It should be understood that the user inputs the target displacement and the target speed, which are two values set by the user according to the requirement, the target speed is the maximum speed reached by the stepping motor in the operation stage, and the present embodiment does not limit the range of the target displacement and the target speed.

The speed calculation module 20 is configured to calculate a time speed of the stepping motor at each moment in the operation stage according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm;

it should be noted that, the control module of the stepping motor control system uses a high-performance embedded processor as a control core, a preset sine S-curve acceleration algorithm is built in firmware of the control module, so as to realize stable and reliable acceleration and deceleration of the motor, and the on-chip SPI peripheral of the processor is used for communicating with the motor driver chip to read and write the register of the driver chip, thereby achieving the purpose of configuring the parameters of the driver chip.

It should be understood that, the acceleration of the preset sine S curve acceleration algorithm is a sine function, which can be derived continuously, while the acceleration of the trapezoidal or parabolic acceleration curve is a step function, which has step change, so that the speed change of the motor is not stable enough, and the sine curve can avoid this problem.

It can be understood that, after the target displacement and the target speed are obtained, the stepping motor control device calculates the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm built in the stepping motor control device to obtain a time speed of the stepping motor in the operation stage, where the time speed is an operation speed at each time.

It should be understood that the operation phase of the stepping motor includes an acceleration phase and a constant speed phase, the acceleration phase includes an acceleration phase, a uniform acceleration phase and an acceleration reduction phase, the acceleration phase is a phase in which the acceleration is increasing continuously, the uniform acceleration phase is a phase in which the acceleration is not changing, and the acceleration reduction phase is a phase in which the acceleration is decreasing continuously.

It can be understood that, in this embodiment, the operation stages of the stepping motor are in the order of an acceleration increasing stage, an acceleration uniforming stage, an acceleration decreasing stage and a constant speed stage, that is, the stepping motor is continuously accelerated when it starts to operate, and when the maximum speed is reached (the maximum speed of the acceleration decreasing stage), the acceleration is not continued, but the maximum speed is kept to operate at a constant speed. The speed variation of the stepper motor is shown in FIG. 3, t0To t1The section is an acceleration stage, t1To t2The section is a uniform acceleration stage t2To t3To reduce the acceleration phase, t3Followed by a constant velocity phase.

And the motor control module 30 is used for controlling the stepper motor to operate according to the time speed.

It should be noted that the acceleration stage of the stepping motor in the prior art is not stable, but in this embodiment, the acceleration stage is divided into an acceleration increasing stage, an acceleration uniforming stage and an acceleration decreasing stage, the time speed is calculated by a sinusoidal speed curve algorithm, and the stepping motor is controlled to operate according to the time speed, so that the speed of the stepping motor is increased according to the optimal speed to maintain the stability of the stepping motor.

In this embodiment, by receiving a data instruction of the upper computer, where the data instruction includes a target displacement and a target speed, the time speed of the stepping motor at each time in the operation stage is calculated by a preset sine S-curve acceleration algorithm according to the target displacement and the target speed, and the operation of the stepping motor is controlled according to the time speed, so that the time speed is calculated by the obtained target displacement and the target speed, and the operation of the stepping motor is controlled according to the time speed, so that the operation of the stepping motor is more stable, and the technical problem of how to stably operate the stepping motor is solved.

In an embodiment, the speed calculating module 20 is further configured to calculate a jerk and a jerk time of the jerk phase according to the target displacement and the target speed; determining uniform acceleration time of the uniform acceleration stage according to the acceleration time; and calculating the time speed of the running stage of the stepping motor according to the target displacement, the target speed, the accelerated time and the uniform acceleration time.

In an embodiment, the speed calculating module 20 is further configured to calculate a first maximum speed of the acceleration phase and a second maximum speed of the uniform acceleration phase according to the target displacement, the target speed, the jerk, the acceleration time, and the uniform acceleration time, respectively; calculating the maximum acceleration according to the jerk and the jerk time; and calculating the time speed of the running stage of the stepping motor according to the accelerated speed, the accelerated speed adding time, the uniform accelerated time, the first maximum speed, the second maximum speed and the maximum accelerated speed.

In an embodiment, the speed calculating module 20 is further configured to calculate a first maximum speed of the jerk phase according to the jerk and the jerk time; and calculating a second maximum speed of the uniform acceleration stage according to the accelerated speed, the accelerated time and the uniform acceleration time.

In an embodiment, the speed calculation module 20 is further configured to determine a first operation time when the uniform acceleration phase starts and a second operation time when the deceleration phase starts according to the jerk time, the first operation time, and the uniform acceleration time; and calculating the time speed of the running stage of the stepping motor according to the accelerated speed value, the accelerated speed time, the first running time, the second running time, the first maximum speed and the second maximum speed and the maximum acceleration.

In an embodiment, the speed calculating module 20 is further configured to determine a first operation time when the uniform acceleration phase starts according to the acceleration time; and determining a second operation time when the deceleration and acceleration stage starts according to the first operation time and the uniform acceleration time.

In an embodiment, the speed calculating module 20 is further configured to calculate a first integral constant according to the jerk and the jerk time; calculating a second integral constant from the first integral constant and the second maximum speed; and calculating the moment speed according to the jerk, the jerk time, the first operation moment, the second operation moment, the first maximum speed, the first integral constant and the second integral constant.

Other embodiments or specific implementation methods of the stepping motor control device according to the present invention may refer to the above embodiments, and are not described herein again.

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.

Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a computer-readable storage medium (such as ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling an intelligent stepping motor control device (such as a mobile phone, a computer, a stepping motor control device, an air conditioner, or a network stepping motor control device) to execute the method according to the embodiments of the present invention.

The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

21页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种编码器输出电平控制电路

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!