WO2021042637A1 - Method, apparatus and system for controlling stepping motor, and storage medium - Google Patents

Method, apparatus and system for controlling stepping motor, and storage medium Download PDF

Info

Publication number
WO2021042637A1
WO2021042637A1 PCT/CN2019/129090 CN2019129090W WO2021042637A1 WO 2021042637 A1 WO2021042637 A1 WO 2021042637A1 CN 2019129090 W CN2019129090 W CN 2019129090W WO 2021042637 A1 WO2021042637 A1 WO 2021042637A1
Authority
WO
WIPO (PCT)
Prior art keywords
time
jerk
speed
acceleration
stepping motor
Prior art date
Application number
PCT/CN2019/129090
Other languages
French (fr)
Chinese (zh)
Inventor
刘元江
赵雲峰
王子铭
贺子和
周忠厚
Original Assignee
歌尔股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 歌尔股份有限公司 filed Critical 歌尔股份有限公司
Publication of WO2021042637A1 publication Critical patent/WO2021042637A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H02GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
    • H02PCONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
    • H02P8/00Arrangements for controlling dynamo-electric motors rotating step by step
    • H02P8/14Arrangements for controlling speed or speed and torque
    • HELECTRICITY
    • H02GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
    • H02PCONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
    • H02P8/00Arrangements for controlling dynamo-electric motors rotating step by step
    • H02P8/36Protection against faults, e.g. against overheating or step-out; Indicating faults

