Servo motor control method, servo motor control system and storage medium

By configuring the comparison register of the PWM timer, the precise acquisition time control of the servo motor phase current and position data is realized, which solves the problem of insufficient acquisition time accuracy in the prior art, improves control performance and reduces jitter.

CN118801760BActive Publication Date: 2025-02-14GUANGDONG JIANGXINCHUANG TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411274210.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2025-02-14
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

In the prior art, the time accuracy of the phase current and position data acquisition of the servo motor is limited by the processing efficiency of the control module, which easily leads to control jitter.

Method used

By configuring the comparison register of the PWM timer, precise control of the acquisition time of phase current and position data is achieved. The specific method includes configuring the first comparison register for outputting the PWM signal, triggering current acquisition through the second comparison register, triggering position information acquisition through the third comparison register, and updating the comparison value of the comparison register based on the collected data.

Benefits of technology

Improves the accuracy of phase current and position data acquisition time, reduces control jitter, and improves the control performance of the servo motor.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118801760B_ABST
    Figure CN118801760B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a control method for a servo motor, a servo motor control system and a storage medium, which belong to the field of motor technology; the method includes configuring a first comparison register, a second comparison register and a third comparison register of a PWM timer and starting the counting of the PWM timer in the current control cycle; triggering a first PWM signal for current acquisition of the servo motor through the second comparison register to obtain phase current data; triggering a second PWM signal for position information acquisition of the servo motor through the third comparison register to obtain the current motor position information; performing current loop calculation according to the phase current data and the motor position information to obtain the PWM duty cycle; updating the PWM duty cycle to the first comparison register so that the first comparison register outputs a third PWM signal to the drive circuit based on the PWM duty cycle within the current control cycle, thereby improving the accuracy of the timing of acquisition of the phase current and position data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of motor technology, and in particular to a servo motor control method, a servo motor control system and a storage medium. Background Art

[0002] When controlling a servo motor, it is necessary to perform a current loop operation on the servo motor, and the current loop operation requires the acquisition of the motor phase current and encoder position data. Among them, the timing control of the acquisition of phase current and position data is closely related to the control performance of the current loop; however, in related technologies, the acquisition of phase current and position data is usually triggered by a control module. At this time, the accuracy of the timing of the acquisition of phase current and position data is limited by the processing efficiency of the control module, which can easily lead to control jitter. Therefore, how to improve the accuracy of the timing of the acquisition of phase current and position data is a technical problem that needs to be solved urgently. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to provide a servo motor control method, a servo motor control system and a storage medium, which can improve the accuracy of the timing of collecting phase current and position data.

[0004] To achieve the above object, a first aspect of an embodiment of the present application provides a method for controlling a servo motor, the method comprising:

[0005] A first comparison register, a second comparison register and a third comparison register of a pulse width modulation (PWM) timer are configured; the first comparison register is used to output a third PWM signal to a driving circuit of a servo motor when the accumulated count of the PWM timer reaches a comparison value in the first comparison register;

[0006] After the first comparison register, the second comparison register and the third comparison register are configured, starting the counting of the PWM timer in the current control cycle;

[0007] The first PWM signal for current acquisition of the servo motor is triggered by the second comparison register to obtain phase current data acquired based on the first PWM signal in the current control cycle;

[0008] The second PWM signal for collecting position information of the servo motor is triggered by the third comparison register to obtain the motor position information collected based on the second PWM signal in the current control cycle;

[0009] Performing current loop calculation according to the phase current data and the motor position information to obtain a PWM duty cycle;

[0010] The PWM duty cycle is updated to the first comparison register, so that the first comparison register outputs a third PWM signal to the driving circuit based on the PWM duty cycle in a current control cycle.

[0011] To achieve the above object, a second aspect of an embodiment of the present application provides a servo motor control system, comprising:

[0012] A PWM timer, wherein an output end of a first comparison register of the PWM timer is connected to a driving circuit of the servo motor, and the first comparison register is used to output a third PWM signal to the driving circuit of the servo motor when the accumulated count of the PWM timer reaches a comparison value in the first comparison register;

