PI controller parameter optimization method and device based on adaptive algorithm, and terminal

By dynamically adjusting the proportional and integral gain of the sewing machine presser foot controller using an adaptive algorithm, the problem of insufficient control accuracy caused by improper PI controller parameter settings is solved, thus achieving precise presser foot control and efficient sewing.

CN120802597BActive Publication Date: 2026-07-14ZHEJIANG ZOBOW MECHANICAL & ELECTRICAL TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG ZOBOW MECHANICAL & ELECTRICAL TECH
Filing Date
2025-08-07
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

In existing sewing machine presser foot controls, improper PI controller parameter settings lead to insufficient control accuracy, affecting sewing efficiency and sewing quality.

Method used

An adaptive algorithm is used to dynamically adjust the proportional gain KP and integral gain KI of the PI controller. Initial parameters are determined through preliminary testing, and multiple height sampling points are set within the travel range of the sewing machine presser foot. The adaptive algorithm is then used to optimize the parameters.

Benefits of technology

It enables precise control of different presser foot heights, adapting to different sewing materials and working conditions, and improving the efficiency and quality of sewing work.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120802597B_ABST
    Figure CN120802597B_ABST
Patent Text Reader

Abstract

The application provides a PI controller parameter optimization method and device based on an adaptive algorithm, and a terminal. The method comprises the following steps: determining initial parameters of proportional gain KP and initial parameters of integral gain KI of a PI controller through preliminary testing; setting a plurality of height sampling points within a presser foot stroke range of a sewing machine; for each height sampling point, keeping any one of the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI constant, dynamically adjusting the other parameter based on an adaptive algorithm, and obtaining optimized parameters of the PI controller. The application realizes accurate PI controller parameter optimization design based on an adaptive algorithm, and can meet the control accuracy of different presser foot heights of users. In addition, the application can also effectively adapt to the characteristics of different sewing materials and diversified working condition requirements, and provides strong support for efficient and high-quality implementation of sewing work.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of sewing machine presser foot control technology, and relates to a PI controller parameter optimization method, device, and terminal based on an adaptive algorithm. Background Technology

[0002] In the field of sewing machine presser foot control, the proportional-integral-differential (PID) closed-loop control algorithm is often used to achieve presser foot hovering at any target height. However, the control performance of this algorithm is highly dependent on the proper setting of control parameters such as proportional gain KP and integral gain KI. If these control parameters are not set properly, it may lead to insufficient control accuracy during the presser foot lifting process.

[0003] Specifically, the proportional gain KP determines the controller's response speed. A larger proportional gain KP means the controller can identify and correct deviations more quickly, thus rapidly adjusting the presser foot to the target height. However, an excessively large proportional gain KP may cause overshoot or even oscillation, affecting the system's stability and reliability. Conversely, an excessively small proportional gain KP will lead to a slow controller response and may generate a large steady-state error. Additionally, the integral gain KI reduces the system's steady-state error and improves output accuracy. As the integral gain KI increases, the controller's ability to correct accumulated errors strengthens, helping to speed up the process of reaching the setpoint. However, an excessively large integral gain KI can also exacerbate the system's oscillation tendency. The problems caused by using inappropriate control parameters not only reduce sewing efficiency but also seriously affect sewing quality and equipment reliability. Summary of the Invention

[0004] This application provides a method, apparatus, and terminal for optimizing PI controller parameters based on an adaptive algorithm, which is used to solve the problem of insufficient control accuracy of presser foot lifting caused by unoptimized PI controller parameters.

[0005] In a first aspect, this application provides a method for optimizing PI controller parameters based on an adaptive algorithm, comprising: determining the initial parameters of the proportional gain KP and the integral gain KI of the PI controller through preliminary testing; setting multiple height sampling points within the presser foot stroke range of a sewing machine; for each height sampling point, keeping one of the initial parameters of the proportional gain KP and the integral gain KI constant, and dynamically adjusting the other parameter based on an adaptive algorithm to obtain the optimized parameters of the PI controller.

[0006] In one implementation of the first aspect, dynamically adjusting the initial parameters of the proportional gain KP based on an adaptive algorithm includes: step S310, generating a pulse width modulation control signal based on the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI to drive the presser foot lifting mechanism of the sewing machine to perform a presser foot lifting action; step S320, acquiring the presser foot displacement signal collected in real time by the presser foot height sensor, and generating a presser foot lifting trajectory after signal processing; step S330, acquiring the overshoot of the presser foot lifting trajectory; step S340, determining whether the overshoot exceeds the allowable overshoot range; step S350, if yes, increasing the initial parameters of the proportional gain KP to obtain an optimized proportional gain KP; step S360, otherwise decreasing the initial parameters of the proportional gain KP to obtain an optimized proportional gain KP.

[0007] In one implementation of the first aspect, increasing the initial parameter of the proportional gain KP includes: step S351, determining the initial parameter range of the proportional gain KP through preliminary testing; step S352, adding a first preset value to the initial parameter of the proportional gain KP to obtain an incremental proportional gain KP; step S353, determining whether the incremental proportional gain KP is within the initial parameter range; step S354, if yes, replacing the initial parameter of the proportional gain KP with the incremental proportional gain KP, repeating steps S310 and S320 to generate a new presser foot lifting trajectory, and repeating steps S330 and S340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, returning to step S352; otherwise, subtracting a second preset value from the incremental proportional gain KP to obtain the optimized proportional gain KP; step S355, otherwise reporting an error and ending the loop.

[0008] In one implementation of the first aspect, reducing the initial parameter of the proportional gain KP includes: step S361, determining the initial parameter range of the proportional gain KP through preliminary testing; step S362, subtracting a first preset value from the initial parameter of the proportional gain KP to obtain a proportional gain KP with a reduction; step S363, determining whether the proportional gain KP with a reduction is within the initial parameter range; step S364, if yes, replacing the initial parameter of the proportional gain KP with the proportional gain KP with a reduction, repeating steps 310 and S320 to generate a new presser foot lifting trajectory, and repeating steps S330 and S340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, returning to step S362; otherwise, increasing the proportional gain KP with a reduction by a second preset value to obtain the optimized proportional gain KP; step S365, otherwise reporting an error and ending the loop.