Definitions

  • the present invention relates to the technical field of motor driving, in particular to a stepping motor control method, device, system and storage medium.
  • Stepping motors are electromechanical actuators that convert electrical pulse signals into linear or angular displacements. They are the main execution units in modern digital program control systems. They are widely used. However, stepping motors cannot be as effective as ordinary DC motors and AC motors. Under normal use, it must be composed of a dual-loop pulse signal, power drive circuit, etc. to form a control system before it can be used. However, the existing two-phase stepper motor drive system has larger volume, lower accuracy, higher energy consumption, higher cost, etc. problem.
  • the stepper motor has a no-load starting frequency, that is, the pulse frequency that the stepper motor can start normally under no-load conditions. Therefore, in actual applications, if the starting pulse frequency is higher than this value, the motor may lose synchronization or stall. Therefore, it cannot start normally.
  • the key to solving these problems lies in the speed control when the motor starts.
  • acceleration curve algorithms are generally adopted to control the speed.
  • the acceleration curve algorithms generally have linear and parabolic types. Among them, the linear acceleration curve has the most time. Features such as excellent and simple operation, but this acceleration mode does not consider the characteristics of improving the torque change of the motor. At the same time, due to the sudden change in acceleration when the acceleration starts and when the acceleration is completed, mechanical shock induced vibration will be generated, which will adversely affect the smooth operation of the system.
  • the main purpose of the present invention is to propose a stepping motor control method, device, system and storage medium, which aims to solve the technical problem of how to make the stepping motor run more smoothly to meet the demands of higher application occasions.
  • the present invention provides a stepping motor control method.
  • the stepping motor control method includes the following steps:
  • the data instruction including a target displacement and a target speed
  • the operation of the stepping motor is controlled according to the speed at the time.
  • the calculation of the instantaneous speed of the stepping motor at each moment in the operation phase through a preset sinusoidal S-curve acceleration algorithm according to the target displacement and the target speed specifically includes:
  • the target displacement the target speed, the jerk, the jerk time, and the uniform acceleration time
  • the time speed of the stepping motor at each time in the operation phase is calculated.
  • the calculation of the time speed of the stepping motor at each time in the operation phase according to the target displacement, the target speed, the jerk, the jerk time and the uniform acceleration time specifically includes:
  • the target displacement the target speed, the jerk, the jerk time, and the uniform acceleration time, the first maximum speed in the jerk phase and the second maximum speed in the uniform acceleration phase are respectively calculated ;
  • the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration calculate the time speed of the stepping motor at each time during the operation phase .
  • the first maximum speed of the jerk phase and the uniform acceleration phase are calculated respectively according to the target displacement, the target speed, the jerk, the jerk time and the constant acceleration time
  • the second maximum speed including:
  • the second maximum speed in the uniform acceleration stage is calculated according to the jerk, the jerk time and the uniform acceleration time.
  • the stepping motor is calculated in the operating phase according to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration
  • the time speed at each time specifically including:
  • the first operating time at the beginning of the uniform acceleration phase and the second operating time at the beginning of the deceleration phase are determined according to the jerk time, the first operating time and the uniform acceleration time , Specifically including:
  • the second operating time at the beginning of the deceleration phase is determined according to the first operating time and the uniform acceleration time.
  • the calculation of the maximum acceleration based on the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, and the second maximum speed specifically includes:
  • the present invention also provides a stepping motor control device, the stepping motor control device includes:
  • the data communication module is used to receive data instructions from the upper computer, the data instructions including target displacement and target speed;
  • a speed calculation module configured to calculate the instantaneous speed of the stepper motor at each time during the operation phase according to the target displacement and the target speed;
  • the motor control module is used to control the operation of the stepping motor according to the speed at the time.
  • the present invention also proposes a stepping motor control device.
  • the stepping motor control device includes a memory, a processor, and steps stored in the memory and capable of running on the processor. Enter the motor control program, and the stepper motor control program is configured with steps for implementing the stepper motor control method as described above.
  • the present invention also provides a storage medium that stores a stepping motor control program, and the stepping motor control program is executed by a processor to realize the stepping motor as described above. Steps of the control method.
  • the stepping motor control method proposed by the present invention receives data instructions from a host computer.
  • the data instructions include a target displacement and a target speed.
  • the preset sinusoidal S-curve acceleration algorithm is used to calculate the The speed of the stepping motor at each time in the operation phase is controlled according to the speed of the time, so as to calculate the speed of the time by the target displacement and target speed obtained, and control the operation of the stepping motor according to the speed of the time to make the stepping
  • the motor runs more smoothly, which solves the technical problem of how to make the stepper motor run smoothly.
  • FIG. 1 is a schematic diagram of the structure of a stepping motor control system in a hardware operating environment involved in a solution of an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of the first embodiment of the stepping motor control method of the present invention
  • Fig. 3 is an exemplary diagram of the first embodiment of the stepping motor control method of the present invention.
  • FIG. 4 is a schematic flowchart of a second embodiment of a stepping motor control method according to the present invention.
  • FIG. 5 is a schematic flowchart of a third embodiment of a stepping motor control method according to the present invention.
  • Fig. 6 is a schematic diagram of functional modules of the first embodiment of the stepping motor control device of the present invention.
  • FIG. 1 is a structural diagram of a stepping motor control system in a hardware operating environment involved in a solution of an embodiment of the present invention.
  • the stepping motor control system may include: a control module 1001, a driving module 1002, a stepping motor 1003, a host computer 1004, a data storage module 1005, a power module 1006, and a communication module 1007.
  • the control module uses a 32-bit high-performance embedded processor as the control core, and its firmware has a built-in sinusoidal speed curve algorithm to realize the smooth and reliable acceleration and deceleration of the motor; the communication between the on-chip SPI peripheral of the processor and the motor drive chip is adopted to achieve Read and write the registers of the driver chip to achieve the purpose of configuring the parameters of the driver chip; use the on-chip IIC peripheral of the processor to communicate with the storage chip AT24C16C, so that the parameter data can be saved after power-off.
  • the power supply module converts the externally input 24V voltage into 3.3V through the power supply chip AOZ1282CI, which can supply power to the control module, the drive module, the communication module and the data storage module.
  • the data storage module saves drive parameters such as subdivision, current, S-curve acceleration steps, target speed, drive CAN.ID, etc. through an external storage chip AT24C16C, so that these important parameters are not lost after power failure, so that the drive It can be used normally after power-on again, without resetting the parameters.
  • the communication module can realize CAN communication through the on-chip CAN peripherals of the high-performance embedded processor and cooperate with the CAN transceiver chip SN65HVD230; it can receive control commands and data from the control card or PLC through this communication interface, and can also receive The commands and data sent from the host computer realize the control function of the drive and the reading and writing of parameters.
  • the drive module adopts a high-performance stepping drive chip TMC2660.
  • the direction and pulse interface of the drive chip are controlled through the IO port of the main control chip to realize the direction and speed control of the motor.
  • the control is realized through the SPI peripheral of the main control chip. Reading and writing of the parameters of the drive chip.
  • the power module includes a voltage divider circuit through which the power interface voltage is connected to the AD peripheral interface of the high-performance main control chip, so that the main control chip can read the current voltage value, and the main control chip
  • the chip has a built-in power management mechanism. When the external input voltage is too low or too high, the driver will throw out the corresponding alarm information.
  • the communication module is CAN bus communication, using the CAN peripherals of the high-performance main control chip, and cooperates with the external CAN transceiver chip SN65HVD230 to achieve a communication rate of up to 1 Mbps; Mechanisms such as timeout retransmission and heartbeat monitoring make CAN communication more reliable and stable.
  • the jerk of the sine acceleration curve is a sine function, which can be continuously derived, while the jerk of the trapezoidal and parabolic acceleration curve is a step function, and there is a step transformation, which makes the speed change of the motor not stable enough, and the sine The curve can avoid this problem.
  • the sine curve better conforms to the characteristic that the torque of the stepper motor decreases with the increase of speed, makes full use of the effective torque of the motor, and at the same time can reduce the mechanical shock.
  • FIG. 1 does not constitute a limitation on the stepper motor control system, and may include more or fewer components than shown, or a combination of certain components, or different components Layout.
  • the data storage module 1005 as a storage medium may include an operating system, a communication module, a user interface module, driver parameters, and a stepper motor control program.
  • the communication module 1007 is mainly used to connect to a host computer or a control card to receive control commands or data; the present invention calls the stepping motor control stored in the data storage module 1005 through the control module 1001 Program and do the following:
  • the data instruction including a target displacement and a target speed
  • the operation of the stepping motor is controlled according to the speed at the time.
  • control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
  • the target displacement the target speed, the jerk, the jerk time, and the uniform acceleration time
  • the time speed of the stepping motor at each time in the operation phase is calculated.
  • control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
  • the target displacement the target speed, the jerk, the jerk time, and the uniform acceleration time, the first maximum speed in the jerk phase and the second maximum speed in the uniform acceleration phase are respectively calculated ;
  • the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration calculate the time speed of the stepping motor at each time during the operation phase .
  • control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
  • the second maximum speed in the uniform acceleration stage is calculated according to the jerk, the jerk time and the uniform acceleration time.
  • control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
  • control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
  • the second operating time at the beginning of the deceleration phase is determined according to the first operating time and the uniform acceleration time.
  • control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
  • the data instruction includes a target displacement and a target speed.
  • a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase.
  • the time speed at each time the stepping motor is controlled to operate according to the time speed, so that the time speed is calculated by the acquired target displacement and target speed, and the stepping motor is controlled according to the time speed to make the stepping motor run more smoothly.
  • FIG. 2 is a schematic flowchart of a first embodiment of a stepping motor control method of the present invention.
  • the stepping motor control method includes the following steps:
  • Step S10 Receive a data instruction from the host computer, where the data instruction includes a target displacement and a target speed.
  • the executive body of this embodiment can be the control module of the stepper motor control system, or other devices that can realize the same or similar functions. This embodiment does not limit this, and the control module is used as the control module in this embodiment. Examples are explained.
  • the target displacement and target speed are two values set by the user according to requirements.
  • the target speed is the maximum speed reached by the stepper motor during the operation phase.
  • the numerical range of the speed is not limited in this embodiment.
  • Step S20 Calculate the instantaneous speed of the stepping motor at each instant in the operation phase according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm.
  • control module of the stepper motor control system uses a high-performance embedded processor as the control core, and its firmware has a built-in preset sinusoidal S-curve acceleration algorithm to achieve stable and reliable motor acceleration and deceleration. It uses the processor’s on-chip SPI
  • the communication between the peripheral and the motor drive chip realizes reading and writing of the register of the drive chip, thereby achieving the purpose of configuring the parameters of the drive chip, which is not limited in this embodiment.
  • the jerk of the preset sine S-curve acceleration algorithm is a sine function and can be derived continuously, while the jerk of trapezoidal and parabolic acceleration curves is a step function, and there is a step transformation, which makes the motor speed The change is not stable enough, and the sine curve can avoid this problem.
  • the sine curve better conforms to the characteristic that the torque of the stepper motor decreases with the increase of speed, makes full use of the effective torque of the motor, and at the same time can reduce the mechanical shock.
  • the stepper motor control device calculates the target displacement and target speed through its built-in preset sinusoidal S-curve acceleration algorithm to obtain the time of the stepping motor's operation phase Speed, the speed at the moment is the running speed at each moment.
  • the operation phase of a stepper motor includes an acceleration phase and a constant speed phase.
  • the acceleration phase includes an acceleration phase, a uniform acceleration phase, and a deceleration phase.
  • the acceleration phase is a phase in which the acceleration is continuously increasing.
  • the phase is a phase in which the acceleration is constant, and the de-acceleration phase is a phase in which the acceleration is continuously decreasing.
  • the sequence of the operating phases of the stepping motor in this embodiment is the acceleration phase, the uniform acceleration phase, the deceleration phase, and the uniform speed phase, that is, the stepping motor continuously accelerates when it starts to run, and when it reaches the maximum speed ( Decrease the maximum speed in the acceleration phase), no longer continue to accelerate, but maintain the maximum speed to run at a constant speed.
  • the speed change of the stepping motor is shown in Fig. 3, the period from t 0 to t 1 is the acceleration stage, the period from t 1 to t 2 is the uniform acceleration stage, the period from t 2 to t 3 is the deceleration stage, and the period after t 3 is the uniform speed.
  • Step S30 controlling the operation of the stepping motor according to the speed at the time.
  • the acceleration phase of the stepping motor in the prior art is not stable, and in this embodiment, the acceleration phase is divided into an acceleration phase, a uniform acceleration phase, and a deceleration phase, and a preset sinusoidal S-curve acceleration algorithm is used. Calculate the speed at the time, and control the operation of the stepping motor according to the speed at the time, so that the speed of the stepping motor is increased at the optimal speed to maintain its stability.
  • the data instruction includes a target displacement and a target speed.
  • a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase.
  • the time speed at each time the stepping motor is controlled to operate according to the time speed, so that the time speed is calculated by the obtained target displacement and target speed, and the stepping motor is controlled according to the time speed to make the stepping motor run more smoothly.
  • the step S20 includes:
  • Step S201 Calculate jerk and jerk time in the jerk phase according to the target displacement and the target speed.
  • the jerk in the jerk phase can be calculated according to the following formula, and the jerk can be accurately calculated according to this formula.
  • J P is added jerk acceleration phase
  • V P is the target speed
  • S P is a target displacement.
  • the jerk time in the jerk phase can be calculated according to the following formula, and the jerk time can be accurately calculated according to this formula.
  • t J is added plus acceleration time acceleration phase
  • V P is the target speed
  • S P is a target displacement.
  • Step S202 Determine the uniform acceleration time of the uniform acceleration stage according to the acceleration time.
  • Step S203 Calculate the instantaneous speed of the stepping motor during the operation phase according to the target displacement, the target speed, the jerk, the jerk time, and the constant acceleration time.
  • the present embodiment come to jerk time t J, jerk J P, uniform acceleration time t C, the target and the target displacement speed V P S P is a known quantity calculated by the above step, therefore, be According to the target speed V P , the target displacement S P , the jerk time t J , the jerk J P and the constant acceleration time t C , the time speed of the stepping motor in the operation phase is calculated.
  • the jerk and jerk time in the jerk phase are calculated according to the target displacement and target speed, and the jerk time in the jerk phase is determined according to the jerk time, so that the calculated target speed, jerk, and jerk time are determined.
  • Uniform acceleration time, target displacement and target speed are used to calculate the instantaneous speed of the stepping motor during the operation phase.
  • a third embodiment of the stepping motor control method of the present invention is proposed based on the first embodiment or the second embodiment.
  • the description is based on the second embodiment.
  • the step S203 includes:
  • Step S2031 according to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, respectively calculate the first maximum speed of the jerk phase and the first speed of the uniform acceleration phase 2. Maximum speed.
  • the first maximum speed in the jerk phase is calculated according to the jerk and the jerk time
  • the second maximum speed in the uniform acceleration phase is calculated according to the jerk, the jerk time and the constant acceleration time
  • the first maximum speed is The maximum speed in the acceleration phase
  • the second maximum speed is the maximum speed in the uniform acceleration phase.
  • V 1 is the first maximum speed in the jerk phase
  • t J is the jerk time
  • J P is the jerk.
  • the formula for calculating the second maximum speed in the uniform acceleration phase 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 this formula.
  • V 2 is the second maximum speed in the uniform acceleration stage
  • t J is the jerk time
  • J P is the jerk.
  • Step S2032 Calculate the maximum acceleration according to the jerk and the jerk time.
  • a P is the maximum acceleration
  • t J is the jerk time
  • J P is the jerk.
  • Step S2033 Calculate the time of the operation phase of the stepping motor according to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration speed.
  • the first operation time at the beginning of the constant acceleration phase is determined according to the acceleration time
  • the second operation time at the beginning of the deceleration phase is determined according to the first operation time and the constant acceleration time.
  • the first integral constant is calculated according to the jerk and the jerk time
  • the second integral constant is calculated according to the first integral constant and the second maximum speed
  • the second integral constant is calculated according to the jerk and the jerk time
  • the first operation time, the second operation time, the first maximum speed, the first integral constant, and the second integral constant calculate the speed at the time.
  • the acceleration time to determine the first operating moment at the beginning of the uniform acceleration phase
  • the initial time is 0
  • the acceleration time has been calculated by the above steps
  • the acceleration phase is the first operation phase
  • the first stage is followed by the uniform acceleration stage. Therefore, according to the acceleration time, the first operation time at the beginning of the uniform acceleration stage can be obtained.
  • the first operation time is recorded as t 1.
  • the acceleration time is 2S, then That is to say, the acceleration phase lasts for 2S and then changes to the uniform acceleration phase, that is, the uniform acceleration phase starts with the 2nd second, that is, the first running moment is the 2nd second.
  • the second operating time at the beginning of the deceleration phase is determined. It can be understood that, as shown in FIG. 3, the first operating time and the uniform acceleration time have been changed from the above steps. It is calculated that the uniform acceleration stage is the second stage, and the deceleration stage is the third stage. Therefore, according to the first operation time and uniform acceleration time, the second operation time at the beginning of the deceleration stage can be obtained. Denoted as t 2 , for example, the jerk time is 2S, and the uniform acceleration time is the same as the jerk time is also 2S. Therefore, the first running time is 2S and the second running time is 4S.
  • the formula for calculating the first integral constant according to the jerk and the jerk time is as follows, and the first integral constant can be accurately calculated according to the formula.
  • C 0 is the first integral constant
  • t J is the jerk time
  • J P is the jerk.
  • the formula for calculating the second integration constant according to the first integration constant and the second maximum speed is as follows, and the second integration constant can be accurately calculated according to the formula.
  • C 1 is the second integral constant
  • C 0 is the first integral constant
  • V 2 is the second maximum speed.
  • this algorithm also includes the jerk equation in the acceleration process, as follows, according to the equation, the jerk can be accurately calculated.
  • t J is the jerk time
  • J P is the jerk
  • t 1 is the first running moment
  • t 2 is the second running moment
  • t 3 is the third running moment
  • the third running moment is the end of the deceleration phase
  • the moment of time, t is the current moment.
  • acceleration equation in the acceleration process as follows, according to which the acceleration can be accurately calculated.
  • t J is the jerk time
  • J P is the jerk
  • t 1 is the first running moment
  • t 2 is the second running moment
  • t 3 is the third running moment
  • a P is the maximum acceleration
  • t is the current moment.
  • t J is the jerk time
  • J P is the jerk
  • t 1 is the first running moment
  • t 2 is the second running moment
  • t 3 is the third running moment
  • a P is the maximum acceleration
  • t is the current moment
  • V 1 is the first maximum speed
  • C 0 is the first integral constant
  • C 1 is the second integral constant.
  • the second integral constant will be calculated according to the first integral constant and the second maximum speed obtained in the above steps, and the second integral constant will be calculated according to the jerk, the jerk time, the first operating time, and the first
  • the second running time, the first maximum speed, the first integral constant, and the second integral constant are substituted into the speed equation of the acceleration process to calculate the instantaneous speed, that is, the speed that the stepper motor should maintain at each moment. Controlling the operation of the stepping motor according to the speed at the time can make the stepping motor run more smoothly.
  • the operation phase of a stepper motor also includes a deceleration phase.
  • the acceleration phase and the deceleration phase are symmetrical, and the corresponding deceleration phase corresponds to the acceleration phase.
  • the time speed can also be calculated by the speed equation, and the step speed can be controlled according to the time speed. The decelerated operation of the stepping motor makes the stepping motor run more smoothly.
  • the first maximum speed of the jerk phase and the uniform acceleration phase are respectively calculated according to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time.
  • the maximum speed and the maximum acceleration calculate the time speed of the stepping motor during the operation phase, so that these values calculated in the above steps are substituted into the speed equation to calculate the time speed, and the stepping motor is controlled according to the time speed to make the step The motor runs more smoothly.
  • the embodiment of the present invention also provides a storage medium, the storage medium stores a stepping motor control program, and when the stepping motor control program is executed by a processor, the following operations are implemented:
  • the data instruction including a target displacement and a target speed
  • the operation of the stepping motor is controlled according to the speed at the time.
  • stepper motor control program when executed by the processor, the following operations are also implemented:
  • calculating the instantaneous speed of the stepping motor during the operation phase includes:
  • the target displacement the target speed, the jerk, the jerk time, and the uniform acceleration time
  • the time speed of the stepping motor in the operation phase is calculated.
  • stepper motor control program when executed by the processor, the following operations are also implemented:
  • the target displacement the target speed, the jerk, the jerk time, and the uniform acceleration time, the first maximum speed in the jerk phase and the second maximum speed in the uniform acceleration phase are respectively calculated ;
  • the jerk time the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration, the time speed of the stepping motor during the operation phase is calculated.
  • stepper motor control program when executed by the processor, the following operations are also implemented:
  • the second maximum speed in the uniform acceleration stage is calculated according to the jerk, the jerk time and the uniform acceleration time.
  • stepper motor control program when executed by the processor, the following operations are also implemented:
  • stepper motor control program when executed by the processor, the following operations are also implemented:
  • the second operating time at the beginning of the deceleration phase is determined according to the first operating time and the uniform acceleration time.
  • stepper motor control program when executed by the processor, the following operations are also implemented:
  • the time speed is calculated according to the jerk, the jerk time, the first operating time, the second operating time, the first maximum speed, the first integral constant, and the second integral constant.
  • the data instruction includes a target displacement and a target speed; according to the target displacement and the target speed, a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase Time speed at each time; to control the operation of the stepping motor according to the time speed, so as to calculate the time speed from the acquired target displacement and target speed, and control the operation of the stepping motor according to the time speed to make the stepping motor run more smoothly,
  • the technical problem of how to make the stepper motor run smoothly is solved.
  • an embodiment of the present invention also proposes a stepping motor control device, and the stepping motor control device includes:
  • the data communication module 10 is used to receive a data instruction from the upper computer, and the data instruction includes a target displacement and a target speed;
  • execution body of this embodiment may be a control module of a stepper motor control system, or may be other devices that can implement the same or similar functions, which is not limited in this embodiment.
  • the target displacement and target speed are two values set by the user according to requirements.
  • the target speed is the maximum speed reached by the stepper motor during the operation phase.
  • the numerical range of the speed is not limited in this embodiment.
  • the speed calculation module 20 is configured to calculate the instantaneous speed of the stepping motor at each time during the operation phase by using a preset sinusoidal S-curve acceleration algorithm according to the target displacement and the target speed;
  • control module of the stepper motor control system uses a high-performance embedded processor as the control core, and its firmware has a built-in preset sinusoidal S-curve acceleration algorithm to achieve stable and reliable motor acceleration and deceleration. It uses the processor’s on-chip SPI
  • the communication between the peripheral and the motor drive chip realizes reading and writing of the register of the drive chip, thereby achieving the purpose of configuring the parameters of the drive chip, which is not limited in this embodiment.
  • the jerk of the preset sine S-curve acceleration algorithm is a sine function and can be continuously derived, while the jerk of trapezoidal and parabolic acceleration curves is a step function, and there is a step transformation, which makes the motor speed The change is not stable enough, and the sine curve can avoid this problem.
  • the sine curve better conforms to the characteristic that the torque of the stepper motor decreases with the increase of speed, makes full use of the effective torque of the motor, and at the same time can reduce the mechanical shock.
  • the stepper motor control device calculates the target displacement and target speed through its built-in preset sinusoidal S-curve acceleration algorithm to obtain the time of the stepping motor's operation phase Speed, the speed at the moment is the running speed at each moment.
  • the operation phase of a stepper motor includes an acceleration phase and a constant speed phase.
  • the acceleration phase includes an acceleration phase, a uniform acceleration phase, and a deceleration phase.
  • the acceleration phase is a phase in which the acceleration is continuously increasing.
  • the phase is a phase in which the acceleration is constant, and the de-acceleration phase is a phase in which the acceleration is continuously decreasing.
  • the sequence of the operating phases of the stepping motor in this embodiment is the acceleration phase, the uniform acceleration phase, the deceleration phase, and the uniform speed phase, that is, the stepping motor continuously accelerates when it starts to run, and when it reaches the maximum speed ( Decrease the maximum speed in the acceleration phase), and no longer continue to accelerate, but keep the maximum speed at a constant speed.
  • the speed change of the stepping motor is shown in Fig. 3, the period from t 0 to t 1 is the acceleration stage, the period from t 1 to t 2 is the uniform acceleration stage, the period from t 2 to t 3 is the deceleration stage, and the period after t 3 is the uniform speed.
  • the motor control module 30 is used for controlling the operation of the stepping motor according to the speed at the time.
  • the acceleration phase of the stepping motor in the prior art is not stable, and in this embodiment, the acceleration phase is divided into an acceleration phase, a uniform acceleration phase, and a deceleration phase, and the time is calculated by the sinusoidal speed curve algorithm. Speed, and control the operation of the stepping motor according to the speed at the time, so that the speed of the stepping motor is increased at the optimal speed to maintain its stability.
  • the data instruction includes a target displacement and a target speed.
  • a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase.
  • the time speed at each time the stepping motor is controlled to operate according to the time speed, so that the time speed is calculated by the acquired target displacement and target speed, and the stepping motor is controlled according to the time speed to make the stepping motor run more smoothly.
  • the speed calculation module 20 is further configured to calculate the jerk and the jerk time in the jerk phase according to the target displacement and the target speed; determine the jerk according to the jerk time Uniform acceleration time in the acceleration phase; calculating the instantaneous speed of the stepping motor during the operation phase according to the target displacement, the target speed, the jerk, the jerk time, and the constant acceleration time.
  • the speed calculation module 20 is further configured to calculate the jerk phase according to the target displacement, the target speed, the jerk, the jerk time, and the constant acceleration time. Calculate the maximum acceleration according to the jerk and the jerk time; calculate the maximum acceleration according to the jerk, the jerk time, the uniform acceleration time, The first maximum speed, the second maximum speed, and the maximum acceleration calculate the instantaneous speed of the stepping motor during the operation phase.
  • the speed calculation module 20 is further configured to calculate the first maximum speed in the jerk phase according to the jerk and the jerk time; according to the jerk and the jerk time And the uniform acceleration time to calculate the second maximum speed of the uniform acceleration stage.
  • the speed calculation module 20 is further configured to determine the first running time and the total speed at the beginning of the constant acceleration phase according to the jerk time, the first running time, and the constant acceleration time.
  • the second operating time at the beginning of the acceleration phase; according to the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, the second Maximum Speed The maximum acceleration calculates the instantaneous speed of the stepping motor during the operation phase.
  • the speed calculation module 20 is further configured to determine the first operating moment at the beginning of the uniform acceleration phase according to the jerk time; determine according to the first operating time and the uniform acceleration time The second operating moment at the beginning of the deceleration phase.
  • the speed calculation module 20 is further configured to calculate a first integral constant according to the jerk and the jerk time; calculate a second integral constant according to the first integral constant and the second maximum speed Integral constant; calculated according to the jerk, the jerk time, the first operating time, the second operating time, the first maximum speed, the first integral constant and the second integral constant Time speed.
  • the technical solution of the present invention essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a computer-readable storage medium as described above (such as ROM/RAM, magnetic disk, optical disk), including several instructions to make a smart stepper motor control device (can be a mobile phone, computer, stepper motor control device, air conditioner, or network stepper motor control device, etc.) Perform the methods described in the various embodiments of the present invention.
  • a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk
  • a smart stepper motor control device can be a mobile phone, computer, stepper motor control device, air conditioner, or network stepper motor control device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Power Engineering (AREA)
  • Control Of Stepping Motors (AREA)