[0013] A current acquisition module, wherein a control end of the current acquisition module is connected to an output end of a second comparison register of the PWM timer, and the current acquisition module is used to acquire phase current data of the servo motor;

[0014] A position data acquisition module, wherein a control end of the position data acquisition module is connected to an output end of the third comparison register of the PWM timer, and the position data acquisition module is used to acquire motor position information of the servo motor;

[0015] A control module, wherein the control module executes the method according to claim 1.

[0016] To achieve the above-mentioned purpose, a third aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the control method of the servo motor described in any one of the first aspects is implemented.

[0017] The control method, servo motor control system and storage medium proposed in the present application perform periodic counting by setting a PWM timer, and configure different second comparison registers and third comparison registers for the collection of phase current data and position information, and determine the comparison value of the first comparison register based on the phase current data and motor position information triggered by the second comparison register and the third comparison register, so that the third PWM signal of the control drive circuit can be output by the first comparison register. Therefore, the embodiment of the present application realizes the control of the phase current collection time and the control encoder position information reading time by hardware through the above method, and the phase current, position information and servo motor control are all through the same timer, and the control accuracy is higher. Therefore, compared with the prior art, the embodiment of the present application can improve the accuracy of the phase current and position data collection time. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 is a flow chart of a servo motor control method provided in an embodiment of the present application;

[0019] Figure 2 is a module schematic diagram of a servo motor control system provided in an embodiment of the present application;

[0020] Figure 3 is a control timing diagram of an embodiment of a servo motor control system provided by an embodiment of the present application;

[0021] Figure 4 It is a module diagram of an embodiment of a servo motor control system provided by an embodiment of the present application;

[0022] Figure 5 It is a structural diagram of the hardware structure corresponding to the servo motor control method provided in the embodiment of the present application. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0024] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0025] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0026] First, some nouns involved in this application are analyzed:

[0027] Pulse width modulation, also known as Pulse width modulation, is referred to as PWM.

[0028] Permanent magnet synchronous motor, also known as permanent-magnet synchronous motor, is referred to as PMSM.

[0029] When controlling a servo motor, it is necessary to perform current loop calculation on the servo motor, and the current loop calculation requires the acquisition of the motor phase current and encoder position data. Among them, the timing control of the acquisition of phase current and position data is closely related to the control performance of the current loop; however, in related technologies, the acquisition of phase current and position data is usually triggered by a control module. At this time, the accuracy of the acquisition of phase current and position data is limited by the processing efficiency of the control module, which can easily lead to control jitter. Therefore, how to improve the accuracy of the acquisition of phase current and position data is a technical problem that needs to be solved urgently. Based on this, a control method for a servo motor, a servo motor control system and a storage medium are proposed, which can improve the accuracy of the acquisition of phase current and position data.

[0030] The control method of the servo motor, the servo motor control system and the storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the control method of the servo motor in the embodiments of the present application is described.

[0031] Refer to the following Figure 1 As shown, according to the control method of the servo motor provided in the embodiment of the present application, the control method of the servo motor includes:

[0032] Step S100, configuring a first comparison register, a second comparison register and a third comparison register of a pulse width modulation (PWM) timer; the first comparison register is used to output a third PWM signal to a driving circuit of the servo motor when the accumulated count of the PWM timer reaches a comparison value in the first comparison register;

[0033] Step S200, after the first comparison register, the second comparison register and the third comparison register are configured, start the PWM timer to count in the current control cycle;

[0034] Step S300, triggering a first PWM signal for current acquisition of the servo motor through a second comparison register, and obtaining phase current data acquired based on the first PWM signal in a current control cycle;

[0035] Step S400, triggering a second PWM signal for collecting position information of the servo motor through a third comparison register, and obtaining motor position information collected based on the second PWM signal in a current control cycle;

[0036] Step S500, performing current loop calculation according to phase current data and motor position information to obtain PWM duty cycle;

[0037] Step S600: Update the PWM duty cycle to the first comparison register, so that the first comparison register outputs a third PWM signal to the driving circuit based on the PWM duty cycle in the current control cycle.