[0009] In one implementation of the first aspect, dynamically adjusting the initial parameters of the integral gain KI based on an adaptive algorithm includes: step S410, generating a pulse width modulation control signal based on the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI to drive the presser foot lifting mechanism of the sewing machine to perform a presser foot lifting action; step S420, acquiring the presser foot displacement signal collected in real time by the presser foot height sensor, and generating a presser foot lifting trajectory after signal processing; step S430, acquiring the overshoot of the presser foot lifting trajectory; step S440, determining whether the overshoot exceeds the allowable overshoot range; step S450, if yes, decreasing the initial parameters of the integral gain KI to obtain an optimized integral gain KI; step S460, otherwise increasing the initial parameters of the integral gain KI to obtain an optimized integral gain KI.

[0010] In one implementation of the first aspect, determining the initial parameters of the proportional gain KP and integral gain KI of the PI controller through preliminary testing includes: selecting multiple sewing machines of the same model and specifications as test prototypes; testing each of the test prototypes to obtain the proportional gain KP test parameters and integral gain KI test parameters that optimize the performance of the test prototype at each height sampling point; calculating the arithmetic mean of the proportional gain KP test parameters of all test prototypes at the same height sampling point to obtain the initial parameters of the proportional gain KP; and calculating the arithmetic mean of the integral gain KI test parameters of all test prototypes at the same height sampling point to obtain the initial parameters of the integral gain KI.

[0011] In one implementation of the first aspect, the method further includes: setting all the pressure adjusting nuts of the test prototypes to the middle scale; at the middle scale, the compression amount corresponding to the pressure adjusting springs of all the test prototypes remains consistent.

[0012] In one implementation of the first aspect, determining the initial parameter range of the proportional gain KP through preliminary testing includes: selecting multiple sewing machines of the same model and specifications as test prototypes; testing each of the test prototypes to obtain the proportional gain KP test parameters that optimize the performance of the test prototype at each height sampling point; determining the fluctuation range of the proportional gain KP test parameters based on the distribution characteristics of the proportional gain KP test parameters of all test prototypes at the same height sampling point, and using the fluctuation range as the initial parameter range of the proportional gain KP.

[0013] Secondly, this application provides a PI controller parameter optimization device based on an adaptive algorithm, comprising: a preliminary testing module for determining the initial parameters of the proportional gain KP and integral gain KI of the PI controller through preliminary testing; a sampling setting module for setting multiple height sampling points within the presser foot stroke range of a sewing machine; and a parameter adjustment module for keeping one of the initial parameters of the proportional gain KP and the integral gain KI constant for each height sampling point, and dynamically adjusting the other parameter based on an adaptive algorithm to obtain the optimized parameters of the PI controller.

[0014] Thirdly, this application provides a terminal, comprising: a memory for storing a computer program; and a processor for executing the computer program stored in the memory to cause the terminal to perform the method described in any of the above-mentioned embodiments.

[0015] As described above, the PI controller parameter optimization method, apparatus, and terminal based on adaptive algorithms described in this application have the following beneficial effects:

[0016] (1) Based on the adaptive algorithm, the precise PI controller parameter optimization design was realized, which can meet the user's control accuracy for different presser foot heights;

[0017] (2) It can effectively adapt to the characteristics of different sewing materials and the diverse working conditions, providing strong support for the efficient and high-quality development of sewing work. Attached Figure Description

[0018] Figure 1 The diagram shows the presser foot lifting curves corresponding to different integral gains KI in one embodiment of this application.

[0019] Figure 2 The diagram shows the presser foot lifting curves corresponding to different integral gains KP in an embodiment of this application.

[0020] Figure 3 The diagram shown is a structural schematic of an industrial sewing machine according to an embodiment of this application.

[0021] Figure 4 The flowchart shown is a PI controller parameter optimization method based on an adaptive algorithm according to an embodiment of this application.

[0022] Figure 5 The flowchart shown is a preliminary test flowchart of an embodiment of this application.

[0023] Figure 6 The flowchart shown illustrates the dynamic adjustment of the initial parameters of the scaling gain KP according to an embodiment of this application.

[0024] Figure 7The diagram shown illustrates the presser foot lifting trajectory according to an embodiment of this application.

[0025] Figure 8 The flowchart shown illustrates the initial parameters for increasing the proportional gain KP according to an embodiment of this application.

[0026] Figure 9 The flowchart shown is a process for reducing the initial parameters of the proportional gain KP according to an embodiment of this application.

[0027] Figure 10 The flowchart shown is a process for dynamically adjusting the initial parameters of the integral gain KI according to an embodiment of this application.

[0028] Figure 11 The flowchart shown is a process for reducing the initial parameters of the integral gain KI according to an embodiment of this application.

[0029] Figure 12 The flowchart shown is for increasing the initial parameters of the integral gain KI according to another embodiment of this application.

[0030] Figure 13 The diagram shown is a structural schematic of a PI controller parameter optimization device based on an adaptive algorithm according to an embodiment of this application.

[0031] Figure 14 The diagram shown is a structural schematic of a terminal according to an embodiment of this application.

[0032] Component designation explanation

[0033] 11. Lifting the pressure foot electromagnet

[0034] 12. Presser foot lifting mechanism

[0035] 13 Presser foot

[0036] 14 Pressure Adjusting Spring

[0037] 15 Pressure Adjusting Nut

[0038] 16. Presser foot height sensor

[0039] 21 Preliminary Test Module

[0040] 22 Sampling Settings Module

[0041] 23 Parameter Adjustment Module

[0042] 31 Memory

[0043] 32 processors Detailed Implementation

[0044] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.

[0045] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. Therefore, the drawings only show the components related to this application and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0046] Before providing a further detailed description of this application, the controller and control parameters that may be involved in the following embodiments of this application will be explained first:

[0047] <1> This application employs a PI controller, which can be either an incremental PI controller or a positional PI controller. An incremental PI controller calculates the difference between the current control quantity and the control quantity from the previous time step, using this difference as the new control quantity, effectively avoiding the error accumulation problem of the integral stage. Its core features include a differential calculation mechanism and recursive output calculation. A positional PI controller, on the other hand, achieves its control objective by controlling the deviation between the current actual position and the desired position of the system.

[0048] <2> The control parameters corresponding to the PI controller include proportional gain KP and integral gain KI. The precise control of the presser foot height is achieved through the synergistic effect of these two key parameters. The proportional gain KP refers to the ratio of the output signal to the input signal, and the integral gain KI refers to the integral of the output signal with time.

[0049] <3> The effect of integral gain KI on presser foot lifting response speed: When the proportional gain KP is fixed (e.g., KP = 1.2) and the integral gain KI is adjusted, the presser foot lifting curves corresponding to different integral gains KI (e.g., 0.05, 0.1, 0.2) are tested at the same target height (e.g., 5mm). Figure 1 As shown, the purple curve (KI1 = 0.2) exhibits the fastest response speed, but is accompanied by significant overshoot and subsequent oscillations; the red curve (KI2 = 0.1) achieves a better balance between speed and stability; while the blue curve (KI3 = 0.05) completely avoids overshoot, but the rise time is prolonged.

[0050] <4> The effect of proportional gain KP on presser foot lifting response speed: When the integral gain KI is fixed (e.g., KI = 0.1) and the proportional gain KP is adjusted, such as... Figure 2 As shown, the green curve (KP1 = 2.0) exhibits a slow but steady upward trend, with an ascent time of 120ms; the red curve (KP2 = 1.5) completes positioning within 90ms without overshoot; while the blue curve (KP3 = 0.8) reaches the target height in just 60ms, but it exhibits overshoot and continuous oscillation.

[0051] Figure 1 and Figure 2 The horizontal axis corresponds to different data collection points. These data collection points are set at fixed time intervals (e.g., 180 microseconds) during the lifting of the presser foot, meaning that the presser foot height data is collected every 180 microseconds. The vertical axis represents the collected presser foot height value. At this point, the presser foot height value is actually just a sampled value from the microcontroller's analog-to-digital converter (ADC), and has not yet been converted into an actual height value in millimeters.

[0052] It should be noted that the controller's control parameters also include the differential gain KD, but the differential gain KD is not within the scope of this application.

[0053] In practical applications, PI controller parameters need to be dynamically adjusted according to changes in operating conditions. For example, due to the complex and variable operating environment of sewing machines, electromagnets are prone to overheating during operation, and this heating affects their performance, thus impacting the effectiveness of control parameters. Furthermore, factors such as differences in the scale of different pressure adjusting nuts, changes in mechanical friction after prolonged use, dimensional changes in the mechanical structure due to thermal expansion and contraction, and inherent errors in the production and assembly of machine parts can also lead to changes in control parameters. Because errors are unavoidable in the production and assembly of machine parts, parameter settings may differ significantly between different devices. Even if parameters are calibrated at the factory, they may become inapplicable with prolonged use, leading to a gradual decline in control performance.

[0054] The following embodiments of this application provide a method and apparatus for optimizing PI controller parameters, a control system, a terminal, and a medium. The technical solutions of this application can be applied to scenarios such as motor speed control systems, presser foot height control, and thread tension adjustment in sewing machines. By optimizing control parameters, sewing quality can be improved, and the system can effectively adapt to the characteristics of different sewing materials and diverse working conditions, providing strong support for the efficient and high-quality operation of sewing work.

[0055] Please see Figure 3The image shown is a structural schematic diagram of an industrial sewing machine according to an embodiment of this application. Figure 3 As shown, the industrial sewing machine in this embodiment includes a presser foot lifting electromagnet 11, a presser foot lifting mechanism 12, a presser foot 13, a pressure adjusting spring 14, a pressure adjusting nut 15, and a presser foot height sensor 16.

[0056] Specifically, the presser foot lifting electromagnet 11 is connected to the presser foot 13 via a presser foot lifting mechanism 12, which includes a presser foot rod capable of vertical movement. The lower end of the pressure adjusting spring 14 acts on the presser foot rod, and the upper end abuts against a graduated pressure adjusting nut 15. The presser foot 13 is fixedly mounted at the end of the presser foot rod, forming a bidirectional force system: the presser foot lifting electromagnet 11 applies an upward pulling force to the presser foot 13 through the presser foot lifting mechanism 12, while the pressure adjusting spring 14 generates downward pressure through the presser foot rod. During sewing operations, a presser foot height sensor 16 located at the sewing machine head can monitor the displacement changes of the presser foot in real time.

[0057] During sewing machine operation, the pedal displacement or the pressure signal from the electronic knee rest can be converted into an input current signal for the presser foot lifting electromagnet 11. When the operator presses the pedal backward or applies knee rest pressure, the presser foot lifting electromagnet 11 generates magnetic force under the action of current, lifting the presser foot 13 upward through the presser foot lifting mechanism 12. Theoretically, the pedal displacement or knee rest pressure value is positively correlated with the lifting height of the presser foot 13. Conversely, when the pedal or knee rest pressure is released, the current to the presser foot lifting electromagnet 11 decreases or disconnects, and the presser foot lifting mechanism 12 descends under the action of gravity. Theoretically, the descent distance is positively correlated with the pedal displacement or knee rest pressure value. When the pedal or knee rest is fully reset, the presser foot lifting mechanism 12 returns to its initial position.

[0058] It should be noted that the PI controller parameter optimization method based on adaptive algorithms described in this application can run on various types of hardware devices. The hardware device may be a computer including components such as memory, memory controller, one or more microcontroller units (MCUs), peripheral interfaces, RF circuits, audio circuits, speakers, microphones, input / output (I / O) subsystems, displays, other output or control devices, and external ports; the computer includes, but is not limited to, personal computers such as desktop computers, laptops, tablets, smartphones, smart TVs, and personal digital assistants (PDAs). In other embodiments, the hardware device may also be a local server or a cloud server. The server may be deployed on one or more physical servers depending on factors such as function and load, or it may consist of a distributed or centralized server cluster; this embodiment does not impose any limitations.

