Motor driving method and device and motion control system

文档序号:1864397 发布日期:2021-11-19 浏览:23次 中文

阅读说明:本技术 电机的驱动方法、装置和运动控制系统 (Motor driving method and device and motion control system ) 是由 刘丹 宋明岑 马徐武 吴信宜 莫玉麟 于 2021-09-01 设计创作,主要内容包括:本申请提供了一种电机的驱动方法、装置和运动控制系统,该驱动方法包括:获取电机的目标转速和目标步数;根据目标转速和目标步数,确定第一时间和第一周期,第一时间为目标步数和第一周期的乘积;控制模拟定时器以第一周期和预设占空比分别作为周期和占空比,运行第一时间生成第一PWM脉冲信号;根据第一PWM脉冲信号控制电机运行。该驱动方法通过模拟定时器生成上述第一PWM脉冲信号,来控制电机运行,即通过软件算法实现电机控制,开放性摆脱了硬件的限值,解决了现有技术中电机的控制受限于硬件的问题。(The application provides a motor driving method, a motor driving device and a motion control system, wherein the driving method comprises the following steps: acquiring a target rotating speed and a target step number of a motor; determining a first time and a first period according to the target rotating speed and the target steps, wherein the first time is the product of the target steps and the first period; controlling an analog timer to operate for the first time to generate a first PWM pulse signal by respectively taking a first period and a preset duty ratio as the period and the duty ratio; and controlling the motor to operate according to the first PWM pulse signal. The driving method generates the first PWM pulse signal through the analog timer to control the motor to run, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor in the prior art is limited by the hardware is solved.)

1. A method of driving a motor, comprising:

acquiring a target rotating speed and a target step number of a motor;

determining a first time and a first period according to the target rotating speed and the target steps, wherein the first time is the product of the target steps and the first period;

controlling an analog timer to operate the first time to generate a first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio;

and controlling the motor to operate according to the first PWM pulse signal.

2. The method of claim 1, wherein controlling the operation of the motor according to the first PWM pulse signal comprises:

determining a control module in communication connection with the motor according to a motor driving configuration file, wherein the control module comprises a pulse width modulator and/or a timer, and the motor driving configuration file at least comprises connection relation information of the motor and the control module;

and controlling the control module to send the first PWM pulse signal to the motor.

3. The method of claim 1, wherein after controlling the operation of the motor according to the first PWM pulse signal, the method further comprises:

under the condition that the motor is in an enabling state and the driving mode is the automatic mode, calculating second time according to the frequency of the motor, wherein the second time is the time for prolonging the operation of the simulation timer to make up the number of unfinished steps of the motor;

controlling the analog timer to operate for the second time to generate a second PWM pulse signal by respectively taking the first period and the preset duty ratio as a period and a duty ratio;

and controlling the motor to operate according to the second PWM pulse signal.

4. The method of claim 1, wherein after controlling the operation of the motor according to the first PWM pulse signal, the method further comprises:

under the condition that the motor is in an enabling state and a driving mode is a manual mode, acquiring the actual movement steps of the motor;

under the condition that the actual movement step number is smaller than the target step number, calculating second time according to the frequency of the motor, wherein the second time is the time for prolonging the operation of the simulation timer to make up the number of unfinished steps of the motor;

controlling the analog timer to operate for the second time to generate a second PWM pulse signal by respectively taking the first period and the preset duty ratio as a period and a duty ratio;

and controlling the motor to operate according to the second PWM pulse signal.

5. The method of claim 4, wherein after controlling the operation of the motor according to the first PWM pulse signal, the method further comprises:

and under the condition that the motor is in a de-enabling state or the actual movement step number is greater than or equal to the target step number, adjusting the driving mode of the motor to an automatic mode without restarting the simulation timer, and controlling the motor to stop running.

6. The method according to any one of claims 1 to 5, wherein before controlling the operation of the motor according to the first PWM pulse signal, the method further comprises:

and clearing the actual motion steps of the motor.

7. The method according to any one of claims 1 to 5, wherein before controlling the operation of the motor according to the first PWM pulse signal, the method comprises:

sending an enable signal to the motor.