[0038] Therefore, by setting the PWM timer for periodic counting, and configuring different second comparison registers and third comparison registers for the collection of phase current data and position information, and determining the comparison value of the first comparison register based on the phase current data and motor position information triggered by the second comparison register and the third comparison register, the third PWM signal of the control drive circuit can be output by the first comparison register. Therefore, the embodiment of the present application realizes the control of the phase current collection time and the control encoder position information reading time by hardware through the above method, and the phase current, position information and servo motor control are all through the same timer, and the control accuracy is higher. Therefore, compared with the prior art, the embodiment of the present application can improve the accuracy of the phase current and position data collection time.

[0039] The PWM timer determines the carrier frequency of the current loop control of the servo motor. In some embodiments, the PWM frequency is set to 8kHz~20kHz, and the PWM timer can be set to 20kHz. At this time, a control cycle of the motor current loop control is 50us. In each control cycle, the loop control of the current loop needs to obtain phase current data and obtain motor position information from the encoder. When the count value of the PWM timer reaches the comparison value B of the second comparison register, a PWM_TRGB pulse will be generated, and the PWM_TRGB pulse can be used to trigger the current acquisition module corresponding to the phase current data to work. When the count value of the PWM timer reaches the comparison value C of the third comparison register, a pulse PWM_TRGC signal will also be generated, and the PWM_TRGC signal will be used to trigger the reading of the motor position information of the position encoder. Among them, the phase current data and the motor position information will be transmitted to the control module (such as MCU) for current loop calculation, and the calculation result is the PWM duty cycle, which will be updated to the first comparison register, so as to generate a complementary PWM signal through the first comparison register to control the operation of the servo motor. In some embodiments, the first comparison register will generate three pairs of complementary PWM signals.

[0040] In the embodiment of the present application, the PWM timer needs to be able to cover the current loop carrier frequency range and the count is symmetrical within a control cycle, that is, it increases first and then decreases. Those skilled in the art can selectively set the model of the PWM timer according to actual needs, and the embodiment of the present application does not impose too many restrictions.

[0041] The PWM timer started in step S200 counts in the current control cycle, which means that the count starts from 0.

[0042] The current acquisition in step S300 can be performed by an ADC circuit. Taking the current acquisition using an ADC circuit as an example, the first PWM signal enables the ADC circuit to perform current acquisition. The phase current data records the phase current of the current control cycle, and the phase current data includes the current of at least one phase.

[0043] The motor position information in step S400 can send a position query instruction to the encoder of the servo motor to obtain the motor position information. The second PWM signal can enable the sending of the position query instruction.

[0044] In the current regulation process, the current loop first calculates the deviation between the given current value and the actual measured value. This deviation reflects the difference between the actual current value and the expected value. Based on this deviation, the current regulator will make corresponding adjustments based on the control algorithm to reduce the deviation and make the output current follow the given current. The calculation and adjustment of the PWM duty cycle is based on the output result of the control algorithm. By adjusting the ratio of the high level time to the entire cycle time, the output signal can be controlled. Therefore, the PWM duty cycle can be obtained through the current loop calculation.

[0045] ‌PWM duty cycle indicates the duration of a high level in a control cycle. The present application embodiment does not limit how the PWM duty cycle refreshes the comparison value of the first comparison register, and those skilled in the art can selectively set it according to actual needs. In some embodiments, the third PWM signal is a three-phase differential complementary PWM signal, such as Figure 2 As shown, PWM0A and PWM0B are a pair of differential complementary signals, PWM1A and PWM1B are a pair of differential complementary signals, and PWM2A and PWM2B are another pair of differential complementary signals. By controlling the PWM duty cycle, the output timing of each pair of differential complementary signals can be adjusted, thereby achieving control of the current loop output.

[0046] Each control cycle will re-count and execute steps S300 to S600.

[0047] It is understandable that the comparison value of the third comparison register is smaller than the comparison value of the second comparison register, and the comparison value of the third comparison register is determined by the following steps:

[0048] Get the encoder delay data of the servo motor;

[0049] The comparison value of the third comparison register is determined according to the encoder delay data and the comparison value of the second comparison register, so that the position information and the phase current data are acquired synchronously.