[0059] The following will describe in detail the principle and implementation of a PI controller parameter optimization method, device, and terminal based on an adaptive algorithm according to this embodiment, so that those skilled in the art can understand the PI controller parameter optimization method, device, and terminal based on an adaptive algorithm according to this embodiment without creative effort.

[0060] Please see Figure 4 The diagram shows a flowchart of a PI controller parameter optimization method based on an adaptive algorithm according to an embodiment of this application. Figure 4 As shown, this embodiment provides a PI controller parameter optimization method based on an adaptive algorithm, including the following steps S100 to S300.

[0061] In step S100, the initial parameters of the proportional gain KP and integral gain KI of the PI controller are determined through preliminary testing.

[0062] Please see Figure 5 The diagram shows a flowchart of a preliminary test according to an embodiment of this application. Figure 5 As shown, step S100, which determines the initial parameters of the proportional gain KP and integral gain KI of the PI controller through preliminary testing, may include steps S110 to S140.

[0063] In step S110, multiple sewing machines of the same model and specifications are selected as test samples.

[0064] In this embodiment, the number of test samples can be flexibly set according to actual needs. For example, five sewing machines can be selected as test samples, or it can be expanded to ten or more as needed. By increasing the number of samples, the test coverage can be effectively expanded, thereby comprehensively covering different usage scenarios and potential variable factors, and significantly improving the applicability and reliability of the test results.

[0065] In step S120, each of the test prototypes is tested to obtain the proportional gain KP test parameters and integral gain KI test parameters that optimize the performance of the test prototype at each height sampling point.

[0066] Taking five test prototypes (such as A, B, C, D, and E) as an example, Table 1 shows the proportional gain KP test parameters and integral gain KI test parameters that optimize the performance of each test prototype when the height sampling point is 2mm.

[0067] Table 1. Optimized parameters and duty cycle data of test prototype A at some height sampling points.

[0068]

[0069]

[0070] It should be noted that the proportional gain KP test parameters and integral gain KI test parameters in this embodiment are values ​​obtained during the coarse parameter tuning stage, and their accuracy is lower than that of the final optimized parameters in this application.

[0071] In step S130, the arithmetic mean of the proportional gain KP test parameters of all test prototypes at the same height sampling point is calculated to obtain the initial parameters of the proportional gain KP.

[0072] Specifically, the arithmetic mean of the proportional gain KP of the five test prototypes at a height sampling point of 2mm can be calculated using the following formula:

[0073]

[0074] It should be noted that the initial parameter calculation process for the proportional gain KP of the test prototype at other height sampling points is similar, and will not be described in detail here.

[0075] In step S140, the arithmetic mean of the integral gain KI test parameters of all test prototypes at the same height sampling point is calculated to obtain the initial parameters of the integral gain KI.

[0076] Specifically, the arithmetic mean of the integral gain KI of the five test prototypes at a height sampling point of 2mm can be calculated using the following formula:

[0077]

[0078] It should be noted that the initial parameter calculation process for the integral gain KI of the test prototype at other sampling points is similar, and will not be described in detail here.

[0079] In one embodiment of this application, the PI controller parameter optimization method based on adaptive algorithm described in this application further includes: setting the pressure adjusting nuts of the test prototypes to the middle scale; at the middle scale, the compression amount corresponding to the pressure adjusting springs of all the test prototypes remains consistent.

[0080] For example, the scale markings on the adjusting nut may range from 2.0 to 3.2. Users can manually adjust the compression of the adjusting spring by rotating the adjusting nut. As the adjusting nut is rotated downwards, i.e., the scale value increases, the adjusting spring is compressed more tightly, resulting in a significant increase in the force required to lift the pressure foot. Conversely, the smaller the scale value of the adjusting nut, the less the spring is compressed, and the less force is required to lift the pressure foot.

[0081] It should be noted that, in order to effectively reduce the randomness caused by differences in the setting of the pressure regulating nut and to ensure the consistency and comparability of the test conditions, the intermediate scale (i.e., scale = 2.6) is used as the standard position for testing in this embodiment, so as to ensure the accuracy and reliability of the experimental data.

[0082] In this implementation, by averaging the test data of multiple sewing machines, the parameter deviation caused by individual differences or random errors of a single machine can be effectively eliminated, making the final generated control parameters more universal and representative.

[0083] In step S200, multiple height sampling points are set within the presser foot stroke range of the sewing machine.

[0084] In this embodiment, the presser foot travel range of the sewing machine refers to the vertical movement range of the presser foot from its initial position to the target height, and its specific value is determined by the mechanical structure and control system of the sewing machine.

[0085] Specifically, the initial position corresponds to the reference position of the presser foot, which is the initial height when the operator has not activated the pedal or knee rest device; while the target height depends on the maximum travel displacement of the pedal or knee rest.

[0086] In practical applications, the determination of the presser foot stroke range needs to take into account factors such as sewing thickness requirements and mechanical limit protection. The typical industrial sewing machine presser foot stroke range is between 0 and 15 millimeters (mm).

[0087] In this embodiment, the height sampling points can be set using an equidistant distribution principle. For example, one sampling point can be set every millimeter within the presser foot travel range of 0 to 15 mm, thus obtaining a total of 16 discretized positions. The sampling point density can be adjusted according to the control accuracy requirements. For high-precision sewing applications, the density can be increased to one sampling point every 0.5 mm, while in ordinary applications, a sparse configuration of one sampling point every 2 mm can be used. This discretized height sampling method can effectively avoid the signal noise problem caused by continuous detection, and at the same time provide a clear setpoint sequence for subsequent parameter adjustments.