8. A drive device of a motor, characterized by comprising:

the acquiring unit is used for acquiring a target rotating speed and a target step number of the motor;

a determining unit, configured to determine a first time and a first period according to the target rotation speed and the target number of steps, where the first time is a product of the target number of steps and the first period;

the first control unit is used for controlling the analog timer to operate the first time to generate a first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio;

and the second control unit is used for controlling the motor to operate according to the first PWM pulse signal.

9. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a stored program, wherein the program performs the method of any one of claims 1 to 7.

10. A processor, characterized in that the processor is configured to run a program, wherein the program when running performs the method of any of claims 1 to 7.

11. A motion control system comprising an electric motor and a drive for the electric motor, characterized in that the drive for the electric motor is adapted to perform the method of any of claims 1 to 7.

12. The system of claim 11, wherein the driving device of the motor is a driver chip, and the analog timer is installed in a kernel of an operating system of the driver chip.

13. The system of claim 12, wherein the driver chip comprises a pulse width modulator and/or a timer, the pulse width modulator and/or the timer being in communication with the corresponding motor, the pulse width modulator and/or the timer being configured to send a PWM pulse signal to the motor to control the operation of the motor.

Technical Field

The present application relates to the field of motor control technologies, and in particular, to a method and an apparatus for driving a motor, a computer-readable storage medium, a processor, and a motion control system.

Background

A traditional motion control system generally adopts a PLC to control a motor in a pulse mode, the mode has low efficiency, cannot meet the requirement of high real-time requirement, and the cost of the PLC equipment is high compared with that of embedded equipment. The PLC device does not consider the problem of network security, and as more and more industrial products access the internet, it becomes more and more important to prevent the network products from being attacked.

The above information disclosed in this background section is only for enhancement of understanding of the background of the technology described herein and, therefore, certain information may be included in the background that does not form the prior art that is already known in this country to a person of ordinary skill in the art.

Disclosure of Invention

The present application mainly aims to provide a method and an apparatus for driving a motor, a computer-readable storage medium, a processor, and a motion control system, so as to solve the problem that the control of the motor is limited by hardware in the prior art.

According to an aspect of an embodiment of the present invention, there is provided a driving method of a motor, including: acquiring a target rotating speed and a target step number of a motor; determining a first time and a first period according to the target rotating speed and the target steps, wherein the first time is the product of the target steps and the first period; controlling an analog timer to operate the first time to generate a first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio; and controlling the motor to operate according to the first PWM pulse signal.

Optionally, controlling the motor to operate according to the first PWM pulse signal includes: determining a control module in communication connection with the motor according to a motor driving configuration file, wherein the control module comprises a pulse width modulator and/or a timer, and the motor driving configuration file at least comprises connection relation information of the motor and the control module; and controlling the control module to send the first PWM pulse signal to the motor.

Optionally, after controlling the motor to operate according to the first PWM pulse signal, the method further includes: under the condition that the motor is in an enabling state and the driving mode is the automatic mode, calculating second time according to the frequency of the motor, wherein the second time is the time for prolonging the operation of the simulation timer to make up the number of unfinished steps of the motor; controlling the analog timer to operate for the second time to generate a second PWM pulse signal by respectively taking the first period and the preset duty ratio as a period and a duty ratio; and controlling the motor to operate according to the second PWM pulse signal.

Optionally, after controlling the motor to operate according to the first PWM pulse signal, the method further includes: under the condition that the motor is in an enabling state and a driving mode is a manual mode, acquiring the actual movement steps of the motor; under the condition that the actual movement step number is smaller than the target step number, calculating second time according to the frequency of the motor, wherein the second time is the time for prolonging the operation of the simulation timer to make up the number of unfinished steps of the motor; controlling the analog timer to operate for the second time to generate a second PWM pulse signal by respectively taking the first period and the preset duty ratio as a period and a duty ratio; and controlling the motor to operate according to the second PWM pulse signal.

Optionally, after controlling the motor to operate according to the first PWM pulse signal, the method further includes: and under the condition that the motor is in a de-enabling state or the actual movement step number is greater than or equal to the target step number, adjusting the driving mode of the motor to an automatic mode without restarting the simulation timer, and controlling the motor to stop running.