[0050] The encoder delay data is the delay time from when the encoder receives the query instruction to when it feeds back the query result. The comparison value of the second comparison register can be subtracted from the encoder delay data, and the comparison value of the third comparison register can be determined based on the result of the subtraction, such as using the result of the subtraction as the comparison value of the third comparison register. Based on the encoder delay data, when there is a delay in the encoder's query interface, the motor position information and phase current data can be guaranteed to be the data obtained at the same time as much as possible.

[0051] It is understandable that, in order to implement a complete control loop, the servo motor drive often also needs to convert the position data into a frequency-divided orthogonal signal. And the closed-loop control of the servo motor is performed based on the feedback frequency-divided orthogonal signal. The homogenization of the frequency-divided orthogonal signal has a great relationship with the timing control of the motor position data acquisition. Therefore, in some embodiments, the method also includes:

[0052] Configure the frequency division period of the orthogonal frequency division timer, wherein the orthogonal frequency division timer restarts counting when the cumulative count of the PWM timer reaches the comparison value of the third comparison register;

[0053] Obtaining a position frequency-divided pulse signal, wherein the position frequency-divided pulse signal is obtained by frequency-dividing the pulse signal based on the motor position information after the orthogonal frequency-divided timer times out;

[0054] The servo motor is controlled in a closed loop according to the position frequency-divided pulse signal.

[0055] Therefore, by associating the third comparison register with the orthogonal frequency division timer, a frequency division orthogonal signal will be generated after each motor position data collection, and the orthogonal frequency division timer is used to ensure that the frequency division processing is performed only after the motor position data is collected, thereby ensuring that the frequency division orthogonal signal is synchronized with the motor position information and phase current collection.

[0056] Reference Figure 2 As shown, a servo motor control system provided according to an embodiment of the present application includes:

[0057] A PWM timer, wherein an output end of a first comparison register of the PWM timer is connected to a driving circuit of the servo motor, and the first comparison register is used to output a third PWM signal to the driving circuit when the accumulated count of the PWM timer reaches a comparison value in the first comparison register;

[0058] A current acquisition module, wherein a control end of the current acquisition module is connected to an output end of a second comparison register of a PWM timer, and the current acquisition module is used to acquire phase current data of a servo motor;

[0059] A position data acquisition module, wherein a control end of the position data acquisition module is connected to an output end of the third comparison register of the PWM timer, and the position data acquisition module is used to acquire motor position information of the servo motor;

[0060] A control module executes the control method of the servo motor.

[0061] The servo motor is integrated with an encoder, which provides an interface to query the motor position information.

[0062] The control module may include an MCU, a PLC or other devices (such as a host computer), etc. In this regard, the embodiment of the present application does not limit it, for example, an MCU may be included to perform current loop calculation.

[0063] For example, refer to Figure 2 and Figure 3 As shown, after the PWM timer is started, when the cumulative count of the PWM timer reaches the comparison value B of the second comparison register, the current acquisition module is triggered to collect current and upload the collected current to the MCU. When the cumulative count of the PWM timer reaches the comparison value C of the third comparison register, the position data acquisition module is triggered to collect the motor position information and upload the motor position information to the MCU. When the cumulative count of the PWM timer reaches the comparison value A of the first comparison register, the third PWM signal is triggered.

[0064] Understandably, referring to Figure 3 As shown, the current acquisition module includes two queue control submodules and analog-to-digital converters corresponding to the queue control submodules one by one; the two analog-to-digital converters are respectively connected to the two phase current output ends of the driving circuit; the queue control submodule is used to cache the data sampled by the corresponding analog-to-digital converter.

[0065] The queue control submodule can be configured as a memory with a storage function. In this regard, the embodiment of the present application does not impose too many restrictions on the model of the memory. Figure 3 As shown, the two queue submodules are queue control 0 and queue control 1. The analog-to-digital converter corresponding to queue control 0 is ADC0; the analog-to-digital converter corresponding to queue control 1 is ADC1. The drive circuit provides three-phase current to the servo motor, which are U, V, and W. The two analog-to-digital converters ADC0 and ADC1 are respectively connected to the U-phase current output terminal and the V-phase current output terminal of the drive circuit.