[0088] In this implementation, by setting multiple height sampling points, the lifting height of the presser foot can be tracked and controlled more accurately. This method is more adaptable to the needs of sewing machines under different working conditions than the traditional single sampling point.

[0089] In step S300, for each height sampling point, keep either the initial parameter of the proportional gain KP or the initial parameter of the integral gain KI constant, and dynamically adjust the other parameter based on an adaptive algorithm to obtain the optimized parameters of the PI controller.

[0090] Please see Figure 6The diagram shows a flowchart illustrating the dynamic adjustment of the initial parameters of the scaling gain KP according to an embodiment of this application. Figure 6 As shown, the dynamic adjustment of the initial parameters of the proportional gain KP based on the adaptive algorithm includes the following steps S310 to S360.

[0091] Step S310: Based on the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI, generate a pulse width modulation (PWM) control signal to drive the presser foot lifting mechanism of the sewing machine to perform the presser foot lifting action.

[0092] In this embodiment, the duty cycle of the PWM control signal determines the magnitude of the driving force of the lifting foot mechanism.

[0093] Specifically, a larger duty cycle in the PWM control signal means a longer energized time in the coil of the pressure foot lifting electromagnet per unit cycle. According to the principle of electromagnetic induction, the extended energizing time strengthens the magnetic field around the coil, thus increasing the attractive force generated by the electromagnet. This increased attractive force acts on the pressure foot, causing it to lift upwards. Conversely, a smaller duty cycle in the PWM control signal means a shorter energized time in the coil of the pressure foot lifting electromagnet per unit cycle, resulting in a weaker magnetic attraction and a slower lifting speed of the pressure foot.

[0094] Step S320: Obtain the real-time displacement signal of the presser foot from the presser foot height sensor, and generate the presser foot lifting trajectory through signal processing.

[0095] In this embodiment, the actual presser foot lifting trajectory is visually reflected by the time-height curve, showing the dynamic movement process of the presser foot from its initial position to the target height.

[0096] The presser foot height sensor continuously captures the presser foot's displacement, with each data point corresponding to a precise timestamp. These data points are arranged in a time sequence, forming the presser foot's position coordinates at various moments during its movement. By establishing a coordinate system with time as the horizontal axis and displacement as the vertical axis, and mapping all data points onto this plane, advanced curve fitting technology is then used to seamlessly connect these discrete points into a smooth curve. This curve represents the actual presser foot lifting trajectory, achieving precise visualization of the presser foot's movement state.

[0097] Please see Figure 7 The image shown is a schematic diagram illustrating the presser foot lifting trajectory according to an embodiment of this application.

[0098] The presser foot's lifting trajectory can reflect the speed changes and stability characteristics of the presser foot during the lifting process. For example... Figure 7As shown, the horizontal axis represents time, and the vertical axis represents the displacement of the presser foot. The trajectory begins at the starting point, marking the start of the lifting action. During continuous movement, the presser foot undergoes a period of oscillation and adjustment, which is represented in the graph as slight fluctuations in the trajectory line. Finally, the presser foot movement gradually stabilizes and precisely converges to the pre-set target height.

[0099] Step S330: Obtain the overshoot of the presser foot lifting trajectory.

[0100] In this embodiment, the overshoot of the presser foot lifting trajectory refers to the maximum deviation of the presser foot from the target height during the lifting process. For example, if the target presser foot lifting height is H, and the presser foot is actually lifted to H+ΔH, then ΔH is the overshoot of the presser foot lifting trajectory.

[0101] Step S340: Determine whether the overshoot exceeds the allowable overshoot range.

[0102] Step S350: If so, increase the initial parameter of the proportional gain KP to obtain the optimized proportional gain KP.

[0103] Step S360: Otherwise, reduce the initial parameter of the proportional gain KP to obtain the optimized proportional gain KP.

[0104] Please see Figure 8 The flowchart shown illustrates the initial parameters for increasing the proportional gain KP according to an embodiment of this application. Figure 8 As shown, the initial parameters for increasing the proportional gain KP in step S350 include the following steps S351 to S355.

[0105] Step S351: Determine the initial parameter range of the proportional gain KP through preliminary testing.

[0106] In one embodiment of this application, the determination of the initial parameter range of the proportional gain KP through preliminary testing in step S351 includes: selecting multiple sewing machines of the same model and specifications as test prototypes; testing each of the test prototypes to obtain the proportional gain KP test parameters that optimize the performance of the test prototype at each height sampling point; determining the fluctuation range of the proportional gain KP test parameters based on the distribution characteristics of the proportional gain KP test parameters of all test prototypes at the same height sampling point, and using the fluctuation range as the initial parameter range of the proportional gain KP.

[0107] Specifically, the proportional gain KP test parameters shown in Table 1 can first be sorted. For example, they can be arranged in ascending order to obtain an ordered sequence. Next, the mean and standard deviation of all proportional gain KP test parameters are calculated, where the mean reflects the central location of the data and the standard deviation reflects the dispersion of the data. Finally, the fluctuation range can be determined by adding or subtracting a certain number of times the standard deviation from the mean. For example, if 2 times the standard deviation is added or subtracted, the fluctuation range can be expressed as: in σ represents the average of the five proportional gain KP test parameters, and σ represents the standard deviation of the five proportional gain KP test parameters.

[0108] In other embodiments, appropriate percentiles can be selected to determine the fluctuation range. For example, the 5th percentile and the 95th percentile can be selected as the lower and upper limits of the fluctuation range, respectively.

[0109] Step S352: Add a first preset value to the initial parameter of the proportional gain KP to obtain the proportional gain KP with increment.

[0110] Step S353: Determine whether the incremental proportional gain KP is within the initial parameter range.

[0111] Step S354: If yes, replace the initial parameter of the proportional gain KP with the incremental proportional gain KP, repeat steps S310 and S320 to generate a new presser foot lifting trajectory, and repeat steps S330 and S340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, return to step S352; otherwise, subtract the second preset value from the incremental proportional gain KP to obtain the optimized proportional gain KP.