Optionally, before controlling the motor to operate according to the first PWM pulse signal, the method further includes: and clearing the actual motion steps of the motor.

Optionally, before controlling the motor to operate according to the first PWM pulse signal, the method includes: sending an enable signal to the motor.

According to another aspect of the embodiments of the present invention, there is also provided a driving apparatus of a motor, including: the acquiring unit is used for acquiring a target rotating speed and a target step number of the motor; a determining unit, configured to determine a first time and a first period according to the target rotation speed and the target number of steps, where the first time is a product of the target number of steps and the first period; the first control unit is used for controlling the analog timer to operate the first time to generate a first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio; and the second control unit is used for controlling the motor to operate according to the first PWM pulse signal.

According to still another aspect of embodiments of the present invention, there is also provided a computer-readable storage medium including a stored program, wherein the program executes any one of the methods.

According to another aspect of the embodiments of the present invention, there is also provided a processor, configured to execute a program, where the program executes any one of the methods.

According to a further aspect of the embodiments of the present invention, there is also provided a motion control system, comprising a motor and a driving device of the motor, the driving device of the motor being configured to perform any one of the methods.

Optionally, the driving device of the motor is a driving chip, and the analog timer is installed in a kernel of an operating system of the driving chip.

Optionally, the driving chip includes a pulse width modulator and/or a timer, the pulse width modulator and/or the timer is in communication connection with the corresponding motor, and the pulse width modulator and/or the timer is configured to send a PWM pulse signal to the motor to control the motor to operate.

In an embodiment of the present invention, in the above method for driving a motor, first, a target rotation speed and a target number of steps of the motor are obtained; then, according to the target rotating speed and the target step number, determining a first time and a first period, wherein the first time is the product of the target step number and the first period; then, controlling an analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as a period and a duty ratio; and finally, controlling the motor to operate according to the first PWM pulse signal. The driving method controls the motor to run by generating the first PWM pulse signal through the analog timer, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor is limited by the hardware in the prior art is solved.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the application and, together with the description, serve to explain the application and are not intended to limit the application. In the drawings:

fig. 1 shows a flow chart of a method of driving an electric machine according to an embodiment of the present application;

FIG. 2 shows a flow diagram of an analog timer operation according to an embodiment of the present application;

FIG. 3 shows a schematic view of a drive arrangement of a motor according to an embodiment of the present application;

FIG. 4 shows a schematic diagram of a motion control system according to an embodiment of the present application.

Detailed Description

It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.

In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be used. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.

It will be understood that when an element such as a layer, film, region, or substrate is referred to as being "on" another element, it can be directly on the other element or intervening elements may also be present. Also, in the specification and claims, when an element is described as being "connected" to another element, the element may be "directly connected" to the other element or "connected" to the other element through a third element.

For convenience of description, some terms or expressions referred to in the embodiments of the present application are explained below:

PWM: pulse width modulation, i.e., pulse width modulation;

hrtimer: a high resolution timer, namely a high-precision timer provided by the kernel;

eHRPWM: enhanced High Resolution Pulse Width Modulator, i.e. Enhanced High precision Pulse Width Modulator.

As mentioned in the background of the invention, in order to solve the above problems, in the related art, in which control of a motor is limited to hardware, in an exemplary embodiment of the present application, a driving method of a motor, an apparatus, a computer-readable storage medium, a processor, and a motion control system are provided.

According to an embodiment of the present application, there is provided a driving method of a motor.

Fig. 1 is a flowchart of a driving method of a motor according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:

step S101, acquiring a target rotating speed and a target step number of a motor;

step S102, determining a first time and a first period according to the target rotating speed and the target step number, wherein the first time is the product of the target step number and the first period;

step S103, controlling an analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as a period and a duty ratio;

and step S104, controlling the motor to operate according to the first PWM pulse signal.

In the driving method of the motor, firstly, the target rotating speed and the target step number of the motor are obtained; then, according to the target rotating speed and the target step number, determining a first time and a first period, wherein the first time is the product of the target step number and the first period; then, controlling an analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as a period and a duty ratio; and finally, controlling the motor to operate according to the first PWM pulse signal. The driving method controls the motor to run by generating the first PWM pulse signal through the analog timer, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor is limited by the hardware in the prior art is solved.