[0066] Understandably, referring to Figure 3As shown, the position data acquisition module includes an encoder protocol conversion submodule and a position command processing submodule. The position command processing submodule is used to generate a position query command; the encoder protocol conversion submodule is used to adapt the position query command according to the model of the encoder of the servo motor; the position command processing submodule is also used to receive the motor position information corresponding to the adapted position query command.

[0067] By setting different encoder protocol conversion submodules, different servo motors can be adapted. For example, Figure 3 As shown, the second PWM signal (i.e., PWM_TRGC in the figure) triggers the sending of the position query command. The position query command is adapted by the encoder protocol conversion submodule and outputs the position query command recognized by the currently connected servo motor to the servo motor. The servo motor returns the motor position information to the encoder protocol conversion submodule. The encoder protocol conversion submodule converts the motor position information returned by the servo motor into motor position information that can be recognized by the MCU and uploads it to the MCU.

[0068] Understandably, referring to Figure 3 As shown, the servo motor control system also includes:

[0069] A frequency division module, the input of the frequency division module is connected to the position data acquisition module and the output of the third comparison register, the output of the frequency division module is connected to the control module, and the frequency division module is used to divide the motor position information and output a position frequency division pulse signal when the cumulative count of the PWM timer reaches the comparison value of the third comparison register.

[0070] In some embodiments, the divided frequency pulse signal controls the servo motor via a PLC chip, and accordingly, the control module includes a PLC chip. In other embodiments, the divided frequency pulse signal controls the servo motor via other terminals, and accordingly, the control module includes other terminal devices.

[0071] Understandably, referring to Figure 3 As shown, the frequency division module includes an orthogonal frequency division timer and a frequency division calculation submodule. The input of the orthogonal frequency division timer is connected to the output of the third comparison register, and the output of the orthogonal frequency division timer is connected to the frequency division calculation submodule. The orthogonal frequency division timer restarts the counting when the cumulative count of the PWM timer reaches the comparison value of the third comparison register. The frequency division calculation submodule is used to distribute and process the motor position information and output it when the orthogonal frequency division timer times out.

[0072] Exemplarily, in some embodiments, the frequency division module further includes a position data acquisition module to cache the motor position information collected by the position data collection module.

[0073] The embodiment of the present application does not restrict the specific frequency division process of the frequency division calculation submodule, and those skilled in the art can selectively set it according to actual needs. For example, it can be based on the technology of timer and phase-locked loop; this method generates speed information and position information through the original signal of the encoder through calculation, and the phase-locked loop follows the position signal at a certain response speed. The timer generates a pair of centrally symmetrical PWM signals, and the frequency division output signal generated by phase shifting is sampled by the orthogonal pulse interface of the second timer to form a negative feedback closed loop, thereby realizing variable integer frequency division output.

[0074] For example, refer to Figure 3 and Figure 4 Describe the servo motor control system of the embodiment of the present application, such as Figure 3 As shown, the servo motor control system includes a PWM timer, a current acquisition module, a position data acquisition module, a frequency division module and a control module; the control module includes an MCU and a PLC. The PWM timer is provided with three comparison registers, namely, a first comparison register, a second comparison register and a third comparison register. The comparison value A0 / 1 / 2 set in the first comparison register indicates that a three-phase differential complementary PWM signal can be generated to realize the output control of the duty cycle of the PWM signal output to the drive circuit. The comparison value B in the second comparison register indicates that a PWM_TRGB signal is generated when the count value of the PWM timer reaches the comparison value B. This signal is used to generate a trigger analog-to-digital converter to collect two-phase currents, such as Figure 3 As shown, it can support the simultaneous triggering of two ADCs (i.e., ADC0 and ADC1), ensuring the correctness of the current loop front-end acquisition. When the count value of the PWM timer reaches the comparison C value, the PWM_TRGC signal is generated to generate a trigger position encoder to send an encoder command and read position data. Among them, the encoder interface supports the pulse trigger interface to send and receive commands.

[0075] For the current acquisition module, such as Figure 3 As shown, two queue control submodules (i.e., queue control 0 and queue control 1) are used to sample the motor phase currents of two ADCs (ADC0 and ADC1) at the same time. Therefore, the queue control submodule can be triggered in real time through the PWM_TRGB trigger signal to send a sampling signal to the ADC, and the data is saved in time after the ADC completes the sampling conversion, and the sampled current data is reported to the MCU.