[0112] Step S355: Otherwise, report an error and end the loop.

[0113] In one embodiment of this application, the initial parameter of the proportional gain KP is KP0, and the corresponding initial parameter range is [KPmin, KPmax]. The initial parameter of the integral gain KI is KI0, and the corresponding initial parameter range is [KImin, KImax].

[0114] When the presser foot lifting trajectory generated based on initial parameters KP0 and KI0 exhibits overshoot, it indicates that the current initial parameter KP0 may be too small. It is necessary to increase the initial parameter KP0 by 1 to obtain an incremental proportional gain (KP0+1).

[0115] First, a range check is performed: if the incremental proportional gain (KP0+1) is within the range [KPmin, KPmax], then (KP0+1) replaces the initial parameter KP0, generating a new initial parameter (KP0+1). If (KP0+1) is not within the range [KPmin, KPmax], an error is reported, and the loop ends.

[0116] Next, overshoot is checked: if the presser foot lifting trajectory generated based on the initial parameter KI0 and the new initial parameter (KP0+1) still exhibits overshoot, it indicates that the current initial parameter (KP0+1) is still too small, and an incremental proportional gain (KP0+1+1) needs to be obtained again. If the presser foot lifting trajectory generated based on the initial parameter KI0 and the new initial parameter (KP0+1) does not exhibit overshoot, then (KP0+1-0.5) is used as the optimized proportional gain KP.

[0117] Please see Figure 9 The flowchart shown illustrates the initial parameters for reducing the proportional gain KP according to an embodiment of this application. Figure 9 As shown, reducing the initial parameters of the proportional gain KP includes the following steps S361 to S365.

[0118] Step S361: Determine the initial parameter range of the proportional gain KP through preliminary testing.

[0119] Step S362: Subtract the first preset value from the initial parameter of the proportional gain KP to obtain the proportional gain KP with reduction.

[0120] Step S363: Determine whether the proportional gain KP with the reduction is within the initial parameter range.

[0121] Step S364: If yes, replace the initial parameter of the proportional gain KP with the reduced proportional gain KP, repeat steps 310 and S320 to generate a new presser foot lifting trajectory, and repeat steps S330 and S340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, return to step S362; otherwise, increase the proportional gain KP with the reduced proportional gain KP by a second preset value to obtain the optimized proportional gain KP.

[0122] Step S365: Otherwise, report an error and end the loop.

[0123] In one embodiment of this application, when the presser foot lifting trajectory generated based on the initial parameters KP0 and KI0 does not have an overshoot phenomenon, it indicates that the current initial parameter KP0 may be too large, and it is necessary to subtract 1 from the initial parameter KP0 to obtain a proportional gain with reduction (KP0-1).

[0124] First, the range is checked: if the proportional gain with reduction (KP0-1) is within the range [KPmin, KPmax], then (KP0-1) replaces the initial parameter KP0, generating a new initial parameter (KP0-1). If (KP0-1) is not within the range [KPmin, KPmax], an error is reported, and the loop ends.

[0125] Next, overshoot detection is performed: if the presser foot lifting trajectory generated based on the initial parameter KI0 and the new initial parameter (KP0-1) still does not exhibit overshoot, it indicates that the current initial parameter (KP0-1) is still too large, and a reduced proportional gain (KP0-1-1) needs to be obtained again. If the presser foot lifting trajectory generated based on the initial parameter KI0 and the new initial parameter (KP0-1) exhibits overshoot, then (KP0-1+0.5) is used as the optimized proportional gain KP.

[0126] Please see Figure 10 The diagram shows a flowchart of dynamically adjusting the initial parameters of the integral gain KI according to an embodiment of this application. Figure 10 As shown, the dynamic adjustment of the initial parameters of the integral gain KI based on the adaptive algorithm includes the following steps S410 to S460.

[0127] Step S410: Based on the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI, generate a pulse width modulation control signal to drive the presser foot lifting mechanism of the sewing machine to perform the presser foot lifting action.

[0128] Step S420: Obtain the real-time displacement signal of the presser foot from the presser foot height sensor, and generate the presser foot lifting trajectory through signal processing.

[0129] Step S430: Obtain the overshoot of the presser foot lifting trajectory.

[0130] Step S440: Determine whether the overshoot exceeds the allowable overshoot range.

[0131] Step S450: If yes, then reduce the initial parameter of the integral gain KI to obtain the optimized integral gain KI.

[0132] Step S460: Otherwise, increase the initial parameter of the integral gain KI to obtain the optimized integral gain KI.

[0133] Please see Figure 11 The flowchart shown illustrates the initial parameters for reducing the integral gain KI according to an embodiment of this application. Figure 11 As shown, the initial parameters for reducing the integral gain KI in step S450 include the following steps S451 to S455.

[0134] Step S451: Determine the initial parameter range of the integral gain KI through preliminary testing.

[0135] Step S452: Subtract the first preset value from the initial parameter of the integral gain KI to obtain the integral gain KI with reduction.

[0136] Step S453: Determine whether the integral gain KI with decrement is within the initial parameter range.

[0137] Step S454: If yes, replace the initial parameter of the integral gain KI with the reduced integral gain KI, repeat steps 410 and S420 to generate a new presser foot lifting trajectory, and repeat steps S430 and S440 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, return to step S452; otherwise, increase the reduced integral gain KIP by a second preset value to obtain the optimized integral gain KI.

[0138] Step S455: Otherwise, report an error and end the loop.

[0139] In one embodiment of this application, when the presser foot lifting trajectory generated based on the initial parameters KP0 and KI0 has an overshoot phenomenon, it indicates that the current integral gain KI0 may be too large, and it is necessary to subtract 1 from the initial parameter KI0 to obtain the integral gain with reduction (KI0-1).

[0140] First, the range is checked: if the integral gain with decrement (KI0-1) is within the range [KImin, KImax], then (KI0-1) replaces the initial parameter KI0, generating a new initial parameter (KI0-1). If (KI0-1) is not within the range [KImin, KImax], an error is reported, and the loop ends.

