Stepping motor pulse output control test method and structure
Through the pulse width modulation module of the digital signal processor and the orthogonal coded pulse module, combined with the acceleration and deceleration algorithm, the flexibility and precision of the pulse output control of stepper motors are achieved, and the problems of high costs and large resource occupation in the existing technology are solved.
Patent Information
- Application Number
- CN202411374734.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-05-13
AI Technical Summary
In the prior art, stepper motor pulse output control costs are high, occupies a large amount of processor resources, and changes the frequency requires re-initialization of the timer, which cannot be modified during the process.
Through the pulse width modulation module and the orthogonal coded pulse module of the digital signal processor, the pulse number output control of the stepper motor is accurately realized, and the frequency of the pulse width modulation module is controlled by using the S-curve algorithm or trapezoidal acceleration and deceleration algorithm, and the pulse frequency and acceleration are dynamically adjusted.
It realizes pulse output control with low cost, low resource occupancy and flexible frequency adjustment, meets the needs of various working conditions and improves the precision and efficiency of motor control.
Smart Images

Figure CN119995415A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of pulse control of stepper motors, and in particular to a stepper motor pulse output control test method and structure. Background Art
[0002] As a control motor, the stepper motor has an input signal of an electrical pulse signal and an output of an angular displacement. It is an important component in the automation control system. The angular speed and running step length of the stepper motor depend on the input pulse frequency and the number of pulses. In open-loop control, the number of pulses input to the motor can be calculated by the displacement, and the motor can run to the predetermined position by outputting the accurate number of pulses. At present, the frequency and number of pulse outputs are generally controlled by the processing unit plus programmable logic, or by using the processor's general input and output interface (GPIO) plus a timer. The former is sent by the processor, and the programmable logic is responsible for controlling the pulse output. This method occupies a lot of resources and has a high implementation cost. The latter uses the processor's timer, which sets a fixed timing time. In the timer interrupt, the GPIO is set high or low to achieve pulse output. This method occupies a lot of processor resources, and the timer needs to be reinitialized to change the frequency. The timer timing cannot be modified during the process, which is inconvenient to use. Summary of the invention
[0003] In order to overcome the defects of the above-mentioned prior art, the purpose of the present invention is to provide a stepper motor pulse output control test method and structure to solve the technical problems in the prior art that the cost is high, a large amount of processor resources are occupied, and the frequency needs to be changed. The timer needs to be re-initialized and the timing of the timer needs to be modified, and the modification cannot be made during the process.
[0004] The present invention is achieved through the following technical solutions: In a first aspect, the present invention provides a stepper motor pulse output control test method, comprising the following steps: Initializing and setting a digital signal processor, wherein the digital signal processor includes a peripheral pulse width modulation module, a first orthogonal coding pulse module, and a second orthogonal coding pulse module; Based on the initialized digital signal processor, the number of output pulses of the pulse width modulation module is calculated according to the displacement required for the stepping motor to run; Set the effective position comparison register of the first orthogonal encoding pulse module to the number of pulse outputs; The pulse width modulation module is started according to the obtained number of output pulses of the pulse width modulation module, and the frequency of the pulse width modulation module is controlled according to the S-curve algorithm or the trapezoidal acceleration and deceleration algorithm. When the first orthogonal encoding pulse module initiates an interrupt, the output of the pulse width modulation module is stopped in the interrupt service program, and the encoder data is collected through the second orthogonal encoding pulse module to calculate the displacement information of the stepper motor, and the stepper motor pulse number test is realized through the displacement information.
[0005] Preferably, the specific process of initializing the digital signal processor is as follows: Set the duty cycle of the pulse width modulation module to 50%; Setting the working mode of the first orthogonal encoding pulse module to the direction counting mode; Set the working mode of the second orthogonal encoding pulse module to the orthogonal counting mode.
[0006] Preferably, after the pulse width modulation module is started, the frequency of the pulse width modulation module is controlled according to the acceleration and deceleration algorithm combined with the number of output pulses of the pulse width modulation module.
[0007] Furthermore, the acceleration / deceleration algorithm adopts an S-curve algorithm or a trapezoidal acceleration / deceleration algorithm.
[0008] Preferably, the mechanism for the first orthogonal coding pulse module to initiate an interrupt is that the first orthogonal coding pulse module initiates an interrupt when it detects that the data in the current position counter value register is equal to the data in the set effective position comparison register.
[0009] Furthermore, the specific process of initiating an interrupt when the first orthogonal encoding pulse module detects that the data in the current position counter value register is equal to the data in the set effective position comparison register is as follows: The output of the pulse width modulation module is connected to the first orthogonal coding pulse module and the driving circuit respectively, that is, the output of the pulse width modulation module is the input of the first orthogonal coding pulse module. When the pulse width modulation module has an output, the first orthogonal coding pulse module starts counting, and the count value is stored in the position counter value register. At the same time, the first orthogonal coding pulse module compares the data of the current position counter value register with the data in the set effective position comparison register to see if they are equal. When the values of the two are equal, the first orthogonal coding pulse module initiates an interrupt.
[0010] Preferably, the encoder is a displacement sensor of the motor, and the displacement of the stepper motor acquired by the encoder is used to implement the test of the number of pulses output by the pulse width modulation module.
[0011] In a second aspect, the present invention provides a stepper motor pulse output control test structure, which is used to implement the stepper motor pulse output control test method described above, and the stepper motor pulse output control test structure includes a digital signal processor, a drive circuit and a stepper motor; The output end of the digital signal processor is connected to the input end of the drive circuit, and the output end of the drive circuit is connected to the input end of the stepper motor; an encoder is arranged on the stepper motor; and the output end of the encoder is connected to the input end of the digital signal processor.
[0012] Further, the digital signal processor includes a peripheral pulse width modulation module, a first orthogonal coding pulse module and a second orthogonal coding pulse module; The output end of the pulse width modulation module is connected to the input end of the driving circuit and the first orthogonal coding pulse module respectively; The output end of the encoder is connected to the input end of the second orthogonal encoding pulse module.
[0013] Compared with the prior art, the present invention has the following beneficial technical effects: The present invention provides a stepper motor pulse output control test method, which accurately realizes the pulse number output control of the stepper motor based on the peripheral pulse width modulation module and the orthogonal encoding pulse module of the digital signal processor. Only one digital signal processor is needed to realize the control of the pulse number and frequency. Due to the characteristics of the motor itself, in order to control the smooth operation of the motor, it is often necessary to control the motor operation according to a certain acceleration and deceleration algorithm. The pulse number output control method proposed by the present invention is not limited by the frequency change of the pulse width modulation module, and can also output the set number of pulses when the frequency of the pulse width modulation module changes. The method is simple in design and low in cost. In addition, after configuration, the digital signal processor can control the pulse width modulation module to output a specified number of pulses without too much involvement, occupying less processor resources, and the processor can focus on the calculation and processing of the stepper motor control algorithm and other applications.
[0014] Furthermore, the pulse width modulation module and orthogonal encoding module of the digital signal processor can accurately generate a specified number of pulses, which is critical for stepper motor applications that require precise position control. The flexible adjustment of the pulse width modulation module frequency allows the motor to run at different speeds to meet the needs of various working conditions. Based on real-time feedback, including motor position or speed information obtained through the orthogonal encoding pulse module, the pulse frequency and acceleration are dynamically adjusted to achieve more refined control. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a flow chart of the stepping motor pulse output control test method in the present invention; Figure 2It is a schematic diagram of the stepping motor pulse output control test structure in the present invention; In the figure: 1-digital signal processor; 2-driving circuit; 3-stepping motor; 4-encoder; 11-pulse width modulation module; 12-first orthogonal encoding pulse module; 13-second orthogonal encoding pulse module. DETAILED DESCRIPTION
[0016] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0017] The present invention is further described in detail below in conjunction with the accompanying drawings: The purpose of the present invention is to provide a stepper motor pulse output control test method and structure to solve the technical problems in the prior art that the cost is high, a large amount of processor resources are occupied, and the timer needs to be re-initialized to change the frequency, the timing of the timer needs to be modified, and the modification cannot be made during the process.
[0018] Example 1 See also Figure 1 In one embodiment of the present invention, a stepper motor pulse output control test method is provided, comprising the following steps: Initialize and set the digital signal processor 1, wherein the digital signal processor 1 includes a peripheral pulse width modulation module 11, a first orthogonal coding pulse module 12 and a second orthogonal coding pulse module 13; The number of output pulses of the pulse width modulation module 11 is calculated based on the initialized digital signal processor 1 and the displacement required by the stepping motor 3; Set the effective position comparison register of the first orthogonal encoding pulse module 12 to the number of pulse outputs; The pulse width modulation module 11 is started according to the obtained number of output pulses of the pulse width modulation module 11, and the frequency of the pulse width modulation module is controlled according to the S-curve algorithm or the trapezoidal acceleration and deceleration algorithm. When the first orthogonal encoding pulse module 12 initiates an interrupt, the output of the pulse width modulation module 11 is stopped in the interrupt service program, and the data of the encoder 4 is collected and the displacement information of the stepper motor 3 is calculated through the second orthogonal encoding pulse module 13, and the stepper motor pulse number test is realized through the displacement information.
[0019] Specifically, the specific process of initializing the digital signal processor 1 is as follows: Set the duty cycle of the pulse width modulation module to 50%; Setting the working mode of the first orthogonal encoding pulse module to the direction counting mode; Set the working mode of the second orthogonal encoding pulse module to the orthogonal counting mode.
[0020] In this embodiment, the pulse width modulation module controls the speed of the stepper motor by generating a periodic signal with a specified duty cycle. The frequency of the pulse width modulation module 11 determines the average voltage or current received by the motor in each cycle, thereby controlling the speed of the motor.
[0021] The orthogonal encoding pulse module detects the rotation direction and position of the motor by receiving the A and B phase signals of the encoder. In the direction counting mode, the orthogonal encoding pulse module collects the number of pulses; while in the orthogonal counting mode, the orthogonal encoding pulse module collects the displacement of the encoder 4.
[0022] Specifically, after the pulse width modulation module 11 is started, the frequency of the pulse width modulation module 11 is controlled according to the acceleration and deceleration algorithm combined with the number of output pulses of the pulse width modulation module 11 .
[0023] In this embodiment, after the pulse width modulation module 11 is started, the frequency of the pulse width modulation module 11 is controlled according to the number of pulse outputs and the acceleration and deceleration algorithm, and combined with the required number of pulse outputs, a dynamic motor speed control process is actually implemented. The specific working principle is as follows: Initialization settings: First, according to the specifications of the motor and the requirements of the control system, the pulse width modulation module 11 is initialized, including setting parameters such as the initial frequency and duty cycle.
[0024] Start the PWM module 11: The pulse width modulation module 11 is enabled to start generating the pulse width modulation module 11 signal. At this time, the frequency and duty cycle of the pulse width modulation module 11 signal can be set to an initial value, which should correspond to the speed of the motor when it starts.
[0025] Acceleration and deceleration algorithm: Write or use an existing acceleration / deceleration algorithm (such as S-curve, linear acceleration / deceleration, etc.), which calculates the speed that the motor should reach in the next time period based on the motor's target speed, current speed, acceleration / deceleration and other parameters.
[0026] The acceleration and deceleration algorithm will output a speed instruction, which needs to be converted into a frequency value that can be understood by the pulse width modulation module 11.
[0027] Control the frequency of the pulse width modulation module 11: According to the speed command calculated by the acceleration and deceleration algorithm, the frequency of the pulse width modulation module 11 is dynamically adjusted. The frequency of the pulse width modulation module 11 is proportional to the rotation speed of the motor. Therefore, by changing the frequency of the pulse width modulation module 11, the speed of the motor can be controlled.
[0028] If the acceleration / deceleration algorithm requires the motor to accelerate, the frequency of the pulse width modulation module 11 is increased; if deceleration is required, the frequency of the pulse width modulation module 11 is reduced.
[0029] Pulse output number control: The control of the number of pulse outputs is usually related to the position control of the motor. In a stepper motor, each pulse represents a step angle of the motor. Therefore, by controlling the number of pulses of the pulse width modulation module 11 signal, the rotation angle or position of the motor can be controlled.
[0030] When the motor reaches the target position or speed, when the count of the first orthogonal encoding pulse module 12 reaches the set value, an interrupt will be triggered. In the interrupt service program, the pulse width modulation module 11 will stop generating the pulse width modulation module 11 signal, and the stepper motor 3 will stop accordingly.
[0031] Specifically, the mechanism for the first orthogonal coding pulse module 12 to initiate an interrupt is that the first orthogonal coding pulse module 12 initiates an interrupt when it detects that the data in the current position counter value register is equal to the data in the set effective position comparison register.
[0032] The specific process is as follows: The output of the pulse width modulation module 11 is connected to the first orthogonal coding pulse module 12 and the driving circuit 2 respectively, that is, the output of the pulse width modulation module 11 is the input of the first orthogonal coding pulse module 12. When the pulse width modulation module 11 has an output, the first orthogonal coding pulse module 12 starts counting, and the count value is stored in the position counter value register. At the same time, the first orthogonal coding pulse module 12 compares the data of the current position counter value register with the data in the set effective position comparison register to see if they are equal. When the values of the two are equal, the first orthogonal coding pulse module 12 initiates an interrupt.
[0033] Specifically, the encoder 4 is a displacement sensor of the motor, and the displacement of the stepper motor 3 acquired by the encoder 4 is used to implement the test of the number of pulses output by the pulse width modulation module 11 .
[0034] In summary, the present invention provides a stepper motor pulse output control test method, which uses a digital signal processor's peripheral pulse width modulation module 11 and an orthogonal coding pulse module to accurately implement the pulse number output control of the stepper motor. The output of the pulse width modulation module 11 is connected to the first orthogonal coding pulse module 12 and the drive circuit. The first orthogonal coding pulse module 12 is set to a direction counting mode, counts the pulses output by the pulse width modulation module 11, and sets the value of the effective position comparison register to the number of output pulses. When the count value accumulates to the set number of pulses, the first orthogonal coding pulse module 12 initiates an interrupt, and at this time, the pulse width modulation module 11 is stopped to output and realize the pulse number output control. Changing the frequency of the pulse width modulation module 11 can realize the control of the pulse frequency. An encoder is arranged at the output end of the motor, and the data of the encoder is collected to obtain the displacement of the stepper motor, so as to test the accuracy of the pulse output control. The method is simple in design and saves costs. It can realize the precise control of pulse output with only one digital signal processor.
[0035] Example 2 This embodiment provides a stepper motor pulse output control test structure, which is used to implement the stepper motor pulse output control test method described above. The stepper motor pulse output control test structure includes a digital signal processor 1, a drive circuit 2 and a stepper motor 3; The output end of the digital signal processor 1 is connected to the input end of the drive circuit 2, and the output end of the drive circuit 2 is connected to the input end of the stepper motor 3; an encoder 4 is arranged on the stepper motor 3; and the output end of the encoder 4 is connected to the input end of the digital signal processor 1.
[0036] Specifically, the digital signal processor 1 includes a peripheral pulse width modulation module 11, a first orthogonal coding pulse module 12 and a second orthogonal coding pulse module 13; The output end of the pulse width modulation module 11 is connected to the input end of the driving circuit 2 and the first orthogonal coding pulse module 12 respectively; The output end of the encoder 4 is connected to the input end of the second orthogonal encoding pulse module 13 .
[0037] In this embodiment, the digital signal processor 1 is used as the control core, and is responsible for generating pulse signals and processing feedback signals from the encoder. The digital signal processor 1 includes peripherals such as a pulse width modulation module 11, a first orthogonal encoding pulse module 12, and a second orthogonal encoding pulse module 13.
[0038] The pulse width modulation module 11 outputs a signal to the driving circuit 2 to control the speed and displacement of the stepper motor 3. At the same time, the output of the module may also be input as a reference signal to the first orthogonal encoding pulse module 12 to control the number of pulses output by the pulse width modulation module 11.
[0039] The driving circuit 2 receives the signal from the pulse width modulation module 11 and converts it into the driving current or voltage required by the stepping motor 3, thereby driving the motor to rotate.
[0040] The stepper motor 3, as the object under test, rotates according to the current or voltage signal provided by the driving circuit 2. The encoder 4 installed on the motor is used to monitor the position and speed of the motor in real time.
[0041] The encoder 4 converts the rotation angle and speed of the stepper motor 3 into electrical pulse signals, and feeds these signals back to the second orthogonal encoding pulse module 13 .
[0042] In this embodiment, the pulse width modulation module 11 of the digital signal processor 1 generates a pulse width modulation signal according to a preset algorithm and parameters, and the signal is sent to the driving circuit 2 through the output end of the digital signal processor 1 .
[0043] After receiving the pulse width modulation signal, the driving circuit 2 converts it into a driving signal suitable for the stepping motor 3 to drive the motor to rotate.
[0044] When the stepper motor 3 is rotating, the encoder 4 thereon will generate an electrical pulse signal representing the position and speed of the motor in real time.
[0045] These pulse signals are sent to the second orthogonal encoding pulse module 13 of the digital signal processor 1 through the output end of the encoder 4 .
[0046] The second orthogonal encoding pulse module 13 receives the pulse signal from the encoder 4, and decodes and processes it to obtain the actual position and speed information of the motor.
[0047] The digital signal processor 1 can adjust the frequency of the pulse width modulation module 11 in real time according to the information, so as to realize accurate control of the stepping motor 3 .
[0048] At the same time, the first orthogonal coding pulse module 12 counts the pulse width modulation signal output by the pulse width modulation module 11, and when the count value reaches a set value, an interrupt is initiated, and the output of the pulse width modulation module 11 is stopped in the interrupt service program.
[0049] By observing the rotation of the stepper motor 3, the feedback signal of the encoder 4 and the processing result of the first orthogonal encoding pulse module 12, the performance and accuracy of the stepper motor pulse output control test structure can be verified.
[0050] In summary, this embodiment provides a stepper motor pulse output test structure, which can accurately generate a specified number of pulses through the pulse width modulation module of the digital signal processor combined with the orthogonal encoding pulse module, which is crucial for stepper motor applications that require precise position control. The flexible adjustment of the pulse width modulation module frequency allows the motor to run at different speeds to meet the needs of various working conditions. By utilizing the powerful computing power of the digital signal processor, complex acceleration and deceleration algorithms, such as S-curve acceleration, can be easily implemented to ensure the smoothness of the motor when starting and stopping, and reduce mechanical shock and vibration. According to real-time feedback including the motor position or speed information obtained through the orthogonal encoding pulse module, the pulse frequency and acceleration are dynamically adjusted to achieve more precise control.
[0051] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A stepper motor pulse output control test method, characterized in that: The steps include: Initializing a digital signal processor (1), wherein the digital signal processor (1) comprises a peripheral pulse width modulation module (11), a first orthogonal coding pulse module (12), and a second orthogonal coding pulse module (13); Based on the initialized digital signal processor (1), the number of output pulses of the pulse width modulation module (11) is calculated according to the displacement required for the stepping motor (3) to run; Setting the effective position comparison register of the first orthogonal encoding pulse module (12) to the number of pulse outputs; The pulse width modulation module (11) is started according to the obtained number of output pulses of the pulse width modulation module (11), and the frequency of the pulse width modulation module is controlled according to an S-curve algorithm or a trapezoidal acceleration and deceleration algorithm; when the first orthogonal encoding pulse module (12) initiates an interrupt, the output of the pulse width modulation module (11) is stopped in the interrupt service program, data of the encoder (4) is collected through the second orthogonal encoding pulse module (13) and displacement information of the stepping motor (3) is calculated, and the stepping motor pulse number test is implemented through the displacement information.
2. A stepper motor pulse output control test method according to claim 1, characterized in that: The specific process of initializing the digital signal processor (1) is as follows: Set the duty cycle of the pulse width modulation module (11) to 50%; Setting the working mode of the first orthogonal encoding pulse module (12) to a direction counting mode; The working mode of the second orthogonal encoding pulse module (13) is set to an orthogonal counting mode.
3. A stepper motor pulse output control test method according to claim 1, characterized in that: After the pulse width modulation module (11) is started, the frequency of the pulse width modulation module (11) is controlled according to the acceleration and deceleration algorithm combined with the number of output pulses of the pulse width modulation module (11).
4. A stepper motor pulse output control test method according to claim 3, characterized in that: The acceleration / deceleration algorithm adopts an S-curve algorithm or a trapezoidal acceleration / deceleration algorithm.
5. A stepper motor pulse output control test method according to claim 1, characterized in that: The mechanism by which the first orthogonal encoding pulse module (12) initiates an interrupt is that the first orthogonal encoding pulse module (12) initiates an interrupt when it detects that the data in the current position counter value register is equal to the data in the set effective position comparison register.
6. A stepper motor pulse output control test method according to claim 5, characterized in that: The specific process of initiating an interrupt when the first orthogonal encoding pulse module (12) detects that the data in the current position counter value register is equal to the data in the set effective position comparison register is as follows: The output of the pulse width modulation module (11) is connected to the first orthogonal coding pulse module (12) and the driving circuit (2) respectively, that is, the output of the pulse width modulation module (11) is the input of the first orthogonal coding pulse module (12); when the pulse width modulation module (11) has an output, the first orthogonal coding pulse module (12) starts counting, and the count value is stored in the position counter value register. At the same time, the first orthogonal coding pulse module (12) compares the data of the current position counter value register with the data in the set effective position comparison register to see whether they are equal. When the values of the two are equal, the first orthogonal coding pulse module (12) initiates an interrupt.
7. A stepper motor pulse output control test method according to claim 1, characterized in that: Models of the digital signal processor (1) include TMS320F28335 and TMS320F28377.
8. A stepper motor pulse output control test method according to claim 1, characterized in that: The encoder (4) is a displacement sensor of the motor, and the displacement of the stepping motor (3) acquired by the encoder (4) is used to implement a test of the number of pulses output by the pulse width modulation module (11).
9. A stepper motor pulse output control test structure, characterized in that: A stepper motor pulse output control test method for implementing any one of claims 1 to 8, the stepper motor pulse output control test structure comprising a digital signal processor (1), a drive circuit (2) and a stepper motor (3); The output end of the digital signal processor (1) is connected to the input end of the drive circuit (2), and the output end of the drive circuit (2) is connected to the input end of the stepper motor (3); an encoder (4) is provided on the stepper motor (3); and the output end of the encoder (4) is connected to the input end of the digital signal processor (1).
10. A stepper motor pulse output control test structure according to claim 9, characterized in that: The digital signal processor (1) comprises a peripheral pulse width modulation module (11), a first orthogonal coding pulse module (12) and a second orthogonal coding pulse module (13); The output end of the pulse width modulation module (11) is respectively connected to the input end of the drive circuit (2) and the first orthogonal coding pulse module (12); The output end of the encoder (4) is connected to the input end of the second orthogonal encoding pulse module (13).