It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than presented herein.

In an embodiment of the present application, controlling the motor to operate according to the first PWM pulse signal includes: determining a control module in communication connection with the motor according to a motor driving configuration file, wherein the control module comprises a pulse width modulator and/or a timer, and the motor driving configuration file at least comprises connection relation information of the motor and the control module; and controlling the control module to send the first PWM pulse signal to the motor. Specifically, a motor drive configuration file is inquired, a control module in communication connection with the motor is determined, and a first PWM pulse signal is sent to the motor through the corresponding control module.

In an embodiment of the present application, as shown in fig. 2, after controlling the operation of the motor according to the first PWM pulse signal, the method further includes: under the condition that the motor is in an enabling state and the driving mode is the automatic mode, calculating a second time according to the frequency of the motor, wherein the second time is the time for prolonging the operation of the analog timer to make up the number of unfinished steps of the motor; controlling the analog timer to operate for the second time to generate a second PWM pulse signal by respectively taking the first period and the preset duty ratio as a period and a duty ratio; and controlling the motor to operate according to the second PWM pulse signal. Specifically, the driving mode is an automatic mode without PWM pulse signalThe control motor can also automatically run, the motor can not finish the target number of steps after the current control process is finished, in this case, in order to avoid the automatic running of the motor, the simulation timer needs to be restarted quickly, the running time of the simulation timer is prolonged to make up for the number of unfinished steps, the second time is calculated, namely the time for prolonging the running time of the simulation timer to make up for the number of unfinished steps of the motor is calculated, and the second time t2The calculation formula is t2=t1-t1f1T, wherein T1For the first time, f1And the frequency of the motor is T is a first period, then the analog timer is automatically restarted to carry out the next control flow, the analog timer prolongs the second operation time to generate a second PWM pulse signal, and the motor is controlled to operate by the second PWM pulse signal, so that the motor finishes the number of unfinished steps of the previous control flow.

In an embodiment of the present application, as shown in fig. 2, after controlling the operation of the motor according to the first PWM pulse signal, the method further includes: acquiring the actual movement steps of the motor under the condition that the motor is in an enabling state and the driving mode is a manual mode; calculating a second time according to the frequency of the motor when the actual number of steps is less than the target number of steps, wherein the second time is the time for the analog timer to extend to compensate the number of unfinished steps of the motor; controlling the analog timer to operate for the second time to generate a second PWM pulse signal by respectively taking the first period and the preset duty ratio as a period and a duty ratio; and controlling the motor to operate according to the second PWM pulse signal. Specifically, the driving mode is a manual mode, no PWM pulse signal is used for control, the motor does not run automatically, after the current control process is completed, the motor may not complete the target number of steps, the simulation timer does not need to be restarted quickly, the actual number of steps of the motor is obtained to determine whether the motor does not complete the target number of steps, if the motor does not complete the target number of steps, the second time is calculated, that is, the time for the simulation timer to extend the running time to compensate the number of steps of the motor that are not complete is calculated, and the second time t is calculated2Formula for calculationIs t2=t1-t1f1T, wherein T1For the first time, f1And the frequency of the motor is T is a first period, then the analog timer is automatically restarted to carry out the next control flow, the analog timer prolongs the second operation time to generate a second PWM pulse signal, and the motor is controlled to operate by the second PWM pulse signal, so that the motor finishes the number of unfinished steps of the previous control flow.

In an embodiment of the present application, as shown in fig. 2, after controlling the operation of the motor according to the first PWM pulse signal, the method further includes: and under the condition that the motor is in a de-enabling state or the actual movement step number is greater than or equal to the target step number, adjusting the driving mode of the motor to an automatic mode without restarting the simulation timer, and controlling the motor to stop running. Specifically, when the motor is in the disable state, the motor cannot be controlled to operate by a PWM pulse signal, the actual number of moving steps is greater than or equal to the target number of steps, which indicates that the target number of steps is completed, and the operation time does not need to be extended to compensate for the number of unfinished steps.