[0141] Next, overshoot is checked: if the presser foot lifting trajectory generated based on the initial parameter KP0 and the new initial parameter (KI0-1) still exhibits overshoot, it indicates that the current initial parameter (KI0-1) is still too large, and a new integral gain with reduction (KI0-1-1) needs to be obtained. If the presser foot lifting trajectory generated based on the initial parameter KP0 and the new initial parameter (KI0-1) does not exhibit overshoot, then (KI0-1+0.5) is used as the optimized integral gain KI.

[0142] Please see Figure 12 The flowchart shown illustrates the initial parameters for increasing the integral gain KI according to an embodiment of this application. Figure 12 As shown, the initial parameters for increasing the integral gain KI in step S460 include the following steps S461 to S465.

[0143] Step S461: Determine the initial parameter range of the integral gain KI through preliminary testing.

[0144] Step S462: Add a first preset value to the initial parameter of the integral gain KI to obtain the integral gain KI with increment.

[0145] Step S463: Determine whether the incremental integral gain KI is within the initial parameter range.

[0146] Step S464: If yes, replace the initial parameter of the integral gain KI with the incremental integral gain KI, repeat steps S410 and S420 to generate a new presser foot lifting trajectory, and repeat steps S430 and S4340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory does not have overshoot, return to step S462; otherwise, subtract the second preset value from the incremental integral gain KI to obtain the optimized integral gain KI.

[0147] Step S465: Otherwise, report an error and end the loop.

[0148] In one embodiment of this application, when the presser foot lifting trajectory generated based on the initial parameters KP0 and KI0 does not have an overshoot phenomenon, it indicates that the current initial parameter KI0 may be too small, and it is necessary to increase the initial parameter KI0 by 1 to obtain an incremental integral gain (KI0+1).

[0149] First, the range is checked: if the incremental integral gain (KI0+1) is within the range [KImin, KImax], then (KI0+1) replaces the initial parameter KI0, generating a new initial parameter (KI0+1). If (KI0+1) is not within the range [KImin, KImax], an error is reported, and the loop ends.

[0150] Next, an overshoot judgment is performed: if the presser foot lifting trajectory generated based on the initial parameter KP0 and the new initial parameter (KI0+1) still does not exhibit overshoot, it indicates that the current initial parameter (KI0+1) is still too small, and an incremental integral gain (KI0+1+1) needs to be obtained again. If the presser foot lifting trajectory generated based on the initial parameter KP0 and the new initial parameter (KI0+1) exhibits overshoot, then (KI0+1-0.5) is used as the optimized integral gain.

[0151] This implementation significantly reduces the complexity of parameter optimization by employing a single-variable strategy of fixing one parameter and adjusting another. For example, by fixing the integral gain KI when testing the effect of the proportional gain KP, the independent effect of the proportional gain on the system's dynamic characteristics can be clearly observed, avoiding interference caused by two-parameter coupling. This step-by-step optimization method not only reduces the trial-and-error cost of parameter tuning but also allows engineers to more systematically understand the actual impact of each parameter. Compared to traditional manual parameter tuning methods, it is more flexible and efficient, and better adapts to the nonlinear characteristics of sewing machines and external disturbances.

[0152] Please see Figure 13 The image shown is a schematic diagram of a PI controller parameter optimization device based on an adaptive algorithm according to an embodiment of this application. Figure 13 As shown, this application provides a PI controller parameter optimization device based on an adaptive algorithm, including a preliminary testing module 21, a sampling setting module 22, and a parameter adjustment module 23.

[0153] The preliminary test module 21 is used to determine the initial parameters of the proportional gain KP and integral gain KI of the PI controller through preliminary testing.

[0154] The sampling setting module 22 is used to set multiple height sampling points within the presser foot stroke range of the sewing machine.

[0155] The parameter adjustment module 23 is used to keep one of the initial parameters of the proportional gain KP and the integral gain KI constant for each height sampling point, and dynamically adjust the other parameter based on an adaptive algorithm to obtain the optimized parameters of the PI controller.

[0156] Please see Figure 14 The image shown is a schematic diagram of the structure of a terminal according to an embodiment of this application. Figure 14 As shown, this application provides a terminal, including a memory 31 and a processor 32.

[0157] The memory 31 is used to store computer programs.

[0158] The processor 32 is configured to execute the computer program stored in the memory to cause the terminal to perform any of the methods described above.

[0159] Preferably, the processor 32 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The memory 31 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0160] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, or methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules / units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of apparatuses or modules or units may be electrical, mechanical, or other forms.

[0161] The modules / units described as separate components may or may not be physically separate. The components shown as modules / units may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules / units can be selected to achieve the objectives of the embodiments of this application, depending on actual needs. For example, the functional modules / units in the various embodiments of this application may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.

[0162] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. 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.

[0163] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.

[0164] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.

Claims

1. A method for optimizing PI controller parameters based on an adaptive algorithm, characterized in that, include: The initial parameters of the proportional gain KP and integral gain KI of the PI controller were determined through preliminary testing. Multiple height sampling points are set within the presser foot stroke range of the sewing machine; For each height sampling point, keep either the initial parameter of the proportional gain KP or the initial parameter of the integral gain KI constant, and dynamically adjust the other parameter based on an adaptive algorithm to obtain the optimized parameters of the PI controller. The initial parameters of the proportional gain KP are dynamically adjusted based on an adaptive algorithm, including: Step S310: Based on the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI, generate a pulse width modulation control signal to drive the presser foot lifting mechanism of the sewing machine to perform the presser foot lifting action. Step S320: Obtain the real-time displacement signal of the presser foot from the presser foot height sensor, and generate the presser foot lifting trajectory through signal processing; Step S330: Obtain the overshoot of the presser foot lifting trajectory; Step S340: Determine whether the overshoot exceeds the allowable overshoot range; Step S350: If so, increase the initial parameter of the proportional gain KP to obtain the optimized proportional gain KP; Step S360: Otherwise, reduce the initial parameter of the proportional gain KP to obtain the optimized proportional gain KP; The initial parameters for increasing the proportional gain KP include: Step S351: Determine the initial parameter range of the proportional gain KP through preliminary testing; Step S352: Add a first preset value to the initial parameter of the proportional gain KP to obtain the proportional gain KP with increment; Step S353: Determine whether the incremental proportional gain KP is within the initial parameter range; Step S354: If yes, replace the initial parameter of the proportional gain KP with the incremental proportional gain KP, repeat steps S310 and S320 to generate a new presser foot lifting trajectory, and repeat steps S330 and S340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, return to step S352; otherwise, subtract the second preset value from the incremental proportional gain KP to obtain the optimized proportional gain KP. Step S355: Otherwise, report an error and end the loop.