[0076] For the location data acquisition module, such as Figure 3As shown, the position data acquisition module includes position query command sending, motor position information receiving and encoder protocol conversion submodules. The PWM_TRGC signal regularly initiates the sending of position query commands, and sends a physical signal adapted to the timing of the external motor position encoder through the encoder protocol conversion submodule, and receives and parses the motor position information of the position encoder. Therefore, the motor position information automatically triggered and parsed by the hardware each time can be reported to the MCU in a timely manner on the one hand, and can be provided to the orthogonal frequency division output module on the other hand. Therefore, the position data acquisition module can improve the stability of the motor position information acquisition and further improve the accuracy of the speed loop speed measurement of the servo motor control by using the trigger signal generated by the hardware, compared with the acquisition of the encoder position data generated by the software control.

[0077] For the frequency division module, such as Figure 3 As shown, at the moment when PWM_TRGC arrives, the orthogonal frequency division timer will synchronize to 0 and start counting. At the same time, it will obtain the motor position information collected in the position data acquisition module for frequency division calculation and output. The period setting of the frequency division timer can be configured through the hardware register, so that it can flexibly follow the change of the PWM timer period value and adapt to more different scenarios; and after each acquisition of the motor position information, it will pass through the frequency division calculation submodule to calculate the position difference in the current control cycle, and calculate the corresponding number of pulses according to the frequency division ratio. The obtained number of pulses is converted into a correct orthogonal pulse signal and finally sent to the PLC. Therefore, after the frequency division module is controlled by the above hardware, it can ensure that the frequency division module is synchronized with the reading of the motor position information, so that each change of the motor position information can correspond to a position frequency division output, avoiding the situation where the number of frequency division output pulses is 0, thereby ensuring the uniformity of the frequency division output.

[0078] When controlling the servo motor, Figure 4 As shown, the PWM counter of the PWM timer performs statistics periodically. In each control cycle, the count of the PWM counter is set in pairs. Figure 4 Take the two control cycles in the example, in the first control cycle, when the PWM counter counts up to the comparison value C, the second comparison timer is triggered to generate the PWM_TRAGB pulse signal, which in turn triggers Figure 3 The current acquisition module performs synchronous acquisition of the two-phase circuit. When the PWM counter counts cumulatively to the comparison value A, the first comparison register is triggered to continuously generate three pairs of complementary third PWM signals. When the PWM counter counts cumulatively to the comparison value B, the third comparison register is triggered to generate the PWM_TRAGC pulse signal, thereby making Figure 3In the position data acquisition module and the frequency division module, the position data acquisition module starts to collect the motor position information, and the orthogonal frequency division timer of the frequency division module starts counting again from 0. After the position data acquisition module collects the motor position information, the frequency division calculation submodule performs frequency division calculation, so that the orthogonal pulse group 1 is continuously generated during the time period from the generation of the PWM_TRAGC pulse signal in the first control cycle to the generation of the PWM_TRAGC pulse signal in the second control cycle. At the same time, the comparison value A of the first comparison register is updated based on the phase current data and the motor position information in the first control cycle. In the first control cycle, when the count of the PWM counter drops to less than the comparison value A, the high level signal is stopped from being output.

[0079] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the control method of the servo motor when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0080] See also Figure 5 , Figure 5 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0081] The processor 301 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0082] The memory 302 may be a NAND flash, and the relevant program code is stored in the memory 302, and is called by the processor 301 to execute the control method of the servo motor according to the embodiment of the present application;

[0083] Input / output interface 303, used to implement information input and output;

[0084] Communication interface 304, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0085] A bus 305 that transmits information between the various components of the device (e.g., the processor 301, the memory 302, the input / output interface 303, and the communication interface 304);

[0086] The processor 301 , the memory 302 , the input / output interface 303 and the communication interface 304 are connected to each other in communication within the device via the bus 305 .

[0087] An embodiment of the present application further provides a computer-readable storage medium, which is a computer-readable storage medium that stores a computer program. When the computer program is executed by a processor, the control method of the servo motor is implemented.