In an embodiment of the present application, before controlling the motor to operate according to the first PWM pulse signal, the method further includes: and resetting the actual motion step number of the motor. Specifically, before controlling the motor to operate each time, the actual motion step number of the motor is cleared, so that the inaccuracy of judging whether the target step number is finished or not caused by data superposition is avoided, and the accurate control of the motor is ensured.

In an embodiment of the present application, before controlling the motor to operate according to the first PWM pulse signal, the method includes: an enable signal is sent to the motor. Specifically, before controlling the motor to operate each time, an enable signal is sent to the motor to ensure the motor to be enabled, and the motor can be controlled to operate through a PWM pulse signal.

The embodiment of the present application further provides a driving apparatus of a motor, and it should be noted that the driving apparatus of a motor according to the embodiment of the present application may be used to execute the driving method for a motor according to the embodiment of the present application. The following describes a driving device of a motor according to an embodiment of the present application.

Fig. 3 is a schematic view of a driving apparatus of a motor according to an embodiment of the present application. As shown in fig. 3, the apparatus includes:

an acquisition unit 10 for acquiring a target rotation speed and a target step number of the motor;

a determining unit 20, configured to determine a first time and a first period according to the target rotation speed and the target number of steps, where the first time is a product of the target number of steps and the first period;

a first control unit 30, configured to control the analog timer to operate the first time to generate the first PWM pulse signal, with the first period and a preset duty ratio as a period and a duty ratio, respectively;

and a second control unit 40 for controlling the operation of the motor according to the first PWM pulse signal.

In the driving device of the motor, an acquisition unit acquires a target rotating speed and a target step number of the motor; a determining unit for determining a first time and a first period according to the target rotating speed and the target step number, wherein the first time is the product of the target step number and the first period; the first control unit controls the analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio; and the second control unit controls the motor to operate according to the first PWM pulse signal. The driving device generates the first PWM pulse signal through the analog timer to control the operation of the motor, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor is limited by the hardware in the prior art is solved.

In an embodiment of the present application, the second control unit includes a determining module and a first control module, where the determining module is configured to determine a control module communicatively connected to the motor according to a motor driving profile, the first control module includes a pulse width modulator and/or a timer, and the motor driving profile at least includes connection relationship information between the motor and the control module; the control module is used for controlling the control module to send the first PWM pulse signal to the motor. Specifically, a motor drive configuration file is inquired, a control module in communication connection with the motor is determined, and a first PWM pulse signal is sent to the motor through the corresponding control module.

In an embodiment of the present application, as shown in fig. 2, the apparatus further includes a third control unit, where the third control unit includes a first calculating module, a second control module and a third control module, where the first calculating module is configured to calculate a second time according to a frequency of the motor when the motor is in an enabled state and a driving mode is an automatic mode after controlling the motor to operate according to the first PWM pulse signal, and the second time is a time that the analog timer needs to extend an operation to compensate for an incomplete number of steps of the motor; the second control module is used for controlling the analog timer to operate for the second time to generate a second PWM pulse signal by respectively taking the first period and the preset duty ratio as a period and a duty ratio; and the third control module is used for controlling the motor to operate according to the second PWM pulse signal. Specifically, the driving mode is an automatic mode, the motor can automatically operate without being controlled by a PWM pulse signal, and the motor may not complete the target number of steps after the current control process is completedTwo times, namely, the time for the analog timer to extend the running time to compensate the number of unfinished steps of the motor is calculated, and the second time t2The calculation formula is t2=t1-t1f1T, wherein T1For the first time, f1And the frequency of the motor is T is a first period, then the analog timer is automatically restarted to carry out the next control flow, the analog timer prolongs the second operation time to generate a second PWM pulse signal, and the motor is controlled to operate by the second PWM pulse signal, so that the motor finishes the number of unfinished steps of the previous control flow.