2. The method according to claim 1, characterized in that, The initial parameters for reducing the proportional gain KP include: Step S361: Determine the initial parameter range of the proportional gain KP through preliminary testing; Step S362: Subtract the first preset value from the initial parameter of the proportional gain KP to obtain the proportional gain KP with reduction; Step S363: Determine whether the proportional gain KP with the reduction is within the initial parameter range; Step S364: If yes, replace the initial parameter of the proportional gain KP with the reduced proportional gain KP, repeat steps 310 and S320 to generate a new presser foot lifting trajectory, and repeat steps S330 and S340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, return to step S362; otherwise, increase the proportional gain KP with the reduced proportional gain KP by a second preset value to obtain the optimized proportional gain KP. Step S365: Otherwise, report an error and end the loop.

3. The method according to claim 1, characterized in that, The initial parameters of the integral gain KI are dynamically adjusted based on an adaptive algorithm, including: Step S410: Based on the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI, generate a pulse width modulation control signal to drive the presser foot lifting mechanism of the sewing machine to perform the presser foot lifting action. Step S420: Obtain the real-time displacement signal of the presser foot from the presser foot height sensor, and generate the presser foot lifting trajectory through signal processing; Step S430: Obtain the overshoot of the presser foot lifting trajectory; Step S440: Determine whether the overshoot exceeds the allowable overshoot range; Step S450: If yes, then reduce the initial parameter of the integral gain KI to obtain the optimized integral gain KI; Step S460: Otherwise, increase the initial parameter of the integral gain KI to obtain the optimized integral gain KI.

4. The method according to claim 1, characterized in that, The initial parameters for the proportional gain KP and integral gain KI of the PI controller were determined through preliminary testing, including: Multiple sewing machines of the same model and specifications were selected as test samples; Each of the test prototypes was tested to obtain the proportional gain KP test parameters and integral gain KI test parameters that optimize the performance of the test prototypes at each height sampling point. The initial parameters of the proportional gain KP are obtained by arithmetically averaging the test parameters of all test prototypes at the same sampling point. The initial parameters of the integral gain KI are obtained by arithmetically averaging the test parameters of all test prototypes at the same sampling point.

5. The method according to claim 4, characterized in that, Also includes: The pressure adjusting nuts of the test prototypes are all set to the middle scale; at the middle scale, the compression of the pressure adjusting springs of all the test prototypes is consistent.

6. The method according to claim 2, characterized in that, The initial parameter range of the proportional gain KP was determined through preliminary testing, including: Multiple sewing machines of the same model and specifications were selected as test samples; Each of the test prototypes was tested separately to obtain the proportional gain KP test parameters that optimize the performance of the test prototypes at each height sampling point. Based on the distribution characteristics of the proportional gain KP test parameters of all test prototypes at the same height sampling point, the fluctuation range of the proportional gain KP test parameters is determined, and the fluctuation range is used as the initial parameter interval of the proportional gain KP.

7. A PI controller parameter optimization device based on an adaptive algorithm, characterized in that, include: The preliminary test module is used to determine the initial parameters of the proportional gain KP and integral gain KI of the PI controller through preliminary testing. The sampling setting module is used to set multiple height sampling points within the presser foot stroke range of the sewing machine; The parameter adjustment module is used to keep one of the initial parameters of the proportional gain KP and the integral gain KI constant for each height sampling point, and dynamically adjust the other parameter based on an adaptive algorithm to obtain the optimized parameters of the PI controller. The parameter adjustment module dynamically adjusts the initial parameters of the proportional gain KP based on an adaptive algorithm, including: Step S310: Based on the initial parameters of the proportional gain KP and the initial parameters of the integral gain KI, generate a pulse width modulation control signal to drive the presser foot lifting mechanism of the sewing machine to perform the presser foot lifting action. Step S320: Obtain the real-time displacement signal of the presser foot from the presser foot height sensor, and generate the presser foot lifting trajectory through signal processing; Step S330: Obtain the overshoot of the presser foot lifting trajectory; Step S340: Determine whether the overshoot exceeds the allowable overshoot range; Step S350: If so, increase the initial parameter of the proportional gain KP to obtain the optimized proportional gain KP; Step S360: Otherwise, reduce the initial parameter of the proportional gain KP to obtain the optimized proportional gain KP; The initial parameters for increasing the proportional gain KP include: Step S351: Determine the initial parameter range of the proportional gain KP through preliminary testing; Step S352: Add a first preset value to the initial parameter of the proportional gain KP to obtain the proportional gain KP with increment; Step S353: Determine whether the incremental proportional gain KP is within the initial parameter range; Step S354: If yes, replace the initial parameter of the proportional gain KP with the incremental proportional gain KP, repeat steps S310 and S320 to generate a new presser foot lifting trajectory, and repeat steps S330 and S340 to perform overshoot judgment on the new presser foot lifting trajectory; if the new presser foot lifting trajectory has overshoot, return to step S352; otherwise, subtract the second preset value from the incremental proportional gain KP to obtain the optimized proportional gain KP. Step S355: Otherwise, report an error and end the loop.

8. A terminal, characterized in that, include: The memory is used to store computer programs; A processor for executing a computer program stored in the memory to cause the terminal to perform the method of any one of claims 1 to 6.