Abstract

A method, apparatus and system for controlling a stepping motor (1003) and a storage medium, the method comprising: providing a sinusoidal S-curve acceleration algorithm; according to a target displacement and a target velocity, by means of the algorithm, calculating and planning a velocity equation of the stepping motor (1003) during movement; and according to the velocity equation, controlling the stepping motor (1003) to operate by a high-performance processor and a driving module (1002) built into a driver. Since the second derivative of the velocity equation thereof is a sine function, i.e. acceleration and jerk equations are both continuous and derivable, and there is no sudden change, same conforms to the characteristic in which the torque of the stepping motor (1003) decreases along with an increase in velocity, thereby making full use of the effective torque of the motor. At the same time, mechanical shock may be weakened, so that the stepping motor (1003) operates more smoothly and reliably.

Description

步进电机控制方法、装置、系统及存储介质Stepping motor control method, device, system and storage medium 技术领域Technical field
本发明涉及电机驱动技术领域,尤其涉及一种步进电机控制方法、装置、系统及存储介质。The present invention relates to the technical field of motor driving, in particular to a stepping motor control method, device, system and storage medium.
背景技术Background technique
步进电机是将电脉冲信号转变为线位移或者角位移的机电执行元件,是现代数字程序控制系统中的主要执行单元,应用极为广泛,但步进电机不能像普通直流电机、交流电机那样在常规下使用,它必须由双环脉冲信号、功率驱动电路等组成控制系统方可使用,而现有的两相步进电机驱动系统存在体积较大、精度较低、能耗较大、成本较高等问题。Stepping motors are electromechanical actuators that convert electrical pulse signals into linear or angular displacements. They are the main execution units in modern digital program control systems. They are widely used. However, stepping motors cannot be as effective as ordinary DC motors and AC motors. Under normal use, it must be composed of a dual-loop pulse signal, power drive circuit, etc. to form a control system before it can be used. However, the existing two-phase stepper motor drive system has larger volume, lower accuracy, higher energy consumption, higher cost, etc. problem.
步进电机有一个空载启动频率,即步进电机在空载情况下能够正常启动的脉冲频率,因此在实际应用中,如果启动脉冲频率高于该值,电机可能发生失步或堵转,从而不能正常启动。解决这些问题的关键在于电机启动时的速度控制,现有技术中一般采取加速曲线算法来对速度进行控制,所述加速曲线算法一般有直线型、抛物线型,其中,直线型加速曲线具有时间最优和运算简单等特性,但这种加速模式没有考虑进步电机力矩变化的特点。同时由于在加速开始和加速完成时,加速度存在突变,将会产生机械冲击诱发振动,对系统的平稳运行带来不利影响。The stepper motor has a no-load starting frequency, that is, the pulse frequency that the stepper motor can start normally under no-load conditions. Therefore, in actual applications, if the starting pulse frequency is higher than this value, the motor may lose synchronization or stall. Therefore, it cannot start normally. The key to solving these problems lies in the speed control when the motor starts. In the prior art, acceleration curve algorithms are generally adopted to control the speed. The acceleration curve algorithms generally have linear and parabolic types. Among them, the linear acceleration curve has the most time. Features such as excellent and simple operation, but this acceleration mode does not consider the characteristics of improving the torque change of the motor. At the same time, due to the sudden change in acceleration when the acceleration starts and when the acceleration is completed, mechanical shock induced vibration will be generated, which will adversely affect the smooth operation of the system.
所以,存在着如何使步进电机运行更加平稳以满足更高的应用场合需求的技术问题。Therefore, there is a technical problem of how to make the stepper motor run more smoothly to meet the needs of higher applications.
上述内容仅用于辅助理解本发明的技术方案,并不代表承认上述内容是现有技术。The above content is only used to assist the understanding of the technical solution of the present invention, and does not mean that the above content is recognized as prior art.
发明内容Summary of the invention
本发明的主要目的在于提出一种步进电机控制方法、装置、系统及存储介质,旨在解决如何使步进电机运行更加平稳以满足更高的应用场合需求的技术问题。The main purpose of the present invention is to propose a stepping motor control method, device, system and storage medium, which aims to solve the technical problem of how to make the stepping motor run more smoothly to meet the demands of higher application occasions.
为实现上述目的,本发明提供一种步进电机控制方法,所述步进电机控 制方法包括以下步骤:In order to achieve the above objective, the present invention provides a stepping motor control method. The stepping motor control method includes the following steps:
接收上位机的数据指令,所述数据指令包括目标位移和目标速度;Receiving a data instruction from the host computer, the data instruction including a target displacement and a target speed;
根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度;Calculating the instantaneous speed of the stepper motor at each moment in the operation phase according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm;
根据所述时刻速度控制所述步进电机运转。The operation of the stepping motor is controlled according to the speed at the time.
优选地,所述根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度,具体包括:Preferably, the calculation of the instantaneous speed of the stepping motor at each moment in the operation phase through a preset sinusoidal S-curve acceleration algorithm according to the target displacement and the target speed specifically includes:
根据所述目标位移和所述目标速度计算所述加加速阶段的加加速度和加加速时间;Calculating the jerk and jerk time in the jerk phase according to the target displacement and the target speed;
根据所述加加速时间确定所述匀加速阶段的匀加速时间;Determining the uniform acceleration time of the uniform acceleration stage according to the acceleration time;
根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间计算所述步进电机在运行阶段各时刻的时刻速度。According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the time speed of the stepping motor at each time in the operation phase is calculated.
优选地,所述根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间计算所述步进电机在运行阶段各时刻的时刻速度,具体包括:Preferably, the calculation of the time speed of the stepping motor at each time in the operation phase according to the target displacement, the target speed, the jerk, the jerk time and the uniform acceleration time specifically includes:
根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度;According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the first maximum speed in the jerk phase and the second maximum speed in the uniform acceleration phase are respectively calculated ;
根据所述加加速度和所述加加速时间计算最大加速度;Calculating the maximum acceleration according to the jerk and the jerk time;
根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度。According to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration, calculate the time speed of the stepping motor at each time during the operation phase .
优选地,所述根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度,具体包括:Preferably, the first maximum speed of the jerk phase and the uniform acceleration phase are calculated respectively according to the target displacement, the target speed, the jerk, the jerk time and the constant acceleration time The second maximum speed, including:
根据所述加加速度和所述加加速时间计算所述加加速阶段的第一最大速度;Calculating the first maximum speed in the jerk phase according to the jerk and the jerk time;
根据所述加加速度、所述加加速时间和所述匀加速时间计算所述匀加速阶段的第二最大速度。The second maximum speed in the uniform acceleration stage is calculated according to the jerk, the jerk time and the uniform acceleration time.
优选地,所述根据所述加加速度、所述加加速时间、所述匀加速时间、 所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度,具体包括:Preferably, the stepping motor is calculated in the operating phase according to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration The time speed at each time, specifically including:
根据所述加加速度时间、所述第一运行时间和所述匀加速时间确定所述匀加速阶段开始时的第一运行时刻和所述减加速阶段开始时的第二运行时刻;Determining, according to the jerk time, the first running time, and the constant acceleration time, a first running moment at the beginning of the constant acceleration phase and a second running moment at the beginning of the deceleration phase;
根据所述加加速度值、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第二最大速度所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度。Calculate the stepping motor according to the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, the second maximum speed, the maximum acceleration The speed at each moment in the operating phase.
优选地,所述根据所述加加速度时间、所述第一运行时间和所述匀加速时间确定所述匀加速阶段开始时的第一运行时刻和所述减加速阶段开始时的第二运行时刻,具体包括:Preferably, the first operating time at the beginning of the uniform acceleration phase and the second operating time at the beginning of the deceleration phase are determined according to the jerk time, the first operating time and the uniform acceleration time , Specifically including:
根据所述加加速时间确定所述匀加速阶段开始时的第一运行时刻;Determining the first operating moment at the beginning of the uniform acceleration phase according to the acceleration time;
根据所述第一运行时刻和所述匀加速时间确定所述减加速阶段开始时的第二运行时刻。The second operating time at the beginning of the deceleration phase is determined according to the first operating time and the uniform acceleration time.
优选地,所述根据所述加加速度值、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第二最大速度所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度,具体包括:Preferably, the calculation of the maximum acceleration based on the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, and the second maximum speed The time speed of the stepping motor at each time during the operation phase specifically includes:
根据所述加加速度和所述加加速时间计算第一积分常量;Calculating a first integral constant according to the jerk and the jerk time;
根据所述第一积分常量和所述第二最大速度计算第二积分常量;Calculating a second integral constant according to the first integral constant and the second maximum speed;
根据所述加加速度、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第一积分常量和所述第二积分常量计算所述步进电机在运行阶段各时刻的时刻速度。Calculate the step according to the jerk, the jerk time, the first operating time, the second operating time, the first maximum speed, the first integral constant and the second integral constant The speed of the incoming motor at each moment in the running phase.
此外,为实现上述目的,本发明还提出一种步进电机控制装置,所述步进电机控制装置包括:In addition, in order to achieve the above object, the present invention also provides a stepping motor control device, the stepping motor control device includes:
数据通讯模块,用于接收上位机的数据指令,所述数据指令包括目标位移和目标速度;The data communication module is used to receive data instructions from the upper computer, the data instructions including target displacement and target speed;
速度计算模块,用于根据所述目标位移和所述目标速度计算所述步进电机在运行阶段各时刻的时刻速度;A speed calculation module, configured to calculate the instantaneous speed of the stepper motor at each time during the operation phase according to the target displacement and the target speed;
电机控制模块,用于根据所述时刻速度控制所述步进电机运转。The motor control module is used to control the operation of the stepping motor according to the speed at the time.
此外,为实现上述目的,本发明还提出一种步进电机控制设备,所述步进电机控制设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的步进电机控制程序,所述步进电机控制程序配置有实现如上所述的步进电机控制方法的步骤。In addition, in order to achieve the above object, the present invention also proposes a stepping motor control device. The stepping motor control device includes a memory, a processor, and steps stored in the memory and capable of running on the processor. Enter the motor control program, and the stepper motor control program is configured with steps for implementing the stepper motor control method as described above.
此外,为实现上述目的,本发明还提出一种存储介质,所述存储介质上存储有步进电机控制程序,所述步进电机控制程序被处理器执行时实现如上文所述的步进电机控制方法的步骤。In addition, in order to achieve the above-mentioned object, the present invention also provides a storage medium that stores a stepping motor control program, and the stepping motor control program is executed by a processor to realize the stepping motor as described above. Steps of the control method.
本发明提出的步进电机控制方法,通过接收上位机的数据指令,所述数据指令包括目标位移和目标速度,根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度,根据所述时刻速度控制所述步进电机运转,从而通过获取的目标位移和目标速度计算时刻速度,根据时刻速度控制步进电机运转,使步进电机运转更加平稳,解决了如何使步进电机平稳运行的技术问题。The stepping motor control method proposed by the present invention receives data instructions from a host computer. The data instructions include a target displacement and a target speed. According to the target displacement and the target speed, the preset sinusoidal S-curve acceleration algorithm is used to calculate the The speed of the stepping motor at each time in the operation phase is controlled according to the speed of the time, so as to calculate the speed of the time by the target displacement and target speed obtained, and control the operation of the stepping motor according to the speed of the time to make the stepping The motor runs more smoothly, which solves the technical problem of how to make the stepper motor run smoothly.
附图说明Description of the drawings
图1是本发明实施例方案涉及的硬件运行环境的步进电机控制系统结构示意图;FIG. 1 is a schematic diagram of the structure of a stepping motor control system in a hardware operating environment involved in a solution of an embodiment of the present invention;
图2为本发明步进电机控制方法第一实施例的流程示意图;2 is a schematic flowchart of the first embodiment of the stepping motor control method of the present invention;
图3为本发明步进电机控制方法第一实施例的示例图;Fig. 3 is an exemplary diagram of the first embodiment of the stepping motor control method of the present invention;
图4为本发明步进电机控制方法第二实施例的流程示意图;4 is a schematic flowchart of a second embodiment of a stepping motor control method according to the present invention;
图5为本发明步进电机控制方法第三实施例的流程示意图;5 is a schematic flowchart of a third embodiment of a stepping motor control method according to the present invention;
图6为本发明步进电机控制装置第一实施例的功能模块示意图。Fig. 6 is a schematic diagram of functional modules of the first embodiment of the stepping motor control device of the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the objectives, functional characteristics and advantages of the present invention will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限 定本发明。It should be understood that the specific embodiments described here are only used to explain the present invention, but not to limit the present invention.
参照图1,图1为本发明实施例方案涉及的硬件运行环境的步进电机控制系统结构示意图。Referring to FIG. 1, FIG. 1 is a structural diagram of a stepping motor control system in a hardware operating environment involved in a solution of an embodiment of the present invention.
如图1所示,该步进电机控制系统可以包括:控制模块1001,驱动模块1002,步进电机1003,上位机1004,数据存储模块1005,电源模块1006,通信模块1007。As shown in FIG. 1, the stepping motor control system may include: a control module 1001, a driving module 1002, a stepping motor 1003, a host computer 1004, a data storage module 1005, a power module 1006, and a communication module 1007.
所述控制模块,以32位高性能嵌入式处理器为控制核心,其固件内置正弦速度曲线算法,实现电机加减速的平稳可靠;采用处理器的片上SPI外设与电机驱动芯片的通讯,实现对驱动芯片的寄存器读写,从而达到配置驱动芯片参数的目的;使用处理器的片上IIC外设与存储芯片AT24C16C通讯,实现参数数据的掉电可保存。The control module uses a 32-bit high-performance embedded processor as the control core, and its firmware has a built-in sinusoidal speed curve algorithm to realize the smooth and reliable acceleration and deceleration of the motor; the communication between the on-chip SPI peripheral of the processor and the motor drive chip is adopted to achieve Read and write the registers of the driver chip to achieve the purpose of configuring the parameters of the driver chip; use the on-chip IIC peripheral of the processor to communicate with the storage chip AT24C16C, so that the parameter data can be saved after power-off.
所述电源模块,通过电源芯片AOZ1282CI,将外部输入的24V电压转换成3.3V,可以给控制模块、驱动模块、通信模块和数据存储模块供电。The power supply module converts the externally input 24V voltage into 3.3V through the power supply chip AOZ1282CI, which can supply power to the control module, the drive module, the communication module and the data storage module.
所述数据存储模块,通过外置存储芯片AT24C16C,将驱动器的参数如细分、电流、S曲线加速步数、目标速度、驱动器CAN.ID等保存,使得这些重要参数掉电不丢失,从而驱动器重新上电后可正常使用,不必重设参数。The data storage module saves drive parameters such as subdivision, current, S-curve acceleration steps, target speed, drive CAN.ID, etc. through an external storage chip AT24C16C, so that these important parameters are not lost after power failure, so that the drive It can be used normally after power-on again, without resetting the parameters.
所述通信模块,通过高性能嵌入式处理器的片上CAN外设,并配合CAN收发芯片SN65HVD230,便可实现CAN通讯;可以通过此通讯接口接收控制卡或PLC的控制命令、数据,也可以接收来自上位机发送的命令、数据,实现驱动器的控制功能以及参数的读写。The communication module can realize CAN communication through the on-chip CAN peripherals of the high-performance embedded processor and cooperate with the CAN transceiver chip SN65HVD230; it can receive control commands and data from the control card or PLC through this communication interface, and can also receive The commands and data sent from the host computer realize the control function of the drive and the reading and writing of parameters.
所述驱动模块,采用高性能步进驱动芯片TMC2660,通过所述主控芯片的IO口控制驱动芯片的方向、脉冲接口,实现电机的方向和速度控制,通过主控芯片的SPI外设实现对驱动芯片的参数的读写。The drive module adopts a high-performance stepping drive chip TMC2660. The direction and pulse interface of the drive chip are controlled through the IO port of the main control chip to realize the direction and speed control of the motor. The control is realized through the SPI peripheral of the main control chip. Reading and writing of the parameters of the drive chip.
进一步地,所述电源模块包括分压电路,电源接口电压经过此分压电路接到所述高性能主控芯片的AD外设接口,从而主控芯片可以读取当前电压值,所述主控芯片内置电源管理机制,当外部接入电压过低或者过高时,驱动器会抛出相应报警信息。Further, the power module includes a voltage divider circuit through which the power interface voltage is connected to the AD peripheral interface of the high-performance main control chip, so that the main control chip can read the current voltage value, and the main control chip The chip has a built-in power management mechanism. When the external input voltage is too low or too high, the driver will throw out the corresponding alarm information.
进一步地,所述通信模块为CAN总线通讯,采用高性能主控芯片的CAN外设,配合外置CAN收发芯片SN65HVD230,可实现最高1Mbps的通讯速 率;并且所述主控芯片的固件内置通讯的超时重传、心跳监测等机制,使得CAN通讯更加可靠稳定。Further, the communication module is CAN bus communication, using the CAN peripherals of the high-performance main control chip, and cooperates with the external CAN transceiver chip SN65HVD230 to achieve a communication rate of up to 1 Mbps; Mechanisms such as timeout retransmission and heartbeat monitoring make CAN communication more reliable and stable.
进一步地,所述正弦加速曲线,其加加速度为正弦函数,可连续求导,而梯形、抛物线形加速曲线其加加速度为阶跃函数,存在阶跃变换,使得电机速度变化不够平稳,而正弦曲线可以避免此问题,正弦曲线较好地符合了步进电机力矩随速度升高而减小的特点,充分利用了电机的有效转矩,同时能够减弱机械冲击。Further, the jerk of the sine acceleration curve is a sine function, which can be continuously derived, while the jerk of the trapezoidal and parabolic acceleration curve is a step function, and there is a step transformation, which makes the speed change of the motor not stable enough, and the sine The curve can avoid this problem. The sine curve better conforms to the characteristic that the torque of the stepper motor decreases with the increase of speed, makes full use of the effective torque of the motor, and at the same time can reduce the mechanical shock.
本领域技术人员可以理解,图1中示出的设备结构并不构成对步进电机控制系统的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the device structure shown in FIG. 1 does not constitute a limitation on the stepper motor control system, and may include more or fewer components than shown, or a combination of certain components, or different components Layout.
如图1所示,作为一种存储介质的数据存储模块1005中可以包括操作系统、通信模块、用户接口模块、驱动器的参数以及步进电机控制程序。As shown in FIG. 1, the data storage module 1005 as a storage medium may include an operating system, a communication module, a user interface module, driver parameters, and a stepper motor control program.
在图1所示的步进电机控制设备中,通信模块1007主要用于连接上位机或控制卡,接收控制命令或数据;本发明通过控制模块1001调用数据存储模块1005中存储的步进电机控制程序,并执行以下操作:In the stepping motor control device shown in Figure 1, the communication module 1007 is mainly used to connect to a host computer or a control card to receive control commands or data; the present invention calls the stepping motor control stored in the data storage module 1005 through the control module 1001 Program and do the following:
接收上位机的数据指令,所述数据指令包括目标位移和目标速度;Receiving a data instruction from the host computer, the data instruction including a target displacement and a target speed;
根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度;Calculating the instantaneous speed of the stepper motor at each moment in the operation phase according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm;
根据所述时刻速度控制所述步进电机运转。The operation of the stepping motor is controlled according to the speed at the time.
进一步地,控制模块1001可以调用数据存储模块1005中存储的步进电机控制程序,还执行以下操作:Further, the control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
根据所述目标位移和所述目标速度计算所述加加速阶段的加加速度和加加速时间;Calculating the jerk and jerk time in the jerk phase according to the target displacement and the target speed;
根据所述加加速时间确定所述匀加速阶段的匀加速时间;Determining the uniform acceleration time of the uniform acceleration stage according to the acceleration time;
根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间计算所述步进电机在运行阶段各时刻的时刻速度。According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the time speed of the stepping motor at each time in the operation phase is calculated.
进一步地,控制模块1001可以调用数据存储模块1005中存储的步进电机控制程序,还执行以下操作:Further, the control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度;According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the first maximum speed in the jerk phase and the second maximum speed in the uniform acceleration phase are respectively calculated ;
根据所述加加速度和所述加加速时间计算最大加速度;Calculating the maximum acceleration according to the jerk and the jerk time;
根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度。According to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration, calculate the time speed of the stepping motor at each time during the operation phase .
进一步地,控制模块1001可以调用数据存储模块1005中存储的步进电机控制程序,还执行以下操作:Further, the control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
根据所述加加速度和所述加加速时间计算所述加加速阶段的第一最大速度;Calculating the first maximum speed in the jerk phase according to the jerk and the jerk time;
根据所述加加速度、所述加加速时间和所述匀加速时间计算所述匀加速阶段的第二最大速度。The second maximum speed in the uniform acceleration stage is calculated according to the jerk, the jerk time and the uniform acceleration time.
进一步地,控制模块1001可以调用数据存储模块1005中存储的步进电机控制程序,还执行以下操作:Further, the control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
根据所述加加速度时间、所述第一运行时间和所述匀加速时间确定所述匀加速阶段开始时的第一运行时刻和所述减加速阶段开始时的第二运行时刻;Determining, according to the jerk time, the first running time, and the constant acceleration time, a first running moment at the beginning of the constant acceleration phase and a second running moment at the beginning of the deceleration phase;
根据所述加加速度值、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第二最大速度所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度。Calculate the stepping motor according to the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, the second maximum speed, the maximum acceleration The speed at each moment in the operating phase.
进一步地,控制模块1001可以调用数据存储模块1005中存储的步进电机控制程序,还执行以下操作:Further, the control module 1001 can call the stepping motor control program stored in the data storage module 1005, and also perform the following operations:
根据所述加加速时间确定所述匀加速阶段开始时的第一运行时刻;Determining the first operating moment at the beginning of the uniform acceleration phase according to the acceleration time;
根据所述第一运行时刻和所述匀加速时间确定所述减加速阶段开始时的第二运行时刻。The second operating time at the beginning of the deceleration phase is determined according to the first operating time and the uniform acceleration time.
进一步地,控制模块1001可以调用数据存储模块1005中存储的步进电机控制程序,还执行以下操作:Further, the control module 1001 can 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 according to the first integral constant and the second maximum speed;
根据所述加加速度、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第一积分常量和所述第二积分常量计算所述步进电机在运行阶段各时刻的时刻速度。Calculate the step according to the jerk, the jerk time, the first operating time, the second operating time, the first maximum speed, the first integral constant and the second integral constant The speed of the incoming motor at each moment in the running phase.
本实施例中通过接收上位机的数据指令,所述数据指令包括目标位移和目标速度,根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度,根据所述时刻速度控制所述步进电机运转,从而通过获取的目标位移和目标速度计算时刻速度,根据时刻速度控制步进电机运转,使步进电机运转更加平稳,解决了如何使步进电机平稳运行的技术问题。In this embodiment, by receiving a data instruction from a host computer, the data instruction includes a target displacement and a target speed. According to the target displacement and the target speed, a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase. The time speed at each time, the stepping motor is controlled to operate according to the time speed, so that the time speed is calculated by the acquired target displacement and target speed, and the stepping motor is controlled according to the time speed to make the stepping motor run more smoothly. The technical problem of how to make the stepper motor run smoothly.
基于上述硬件结构,提出本发明步进电机控制方法实施例。Based on the above hardware structure, an embodiment of the stepping motor control method of the present invention is proposed.
参照图2,图2为本发明步进电机控制方法第一实施例的流程示意图。Referring to FIG. 2, FIG. 2 is a schematic flowchart of a first embodiment of a stepping motor control method of the present invention.
在第一实施例中,所述步进电机控制方法包括以下步骤:In the first embodiment, the stepping motor control method includes the following steps:
步骤S10,接收上位机的数据指令,所述数据指令包括目标位移和目标速度。Step S10: Receive a data instruction from the host computer, where the data instruction includes a target displacement and a target speed.
需要说明的是,本实施例的执行主体可为步进电机控制系统的控制模块,还可为其他可实现相同或相似功能的设备,本实施例对此不作限制,本实施例以控制模块为例进行说明。It should be noted that the executive body of this embodiment can be the control module of the stepper motor control system, or other devices that can realize the same or similar functions. This embodiment does not limit this, and the control module is used as the control module in this embodiment. Examples are explained.
应当理解的是,用户输入目标位移和目标速度,目标位移和目标速度是用户根据需求设定的两个数值,所述目标速度为步进电机在运行阶段达到的最大速度,对于目标位移和目标速度的数值范围本实施例对此不作限制。It should be understood that the user inputs the target displacement and target speed. The target displacement and target speed are two values set by the user according to requirements. The target speed is the maximum speed reached by the stepper motor during the operation phase. The numerical range of the speed is not limited in this embodiment.
步骤S20,根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度。Step S20: Calculate the instantaneous speed of the stepping motor at each instant in the operation phase according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm.
需要说明的是,步进电机控制系统的的控制模块以高性能嵌入式处理器为控制核心,其固件内置预设正弦S曲线加速算法,实现电机加减速的平稳 可靠,采用处理器的片上SPI外设与电机驱动芯片的通讯,实现对驱动芯片的寄存器读写,从而达到配置驱动芯片参数的目的,本实施例对此不作限制。It should be noted that the control module of the stepper motor control system uses a high-performance embedded processor as the control core, and its firmware has a built-in preset sinusoidal S-curve acceleration algorithm to achieve stable and reliable motor acceleration and deceleration. It uses the processor’s on-chip SPI The communication between the peripheral and the motor drive chip realizes reading and writing of the register of the drive chip, thereby achieving the purpose of configuring the parameters of the drive chip, which is not limited in this embodiment.
应当理解的是,所述预设正弦S曲线加速算法,其加加速度为正弦函数,可连续求导,而梯形、抛物线形加速曲线其加加速度为阶跃函数,存在阶跃变换,使得电机速度变化不够平稳,而正弦曲线可以避免此问题,正弦曲线较好地符合了步进电机力矩随速度升高而减小的特点,充分利用了电机的有效转矩,同时能够减弱机械冲击。It should be understood that the jerk of the preset sine S-curve acceleration algorithm is a sine function and can be derived continuously, while the jerk of trapezoidal and parabolic acceleration curves is a step function, and there is a step transformation, which makes the motor speed The change is not stable enough, and the sine curve can avoid this problem. The sine curve better conforms to the characteristic that the torque of the stepper motor decreases with the increase of speed, makes full use of the effective torque of the motor, and at the same time can reduce the mechanical shock.
可以理解的是,在获取到的目标位移和目标速度之后,步进电机控制设备通过其内置的预设正弦S曲线加速算法对目标位移和目标速度进行计算,得到步进电机的运行阶段的时刻速度,所述时刻速度为每一时刻的运行速度。It is understandable that after obtaining the target displacement and target speed, the stepper motor control device calculates the target displacement and target speed through its built-in preset sinusoidal S-curve acceleration algorithm to obtain the time of the stepping motor's operation phase Speed, the speed at the moment is the running speed at each moment.
应当理解的是,步进电机的运行阶段包括加速阶段和匀速阶段,加速阶段包括加加速阶段、匀加速阶段和减加速阶段,所述加加速阶段为加速度在不断增加的阶段,所述匀加速阶段为加速度不变的阶段,所述减加速阶段为加速度在不断减少的阶段。It should be understood that the operation phase of a stepper motor includes an acceleration phase and a constant speed phase. The acceleration phase includes an acceleration phase, a uniform acceleration phase, and a deceleration phase. The acceleration phase is a phase in which the acceleration is continuously increasing. The phase is a phase in which the acceleration is constant, and the de-acceleration phase is a phase in which the acceleration is continuously decreasing.
可以理解的是,在本实施例中步进电机的运行阶段的顺序为加加速阶段、匀加速阶段、减加速阶段和匀速阶段,即步进电机开始运行时不断加速,在达到最大速度时(减加速阶段的最大速度),不再继续加速,而是保持最大速度匀速运行。步进电机的速度变化如图3所示,t 0至t 1段为加加速阶段,t 1至t 2段为匀加速阶段,t 2至t 3为减加速阶段,t 3之后为匀速阶段。 It can be understood that the sequence of the operating phases of the stepping motor in this embodiment is the acceleration phase, the uniform acceleration phase, the deceleration phase, and the uniform speed phase, that is, the stepping motor continuously accelerates when it starts to run, and when it reaches the maximum speed ( Decrease the maximum speed in the acceleration phase), no longer continue to accelerate, but maintain the maximum speed to run at a constant speed. The speed change of the stepping motor is shown in Fig. 3, the period from t 0 to t 1 is the acceleration stage, the period from t 1 to t 2 is the uniform acceleration stage, the period from t 2 to t 3 is the deceleration stage, and the period after t 3 is the uniform speed.
步骤S30,根据所述时刻速度控制所述步进电机运转。Step S30, controlling the operation of the stepping motor according to the speed at the time.
需要说明的是,现有技术中的步进电机的加速阶段并不稳定,而本实施例中将加速阶段分为加加速阶段、匀加速阶段和减加速阶段,通过预设正弦S曲线加速算法计算出时刻速度,并根据时刻速度控制步进电机运转,以使步进电机的速度按照最佳速度进行提升,以保持其稳定性。It should be noted that the acceleration phase of the stepping motor in the prior art is not stable, and in this embodiment, the acceleration phase is divided into an acceleration phase, a uniform acceleration phase, and a deceleration phase, and a preset sinusoidal S-curve acceleration algorithm is used. Calculate the speed at the time, and control the operation of the stepping motor according to the speed at the time, so that the speed of the stepping motor is increased at the optimal speed to maintain its stability.
本实施例中通过接收上位机的数据指令,所述数据指令包括目标位移和目标速度,根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度,根据所述时刻速度控制所述步进电机运转,从而通过获取的目标位移和目标速度计算时刻速度,根据时刻速度控制步进电机运转,使步进电机运转更加平稳,解决了如何使步进电机平稳运行的技术问题。In this embodiment, by receiving a data instruction from a host computer, the data instruction includes a target displacement and a target speed. According to the target displacement and the target speed, a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase. The time speed at each time, the stepping motor is controlled to operate according to the time speed, so that the time speed is calculated by the obtained target displacement and target speed, and the stepping motor is controlled according to the time speed to make the stepping motor run more smoothly. The technical problem of how to make the stepper motor run smoothly.
在一实施例中,如图4所示,基于第一实施例提出本发明步进电机控制方法第二实施例,所述步骤S20,包括:In one embodiment, as shown in FIG. 4, a second embodiment of the stepping motor control method of the present invention is proposed based on the first embodiment. The step S20 includes:
步骤S201,根据所述目标位移和所述目标速度计算所述加加速阶段的加加速度和加加速时间。Step S201: Calculate jerk and jerk time in the jerk phase according to the target displacement and the target speed.
需要说明是,可根据以下公式计算加加速阶段的加加速度,根据该公式可以精准计算加加速度。It should be noted that the jerk in the jerk phase can be calculated according to the following formula, and the jerk can be accurately calculated according to this formula.
Figure PCTCN2019129090-appb-000001
Figure PCTCN2019129090-appb-000001
其中,J P为加加速阶段的加加速度,V P为目标速度,S P为目标位移。 Wherein, J P is added jerk acceleration phase, V P is the target speed, S P is a target displacement.
可根据以下公式计算加加速阶段的加加速时间,根据该公式可以精准计算加加速时间。The jerk time in the jerk phase can be calculated according to the following formula, and the jerk time can be accurately calculated according to this formula.
Figure PCTCN2019129090-appb-000002
Figure PCTCN2019129090-appb-000002
其中,t J为加加速阶段的加加速时间,V P为目标速度,S P为目标位移。 Wherein, t J is added plus acceleration time acceleration phase, V P is the target speed, S P is a target displacement.
步骤S202,根据所述加加速时间确定所述匀加速阶段的匀加速时间。Step S202: Determine the uniform acceleration time of the uniform acceleration stage according to the acceleration time.
需要说明的是,将匀加速时间记为t C,在本算法中设置t J=t C,即加加时间与匀加速时间相同,所述匀加速时间为匀加速阶段的运行时间,即使加加速阶段和匀加速阶段的运行时间相同。 It should be noted that the uniform acceleration time is recorded as t C , and t J =t C is set in this algorithm, that is, the acceleration time is the same as the uniform acceleration time, and the uniform acceleration time is the running time of the uniform acceleration stage, even if it is added The running time of the acceleration phase and the uniform acceleration phase are the same.
步骤S203,根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间计算所述步进电机的运行阶段的时刻速度。Step S203: Calculate the instantaneous speed of the stepping motor during the operation phase according to the target displacement, the target speed, the jerk, the jerk time, and the constant acceleration time.
可以理解的是,本实施例通过上述步骤计算得出了加加速时间t J、加加速度J P、匀加速时间t C,而目标速度V P和目标位移S P为已知量,因此,可根据目标速度V P、目标位移S P、加加速时间t J、加加速度J P和匀加速时间t C来计算步进电机的运行阶段的时刻速度。 It will be appreciated that the present embodiment come to jerk time t J, jerk J P, uniform acceleration time t C, the target and the target displacement speed V P S P is a known quantity calculated by the above step, therefore, be According to the target speed V P , the target displacement S P , the jerk time t J , the jerk J P and the constant acceleration time t C , the time speed of the stepping motor in the operation phase is calculated.
本实施例中通过根据目标位移和目标速度计算加加速阶段的加加速度和加加速时间,根据加加速时间确定匀加速阶段的匀加速时间,从而根据计算得到的目标速度、加加速度、加加速度时间、匀加速时间以及目标位移、目标速度来计算步进电机的运行阶段的时刻速度。In this embodiment, the jerk and jerk time in the jerk phase are calculated according to the target displacement and target speed, and the jerk time in the jerk phase is determined according to the jerk time, so that the calculated target speed, jerk, and jerk time are determined. , Uniform acceleration time, target displacement and target speed are used to calculate the instantaneous speed of the stepping motor during the operation phase.
在一实施例中,如图5所示,基于第一实施例或第二实施例提出本发明步进电机控制方法第三实施例,在本实施例中,基于第二实施例进行说明,所述步骤S203,包括:In one embodiment, as shown in FIG. 5, a third embodiment of the stepping motor control method of the present invention is proposed based on the first embodiment or the second embodiment. In this embodiment, the description is based on the second embodiment. The step S203 includes:
步骤S2031,根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度。Step S2031, according to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, respectively calculate the first maximum speed of the jerk phase and the first speed of the uniform acceleration phase 2. Maximum speed.
需要说明是的,根据加加速度和加加速时间计算加加速阶段的第一最大速度,根据加加速度、加加速时间和匀加速时间计算匀加速阶段的第二最大速度,所述第一最大速度为加加速阶段的最大速度,所述第二最大速度为匀加速阶段的最大速度。It should be noted that the first maximum speed in the jerk phase is calculated according to the jerk and the jerk time, and the second maximum speed in the uniform acceleration phase is calculated according to the jerk, the jerk time and the constant acceleration time, and the first maximum speed is The maximum speed in the acceleration phase, and the second maximum speed is the maximum speed in the uniform acceleration phase.
应当理解的是,根据加加速度和加加速时间计算加加速阶段的第一最大速度的公式如下,根据该公式可以精准计算第一最大速度。It should be understood that the formula for calculating the first maximum speed in the jerk phase according to the jerk and the jerk time is as follows, and the first maximum speed can be accurately calculated according to this formula.
Figure PCTCN2019129090-appb-000003
Figure PCTCN2019129090-appb-000003
其中,V 1为加加速阶段的第一最大速度,t J为加加速时间,J P为加加速度。 Among them, V 1 is the first maximum speed in the jerk phase, t J is the jerk time, and J P is the jerk.
根据加加速度、加加速时间和匀加速时间计算匀加速阶段的第二最大速度的公式如下,根据该公式可以精准计算第二最大速度。The formula for calculating the second maximum speed in the uniform acceleration phase 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 this formula.
Figure PCTCN2019129090-appb-000004
Figure PCTCN2019129090-appb-000004
其中,V 2为匀加速阶段的第二最大速度,t J为加加速时间,J P为加加速度。 Among them, V 2 is the second maximum speed in the uniform acceleration stage, t J is the jerk time, and J P is the jerk.
步骤S2032,根据所述加加速度和所述加加速时间计算最大加速度。Step S2032: Calculate the maximum acceleration according to the jerk and the jerk time.
应当理解的是,根据加加速度和加加速时间计算最大加速度的公式如下,根据该公式可以精准计算最大加速度。It should be understood that the formula for calculating the maximum acceleration based on the jerk and the jerk time is as follows, and the maximum acceleration can be accurately calculated according to the formula.
Figure PCTCN2019129090-appb-000005
Figure PCTCN2019129090-appb-000005
其中,a P为最大加速度,t J为加加速时间,J P为加加速度。 Among them, a P is the maximum acceleration, t J is the jerk time, and J P is the jerk.
步骤S2033,根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机 的运行阶段的时刻速度。Step S2033: Calculate the time of the operation phase of the stepping motor according to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration speed.
需要说明的是,根据所述加加速时间确定所述匀加速阶段开始时的第一运行时刻,根据所述第一运行时刻和所述匀加速时间确定所述减加速阶段开始时的第二运行时刻,根据所述加加速度和所述加加速时间计算第一积分常量,根据所述第一积分常量和所述第二最大速度计算第二积分常量,根据所述加加速度、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第一积分常量和所述第二积分常量计算时刻速度。It should be noted that the first operation time at the beginning of the constant acceleration phase is determined according to the acceleration time, and the second operation time at the beginning of the deceleration phase is determined according to the first operation time and the constant acceleration time. At time, the first integral constant is calculated according to the jerk and the jerk time, the second integral constant is calculated according to the first integral constant and the second maximum speed, and the second integral constant is calculated according to the jerk and the jerk time , The first operation time, the second operation time, the first maximum speed, the first integral constant, and the second integral constant calculate the speed at the time.
根据所述加加速时间确定所述匀加速阶段开始时的第一运行时刻,可以理解的是,初始时间为0,加加速时间已由上述步骤计算得出,而加加速阶段为运行阶段的第一阶段,后面紧接着匀加速阶段,因此,根据加加速时间便可得出匀加速阶段开始时的第一运行时刻,将第一运行时刻记为t 1,例如,加加速时间为2S,那么就是说加加速阶段持续了2S后再转为匀加速阶段,即匀加速阶段与第2S开始,即第一运行时刻为第2S。 According to the acceleration time to determine the first operating moment at the beginning of the uniform acceleration phase, it can be understood that the initial time is 0, the acceleration time has been calculated by the above steps, and the acceleration phase is the first operation phase The first stage is followed by the uniform acceleration stage. Therefore, according to the acceleration time, the first operation time at the beginning of the uniform acceleration stage can be obtained. The first operation time is recorded as t 1. For example, the acceleration time is 2S, then That is to say, the acceleration phase lasts for 2S and then changes to the uniform acceleration phase, that is, the uniform acceleration phase starts with the 2nd second, that is, the first running moment is the 2nd second.
根据所述第一运行时刻和所述匀加速时间确定所述减加速阶段开始时的第二运行时刻,可以理解的是,如图3所示,第一运行时刻和匀加速时间已由上述步骤计算得出,匀加速阶段为第二阶段,减加速阶段为第三阶段,因此,根据第一运行时刻和匀加速时间可得出减加速阶段开始时的第二运行时刻,将第二运行时刻记为t 2,例如,加加速时间为2S,匀加速时间与加加速时间相同也为2S,因此,第一运行时刻为第2S,第二运行时刻为第4S。 According to the first operating time and the uniform acceleration time, the second operating time at the beginning of the deceleration phase is determined. It can be understood that, as shown in FIG. 3, the first operating time and the uniform acceleration time have been changed from the above steps. It is calculated that the uniform acceleration stage is the second stage, and the deceleration stage is the third stage. Therefore, according to the first operation time and uniform acceleration time, the second operation time at the beginning of the deceleration stage can be obtained. Denoted as t 2 , for example, the jerk time is 2S, and the uniform acceleration time is the same as the jerk time is also 2S. Therefore, the first running time is 2S and the second running time is 4S.
根据所述加加速度和所述加加速时间计算第一积分常量的公式如下,根据该公式可以精准计算第一积分常量。The formula for calculating the first integral constant according to the jerk and the jerk time is as follows, and the first integral constant can be accurately calculated according to the formula.
Figure PCTCN2019129090-appb-000006
Figure PCTCN2019129090-appb-000006
其中,C 0为第一积分常量,t J为加加速时间,J P为加加速度。 Among them, C 0 is the first integral constant, t J is the jerk time, and J P is the jerk.
根据所述第一积分常量和所述第二最大速度计算第二积分常量的公式如下,根据该公式可以精准计算第二积分常量。The formula for calculating the second integration constant according to the first integration constant and the second maximum speed is as follows, and the second integration constant can be accurately calculated according to the formula.
C 1=V 2-C 0C 1 =V 2 -C 0 ;
其中,C 1为第二积分常量,C 0为第一积分常量,V 2为第二最大速度。 Among them, C 1 is the second integral constant, C 0 is the first integral constant, and V 2 is the second maximum speed.
需要说明的是,本算法中还包括加速过程中的加加速度方程,如下,根 据该方程可以精准计算加加速度。It should be noted that this algorithm also includes the jerk equation in the acceleration process, as follows, according to the equation, the jerk can be accurately calculated.
Figure PCTCN2019129090-appb-000007
Figure PCTCN2019129090-appb-000007
其中,t J为加加速时间,J P为加加速度,t 1为第一运行时刻,t 2为第二运行时刻,t 3为第三运行时刻,所述第三运行时刻为减加速阶段结束时的时刻,t为当前时刻。 Among them, t J is the jerk time, J P is the jerk, t 1 is the first running moment, t 2 is the second running moment, t 3 is the third running moment, and the third running moment is the end of the deceleration phase The moment of time, t is the current moment.
进一步地,还包括加速过程中的加速度方程,如下,根据该方程可以精准计算加速度。Further, it also includes an acceleration equation in the acceleration process, as follows, according to which the acceleration can be accurately calculated.
Figure PCTCN2019129090-appb-000008
Figure PCTCN2019129090-appb-000008
其中,t J为加加速时间,J P为加加速度,t 1为第一运行时刻,t 2为第二运行时刻,t 3为第三运行时刻,a P为最大加速度,t为当前时刻。 Among them, t J is the jerk time, J P is the jerk, t 1 is the first running moment, t 2 is the second running moment, t 3 is the third running moment, a P is the maximum acceleration, and t is the current moment.
进一步地,还包括加速过程的速度方程,如下,根据该方程可以精准计算速度。Further, it also includes the speed equation of the acceleration process, as follows, according to the equation, the speed can be accurately calculated.
Figure PCTCN2019129090-appb-000009
Figure PCTCN2019129090-appb-000009
其中,t J为加加速时间,J P为加加速度,t 1为第一运行时刻,t 2为第二运行时刻,t 3为第三运行时刻,a P为最大加速度,t为当前时刻,V 1为第一最大速度,C 0为第一积分常量,C 1为第二积分常量。 Among them, t J is the jerk time, J P is the jerk, t 1 is the first running moment, t 2 is the second running moment, t 3 is the third running moment, a P is the maximum acceleration, and t is the current moment, V 1 is the first maximum speed, C 0 is the first integral constant, and C 1 is the second integral constant.
因此,将根据上述步骤得出的所述第一积分常量和所述第二最大速度计 算第二积分常量,根据所述加加速度、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第一积分常量和所述第二积分常量代入加速过程的速度方程,便可以计算出时刻速度,即步进电机每一时刻应该保持的速度,根据时刻速度控制步进电机的运转即可使步进电机运行的更平稳。Therefore, the second integral constant will be calculated according to the first integral constant and the second maximum speed obtained in the above steps, and the second integral constant will be calculated according to the jerk, the jerk time, the first operating time, and the first The second running time, the first maximum speed, the first integral constant, and the second integral constant are substituted into the speed equation of the acceleration process to calculate the instantaneous speed, that is, the speed that the stepper motor should maintain at each moment. Controlling the operation of the stepping motor according to the speed at the time can make the stepping motor run more smoothly.
可以理解的是,步进电机的运行阶段还包括减速阶段,加速阶段与减速阶段的过程对称,相应的减速阶段与加速阶段对应,也可通过所述速度方程计算时刻速度,根据时刻速度控制步进电机的减速运转,使步进电机运行的更平稳。It can be understood that the operation phase of a stepper motor also includes a deceleration phase. The acceleration phase and the deceleration phase are symmetrical, and the corresponding deceleration phase corresponds to the acceleration phase. The time speed can also be calculated by the speed equation, and the step speed can be controlled according to the time speed. The decelerated operation of the stepping motor makes the stepping motor run more smoothly.
本实施例中通过根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度;根据所述加加速度和所述加加速时间计算最大加速度;根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机的运行阶段的时刻速度,从而将上述步骤计算出的这些数值代入速度方程计算得出时刻速度,根据时刻速度控制步进电机的运转,使步进电机运行的更平稳。In this embodiment, the first maximum speed of the jerk phase and the uniform acceleration phase are respectively calculated according to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time. Calculate the maximum acceleration according to the jerk and the jerk time; according to the jerk, the jerk time, the constant acceleration time, the first maximum speed, the second The maximum speed and the maximum acceleration calculate the time speed of the stepping motor during the operation phase, so that these values calculated in the above steps are substituted into the speed equation to calculate the time speed, and the stepping motor is controlled according to the time speed to make the step The motor runs more smoothly.
此外,本发明实施例还提出一种存储介质,所述存储介质上存储有步进电机控制程序,所述步进电机控制程序被处理器执行时实现如下操作:In addition, the embodiment of the present invention also provides a storage medium, the storage medium stores a stepping motor control program, and when the stepping motor control program is executed by a processor, the following operations are implemented:
接收上位机的数据指令,所述数据指令包括目标位移和目标速度;Receiving a data instruction from the host computer, the data instruction including a target displacement and a target speed;
根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度;Calculating the instantaneous speed of the stepper motor at each moment in the operation phase according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm;
根据所述时刻速度控制所述步进电机运转。The operation of the stepping motor is controlled according to the speed at the time.
进一步地,所述步进电机控制程序被处理器执行时还实现如下操作:Further, when the stepper motor control program is executed by the processor, the following operations are also implemented:
根据所述目标位移和所述目标速度计算所述步进电机的运行阶段的时刻速度,具体包括:According to the target displacement and the target speed, calculating the instantaneous speed of the stepping motor during the operation phase includes:
根据所述目标位移和所述目标速度计算所述加加速阶段的加加速度和加加速时间;Calculating the jerk and jerk time in the jerk phase according to the target displacement and the target speed;
根据所述加加速时间确定所述匀加速阶段的匀加速时间;Determining the uniform acceleration time of the uniform acceleration stage according to the acceleration time;
根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和 所述匀加速时间计算所述步进电机的运行阶段的时刻速度。According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the time speed of the stepping motor in the operation phase is calculated.
进一步地,所述步进电机控制程序被处理器执行时还实现如下操作:Further, when the stepper motor control program is executed by the processor, the following operations are also implemented:
根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度;According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the first maximum speed in the jerk phase and the second maximum speed in the uniform acceleration phase are respectively calculated ;
根据所述加加速度和所述加加速时间计算最大加速度;Calculating the maximum acceleration according to the jerk and the jerk time;
根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机的运行阶段的时刻速度。According to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration, the time speed of the stepping motor during the operation phase is calculated.
进一步地,所述步进电机控制程序被处理器执行时还实现如下操作:Further, when the stepper motor control program is executed by the processor, the following operations are also implemented:
根据所述加加速度和所述加加速时间计算所述加加速阶段的第一最大速度;Calculating the first maximum speed in the jerk phase according to the jerk and the jerk time;
根据所述加加速度、所述加加速时间和所述匀加速时间计算所述匀加速阶段的第二最大速度。The second maximum speed in the uniform acceleration stage is calculated according to the jerk, the jerk time and the uniform acceleration time.
进一步地,所述步进电机控制程序被处理器执行时还实现如下操作:Further, when the stepper motor control program is executed by the processor, the following operations are also implemented:
根据所述加加速度时间、所述第一运行时间和所述匀加速时间确定所述匀加速阶段开始时的第一运行时刻和所述减加速阶段开始时的第二运行时刻;Determining, according to the jerk time, the first running time, and the constant acceleration time, a first running moment at the beginning of the constant acceleration phase and a second running moment at the beginning of the deceleration phase;
根据所述加加速度值、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第二最大速度所述最大加速度计算所述步进电机的运行阶段的时刻速度。Calculate the stepping motor according to the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, the second maximum speed, the maximum acceleration The speed at the moment of the running phase.
进一步地,所述步进电机控制程序被处理器执行时还实现如下操作:Further, when the stepper motor control program is executed by the processor, the following operations are also implemented:
根据所述加加速时间确定所述匀加速阶段开始时的第一运行时刻;Determining the first operating moment at the beginning of the uniform acceleration phase according to the acceleration time;
根据所述第一运行时刻和所述匀加速时间确定所述减加速阶段开始时的第二运行时刻。The second operating time at the beginning of the deceleration phase is determined according to the first operating time and the uniform acceleration time.
进一步地,所述步进电机控制程序被处理器执行时还实现如下操作:Further, when the stepper motor control program is executed by the processor, the following operations are also implemented:
根据所述加加速度和所述加加速时间计算第一积分常量;Calculating a first integral constant according to the jerk and the jerk time;
根据所述第一积分常量和所述第二最大速度计算第二积分常量;Calculating a second integral constant according to the first integral constant and the second maximum speed;
根据所述加加速度、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第一积分常量和所述第二积分常量计算时刻速度。The time speed is calculated according to the jerk, the jerk time, the first operating time, the second operating time, the first maximum speed, the first integral constant, and the second integral constant.
本实施例中通过接收上位机的数据指令,所述数据指令包括目标位移和目标速度;根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度;,根据所述时刻速度控制所述步进电机运转,从而通过获取的目标位移和目标速度计算时刻速度,根据时刻速度控制步进电机运转,使步进电机运转更加平稳,解决了如何使步进电机平稳运行的技术问题。In this embodiment, by receiving a data instruction from a host computer, the data instruction includes a target displacement and a target speed; according to the target displacement and the target speed, a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase Time speed at each time; to control the operation of the stepping motor according to the time speed, so as to calculate the time speed from the acquired target displacement and target speed, and control the operation of the stepping motor according to the time speed to make the stepping motor run more smoothly, The technical problem of how to make the stepper motor run smoothly is solved.
此外,参照图6,本发明实施例还提出一种步进电机控制装置,所述步进电机控制装置包括:In addition, referring to FIG. 6, an embodiment of the present invention also proposes a stepping motor control device, and the stepping motor control device includes:
数据通讯模块10,用于接收上位机的数据指令,所述数据指令包括目标位移和目标速度;The data communication module 10 is used to receive a data instruction from the upper computer, and the data instruction includes a target displacement and a target speed;
需要说明的是,本实施例的执行主体可为步进电机控制系统的控制模块,还可为其他可实现相同或相似功能的设备,本实施例对此不作限制。It should be noted that the execution body of this embodiment may be a control module of a stepper motor control system, or may be other devices that can implement the same or similar functions, which is not limited in this embodiment.
应当理解的是,用户输入目标位移和目标速度,目标位移和目标速度是用户根据需求设定的两个数值,所述目标速度为步进电机在运行阶段达到的最大速度,对于目标位移和目标速度的数值范围本实施例对此不作限制。It should be understood that the user inputs the target displacement and target speed. The target displacement and target speed are two values set by the user according to requirements. The target speed is the maximum speed reached by the stepper motor during the operation phase. The numerical range of the speed is not limited in this embodiment.
速度计算模块20,用于根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度;The speed calculation module 20 is configured to calculate the instantaneous speed of the stepping motor at each time during the operation phase by using a preset sinusoidal S-curve acceleration algorithm according to the target displacement and the target speed;
需要说明的是,步进电机控制系统的的控制模块以高性能嵌入式处理器为控制核心,其固件内置预设正弦S曲线加速算法,实现电机加减速的平稳可靠,采用处理器的片上SPI外设与电机驱动芯片的通讯,实现对驱动芯片的寄存器读写,从而达到配置驱动芯片参数的目的,本实施例对此不作限制。It should be noted that the control module of the stepper motor control system uses a high-performance embedded processor as the control core, and its firmware has a built-in preset sinusoidal S-curve acceleration algorithm to achieve stable and reliable motor acceleration and deceleration. It uses the processor’s on-chip SPI The communication between the peripheral and the motor drive chip realizes reading and writing of the register of the drive chip, thereby achieving the purpose of configuring the parameters of the drive chip, which is not limited in this embodiment.
应当理解的是,所述预设正弦S曲线加速算法,其加加速度为正弦函数,可连续求导,而梯形、抛物线形加速曲线其加加速度为阶跃函数,存在阶跃 变换,使得电机速度变化不够平稳,而正弦曲线可以避免此问题,正弦曲线较好地符合了步进电机力矩随速度升高而减小的特点,充分利用了电机的有效转矩,同时能够减弱机械冲击。It should be understood that the jerk of the preset sine S-curve acceleration algorithm is a sine function and can be continuously derived, while the jerk of trapezoidal and parabolic acceleration curves is a step function, and there is a step transformation, which makes the motor speed The change is not stable enough, and the sine curve can avoid this problem. The sine curve better conforms to the characteristic that the torque of the stepper motor decreases with the increase of speed, makes full use of the effective torque of the motor, and at the same time can reduce the mechanical shock.
可以理解的是,在获取到的目标位移和目标速度之后,步进电机控制设备通过其内置的预设正弦S曲线加速算法对目标位移和目标速度进行计算,得到步进电机的运行阶段的时刻速度,所述时刻速度为每一时刻的运行速度。It is understandable that after obtaining the target displacement and target speed, the stepper motor control device calculates the target displacement and target speed through its built-in preset sinusoidal S-curve acceleration algorithm to obtain the time of the stepping motor's operation phase Speed, the speed at the moment is the running speed at each moment.
应当理解的是,步进电机的运行阶段包括加速阶段和匀速阶段,加速阶段包括加加速阶段、匀加速阶段和减加速阶段,所述加加速阶段为加速度在不断增加的阶段,所述匀加速阶段为加速度不变的阶段,所述减加速阶段为加速度在不断减少的阶段。It should be understood that the operation phase of a stepper motor includes an acceleration phase and a constant speed phase. The acceleration phase includes an acceleration phase, a uniform acceleration phase, and a deceleration phase. The acceleration phase is a phase in which the acceleration is continuously increasing. The phase is a phase in which the acceleration is constant, and the de-acceleration phase is a phase in which the acceleration is continuously decreasing.
可以理解的是,在本实施例中步进电机的运行阶段的顺序为加加速阶段、匀加速阶段、减加速阶段和匀速阶段,即步进电机开始运行时不断加速,在达到最大速度时(减加速阶段的最大速度),不再继续加速,而是保持最大速度匀速运行。步进电机的速度变化如图3所示,t 0至t 1段为加加速阶段,t 1至t 2段为匀加速阶段,t 2至t 3为减加速阶段,t 3之后为匀速阶段。 It can be understood that the sequence of the operating phases of the stepping motor in this embodiment is the acceleration phase, the uniform acceleration phase, the deceleration phase, and the uniform speed phase, that is, the stepping motor continuously accelerates when it starts to run, and when it reaches the maximum speed ( Decrease the maximum speed in the acceleration phase), and no longer continue to accelerate, but keep the maximum speed at a constant speed. The speed change of the stepping motor is shown in Fig. 3, the period from t 0 to t 1 is the acceleration stage, the period from t 1 to t 2 is the uniform acceleration stage, the period from t 2 to t 3 is the deceleration stage, and the period after t 3 is the uniform speed.
电机控制模块30,用于根据所述时刻速度控制所述步进电机运转。The motor control module 30 is used for controlling the operation of the stepping motor according to the speed at the time.
需要说明的是,现有技术中的步进电机的加速阶段并不稳定,而本实施例中将加速阶段分为加加速阶段、匀加速阶段和减加速阶段,通过正弦速度曲线算法计算出时刻速度,并根据时刻速度控制步进电机运转,以使步进电机的速度按照最佳速度进行提升,以保持其稳定性。It should be noted that the acceleration phase of the stepping motor in the prior art is not stable, and in this embodiment, the acceleration phase is divided into an acceleration phase, a uniform acceleration phase, and a deceleration phase, and the time is calculated by the sinusoidal speed curve algorithm. Speed, and control the operation of the stepping motor according to the speed at the time, so that the speed of the stepping motor is increased at the optimal speed to maintain its stability.
本实施例中通过接收上位机的数据指令,所述数据指令包括目标位移和目标速度,根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度,根据所述时刻速度控制所述步进电机运转,从而通过获取的目标位移和目标速度计算时刻速度,根据时刻速度控制步进电机运转,使步进电机运转更加平稳,解决了如何使步进电机平稳运行的技术问题。In this embodiment, by receiving a data instruction from a host computer, the data instruction includes a target displacement and a target speed. According to the target displacement and the target speed, a preset sinusoidal S-curve acceleration algorithm is used to calculate that the stepping motor is in the running phase. The time speed at each time, the stepping motor is controlled to operate according to the time speed, so that the time speed is calculated by the acquired target displacement and target speed, and the stepping motor is controlled according to the time speed to make the stepping motor run more smoothly. The technical problem of how to make the stepper motor run smoothly.
在一实施例中,所述速度计算模块20,还用于根据所述目标位移和所述目标速度计算所述加加速阶段的加加速度和加加速时间;根据所述加加速时间确定所述匀加速阶段的匀加速时间;根据所述目标位移、所述目标速度、 所述加加速度、所述加加速时间和所述匀加速时间计算所述步进电机的运行阶段的时刻速度。In an embodiment, the speed calculation module 20 is further configured to calculate the jerk and the jerk time in the jerk phase according to the target displacement and the target speed; determine the jerk according to the jerk time Uniform acceleration time in the acceleration phase; calculating the instantaneous speed of the stepping motor during the operation phase according to the target displacement, the target speed, the jerk, the jerk time, and the constant acceleration time.
在一实施例中,所述速度计算模块20,还用于根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度;根据所述加加速度和所述加加速时间计算最大加速度;根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机的运行阶段的时刻速度。In one embodiment, the speed calculation module 20 is further configured to calculate the jerk phase according to the target displacement, the target speed, the jerk, the jerk time, and the constant acceleration time. Calculate the maximum acceleration according to the jerk and the jerk time; calculate the maximum acceleration according to the jerk, the jerk time, the uniform acceleration time, The first maximum speed, the second maximum speed, and the maximum acceleration calculate the instantaneous speed of the stepping motor during the operation phase.
在一实施例中,所述速度计算模块20,还用于根据所述加加速度和所述加加速时间计算所述加加速阶段的第一最大速度;根据所述加加速度、所述加加速时间和所述匀加速时间计算所述匀加速阶段的第二最大速度。In an embodiment, the speed calculation module 20 is further configured to calculate the first maximum speed in the jerk phase according to the jerk and the jerk time; according to the jerk and the jerk time And the uniform acceleration time to calculate the second maximum speed of the uniform acceleration stage.
在一实施例中,所述速度计算模块20,还用于根据所述加加速度时间、所述第一运行时间和所述匀加速时间确定所述匀加速阶段开始时的第一运行时刻和所述减加速阶段开始时的第二运行时刻;根据所述加加速度值、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第二最大速度所述最大加速度计算所述步进电机的运行阶段的时刻速度。In one embodiment, the speed calculation module 20 is further configured to determine the first running time and the total speed at the beginning of the constant acceleration phase according to the jerk time, the first running time, and the constant acceleration time. The second operating time at the beginning of the acceleration phase; according to the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, the second Maximum Speed The maximum acceleration calculates the instantaneous speed of the stepping motor during the operation phase.
在一实施例中,所述速度计算模块20,还用于根据所述加加速时间确定所述匀加速阶段开始时的第一运行时刻;根据所述第一运行时刻和所述匀加速时间确定所述减加速阶段开始时的第二运行时刻。In one embodiment, the speed calculation module 20 is further configured to determine the first operating moment at the beginning of the uniform acceleration phase according to the jerk time; determine according to the first operating time and the uniform acceleration time The second operating moment at the beginning of the deceleration phase.
在一实施例中,所述速度计算模块20,还用于根据所述加加速度和所述加加速时间计算第一积分常量;根据所述第一积分常量和所述第二最大速度计算第二积分常量;根据所述加加速度、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第一积分常量和所述第二积分常量计算时刻速度。In an embodiment, the speed calculation module 20 is further configured to calculate a first integral constant according to the jerk and the jerk time; calculate a second integral constant according to the first integral constant and the second maximum speed Integral constant; calculated according to the jerk, the jerk time, the first operating time, the second operating time, the first maximum speed, the first integral constant and the second integral constant Time speed.
在本发明所述步进电机控制装置的其他实施例或具体实现方法可参照上述各方法实施例,此处不再赘述。For other embodiments or specific implementation methods of the stepping motor control device of the present invention, reference may be made to the foregoing method embodiments, which will not be repeated here.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者 装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that in this article, the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, It also includes other elements not explicitly listed, or elements inherent to the process, method, article, or device. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, article, or device that includes the element.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The sequence numbers of the foregoing embodiments of the present invention are only for description, and do not represent the superiority or inferiority of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个计算机可读存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台智能步进电机控制设备(可以是手机,计算机,步进电机控制设备,空调器,或者网络步进电机控制设备等)执行本发明各个实施例所述的方法。Through the description of the above implementation manners, those skilled in the art can clearly understand that the above-mentioned embodiment method can be implemented by means of software plus the necessary general hardware platform, of course, it can also be implemented by hardware, but in many cases the former is better.的实施方式。 Based on this understanding, the technical solution of the present invention essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a computer-readable storage medium as described above (such as ROM/RAM, magnetic disk, optical disk), including several instructions to make a smart stepper motor control device (can be a mobile phone, computer, stepper motor control device, air conditioner, or network stepper motor control device, etc.) Perform the methods described in the various embodiments of the present invention.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and do not limit the scope of the present invention. Any equivalent structure or equivalent process transformation made by using the content of the description and drawings of the present invention, or directly or indirectly applied to other related technical fields , The same reason is included in the scope of patent protection of the present invention.