In an embodiment of the present application, as shown in fig. 2, the apparatus further includes a fourth control unit, where the fourth control unit includes an obtaining module, a second calculating module, a fourth control module, and a fifth control module, where the obtaining module is configured to obtain an actual number of movement steps of the motor when the motor is in an enabled state and a driving mode is a manual mode after the motor is controlled to operate according to the first PWM pulse signal; the second calculating module is configured to calculate a second time according to the frequency of the motor when the actual number of moving steps is smaller than the target number of steps, where the second time is a time required for the analog timer to extend to compensate for the number of unfinished steps of the motor; the fourth control module is configured to control the analog timer to operate for the second time to generate a second PWM pulse signal, with the first period and the preset duty ratio as a period and a duty ratio, respectively; and the fifth control module is used for controlling the motor to operate according to the second PWM pulse signal. Specifically, the driving mode is a manual mode, no PWM pulse signal is used for control, the motor does not run automatically, after the current control process is completed, the motor may not complete the target number of steps, the simulation timer does not need to be restarted quickly, the actual number of steps of the motor is obtained to determine whether the motor does not complete the target number of steps, if the motor does not complete the target number of steps, the second time is calculated, that is, the time for the simulation timer to extend the running time to compensate the number of steps of the motor that are not complete is calculated, and the second time t is calculated2The calculation formula is t2=t1-t1f1T, wherein T1For the first time, f1And the frequency of the motor is T is a first period, then the analog timer is automatically restarted to carry out the next control flow, the analog timer prolongs the second operation time to generate a second PWM pulse signal, and the motor is controlled to operate by the second PWM pulse signal, so that the motor finishes the number of unfinished steps of the previous control flow.

In an embodiment of the present application, as shown in fig. 2, the apparatus further includes a fifth control unit, and the fifth control unit is configured to, after controlling the motor to operate according to the first PWM pulse signal, adjust a driving mode of the motor to an automatic mode without restarting the analog timer and control the motor to stop operating when the motor is in an disable state or the actual number of movement steps is greater than or equal to the target number of movement steps. Specifically, when the motor is in the disable state, the motor cannot be controlled to operate by a PWM pulse signal, the actual number of moving steps is greater than or equal to the target number of steps, which indicates that the target number of steps is completed, and the operation time does not need to be extended to compensate for the number of unfinished steps.

In an embodiment of the application, the apparatus further includes a processing unit, and the processing unit is configured to zero an actual number of steps of the motor before controlling the motor to operate according to the first PWM pulse signal. Specifically, before controlling the motor to operate each time, the actual motion step number of the motor is cleared, so that the inaccuracy of judging whether the target step number is finished or not caused by data superposition is avoided, and the accurate control of the motor is ensured.

In an embodiment of the present application, the apparatus further includes a sending unit, where the sending unit is configured to send an enable signal to the motor before controlling the motor to operate according to the first PWM pulse signal. Specifically, before controlling the motor to operate each time, an enable signal is sent to the motor to ensure the motor to be enabled, and the motor can be controlled to operate through a PWM pulse signal.

An embodiment of the present application further provides a motion control system, as shown in fig. 4, where the motion control system includes a motor and a driving device of the motor, and the driving device of the motor is configured to perform any one of the above methods.

The motion control system comprises a motor and a driving device of the motor, and an acquisition unit acquires a target rotating speed and a target step number of the motor; a determining unit for determining a first time and a first period according to the target rotating speed and the target step number, wherein the first time is the product of the target step number and the first period; the first control unit controls the analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio; and the second control unit controls the motor to operate according to the first PWM pulse signal. The driving device generates the first PWM pulse signal through the analog timer to control the operation of the motor, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor is limited by the hardware in the prior art is solved.

In an embodiment of the present application, the driving device of the motor is a driving chip, and the analog timer is installed in a kernel of an operating system of the driving chip. Specifically, as shown in fig. 4, the driver chip is Am5728, and is composed of 1.5GHz dual ARM Cortex-a15, 750MHz floating point dual DSP C66x, dual cotex M4, and the like, the CPU performance is high, the operating system of Am5728 is a Linux-RT system, the system applies an open source RT PREEMPT mechanism, adjusts and tests the Linux-RT kernel to which RT PREEMPT patches are added, and increases the certainty and real-time of system response, the analog timer is installed in the kernel of the operating system of the driver chip, the accuracy of the analog timer can reach 2MHz, and the control of the motor can reach us-level accuracy.

