A method, device and terminal equipment for interpolation operation control of a stepper motor
By acquiring the initial frequency and acceleration values of the stepper motor, determining the target interpolation frequency, and controlling the stepper motor at the interpolation time point, the frequency and speed error problems in the stepper motor interpolation operation are solved, achieving higher operating accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-25
- Publication Date
- 2026-03-24
AI Technical Summary
In the existing technology, the interpolation operation of stepper motors has frequency error and speed control error, resulting in insufficient operating accuracy.
By acquiring the initial frequency and acceleration value of the stepper motor, the target interpolation frequency corresponding to each interpolation timing sequence is determined, and the stepper motor is precisely controlled to perform interpolation operations at the interpolation time points to avoid time errors.
It improves the operating accuracy of the stepper motor, ensures precise control of acceleration and speed, and reduces the delay error of interpolation operation.
Smart Images

Figure CN115313924B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of industrial control, and particularly relates to a stepping motor interpolation operation control method and device, a terminal device and a computer readable storage medium. BACKGROUND
[0002] At present, with the rapid development of industrial technology, the application of stepping motors is becoming more and more widespread. For example, in 3D printers or numerical control machine tools and other industrial equipment, the stepping motor is controlled to accelerate or decelerate based on a linear acceleration and deceleration method, so that the 3D printer or numerical control machine tool realizes the corresponding function.
[0003] For example, Figure 1 is a frequency curve diagram corresponding to the stepping motor in the acceleration and deceleration stage in the traditional technical solution. The formula for the running frequency of the stepping motor changing with time is f(t) = at + f0; where a represents the acceleration value of the stepping motor, t represents the running time of the stepping motor, and f0 represents the initial frequency of the stepping motor.
[0004] In actual operation, in order to further improve the precision of the workpiece produced by the industrial equipment, interpolation operation needs to be performed on the motion trajectory of the workpiece or the tool in the industrial equipment, that is, interpolation operation needs to be performed on the motion trajectory of the stepping motor used to control the motion of the workpiece or the tool. The motion trajectory can be approximated as a plurality of small straight line segments, and the interpolation path determined is also discrete, that is, the frequency of each interpolation segment corresponding to the interpolation path is not continuously changed, and interpolation operation can be achieved by determining the interpolation frequency of each interpolation segment.
[0005] Figure 2 is a schematic diagram of the interpolation frequency change of the stepping motor in the acceleration stage in the traditional technical solution. The frequency of the interpolation segment is generally controlled by pulses, and the length of each interpolation segment is fixed. The area of each pulse corresponding to the interpolation segment is 1. In the traditional technical solution, when calculating the interpolation frequency, the change process of the interpolation frequency is generally regarded as a continuous change process, and the discrete frequency is calculated according to the formula f(t) = at + f0, that is, the interpolation frequency corresponding to the interpolation period is obtained. And in actual application, the interpolation frequency can be updated in a timing accumulation manner through formula conversion: f n = f n-1 + Δf; where Δf represents the change amount of the frequency within the interpolation period.
[0006] However, when the interpolation operation is performed according to the conventional technical solution, after the interpolation frequency is determined by the periodic timing, the interpolation operation is performed according to the calculated interpolation frequency, that is, there is a certain error between the time when the interpolation operation is performed and the time when the interpolation operation is planned, so as to cause a large error between the actual interpolation operation corresponding interpolation frequency and the planned interpolation frequency; and the interpolation frequency at the current time point is calculated according to the interpolation frequency at the last time point, so that when the interpolation operation needs to be controlled, the interpolation frequency corresponding to the current time point is not updated, and the interpolation operation needs to be controlled according to the interpolation frequency at the last time point, which will cause that the actual acceleration value of the stepper motor cannot reach the preset value; in addition, it will cause that the planned interpolation frequency cannot be sent within the preset time, so that the interpolation operation is continuously controlled according to the interpolation frequency at the last time point at the last moment, causing the error of speed control.
[0007] Therefore, how to improve the operation accuracy of the stepper motor is a technical problem to be solved by those skilled in the art at present. SUMMARY
[0008] The purpose of the present application is to provide a stepper motor interpolation operation control method, device, terminal equipment and computer readable storage medium, aiming at solving the problem of improving the operation accuracy of the stepper motor.
[0009] In a first aspect, the present application provides a stepper motor interpolation operation control method. The method comprises:
[0010] obtaining an initial frequency and an acceleration value of a stepper motor;
[0011] determining a target interpolation frequency corresponding to each interpolation timing according to the initial frequency and the acceleration value;
[0012] controlling the stepper motor to perform interpolation operation by using the target interpolation frequency corresponding to the interpolation timing at the interpolation time point corresponding to the interpolation timing.
[0013] In one of the embodiments, the method further comprises:
[0014] determining a current intermediate frequency corresponding to the current interpolation timing according to the initial frequency and the acceleration value;
[0015] obtaining a last intermediate frequency of a last interpolation timing corresponding to the current interpolation timing;
[0016] determining the target interpolation frequency corresponding to the current interpolation timing according to the current intermediate frequency and the last intermediate frequency.
[0017] In one of the embodiments, the determining the current intermediate frequency corresponding to the current interpolation timing according to the initial frequency and the acceleration value comprises:
[0018] determining an initial total accumulation value according to the initial frequency;
[0019] determining an accumulation factor according to the acceleration value;
[0020] obtaining a previous total accumulation value of a previous interpolation timing corresponding to the current interpolation timing, wherein the previous total accumulation value of the first calculated current interpolation timing is the initial total accumulation value;
[0021] determining a current total accumulation value of the current interpolation timing according to the previous total accumulation value and the accumulation factor;
[0022] determining the current intermediate frequency corresponding to the current interpolation timing according to the current total accumulation value.
[0023] In one of the embodiments, the method further comprises:
[0024] determining whether the interpolation operation corresponding to the current interpolation timing meets a preset condition;
[0025] if yes, ending the process;
[0026] if no, returning to the step of obtaining the previous total accumulation value of the previous interpolation timing corresponding to the current interpolation timing.
[0027] In one of the embodiments, the preset condition comprises that the number of interpolations reaches a preset number threshold, or the target interpolation frequency corresponding to the current interpolation timing reaches a preset frequency threshold.
[0028] In one of the embodiments, the obtaining the initial frequency and the acceleration value of the stepper motor comprises:
[0029] obtaining a current path segment and a next path segment corresponding to a running trajectory of the stepper motor;
[0030] performing motion trajectory planning according to the current path segment and the next path segment to obtain a planned path;
[0031] determining the initial frequency and the acceleration value of the stepper motor according to the planned path.
[0032] In one of the embodiments, if the stepper motor is a stepper motor in a 3D printer, the method further comprises:
[0033] determining an extrusion speed of extruding a printing material in the 3D printer according to the target interpolation frequency.
[0034] In a second aspect, the present application provides a step motor interpolation operation control device. The device comprises:
[0035] an acquisition module configured to acquire an initial frequency and an acceleration value of the step motor;
[0036] a determination module configured to determine a target interpolation frequency corresponding to each interpolation timing according to the initial frequency and the acceleration value;
[0037] an interpolation control module configured to control the step motor to perform interpolation operation at an interpolation time point corresponding to the interpolation timing by using the target interpolation frequency corresponding to the interpolation timing.
[0038] In a third aspect, the present application provides a terminal device. The terminal device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method as described above when executing the computer program.
[0039] In a fourth aspect, the present application provides a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program is executable on a processor to implement the steps of the method as described above.
[0040] The step motor interpolation operation control method provided by the embodiments of the present application acquires an initial frequency and an acceleration value of the step motor, and determines a target interpolation frequency corresponding to each interpolation timing according to the initial frequency and the acceleration value. The step motor is controlled to perform interpolation operation at an interpolation time point corresponding to the interpolation timing by using the target interpolation frequency corresponding to the interpolation timing. It can be seen that the target interpolation frequency corresponding to each interpolation timing is determined in advance by using the initial frequency and the acceleration value, and then the step motor is controlled to perform interpolation operation at the interpolation time point corresponding to the interpolation timing, so as to avoid the time error between the execution of interpolation operation and the planning of interpolation operation, thereby avoiding the motion control error caused by the delay of interpolation operation. Moreover, the step motor is controlled to perform interpolation operation at the interpolation time point corresponding to the interpolation timing, so as to accurately perform interpolation operation by using each planned target interpolation frequency, and accurately control the acceleration value and the speed value of the step motor. Therefore, the present application can improve the operation accuracy of the step motor.
[0041] It can be understood that the beneficial effects of the second aspect, the third aspect and the fourth aspect described above can be referred to the related description of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0042] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0043] Figure 1 This is a frequency curve diagram of a stepper motor during acceleration and deceleration in a traditional technical solution.
[0044] Figure 2 This is a schematic diagram showing the change in interpolation frequency of a stepper motor during the acceleration phase in a traditional technical solution.
[0045] Figure 3 A flowchart of a stepper motor interpolation operation control method provided in this application embodiment;
[0046] Figure 4 A schematic diagram of the running trajectory of a stepper motor provided in an embodiment of this application;
[0047] Figure 5 A schematic diagram of a planned path provided for an embodiment of this application;
[0048] Figure 6 A schematic diagram of the speed curve of a stepper motor provided in an embodiment of this application;
[0049] Figure 7 This is a schematic diagram of the frequency calculation process during the acceleration phase in another embodiment of this application;
[0050] Figure 8 This is a flowchart for calculating the target interpolation frequency in another embodiment of this application;
[0051] Figure 9 This is a schematic diagram of an interpolation frequency in another embodiment of this application;
[0052] Figure 10 A schematic diagram of the structure of a stepper motor interpolation operation control device provided in an embodiment of this application;
[0053] Figure 11 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Detailed Implementation
[0054] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of this application with unnecessary detail.
[0055] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0056] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0057] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0058] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0059] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized. "A plurality" means "two or more."
[0060] Figure 3This document illustrates a flowchart of a stepper motor interpolation operation control method according to an embodiment of this application. This method can be executed by the processor of a terminal device when running a corresponding computer program. For ease of explanation, only the parts relevant to this embodiment are shown. The method provided in this embodiment includes the following steps:
[0061] S100: Obtain the initial frequency and acceleration value of the stepper motor.
[0062] The initial frequency refers to the pulse frequency corresponding to the initial velocity of the stepper motor during acceleration and deceleration; the acceleration value can be positive or negative, that is, the stepper motor is accelerating or decelerating.
[0063] In practice, the initial frequency and acceleration values of the stepper motor can be obtained directly by reading data; alternatively, the initial frequency and acceleration values can be determined by obtaining the running trajectory of the stepper motor. This embodiment does not limit the specific method for obtaining the initial frequency and acceleration values of the stepper motor.
[0064] S200: Determine the target interpolation frequency corresponding to each interpolation timing sequence based on the initial frequency and acceleration value.
[0065] It should be understood that in actual operation, pulses of the corresponding frequency are sent to each interpolation segment in the interpolation path to realize the interpolation operation; the interpolation timing refers to the order corresponding to the interpolation segments, that is, the order of each interpolation segment arranged in chronological order.
[0066] The interpolation frequencies corresponding to each interpolation timing sequence are generally different. Therefore, it is necessary to determine the target interpolation frequency corresponding to each interpolation timing sequence. That is, the target interpolation frequency refers to the interpolation frequency corresponding to the interpolation timing sequence. For example, determining the target interpolation frequency at interpolation timing t=1 means determining the frequency of the pulse in the interpolation segment corresponding to time t=1.
[0067] In this embodiment, the target interpolation frequency corresponding to the interpolation timing sequence is obtained by directly calculating based on the initial frequency and acceleration value of each interpolation timing sequence.
[0068] S300: At the interpolation time point corresponding to the interpolation timing sequence, the stepper motor is controlled to perform the interpolation operation using the target interpolation frequency corresponding to the interpolation timing sequence.
[0069] It should be noted that the interpolation time point corresponding to the interpolation timing sequence is the time point at which the planned interpolation operation is to be performed to transmit the pulse.
[0070] In this step, after determining the target interpolation frequency corresponding to the interpolation timing sequence, the system monitors whether the current time is the interpolation time point corresponding to the interpolation timing sequence. At the interpolation time point corresponding to the interpolation timing sequence, a pulse corresponding to the target interpolation frequency is sent to control the stepper motor to perform the interpolation operation. Furthermore, in actual operation, the corresponding pulse can be sent using a timer interrupt or through Direct Memory Access (DMA); this embodiment does not limit the specific method of sending the pulse.
[0071] This application provides a stepper motor interpolation control method. It acquires the initial frequency and acceleration value of the stepper motor and determines the target interpolation frequency corresponding to each interpolation timing sequence based on the initial frequency and acceleration value. At the interpolation time point corresponding to the interpolation timing sequence, the stepper motor is controlled to perform interpolation operation using the target interpolation frequency corresponding to the interpolation timing sequence. As can be seen, this solution uses the initial frequency and acceleration value to determine the target interpolation frequency corresponding to each interpolation timing sequence, thus allowing the target interpolation frequency to be determined in advance. This enables the stepper motor to be controlled to perform interpolation operation at the corresponding interpolation time point, avoiding time errors between the execution of the interpolation operation and the planned interpolation operation, thereby avoiding motion control errors caused by interpolation operation delays. Furthermore, by controlling the stepper motor to perform interpolation operation at the interpolation time point corresponding to the interpolation timing sequence, this solution can accurately utilize each planned target interpolation frequency for interpolation operation, enabling precise control of the stepper motor's acceleration and speed values. Therefore, this solution can improve the operating accuracy of the stepper motor.
[0072] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. Specifically, in this embodiment, the target interpolation frequency corresponding to each interpolation timing sequence is determined according to the initial frequency and acceleration value, including:
[0073] Step 1: Determine the current intermediate frequency corresponding to the current interpolation timing based on the initial frequency and acceleration value.
[0074] Here, the current intermediate frequency refers to the intermediate frequency corresponding to the current interpolation sequence, that is, the frequency corresponding to the completion of the nth pulse segment of the current interpolation sequence. In this embodiment, the current intermediate frequency can be directly calculated based on the initial frequency and acceleration value; for example... Where f0 is the initial frequency, a is the acceleration value, and n is the current interpolation timing. Alternatively, the sequence can be iteratively updated using the initial frequency and acceleration value to determine the total accumulated value Sum. n and according to Determine the current intermediate frequency; where Sum n =Sum n-1+2a;Sum0=f0 2 f0 is the initial frequency, a is the acceleration value, and n is the current interpolation timing.
[0075] Step 2: Obtain the previous intermediate frequency of the previous interpolation timing corresponding to the current interpolation timing.
[0076] Step 3: Determine the target interpolation frequency corresponding to the current interpolation timing based on the current intermediate frequency and the previous intermediate frequency.
[0077] Here, the previous intermediate frequency refers to the intermediate frequency of the previous interpolation timing sequence corresponding to the current interpolation timing sequence; that is, the frequency corresponding to the completion of the (n-1)th pulse segment of the previous interpolation sequence. In this embodiment, the target interpolation frequency corresponding to the current interpolation timing sequence, i.e., the frequency f of the nth pulse segment, is calculated based on the average of the current intermediate frequency and the previous intermediate frequency. n Falling on f n 'and f n ' -1 Midpoint:
[0078]
[0079] As can be seen, the method of this embodiment can conveniently and accurately determine the target interpolation frequency corresponding to the current interpolation timing, thereby improving the accuracy and convenience of the interpolation operation control of the stepper motor.
[0080] In one embodiment, step 1: determining the current intermediate frequency corresponding to the current interpolation timing based on the initial frequency and acceleration value, including:
[0081] Step 1.1: Determine the initial total accumulated value based on the initial frequency.
[0082] Wherein, the initial total accumulated value is the initial value of the current total accumulated value; in this embodiment, the initial total accumulated value is determined based on the initial frequency, and the initial total accumulated value is determined to be the square of the initial frequency, that is, Sum0 = f0. 2 Where Sum0 is the initial total accumulated value and f0 is the initial frequency.
[0083] Step 1.2: Determine the accumulation factor based on the acceleration value.
[0084] The accumulation factor refers to the difference between the current total accumulated values corresponding to two adjacent interpolation timing sequences. In this embodiment, the accumulation factor is determined based on the acceleration value, specifically by determining that the accumulation factor is twice the acceleration value, i.e., the accumulation factor is 2a; where a is the acceleration value.
[0085] Step 1.3: Obtain the previous total accumulated value of the previous interpolation timing corresponding to the current interpolation timing; the first calculated previous total accumulated value of the current interpolation timing is the initial total accumulated value.
[0086] The previous total accumulated value is the total accumulated value calculated in the previous interpolation timing sequence, i.e., obtaining Sum. n-1 Where n is the current interpolation timing sequence. It should be noted that in this embodiment, the previous total accumulated value of the first calculated current interpolation timing sequence is the initial total accumulated value. That is, when the target interpolation frequency is calculated for the first time, the previous total accumulated value of the previous interpolation timing sequence corresponding to the current interpolation timing sequence is the initial total accumulated value. In other words, when n=1, the obtained previous total accumulated value is the initial total accumulated value Sum0.
[0087] Step 1.4: Determine the current total accumulated value of the current interpolation timing based on the previous total accumulated value and the accumulation factor.
[0088] Here, the current total accumulated value refers to the total accumulated value corresponding to the current interpolation timing. In this embodiment, the current total accumulated value of the current interpolation timing is determined based on the previous total accumulated value and the accumulation factor. Specifically, the accumulation factor is added to the previous total accumulated value to obtain the current total accumulated value of the current interpolation timing. That is, the current total accumulated value of the current interpolation timing is the sum of the previous total accumulated value and the accumulation factor, i.e., Sum. n =Sum n-1 +2a; where Sum n This is the current total accumulated value.
[0089] Step 1.5: Determine the current intermediate frequency corresponding to the current interpolation timing based on the current total accumulated value.
[0090] In this step, the square root of the current total accumulated value is taken to obtain the current intermediate frequency corresponding to the current interpolation timing. Among them, f n 'This represents the current intermediate frequency.
[0091] As can be seen, the method of this embodiment can conveniently and accurately calculate the current intermediate frequency, thereby improving the accuracy and convenience of the interpolation operation control of the stepper motor.
[0092] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. Specifically, in this embodiment, the method further includes:
[0093] Determine whether the interpolation operation corresponding to the current interpolation timing meets the preset conditions;
[0094] If the conditions are met, the process terminates.
[0095] If the condition is not met, return to the step of obtaining the previous total accumulated value of the previous interpolation timing corresponding to the current interpolation timing.
[0096] Here, the preset conditions refer to the conditions set in advance to determine whether the interpolation operation needs to continue. In this embodiment, after calculating the target interpolation frequency, it is further determined whether the interpolation operation corresponding to the current interpolation timing meets the preset conditions.
[0097] In practice, if speed control is used as the criterion, the interpolation operation corresponding to the current interpolation timing can be determined to meet the preset conditions by judging whether the target interpolation frequency reaches the preset frequency threshold. If position control is used as the criterion, the interpolation number sequence corresponding to the current interpolation timing can be determined to meet the preset conditions by judging whether the interpolation operation corresponding to the current interpolation timing reaches the preset number threshold.
[0098] More specifically, in one embodiment, the preset conditions include the number of interpolations reaching a preset number threshold, or the target interpolation frequency corresponding to the current interpolation timing reaching a preset frequency threshold.
[0099] The interpolation count refers to the number of interpolation operations required, or the number of pulses that need to be sent. In practice, the total number of interpolation counts corresponding to the stepper motor's running trajectory can be calculated based on this trajectory, thus determining a preset threshold. Each time the target interpolation frequency is determined and the stepper motor is controlled to perform interpolation at the corresponding interpolation time point, the interpolation count is updated. Then, the updated interpolation count is compared with the preset threshold. If the interpolation count is greater than the preset threshold, it indicates that the current interpolation operation has met the preset conditions, and the process ends. Otherwise, it indicates that the current interpolation operation has not yet met the preset conditions, and further interpolation is required. Therefore, the process returns to the step of obtaining the previous total accumulated value of the previous interpolation time sequence corresponding to the current interpolation time sequence.
[0100] Alternatively, after obtaining the preset number of times threshold corresponding to the interpolation operation, the preset number of times threshold is decremented by 1 after each interpolation operation until the preset number of times threshold is 0, indicating that the number of interpolations has reached the preset number of times threshold. For example, suppose the preset threshold for the number of interpolations during the acceleration phase of the stepper motor is N1, the preset threshold for the number of interpolations during the constant speed phase is N2, the preset threshold for the number of interpolations during the deceleration phase is N3, and the preset threshold for the number of interpolations during the handover phase is N4. For each motion phase, after performing the interpolation operation according to the target interpolation frequency, it is determined whether the number of interpolations corresponding to that motion phase has reached the preset threshold. For example, for the acceleration phase, after performing the interpolation operation according to the target interpolation frequency, the corresponding preset threshold N1 is updated to N1-1, and it is determined whether the interpolation operation of the acceleration phase has been completed, that is, whether the updated preset threshold N1 is greater than 0. If it is greater than 0, it means that the interpolation operation has not been completed, that is, the interpolation operation corresponding to the current interpolation timing does not meet the preset conditions, so the process returns to the step of obtaining the previous total accumulated value of the previous interpolation timing corresponding to the current interpolation timing. If it is less than or equal to 0, it means that the interpolation operation corresponding to the current interpolation timing meets the preset conditions, so the process ends.
[0101] The target interpolation frequency is either an increasing or decreasing value that occurs with the interpolation timing sequence. Therefore, a preset frequency threshold can be set. Each time the target interpolation frequency is determined, it is compared with the preset frequency threshold. If the target interpolation frequency corresponding to the current interpolation timing sequence reaches the preset frequency threshold, it means that the current interpolation operation has met the preset conditions, and the process ends. Otherwise, it means that the current interpolation operation has not yet met the preset conditions, and the interpolation operation needs to continue. Therefore, the process returns to the step of obtaining the previous total accumulated value of the previous interpolation timing sequence corresponding to the current interpolation timing sequence.
[0102] As can be seen, the method of this implementation can ensure that when the interpolation operation ends, the interpolation operation corresponding to the current interpolation timing has reached the corresponding preset conditions, thus further ensuring the reliability of the interpolation operation.
[0103] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. Specifically, in this embodiment, obtaining the initial frequency and acceleration value of the stepper motor includes:
[0104] Obtain the current path segment and the next path segment corresponding to the running trajectory of the stepper motor;
[0105] The motion trajectory is planned based on the current path segment and the next path segment to obtain the planned path;
[0106] The initial frequency and acceleration value of the stepper motor are determined based on the planned path.
[0107] Specifically, in actual operation, the running trajectory of the stepper motor can be obtained by reading the G-code, and the current path segment and the next path segment of the stepper motor can be determined based on the running trajectory. Figure 4 This is a schematic diagram of the running trajectory of a stepper motor provided in this embodiment. Figure 5 This embodiment provides a schematic diagram of a planned path; as shown below. Figure 4 As shown, assume the first line segment A0-A1 is the current path segment; A1-A2 is the next path segment; the motion trajectory is planned based on the current path segment and the next path segment. A smooth transition is achieved between the two path segments through a rounding process to obtain the corresponding planned path; as shown... Figure 5 The circular arc portion B0-B1 shown represents the planned path.
[0108] After determining the planned path, the motion speed is planned based on the planned path to determine the speed curve of the stepper motor. For example... Figure 6 The image shown is a schematic diagram of the speed curve of a stepper motor provided in this embodiment; combined with... Figure 5 and Figure 6 It can be seen that at the planned path B0-B1, the stepper motor runs at the switching speed and switches speeds between different interpolation curves through linear acceleration and deceleration; the initial frequency and acceleration value of the stepper motor are determined according to the speed planning or speed curve.
[0109] As can be seen, determining the initial frequency and acceleration value of the stepper motor according to the method of this embodiment, that is, determining the initial frequency and acceleration value of the stepper motor based on the running trajectory of the stepper motor, is not only convenient and efficient in operation, but also the calculated initial frequency and acceleration value are more in line with the actual movement of the stepper motor. Therefore, it can improve the accuracy and convenience of the interpolation operation control of the stepper motor.
[0110] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. Specifically, in this embodiment, if the stepper motor is a stepper motor in a 3D printer, the method further includes:
[0111] The extrusion speed of the printing material in the 3D printer is determined based on the target interpolation frequency.
[0112] It should be understood that a 3D printer (rapid prototyping) is a type of rapid prototyping equipment. A 3D printer creates a three-dimensional model by extruding molten plastic filaments or other printing materials, layer by layer. The motion mechanism of a 3D printer consists of two parts: one is a set of 3-DOF motion control axes, which can be composed of three stepper motors and an extrusion head for extruding the printing material; the other part includes a motor that controls the extrusion speed and a heated copper head that melts the extruded material. The motion control drives the extrusion head to move in three-dimensional space, printing the three-dimensional model.
[0113] As we know from the operating principle of 3D printers, the extrusion speed of the printing material should match the movement speed of the extruder head. If the extrusion speeds do not match, the printed three-dimensional model will be uneven, or even the extruder head will be blocked, leading to printing failure.
[0114] The extruder head's movement speed is the combined speed of a 3-DOF motion control axis group composed of three stepper motors. After determining the target interpolation frequency of the stepper motors, the combined speed of the three stepper motors is adjusted according to the target interpolation frequency. Therefore, it is necessary to further determine the corresponding extrusion speed of the printing material based on the target interpolation frequency. More specifically, when adjusting the extrusion speed, it is necessary to simultaneously adjust the operating frequency of the motor controlling the extrusion speed and the operating power of the heating copper head that melts the extruded material.
[0115] As can be seen, by further determining the extrusion speed of the printing material in the 3D printer according to the target interpolation frequency, the extrusion speed of the printing material in the 3D printer should match the movement speed of the extrusion head, thus further improving the printing quality of the 3D printer.
[0116] To enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application are described in detail below with reference to calculation principles. In the embodiments of this application, the principle for calculating the target interpolation frequency is as follows:
[0117] Combination Figure 7 As shown in the schematic diagram of a frequency calculation process during the acceleration phase, integration is performed on continuous frequencies. It can be viewed as the area S of the trapezoid enclosed by the frequency curves. n Substituting into the formula for the area of a trapezoid, we get:
[0118]
[0119] Where f0 is the initial frequency, f n ' is the frequency corresponding to the completion of the nth pulse segment (which can be regarded as f) nThe intersection of the extended right boundary line of the frequency and the frequency curve of f(t), where t is time;
[0120] Furthermore, according to the formula f(t) = at + f0, the acceleration process can be obtained as follows:
[0121] at = f n '-f0;
[0122] According to the formula And the formula at = f n '-f0, eliminating t, we get:
[0123] 2aS n =f n ' 2 -f0 2 ;
[0124] Right now
[0125] From the physical meaning of frequency, we know that the area S of the trapezoid... n That is, the number of pulses sent, i.e.:
[0126] S n =n;
[0127] As can be seen from the figure, the two triangles formed by the intersection of the continuous frequency curve and the discrete frequency curve are congruent triangles, that is, under the boundary conditions, the areas enclosed by the two are equal, and the area of each pulse is 1.
[0128] Formula (2aS) n +f0 2 The part can be viewed as a sequence Sum. n ;
[0129] Right now
[0130] According to the above formula, we can obtain:
[0131] Sum n =Sum n-1 +2a;
[0132] Sum0=f0 2 ;
[0133] The frequency f of the nth pulse segment n Falling on f n 'and f n ' -1 The midpoint, that is:
[0134]
[0135] That is, determining the frequency of each pulse segment.
[0136] Based on the above principles, combined with Figure 8 The flowchart illustrating the calculation of the target interpolation frequency in another embodiment further explains the process of determining the target interpolation frequency. In a specific embodiment, the steps for determining the target interpolation frequency are as follows:
[0137] S801: Determine the initial total accumulated value AccIntermeSum0 based on the initial frequency f0, where AccIntermeSum0 = f0 2 The first calculated total cumulative value of the current interpolation timing sequence is the previous total cumulative value; that is, when n=1, AccIntermeSum(n-1)=AcccIntermeSum0=f0 2 ;
[0138] S802: Determine the accumulation factor AccAmount based on the acceleration value a, where AccAmount = 2a;
[0139] S803: The initial value of the previous intermediate frequency IntermeFrq is the initial frequency f0;
[0140] S804: Get the previous total accumulated value AccIntermeSum(n-1) of the previous interpolation timing corresponding to the current interpolation timing;
[0141] S805: Determine the current total accumulated value AccIntermeSum(n) of the current interpolation timing based on the previous total accumulated value and the accumulated factor;
[0142] AccIntermeSum(n)=AccIntermeSum(n-1)+AccAmount;
[0143] S806: Determine the current intermediate frequency TempFrq corresponding to the current interpolation timing based on the current total accumulated value; TempFrq = sqrt(AccIntermeSum(n));
[0144] S807: Obtain the previous intermediate frequency IntermeFrq of the previous interpolation timing corresponding to the current interpolation timing;
[0145] S808: Based on the current intermediate frequency and the previous intermediate frequency, determine the target interpolation frequency Frq corresponding to the current interpolation timing, Frq = (IntermeFrq + TempFrq) / 2;
[0146] S809: Update the previous intermediate frequency based on the current intermediate frequency, i.e., IntermeFrq = TempFrq;
[0147] S810: Determine whether the acceleration / deceleration operation has been completed; if yes, terminate the process; otherwise, return to S804.
[0148] As can be seen, according to the method of this embodiment, the stepper motor can be controlled to perform interpolation operation at the interpolation time point corresponding to the interpolation timing sequence, avoiding the time error between the execution of the interpolation operation and the planned interpolation operation, thereby avoiding motion control errors caused by the delay of the interpolation operation; this embodiment controls the stepper motor to perform interpolation operation at the interpolation time point corresponding to the interpolation timing sequence, thus enabling precise use of each planned target interpolation frequency for interpolation operation, and enabling precise control of the acceleration and speed values of the stepper motor; and, as Figure 9 The diagram illustrates an interpolation frequency. According to the method of this embodiment, the target interpolation frequency is calculated, and the frequency of the transmitted pulse is equal to the planned pulse frequency. Therefore, the method according to this embodiment can improve the running accuracy of the stepper motor. Furthermore, in calculating the target interpolation frequency, the variables involved in the calculation only include the initial frequency and acceleration value. Therefore, even if the stepper motor adjusts its operating state, such as changing the acceleration value, the target initial frequency can still be calculated directly using the above method without needing to adjust the algorithm. Thus, the calculation of the target interpolation frequency in this embodiment is highly flexible and can be applied to speed switching between various interpolation curves.
[0149] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0150] Figure 10 The diagram shown is a structural schematic of an interpolation operation control device for a stepper motor provided in an embodiment of this application. Figure 10 As shown, the interpolation operation control device for the stepper motor in this embodiment includes an acquisition module 1010, a determination module 1020, and an interpolation control module 1030; wherein,
[0151] The acquisition module 1010 is used to acquire the initial frequency and acceleration value of the stepper motor;
[0152] The determination module 1020 is used to determine the target interpolation frequency corresponding to each interpolation timing sequence based on the initial frequency and acceleration value;
[0153] The interpolation control module 1030 is used to control the stepper motor to perform interpolation operations at the interpolation time points corresponding to the interpolation timing sequence using the target interpolation frequency corresponding to the interpolation timing sequence.
[0154] The interpolation operation control device for a stepper motor provided in this application embodiment has the same beneficial effects as the interpolation operation control method for a stepper motor described above.
[0155] In one embodiment, the determining module 1020 includes:
[0156] The first determining submodule is used to determine the current intermediate frequency corresponding to the current interpolation timing based on the initial frequency and acceleration value;
[0157] The acquisition submodule is used to acquire the previous intermediate frequency of the previous interpolation timing corresponding to the current interpolation timing.
[0158] The second determining submodule is used to determine the target interpolation frequency corresponding to the current interpolation timing based on the current intermediate frequency and the previous intermediate frequency.
[0159] In one embodiment, the first determining submodule includes:
[0160] The first determining unit is used to determine the initial total accumulated value based on the initial frequency;
[0161] The second determining unit is used to determine the accumulation factor based on the acceleration value;
[0162] The acquisition unit is used to acquire the previous total accumulated value of the previous interpolation timing corresponding to the current interpolation timing; the first calculated previous total accumulated value of the current interpolation timing is the initial total accumulated value.
[0163] The third determining unit is used to determine the current total accumulated value of the current interpolation timing based on the previous total accumulated value and the accumulation factor.
[0164] The fourth determining unit is used to determine the current intermediate frequency corresponding to the current interpolation timing based on the current total accumulated value.
[0165] In one embodiment, a stepper motor interpolation operation control device further includes:
[0166] The judgment module is used to determine whether the interpolation operation corresponding to the current interpolation timing meets the preset conditions; if it does, the process ends; if it does not, the acquisition unit is called.
[0167] In one embodiment, the preset conditions include the number of interpolations reaching a preset number threshold, or the target interpolation frequency corresponding to the current interpolation timing reaching a preset frequency threshold.
[0168] In one embodiment, the acquisition module 1010 includes:
[0169] The path acquisition submodule is used to obtain the current path segment and the next path segment corresponding to the running trajectory of the stepper motor;
[0170] The path planning submodule is used to plan the motion trajectory based on the current path segment and the next path segment to obtain the planned path.
[0171] The runtime data determination submodule is used to determine the initial frequency and acceleration value of the stepper motor based on the planned path.
[0172] In one embodiment, if the stepper motor is a stepper motor in a 3D printer, an interpolation operation control device for the stepper motor further includes:
[0173] The extrusion speed determination module is used to determine the extrusion speed of the printing material in the 3D printer based on the target interpolation frequency.
[0174] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0175] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0176] Figure 11 This is a schematic diagram of a terminal device provided in an embodiment of this application. For example... Figure 11 As shown, the terminal device 110 of this embodiment includes a memory 1110, a processor 1120, and a computer program 1130 stored in the memory 1110 and executable on the processor 1120; when the processor 1120 executes the computer program 1130, it implements the steps in the above-described embodiments of the interpolation operation control method for each stepper motor, for example... Figure 3 S100 to S300 are shown; or when the processor 1120 executes the computer program 1130, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 10 The functions of the acquisition module, determination module, and interpolation control module are shown.
[0177] For example, computer program 1130 can be divided into one or more modules / units, and one or more modules / units are stored in memory 1110 and executed by processor 1120 to implement the method of the embodiments of this application. One or more modules / units can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of computer program 1130 in terminal device 110. For example, computer program 1130 can be divided into an acquisition module, a determination module, and an interpolation control module, with the specific functions of each module as follows:
[0178] The acquisition module is used to acquire the initial frequency and acceleration values of the stepper motor;
[0179] The determination module is used to determine the target interpolation frequency corresponding to each interpolation timing sequence based on the initial frequency and acceleration value;
[0180] The interpolation control module is used to control the stepper motor to perform interpolation operations at the interpolation time points corresponding to the interpolation timing sequence, using the target interpolation frequency corresponding to the interpolation timing sequence.
[0181] In applications, terminal device 110 can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. Terminal device 110 may include, but is not limited to, memory 1110 and processor 1120. Those skilled in the art will understand that... Figure 11 This is merely an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown, or combine certain components, or different components. For example, a terminal device may also include input / output devices, network access devices, buses, etc.; among which, input / output devices may include cameras, audio acquisition / playback devices, displays, etc.; network access devices may include communication modules for wireless communication with external devices.
[0182] In applications, the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0183] In applications, memory can be an internal storage unit of a terminal device, such as its hard drive or RAM; it can also be an external storage device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card; or it can include both internal and external storage units. Memory is used to store operating systems, applications, boot loaders, data, and other programs, such as computer program code. Memory can also be used to temporarily store data that has been output or will be output.
[0184] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps in the above-described method embodiments.
[0185] The computer-readable storage medium provided in this application embodiment has the same beneficial effects as the interpolation operation control method for a stepper motor described above.
[0186] This application implements all or part of the processes in the methods of the above embodiments, which can be accomplished by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, such as a USB flash drive, a portable hard drive, a magnetic disk, or an optical disk.
[0187] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0188] Those skilled in the art will recognize that the device and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0189] In the embodiments provided in this 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 merely illustrative. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interface, or the device may be indirectly coupled or communicated, and may be electrical, mechanical, or other forms.
[0190] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for controlling the interpolation operation of a stepper motor, characterized in that, The method includes: Obtain the initial frequency and acceleration value of the stepper motor; Based on the initial frequency and the acceleration value, a target interpolation frequency corresponding to each interpolation timing sequence is determined; the determination of the target interpolation frequency corresponding to each interpolation timing sequence based on the initial frequency and the acceleration value includes: determining the current intermediate frequency corresponding to the current interpolation timing sequence based on the initial frequency and the acceleration value; obtaining the previous intermediate frequency of the previous interpolation timing sequence corresponding to the current interpolation timing sequence; and determining the target interpolation frequency corresponding to the current interpolation timing sequence based on the current intermediate frequency and the previous intermediate frequency. At the interpolation time point corresponding to the interpolation timing sequence, the stepper motor is controlled to perform interpolation operation using the target interpolation frequency corresponding to the interpolation timing sequence.
2. The method according to claim 1, characterized in that, The step of determining the current intermediate frequency corresponding to the current interpolation timing based on the initial frequency and the acceleration value includes: The initial total accumulated value is determined based on the initial frequency; The accumulation factor is determined based on the acceleration value; Obtain the previous total accumulated value of the previous interpolation timing corresponding to the current interpolation timing; the first calculated previous total accumulated value of the current interpolation timing is the initial total accumulated value; Based on the previous total accumulated value and the accumulation factor, determine the current total accumulated value of the current interpolation timing. The current intermediate frequency corresponding to the current interpolation timing is determined based on the current total accumulated value.
3. The method according to claim 2, characterized in that, The method further includes: Determine whether the interpolation operation corresponding to the current interpolation timing meets the preset conditions; If the conditions are met, the process terminates. If the condition is not met, return to the step of obtaining the previous total accumulated value of the previous interpolation timing corresponding to the current interpolation timing.
4. The method according to claim 3, characterized in that, The preset conditions include the number of interpolations reaching a preset number threshold, or the target interpolation frequency corresponding to the current interpolation timing reaching a preset frequency threshold.
5. The method according to any one of claims 1 to 4, characterized in that, The acquisition of the initial frequency and acceleration values of the stepper motor includes: Obtain the current path segment and the next path segment corresponding to the running trajectory of the stepper motor; Based on the current path segment and the next path segment, a motion trajectory is planned to obtain the planned path; The initial frequency and acceleration value of the stepper motor are determined based on the planned path.
6. The method according to claim 5, characterized in that, If the stepper motor is a stepper motor used in a 3D printer, the method further includes: The extrusion speed of the printing material in the 3D printer is determined based on the target interpolation frequency.
7. A stepper motor interpolation operation control device, characterized in that, The device includes: The acquisition module is used to acquire the initial frequency and acceleration values of the stepper motor; A determining module is configured to determine the target interpolation frequency corresponding to each interpolation timing sequence based on the initial frequency and the acceleration value. The determining module includes: a first determining submodule, configured to determine the current intermediate frequency corresponding to the current interpolation timing sequence based on the initial frequency and the acceleration value; an acquiring submodule, configured to acquire the previous intermediate frequency of the previous interpolation timing sequence corresponding to the current interpolation timing sequence; and a second determining submodule, configured to determine the target interpolation frequency corresponding to the current interpolation timing sequence based on the current intermediate frequency and the previous intermediate frequency. The interpolation control module is used to control the stepper motor to perform interpolation operations at the interpolation time point corresponding to the interpolation timing sequence using the target interpolation frequency corresponding to the interpolation timing sequence.
8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
S-shaped accelerated / decelerated motion control method in sampling mechanical arm interpolation
CN109407621A