Claims (10)

  1. 一种步进电机控制方法,其特征在于,所述步进电机控制包括以下步骤:A stepping motor control method, characterized in that, the stepping motor control includes the following steps:
    接收上位机的数据指令,所述数据指令包括目标位移和目标速度;Receiving a data instruction from the host computer, the data instruction including a target displacement and a target speed;
    根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度;Calculating the instantaneous speed of the stepper motor at each moment in the operation phase according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm;
    根据所述时刻速度控制所述步进电机运转。The operation of the stepping motor is controlled according to the speed at the time.
  2. 如权利要求1所述的步进电机控制方法,其特征在于,所述运行阶段包括加加速阶段、匀加速阶段和减加速阶段;The stepping motor control method according to claim 1, wherein the operation phase includes an acceleration phase, a uniform acceleration phase, and a deceleration phase;
    根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度,具体包括:According to the target displacement and the target speed, calculating the time speed of the stepping motor at each time in the operation phase through a preset sinusoidal S-curve acceleration algorithm, which specifically includes:
    根据所述目标位移和所述目标速度计算所述加加速阶段的加加速度和加加速时间;Calculating the jerk and jerk time in the jerk phase according to the target displacement and the target speed;
    根据所述加加速时间确定所述匀加速阶段的匀加速时间;Determining the uniform acceleration time of the uniform acceleration stage according to the acceleration time;
    根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间计算所述步进电机在运行阶段各时刻的时刻速度。According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the time speed of the stepping motor at each time in the operation phase is calculated.
  3. 如权利要求2所述的步进电机控制方法,其特征在于,所述根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间计算所述步进电机在运行阶段各时刻的时刻速度,具体包括:The stepping motor control method according to claim 2, wherein the step is calculated according to the target displacement, the target speed, the jerk, the jerk time, and the constant acceleration time. The speed of the incoming motor at each time during the operation phase, including:
    根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度;According to the target displacement, the target speed, the jerk, the jerk time, and the uniform acceleration time, the first maximum speed in the jerk phase and the second maximum speed in the uniform acceleration phase are respectively calculated ;
    根据所述加加速度和所述加加速时间计算最大加速度;Calculating the maximum acceleration according to the jerk and the jerk time;
    根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度。According to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, the second maximum speed, and the maximum acceleration, calculate the time speed of the stepping motor at each time during the operation phase .
  4. 如权利要求3所述的步进电机控制方法,其特征在于,所述根据所述目标位移、所述目标速度、所述加加速度、所述加加速时间和所述匀加速时间分别计算所述加加速阶段的第一最大速度和所述匀加速阶段的第二最大速度,具体包括:The stepping motor control method according to claim 3, wherein said calculation of said target displacement, said target speed, said jerk, said jerk time and said constant acceleration time respectively The first maximum speed in the acceleration phase and the second maximum speed in the uniform acceleration phase specifically include:
    根据所述加加速度和所述加加速时间计算所述加加速阶段的第一最大速度;Calculating the first maximum speed in the jerk phase according to the jerk and the jerk time;
    根据所述加加速度、所述加加速时间和所述匀加速时间计算所述匀加速阶段的第二最大速度。The second maximum speed in the uniform acceleration stage is calculated according to the jerk, the jerk time and the uniform acceleration time.
  5. 如权利要求3所述的步进电机控制方法,其特征在于,所述根据所述加加速度、所述加加速时间、所述匀加速时间、所述第一最大速度、所述第二最大速度和所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度,具体包括:The stepping motor control method according to claim 3, wherein the stepping motor control method according to the jerk, the jerk time, the uniform acceleration time, the first maximum speed, and the second maximum speed Calculating the speed of the stepping motor at each time during the operation phase with the maximum acceleration specifically includes:
    根据所述加加速度时间、所述第一运行时间和所述匀加速时间确定所述匀加速阶段开始时的第一运行时刻和所述减加速阶段开始时的第二运行时刻;Determining, according to the jerk time, the first running time, and the constant acceleration time, a first running moment at the beginning of the constant acceleration phase and a second running moment at the beginning of the deceleration phase;
    根据所述加加速度值、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第二最大速度所述最大加速度计算所述步进电机在运行阶段各时刻的时刻速度。Calculate the stepping motor according to the jerk value, the jerk time, the first operating time, the second operating time, the first maximum speed, the second maximum speed, the maximum acceleration The speed at each moment in the operating phase.
  6. 如权利要求5所述的步进电机控制方法,其特征在于,所述根据所述加加速度时间、所述第一运行时间和所述匀加速时间确定所述匀加速阶段开始时的第一运行时刻和所述减加速阶段开始时的第二运行时刻,具体包括:The stepping motor control method according to claim 5, wherein the first operation at the beginning of the uniform acceleration phase is determined according to the jerk time, the first operation time, and the uniform acceleration time The time and the second operating time at the beginning of the deceleration phase specifically include:
    根据所述加加速时间确定所述匀加速阶段开始时的第一运行时刻;Determining the first operating moment at the beginning of the uniform acceleration phase according to the acceleration time;
    根据所述第一运行时刻和所述匀加速时间确定所述减加速阶段开始时的第二运行时刻。The second operating time at the beginning of the deceleration phase is determined according to the first operating time and the uniform acceleration time.
  7. 如权利要求5所述的步进电机控制方法,其特征在于,所述根据所述加加速度值、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第二最大速度所述最大加速度计算所述步进电机在运 行阶段各时刻的时刻速度,具体包括:The stepping motor control method according to claim 5, characterized in that, according to the jerk value, the jerk time, the first operating time, the second operating time, the first The maximum speed and the second maximum speed The maximum acceleration calculation of the time speed of the stepping motor at each time during the operation phase specifically includes:
    根据所述加加速度和所述加加速时间计算第一积分常量;Calculating a first integral constant according to the jerk and the jerk time;
    根据所述第一积分常量和所述第二最大速度计算第二积分常量;Calculating a second integral constant according to the first integral constant and the second maximum speed;
    根据所述加加速度、所述加加速时间、所述第一运行时刻、所述第二运行时刻、所述第一最大速度、所述第一积分常量和所述第二积分常量计算所述步进电机在运行阶段各时刻的时刻速度。Calculate the step according to the jerk, the jerk time, the first operating time, the second operating time, the first maximum speed, the first integral constant and the second integral constant The speed of the incoming motor at each moment in the running phase.
  8. 一种步进电机控制装置,其特征在于,所述步进电机控制装置包括:A stepping motor control device, characterized in that, the stepping motor control device includes:
    数据通讯模块,用于接收上位机的数据指令,所述数据指令包括目标位移和目标速度;The data communication module is used to receive data instructions from the upper computer, the data instructions including target displacement and target speed;
    速度计算模块,用于根据所述目标位移和所述目标速度通过预设正弦S曲线加速算法计算所述步进电机在运行阶段各时刻的时刻速度;A speed calculation module, configured to calculate the instantaneous speed of the stepping motor at each instant in the operation phase according to the target displacement and the target speed through a preset sinusoidal S-curve acceleration algorithm;
    电机控制模块,用于根据所述时刻速度控制所述步进电机运转。The motor control module is used to control the operation of the stepping motor according to the speed at the time.
  9. 一种步进电机控制系统,其特征在于,所述步进电机控制系统包括:控制模块、电源模块、数据存储模块、通信模块、驱动模块、上位机、步进电机及存储在所述数据存储模块上并可在所述控制模块运行的步进电机控制程序,所述步进电机控制程序配置为实现如权利要求1至7中任一项所述的步进电机控制方法的步骤。A stepping motor control system, characterized in that the stepping motor control system includes: a control module, a power supply module, a data storage module, a communication module, a drive module, a host computer, a stepping motor, and the data storage A stepping motor control program on the module that can be run on the control module, and the stepping motor control program is configured to implement the steps of the stepping motor control method according to any one of claims 1 to 7.
  10. 一种存储介质,其特征在于,所述存储介质上存储有步进电机控制程序,所述存储介质上存储有步进电机控制程序,所述步进电机控制程序被处理器执行时实现如权利要求1至7中任一项所述的步进电机控制方法的步骤。A storage medium, characterized in that a stepper motor control program is stored on the storage medium, and a stepper motor control program is stored on the storage medium. When the stepper motor control program is executed by a processor, the The steps of the stepping motor control method described in any one of 1 to 7 are required.