In an embodiment of the application, the driving chip includes a pulse width modulator and/or a timer, the pulse width modulator and/or the timer is in communication connection with the corresponding motor, and the pulse width modulator and/or the timer is configured to send a PWM pulse signal to the motor to control the motor to operate. Specifically, as shown in fig. 4, Am5728 provides 6 enhanced high precision pulse width modulators ehrpms, an ehrpms interface outputs a PWM pulse that can control the operation of the motor, and at most 6 motors are connected, Am5728 also includes 16 timers, and the timers output PWM pulses, control the motor, and at most 9 motors are connected, and the PWM pulses are finally output no matter the ehrpms interface and/or the timer interface.

It should be noted that, as shown in fig. 4, am5728 has very rich GPIO resources, and up to 256 GPIO interfaces, GPIO can be used to control various signals, sensors, indicator lights, and the like, and an encryption chip is externally connected through the I2C interface for data encryption and decryption operations.

The drive device of the motor comprises a processor and a memory, the acquisition unit, the determination unit, the first control unit, the second control unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.

The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the problem that the control of the motor is limited by hardware in the prior art is solved by adjusting kernel parameters.

The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.

An embodiment of the present invention provides a computer-readable storage medium on which a program is stored, which when executed by a processor implements the above-described method.

The embodiment of the invention provides a processor, which is used for running a program, wherein the method is executed when the program runs.

The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein when the processor executes the program, at least the following steps are realized:

step S101, acquiring a target rotating speed and a target step number of a motor;

step S102, determining a first time and a first period according to the target rotating speed and the target step number, wherein the first time is the product of the target step number and the first period;

step S103, controlling an analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as a period and a duty ratio;

and step S104, controlling the motor to operate according to the first PWM pulse signal.

The device herein may be a server, a PC, a PAD, a mobile phone, etc.

The present application further provides a computer program product adapted to perform a program of initializing at least the following method steps when executed on a data processing device:

step S101, acquiring a target rotating speed and a target step number of a motor;

step S102, determining a first time and a first period according to the target rotating speed and the target step number, wherein the first time is the product of the target step number and the first period;

step S103, controlling an analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as a period and a duty ratio;

and step S104, controlling the motor to operate according to the first PWM pulse signal.

In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.

In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

The integrated unit may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a computer-readable storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned computer-readable storage media comprise: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.

From the above description, it can be seen that the above-described embodiments of the present application achieve the following technical effects:

1) in the motor driving method, firstly, a target rotating speed and a target step number of a motor are obtained; then, according to the target rotating speed and the target step number, determining a first time and a first period, wherein the first time is the product of the target step number and the first period; then, controlling an analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as a period and a duty ratio; and finally, controlling the motor to operate according to the first PWM pulse signal. The driving method controls the motor to run by generating the first PWM pulse signal through the analog timer, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor is limited by the hardware in the prior art is solved.

2) In the motor driving device, an acquisition unit acquires a target rotating speed and a target step number of a motor; a determining unit for determining a first time and a first period according to the target rotating speed and the target step number, wherein the first time is the product of the target step number and the first period; the first control unit controls the analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio; and the second control unit controls the motor to operate according to the first PWM pulse signal. The driving device generates the first PWM pulse signal through the analog timer to control the operation of the motor, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor is limited by the hardware in the prior art is solved.

3) The motion control system comprises a motor and a driving device of the motor, and an acquisition unit acquires a target rotating speed and a target step number of the motor; a determining unit for determining a first time and a first period according to the target rotating speed and the target step number, wherein the first time is the product of the target step number and the first period; the first control unit controls the analog timer to operate the first time to generate the first PWM pulse signal by respectively taking the first period and a preset duty ratio as the period and the duty ratio; and the second control unit controls the motor to operate according to the first PWM pulse signal. The driving device generates the first PWM pulse signal through the analog timer to control the operation of the motor, namely, the motor control is realized through a software algorithm, the limitation value of hardware is eliminated openly, and the problem that the control of the motor is limited by the hardware in the prior art is solved.

The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种跨运车车载取力发电控制系统

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!