[0088] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0089] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0090] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0091] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0092] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0093] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0094] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0095] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0097] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0098] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0099] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A servo motor control method, characterized in that: The method comprises: A first comparison register, a second comparison register and a third comparison register of a pulse width modulation (PWM) timer are configured; the first comparison register is used to output a third PWM signal to a driving circuit of a servo motor when the accumulated count of the PWM timer reaches a comparison value in the first comparison register; Configuring a frequency division period of an orthogonal frequency division timer, wherein the orthogonal frequency division timer restarts counting when the cumulative count of the PWM timer reaches the comparison value of the third comparison register; After the first comparison register, the second comparison register and the third comparison register are configured, starting the counting of the PWM timer in the current control cycle; The first PWM signal for current acquisition of the servo motor is triggered by the second comparison register to obtain phase current data acquired based on the first PWM signal in the current control cycle; The second PWM signal for collecting position information of the servo motor is triggered by the third comparison register to obtain the motor position information collected based on the second PWM signal in the current control cycle; Performing current loop calculation according to the phase current data and the motor position information to obtain a PWM duty cycle; updating the PWM duty cycle to the first comparison register, so that the first comparison register outputs a third PWM signal to the driving circuit based on the PWM duty cycle in a current control cycle; Acquire a position frequency-divided pulse signal, wherein the position frequency-divided pulse signal is obtained by frequency-dividing the position pulse signal based on the motor position information after the orthogonal frequency-divided timer times out; The servo motor is closed-loop controlled according to the position frequency-divided pulse signal.

2. The servo motor control method according to claim 1, characterized in that: The comparison value of the third comparison register is smaller than the comparison value of the second comparison register, and the comparison value of the third comparison register is determined by the following steps: Obtaining encoder delay data of the servo motor; The comparison value of the third comparison register is determined according to the encoder delay data and the comparison value of the second comparison register, so that the position information and the phase current data are acquired synchronously.

3. A servo motor control system, characterized in that: include: A PWM timer, wherein an output end of a first comparison register of the PWM timer is connected to a driving circuit of the servo motor, and the first comparison register is used to output a third PWM signal to the driving circuit of the servo motor when the accumulated count of the PWM timer reaches a comparison value in the first comparison register; A current acquisition module, wherein a control end of the current acquisition module is connected to an output end of a second comparison register of the PWM timer, and the current acquisition module is used to acquire phase current data of the servo motor; A position data acquisition module, wherein a control end of the position data acquisition module is connected to an output end of the third comparison register of the PWM timer, and the position data acquisition module is used to acquire motor position information of the servo motor; A control module, wherein the control module executes the method according to claim 1; A frequency division module, wherein the input of the frequency division module is connected to the output of the position data acquisition module and the third comparison register, the output of the frequency division module is connected to the control module, the frequency division module includes an orthogonal frequency division timer and a frequency division calculation submodule, the input of the orthogonal frequency division timer is connected to the output of the third comparison register, the output of the orthogonal frequency division timer is connected to the frequency division calculation submodule, the orthogonal frequency division timer restarts counting when the cumulative count of the PWM timer reaches the comparison value of the third comparison register, and the frequency division calculation submodule is used to distribute, process and output the motor position information when the orthogonal frequency division timer times out.

4. The servo motor control system according to claim 3, characterized in that: The current acquisition module includes two queue control sub-modules and analog-to-digital converters corresponding to the queue control sub-modules one by one; the two analog-to-digital converters are respectively connected to the two phase current output ends of the drive circuit; the queue control sub-module is used to cache the data sampled by the corresponding analog-to-digital converter.

5. The servo motor control system according to claim 3, characterized in that: The servo motor is integrated with an encoder; the position data acquisition module includes an encoder protocol conversion submodule and a position command processing submodule, the position command processing submodule is used to generate a position query command; the encoder protocol conversion submodule is used to adapt the position query command according to the model of the encoder; the position command processing submodule is also used to receive the motor position information corresponding to the adapted position query command.

6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the servo motor control method according to any one of claims 1 to 2 is implemented.

Citation Information

Patent Citations

  • Improved MSMU hardware current loop and control method

    CN116961511A