PCT/CN2019/129090 2019-09-02 2019-12-27 Method, apparatus and system for controlling stepping motor, and storage medium WO2021042637A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910826861.8A CN110601617B (en) 2019-09-02 2019-09-02 Stepping motor control method, device and system and storage medium
CN201910826861.8 2019-09-02

Publications (1)

Publication Number Publication Date
WO2021042637A1 true WO2021042637A1 (en) 2021-03-11

Family

ID=68857372

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/129090 WO2021042637A1 (en) 2019-09-02 2019-12-27 Method, apparatus and system for controlling stepping motor, and storage medium

Country Status (2)

Country Link
CN (1) CN110601617B (en)
WO (1) WO2021042637A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110601617B (en) * 2019-09-02 2021-09-17 歌尔股份有限公司 Stepping motor control method, device and system and storage medium
CN111162703B (en) * 2020-01-21 2021-12-31 追觅科技(上海)有限公司 Stepping motor control method, stepping motor control device and storage medium
CN112666996A (en) * 2020-12-18 2021-04-16 广州极飞科技有限公司 Method, device and system for controlling motion state and non-volatile storage medium
CN114884408B (en) * 2022-05-20 2024-04-09 深圳数联天下智能科技有限公司 Method, device, equipment and medium for controlling operation of stepping motor

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4280084A (en) * 1978-01-26 1981-07-21 David Chiang Method of and apparatus for operating stepping motors
CN101997480A (en) * 2009-08-12 2011-03-30 东元电机股份有限公司 Motor control method
CN103713581A (en) * 2013-12-12 2014-04-09 南京工程学院 Method for realizing S curve acceleration and deceleration of motion control system
CN107070329A (en) * 2017-02-20 2017-08-18 武汉科技大学 S type operation curve computational methods and stepper motor method of controlling rotation
CN109991932A (en) * 2017-12-29 2019-07-09 沈阳新松机器人自动化股份有限公司 A kind of logistics haulage equipment S curve acceleration and deceleration speed planning and control method
CN110109490A (en) * 2019-04-16 2019-08-09 浙江工业大学 A kind of adaptive-feedrate adjustment method of stepper motor driving head
CN110109491A (en) * 2019-05-30 2019-08-09 深圳市众为创造科技有限公司 Continuous S curve acceleration and deceleration motion control method, system and electronic equipment
CN110601617A (en) * 2019-09-02 2019-12-20 歌尔股份有限公司 Stepping motor control method, device and system and storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03215194A (en) * 1990-01-17 1991-09-20 Japan Servo Co Ltd Speed controlling method for stepping motor
CN101130413A (en) * 2006-08-22 2008-02-27 西安交通大学 Method for controlling speed increase and reduction of high speed positioning movement of paper pulling device of paper cutter
CN202634356U (en) * 2012-04-13 2012-12-26 深圳众为兴技术股份有限公司 Motor acceleration and deceleration accuracy control device
CN103279069A (en) * 2013-03-25 2013-09-04 昆山天大精益数控科技发展有限公司 Trigonometric function second order continuous derivable acceleration and deceleration algorithm for numerically controlled machine
CN105867376B (en) * 2016-04-12 2018-10-23 南京工程学院 Industrial robot trajectory planning speeding up or down process method based on trigonometric function
CN108287527B (en) * 2017-07-18 2019-02-01 山东大学 A kind of improvement S curve Acceleration-deceleration Control Method based on trigonometric function
CN110134065B (en) * 2019-05-30 2020-08-18 西安交通大学 Machine tool machining track motion planning method based on sine square acceleration forward-looking

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4280084A (en) * 1978-01-26 1981-07-21 David Chiang Method of and apparatus for operating stepping motors
CN101997480A (en) * 2009-08-12 2011-03-30 东元电机股份有限公司 Motor control method
CN103713581A (en) * 2013-12-12 2014-04-09 南京工程学院 Method for realizing S curve acceleration and deceleration of motion control system
CN107070329A (en) * 2017-02-20 2017-08-18 武汉科技大学 S type operation curve computational methods and stepper motor method of controlling rotation
CN109991932A (en) * 2017-12-29 2019-07-09 沈阳新松机器人自动化股份有限公司 A kind of logistics haulage equipment S curve acceleration and deceleration speed planning and control method
CN110109490A (en) * 2019-04-16 2019-08-09 浙江工业大学 A kind of adaptive-feedrate adjustment method of stepper motor driving head
CN110109491A (en) * 2019-05-30 2019-08-09 深圳市众为创造科技有限公司 Continuous S curve acceleration and deceleration motion control method, system and electronic equipment
CN110601617A (en) * 2019-09-02 2019-12-20 歌尔股份有限公司 Stepping motor control method, device and system and storage medium

Also Published As

Publication number Publication date
CN110601617B (en) 2021-09-17
CN110601617A (en) 2019-12-20

Similar Documents

Publication Publication Date Title
WO2021042637A1 (en) Method, apparatus and system for controlling stepping motor, and storage medium
CN100389401C (en) Automatic method for controlling rotate speed of fan
US10632615B2 (en) Servo driving method, apparatus, and robot thereof
US10627805B2 (en) Method, device, and terminal device for servo movement smoothing
WO2015062504A1 (en) Power consumption control method and terminal
US8462111B2 (en) Electronic device providing regulation of backlight brightness and method thereof
RU2624563C2 (en) Operational performance control of the solid-state storages
EP2808656A1 (en) Data acquisition method, device and mobile terminal
KR20170134090A (en) Method for controlling charge for improving receive sensitivity and electronic device for the same
CN104516747A (en) System switching method and electronic device
WO2020108468A1 (en) Method for driving stepper motor, driver thereof, and computer-readable storage medium
US10831255B2 (en) Sequence controller and electronic device
CN107800338B (en) Stepping motor speed increasing and decreasing control method based on FPGA
US9837836B2 (en) Charging method using compensation impedance in CV charging mode
CN109308275B (en) System and method for converting orthogonal coding pulse
CN103543982A (en) Clock frequency management method and mobile device
CN107749949B (en) Camera self-adaption method, camera self-adaption device and electronic equipment
US20140157022A1 (en) Electronic device and method for reducing cpu power consumption
CN106201022A (en) The processing method of a kind of mobile terminal and mobile terminal
CN108462428B (en) Motor speed adjusting method and device, computer readable storage medium and terminal
TW200521648A (en) Method and apparatus for tuning over lock and tuning method for sub-stable state with high performance
EP1405171A1 (en) Method and apparatus to use task priority to scale processor performance
Quinones Applying acceleration and deceleration profiles to bipolar stepper motors
US20210046647A1 (en) Position control method for servo, computer readable storage medium, and robot
CN111555690A (en) Method for controlling vibration displacement of motor, storage medium, and electronic apparatus

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19944396

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19944396

Country of ref document: EP

Kind code of ref document: A1