An embroidery machine XY frame moving absolute position control method and system based on SPI bus

CN122522498APending Publication Date: 2026-08-07FUZHOU HUICHUANG INTELLIGENT CONTROL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-09
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

传统脉冲方案成本低但可靠性差、精度无保障;而实时以太网方案精度高但成本过高、系统复杂,难以在注重性价比的工业领域大规模应用

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122522498A_ABST
    Figure CN122522498A_ABST
Patent Text Reader

Abstract

The application provides a kind of embroidery machine XY frame moving absolute position control method and system based on SPI bus in the technical field of embroidery machine, method includes: step S1, trajectory look-ahead and motion curve planning are generated frame moving control data;Step S2, motion coprocessor reads frame moving control data;Step S3, frame moving control data is encapsulated into custom protocol frame to form target absolute position instruction, and is sent to XY axis drive processor by SPI bus;Step S4, XY axis drive processor parses custom protocol frame and obtains target absolute position instruction, to drive execution frame moving action;Step S5, real-time actual position information is fed back to motion coprocessor;Step S6, real-time actual position information is compared with target absolute position instruction, and position correction processing or abnormal alarm is carried out according to deviation value.The application has the advantages that: embroidery machine XY frame moving control precision and long-term operation reliability are greatly improved, and hardware cost and implementation complexity are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of embroidery machine technology, and in particular to an absolute position control method and system for XY frame shifting of an embroidery machine based on the SPI bus. Background Technology

[0002] An embroidery machine is an automated device that controls the movement of an XY-axis frame (frame shifter) to create relative displacement between the embroidery fabric and the needle, thereby completing the embroidery of complex patterns. The precision, real-time performance, and reliability of the frame shifter control are core factors determining the quality of the embroidery. Currently, the mainstream control methods in the industry mainly fall into two categories, each with significant drawbacks: 1. Pulse / Dir-based position control method: This method uses a pulse sequence sent by the main controller to the driver to control the motor's rotation angle, thereby indirectly controlling the position. Its inherent drawback is: Open-loop cumulative error: The system cannot directly and in real time obtain the actual absolute position of the motor; it can only estimate the position based on the number of pulses sent. In actual operation, motor step loss or overshoot caused by sudden load changes, mechanical slippage, or interference will produce an accumulated deviation between the commanded position and the actual position that cannot be detected by the system (i.e., "step loss and position deviation"), which seriously affects the accuracy and reliability of long-term operation.

[0003] Limitations on signal reliability: Pulse signals are transmitted over long distances, making them less resistant to interference and more susceptible to environmental electromagnetic noise, which further exacerbates the uncertainty of position control.

[0004] 2. Position control method based on high-end real-time industrial Ethernet (such as EtherCAT, PROFINET): This method sends the target position command through the bus and provides real-time feedback of the encoder position, achieving full closed-loop control with high accuracy. However, its shortcomings are also prominent: High cost: The dedicated master control chip, slave controller chip and physical layer interface that support this type of real-time Ethernet protocol are expensive, which significantly increases the overall cost of the machine.

[0005] System complexity and redundancy: The protocol stack is large, and the data encapsulation, unpacking, and synchronization processes are complex, placing extremely high demands on the computing power and real-time performance of the main controller. In scenarios like embroidery machine frame shifting control, where the number of axes is limited and the data model is relatively fixed, introducing such a complex system is redundant, resulting in unnecessary resource waste and increased development and maintenance difficulties.

[0006] In summary, existing technologies present a dilemma where "high precision and low cost are mutually exclusive." Traditional pulse solutions are low-cost but have poor reliability and unreliable accuracy; while real-time Ethernet solutions offer high precision but are too expensive and complex, making them difficult to apply on a large scale in industrial sectors where cost-effectiveness is paramount.

[0007] Therefore, how to provide an absolute position control method and system for the XY frame shifting of an embroidery machine based on the SPI bus, so as to improve the control accuracy and long-term operational reliability of the XY frame shifting of the embroidery machine, while reducing hardware costs and implementation complexity, has become an urgent technical problem to be solved. Summary of the Invention

[0008] The technical problem to be solved by the present invention is to provide an absolute position control method and system for XY frame shifting of an embroidery machine based on SPI bus, so as to improve the control accuracy and long-term operational reliability of XY frame shifting of the embroidery machine, while reducing hardware cost and implementation complexity.

[0009] In a first aspect, the present invention provides a method for absolute position control of XY frame shifting in an embroidery machine based on an SPI bus, comprising the following steps: Step S1: The main controller parses the embroidery pattern data, performs trajectory look-ahead and motion curve planning, generates frame shifting control data containing the absolute position information of the target, and stores the frame shifting control data in the needle data cache. Step S2: The motion coprocessor, acting as the master device for SPI communication, reads the current and subsequent frame shift control data from the needle data buffer. Step S3: The motion coprocessor encapsulates the read frame-shifting control data into the data segment of a custom protocol frame to form a target absolute position instruction, and sends the custom protocol frame to the XY axis drive processor, which is a slave device, via the SPI bus. Step S4: The XY axis drive processor receives and parses the custom protocol frame to obtain the target absolute position command, and drives the motor to perform the frame-shifting action based on the target absolute position command; Step S5: After the XY axis drive processor completes the execution of the target absolute position command, or during the execution process, it feeds back the real-time actual position information of the motor to the motion coprocessor via the SPI bus. Step S6: The motion coprocessor receives the real-time actual position information, compares the real-time actual position information with the target absolute position command, and performs position correction processing or abnormal alarm based on the deviation value.

[0010] Furthermore, in step S1, the trajectory look-ahead and motion curve planning includes: dynamically calculating the velocity increment of the frame movement based on the angle between consecutive stitch points, so as to achieve smooth acceleration and deceleration during the motion process.

[0011] Furthermore, in step S3, the data segment of the custom protocol frame includes a device bitmap field, a data field length field, and a parameter data field; each bit of the device bitmap field maps to a slave device, used to dynamically indicate whether there is data of the corresponding device in the current frame, so as to realize on-demand adaptation of communication load; the parameter data field is composed of a group of device data units in sequence, and each group of device data units includes a device identifier byte and the parameter data structure corresponding to the device that follows it. When the motion coprocessor communicates with the XY axis drive processor, it uses the NSS chip select signal of the SPI bus to achieve synchronous interpolation. Before the previous frame shifting action ends, the motion coprocessor preloads the target absolute position information of the next frame into the XY axis drive processor. When the spindle synchronization signal is received, the motion coprocessor controls the level transition of the NSS chip select signal to trigger the XY axis drive processor to switch synchronously and execute the new target absolute position command. The XY-axis drive processor has an internal instruction register. During non-NSS chip select signal switching cycles, the XY-axis drive processor executes the target absolute position instruction in the current instruction register. When the NSS chip select signal is triggered by a rising edge, the XY-axis drive processor synchronously switches the pre-loaded new target absolute position instruction to the instruction register and immediately begins execution.

[0012] Furthermore, in step S6, comparing the real-time actual location information with the target absolute location command using a two-way closed-loop verification mechanism specifically involves: The XY axis drive processor receives the target absolute position command in frame T and transmits the real-time actual position information of the motor at the time of frame T via the SPI bus in frame T+1. The motion coprocessor calculates the deviation between the transmitted real-time actual position information and the target absolute position command sent in frame T. If the deviation exceeds a preset threshold, position correction processing or an abnormal alarm is performed. The position correction process specifically involves superimposing a compensation value that is opposite to the deviation amount when calculating the target absolute position command for the next cycle.

[0013] Furthermore, the main controller, motion coprocessor, and XY axis drive processor constitute a three-level computing task decoupled architecture; The main controller is responsible for parsing embroidery pattern data and planning embroidery trajectory; the motion coprocessor is responsible for SPI bus communication, protocol encapsulation, and position feedback processing; and the XY axis drive processor is responsible for executing target absolute position commands and providing real-time actual position information feedback.

[0014] Secondly, the present invention provides an absolute position control system for XY frame shifting of an embroidery machine based on an SPI bus, comprising the following modules: The frame shifting control data generation module is used by the main controller to parse embroidery pattern data, perform trajectory prediction and motion curve planning, generate frame shifting control data containing target absolute position information, and store the frame shifting control data in the needle data cache. The frame shifting control data reading module is used by the motion coprocessor as the master device of SPI communication to read the current and subsequent frame shifting control data from the needle data buffer; A custom protocol frame sending module is used by the motion coprocessor to encapsulate the read frame-shifting control data into the data segment of the custom protocol frame to form the target absolute position instruction, and send the custom protocol frame to the XY axis drive processor as a slave device via the SPI bus; The frame-shifting module is used by the XY axis drive processor to receive and parse the custom protocol frame to obtain the target absolute position command, and drive the motor to perform the frame-shifting action based on the target absolute position command; The real-time actual position information feedback module is used to feed back the real-time actual position information of the motor to the motion coprocessor via the SPI bus after the XY axis drive processor completes the execution of the target absolute position command, or during the execution process. The position comparison module is used by the motion coprocessor to receive the real-time actual position information, compare the real-time actual position information with the target absolute position command, and perform position correction processing or abnormal alarm based on the deviation value.

[0015] Furthermore, in the frame-shifting control data generation module, the trajectory look-ahead and motion curve planning includes: dynamically calculating the frame-shifting speed increment based on the angle between consecutive stitch points, so as to achieve smooth acceleration and deceleration during the motion process.

[0016] Furthermore, in the custom protocol frame sending module, the data segment of the custom protocol frame includes a device bitmap field, a data field length field, and a parameter data field; each bit of the device bitmap field maps to a slave device, used to dynamically indicate whether there is data of the corresponding device in the current frame, so as to realize on-demand adaptation of communication load; the parameter data field is composed of a group of device data units in sequence, and each group of device data units includes a device identifier byte and the parameter data structure corresponding to the device that follows it. When the motion coprocessor communicates with the XY axis drive processor, it uses the NSS chip select signal of the SPI bus to achieve synchronous interpolation. Before the previous frame shifting action ends, the motion coprocessor preloads the target absolute position information of the next frame into the XY axis drive processor. When the spindle synchronization signal is received, the motion coprocessor controls the level transition of the NSS chip select signal to trigger the XY axis drive processor to switch synchronously and execute the new target absolute position command. The XY-axis drive processor has an internal instruction register. During non-NSS chip select signal switching cycles, the XY-axis drive processor executes the target absolute position instruction in the current instruction register. When the NSS chip select signal is triggered by a rising edge, the XY-axis drive processor synchronously switches the pre-loaded new target absolute position instruction to the instruction register and immediately begins execution.

[0017] Furthermore, in the location comparison module, the comparison of the real-time actual location information with the target absolute location command employs a two-way closed-loop verification mechanism, specifically as follows: The XY axis drive processor receives the target absolute position command in frame T and transmits the real-time actual position information of the motor at the time of frame T via the SPI bus in frame T+1. The motion coprocessor calculates the deviation between the transmitted real-time actual position information and the target absolute position command sent in frame T. If the deviation exceeds a preset threshold, position correction processing or an abnormal alarm is performed. The position correction process specifically involves superimposing a compensation value that is opposite to the deviation amount when calculating the target absolute position command for the next cycle.

[0018] Furthermore, the main controller, motion coprocessor, and XY axis drive processor constitute a three-level computing task decoupled architecture; The main controller is responsible for parsing embroidery pattern data and planning embroidery trajectory; the motion coprocessor is responsible for SPI bus communication, protocol encapsulation, and position feedback processing; and the XY axis drive processor is responsible for executing target absolute position commands and providing real-time actual position information feedback. The advantages of this invention are: 1. By establishing a fully digital communication link using the low-cost general-purpose SPI bus and utilizing its NSS signal to achieve multi-axis synchronization, the anti-interference capability and synchronization reliability of signal transmission are fundamentally improved. Simultaneously, a three-level decoupled architecture of the main controller, motion coprocessor, and drive processor is constructed. The motion coprocessor is dedicated to SPI communication and protocol processing, and a custom lightweight protocol including device bitmaps is designed to achieve on-demand communication. This significantly simplifies system complexity and reduces the requirements for main controller computing power and hardware costs. More importantly, the SPI bus enables closed-loop feedback and bidirectional verification of real-time actual position, dynamically calculating position deviations and compensating for them in subsequent instructions. This completely solves the problem of accumulated step loss errors caused by traditional open-loop pulse control, ultimately achieving an optimized balance between system cost and complexity while ensuring high precision and long-term operational reliability.

[0019] 2. Achieving high-precision real-time position feedback and closed-loop control improves embroidery quality and system reliability: The SPI bus is used as the communication medium, and its full-duplex characteristic provides a physical basis for real-time, bidirectional data interaction. The XY axis drive processor can feed back the real-time actual position information of the motor to the motion coprocessor, which can immediately compare it with the target command. Within the next frame cycle after the target command is issued, the system can obtain execution feedback and calculate the deviation, enabling the system to quickly detect and compensate for small position errors (such as superimposing reverse compensation values) or trigger abnormal alarms. This mechanism effectively suppresses the cumulative error caused by factors such as motor step loss, mechanical backlash, or load disturbance, ensuring the long-term accuracy and stability of frame positioning, which is directly related to the contour accuracy and overall quality of the embroidery pattern.

[0020] 3. Through hierarchical task decoupling and a dedicated coprocessor architecture, the system's real-time performance and computational efficiency are significantly optimized: The three-level computational task decoupling architecture, consisting of the main controller, motion coprocessor, and XY axis drive processor, professionally divides complex control tasks: the main controller focuses on high-level pattern analysis and trajectory planning; the motion coprocessor is dedicated to handling high-speed SPI communication, protocol encapsulation, and position data processing; and the drive processor focuses on low-level motor driving and position sampling. This decoupling avoids the processing bottlenecks and timing conflicts that may arise from concentrating all tasks on a single main control chip, enabling each part to work in parallel and efficiently. In particular, the dedicated motion coprocessor manages SPI communication and preprocessing, greatly reducing the interrupt burden on the main controller and ensuring high real-time performance and determinism of motion control commands and feedback information transmission, providing a solid system performance foundation for high-speed embroidery.

[0021] 4. Highly efficient and flexible multi-axis synchronous control was achieved using the SPI bus and a custom protocol frame: A custom protocol frame was designed based on the SPI bus. The device bitmap field in this frame structure allows dynamic indication of the slave device corresponding to the current frame data, realizing on-demand allocation of communication load and improving the utilization efficiency of bus bandwidth. More importantly, by cleverly utilizing the SPI NSS (chip select) signal as a hardware synchronization signal, combined with the instruction register inside the driver processor, the "preloading" and "synchronous trigger execution" of the frame shifting instruction were realized. When the main spindle synchronization signal arrives, the NSS level transition can trigger the synchronous switching of all axes and the execution of new position instructions. This ensures that in multi-axis linkage embroidery movements, the frame shifting of the XY axes can achieve precise hard synchronization with the main spindle (needle movement), effectively avoiding the problem of asynchronous movement caused by communication or processing delays. This is crucial for complex patterns and high-speed embroidery.

[0022] 5. The combination of absolute position control and intelligent trajectory planning enhances motion smoothness and system robustness: The core of the control command is the target's absolute position information, rather than the traditional pulse increment, making each frame of command independent and clear. The system does not rely on historical command sequences, resulting in stronger anti-interference capabilities. Even after a brief communication interruption, it can quickly locate the correct absolute coordinates. Simultaneously, during the trajectory planning stage, the speed increment is dynamically calculated based on the angle between consecutive stitch points, achieving smooth acceleration and deceleration during motion. This proactive planning avoids sudden speed changes, reduces mechanical shock and vibration during motor start-up, shutdown, and reversal, resulting in smoother operation, lower noise, extended service life of mechanical components, and the possibility of further increasing embroidery speed.

[0023] 6. Enhanced scalability and communication reliability: The custom protocol frame structure design offers excellent flexibility; data segments consist of parameter data fields, which in turn are composed of standardized "device data units" in sequence. Each unit contains a device identifier and a corresponding parameter structure. This modular design allows for the addition of new slave devices (such as other auxiliary axes) to the bus simply by following the same unit format, resulting in excellent scalability. Furthermore, the mechanism of using NSS signals for synchronous interpolation and instruction preloading, along with a rigorous "one-to-one" closed-loop verification process, together constitute a robust communication and execution guarantee mechanism. This minimizes the risk of control failure due to communication errors or timing discrepancies, thereby improving the reliability and fault tolerance of the entire control system. Attached Figure Description

[0024] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0025] Figure 1 This is a flowchart of an embroidery machine XY frame shifting absolute position control method based on SPI bus according to the present invention.

[0026] Figure 2 This is a schematic diagram of the structure of an XY shifting absolute position control system for an embroidery machine based on the SPI bus according to the present invention. Detailed Implementation

[0027] The overall concept of the technical solution in this application embodiment is as follows: Addressing the contradiction between "high precision and high cost" and "low cost and low reliability" in existing embroidery machine frame shifting control technology, this paper innovatively adopts a low-cost, universal SPI bus to construct a fully digital communication link. Furthermore, it professionally divides the computational tasks through a three-level decoupled architecture of "main controller - motion coprocessor - XY axis drive processor." Based on this hardware, a control mechanism is developed around the SPI bus, incorporating a lightweight custom protocol, utilizing NSS chip select signals to achieve multi-axis hard synchronization, and performing real-time closed-loop feedback and deviation compensation based on absolute position commands. This significantly reduces system hardware costs and implementation complexity while fundamentally solving the cumulative error problem of traditional open-loop pulse control, achieving high-precision, high-reliability, and high-synchronization absolute position control for the XY frame shifting of an embroidery machine.

[0028] Please refer to Figures 1 to 2 As shown, a preferred embodiment of the present invention, a method for absolute position control of XY frame shifting of an embroidery machine based on SPI bus, includes the following steps: Step S1: The main controller parses the embroidery pattern data, performs trajectory look-ahead and motion curve planning, generates frame shifting control data containing the absolute position information of the target, and stores the frame shifting control data in the needle data cache. Step S2: The motion coprocessor, acting as the master device for SPI communication, reads the current and subsequent frame shift control data from the needle data buffer. Step S3: The motion coprocessor encapsulates the read frame-shifting control data into the data segment of a custom protocol frame to form a target absolute position instruction, and sends the custom protocol frame to the XY axis drive processor, which is a slave device, via the SPI bus. Step S4: The XY axis drive processor receives and parses the custom protocol frame to obtain the target absolute position command, and drives the motor to perform the frame-shifting action based on the target absolute position command; Step S5: After the XY axis drive processor completes the execution of the target absolute position command, or during the execution process, it feeds back the real-time actual position information of the motor to the motion coprocessor via the SPI bus. Step S6: The motion coprocessor receives the real-time actual position information, compares the real-time actual position information with the target absolute position command, and performs position correction processing or abnormal alarm based on the deviation value.

[0029] In step S1, the trajectory look-ahead and motion curve planning includes: dynamically calculating the velocity increment of the frame movement based on the angle between consecutive stitch points, so as to achieve smooth acceleration and deceleration during the motion process.

[0030] In step S3, the data segment of the custom protocol frame includes a device bitmap field, a data field length field, and a parameter data field. Each bit of the device bitmap field maps to a slave device, used to dynamically indicate whether there is data of the corresponding device in the current frame, so as to realize on-demand adaptation of communication load. The parameter data field is composed of a group of device data units in sequence. Each group of device data units includes a device identifier byte and the parameter data structure corresponding to the device. The device bitmap field is 2 bytes long, with a total of 16 bits. Each bit corresponds to a physical or logical driver device. When the value of the bit is 1, it indicates that the data segment contains the data unit of the device. When the value of the bit is 0, it indicates that the data segment does not contain the data unit of the device. The frame structure of the custom protocol frame is as follows:

[0031] HC header: Frame header synchronization code, used to detect bus conflicts and distinguish data from different models.

[0032] Device bitmap: 2 bytes, 16 bits in total. Each bit is set to 1 to indicate that the device data information it represents exists. Each device has a predefined data structure. Through the device index field, the data of a certain device can be added or removed according to the current control needs. This allows for quick parsing of the data information of a certain device and also reduces the data of certain devices that do not need to be controlled at the moment, thereby improving communication efficiency.

[0033] Length len (data field length field): The length of the data field.

[0034] Data (parameter data field): The data segment has a 1-byte device number + the parameter data structure corresponding to that device (first device ID + first device data structure + ... + nth device ID + nth device data structure). CRC check: Cyclic Redundancy Check, ensuring the physical layer security of bus transmission.

[0035] The custom protocol frame, employing the aforementioned structure, offers core advantages in communication flexibility and efficiency. Through the 'device bitmap' field, the master device (motion coprocessor) can flexibly select which slave devices (such as X-axis and Y-axis drivers) to communicate with within a single data frame, achieving 'on-demand communication' and avoiding wasted bus bandwidth. When the number of axes in the system expands, only the bitmap bit depth and the corresponding 'device data unit' in the data segment need to be increased accordingly, demonstrating excellent scalability. Simultaneously, the 'HC header' is used for frame synchronization and machine type identification, enhancing compatibility and anti-interference capabilities between different systems; the 'CRC checksum' ensures the integrity of data transmission. This lightweight protocol design, compared to complex industrial Ethernet protocol stacks, significantly reduces the computational demands on the processor, making it possible to achieve high-performance motion control using general-purpose, low-cost microprocessors.

[0036] When the motion coprocessor communicates with the XY axis drive processor, it uses the NSS chip select signal of the SPI bus to achieve synchronous interpolation. Before the previous frame shifting action ends, the motion coprocessor preloads the target absolute position information of the next frame into the XY axis drive processor. When the spindle synchronization signal is received, the motion coprocessor controls the level transition of the NSS chip select signal to trigger the XY axis drive processor to switch synchronously and execute the new target absolute position command. The XY-axis drive processor has an internal instruction register. During non-NSS chip select signal switching cycles, the XY-axis drive processor executes the target absolute position instruction in the current instruction register. When the NSS chip select signal is triggered by a rising edge, the XY-axis drive processor synchronously switches the pre-loaded new target absolute position instruction to the instruction register and immediately begins execution.

[0037] Utilizing the NSS (Slave Select) signal line inherent in the SPI bus to achieve hardware-level synchronization is key to realizing high-precision multi-axis collaborative control. Its working principle can be analogous to a 'double-buffered' mechanism: before the previous stitch's frame-shifting action is finished, the motion coprocessor pre-transmits (preloads) the 'target absolute position instruction' for the next stitch into the cache of the XY-axis drive processor via the SPI data line. At this time, the drive processor continues to execute the instructions in the current instruction register. When the 'spindle synchronization signal' marking the stitch's movement cycle arrives, the motion coprocessor does not immediately send new data, but simply generates a rising edge (such as a falling edge) of the NSS chip select signal. This rising edge acts as a global hardware synchronization signal, simultaneously triggering all XY-axis drive processors to synchronously and instantaneously switch their internally preloaded new instructions to the instruction register and begin execution. This mechanism ensures that the frame-shifting actions on the X and Y axes can be started in strict synchronization and maintain precise timing alignment with the main axis (embroidery needle) action. It fundamentally avoids the problem of asynchrony between axes caused by software processing delays or communication timing jitter, which is crucial for ensuring the pattern accuracy under high-speed embroidery.

[0038] In step S6, comparing the real-time actual location information with the target absolute location command using a two-way closed-loop verification mechanism specifically involves: The XY axis drive processor receives the target absolute position command in frame T and transmits the real-time actual position information of the motor at the time of frame T via the SPI bus in frame T+1. The motion coprocessor calculates the deviation between the transmitted real-time actual position information and the target absolute position command sent in frame T. If the deviation exceeds a preset threshold, position correction processing or an abnormal alarm is performed. The position correction process specifically involves superimposing a compensation value that is opposite to the deviation amount when calculating the target absolute position command for the next cycle.

[0039] The bidirectional closed-loop verification mechanism constructs a real-time, closed-loop position control circuit. Its 'bidirectional' nature is reflected in the fact that the motion coprocessor sends target commands to the drive processor (forward channel), and the drive processor sends the actual position back to the motion coprocessor (feedback channel). Its 'closed-loop' nature is reflected in the fact that the motion coprocessor compares the commands and feedback and compensates for any discrepancies.

[0040] Specifically, this mechanism operates in steps of communication frame periods (T frames). In frame T, the motion coprocessor sends the target position command P_T; the XY axis drive processor receives and executes it, and during or after execution, samples the encoder in real time to obtain the actual position A_T. In frame T+1, the drive processor sends A_T back as feedback data. Upon receiving this, the motion coprocessor immediately calculates the deviation e = P_T - A_T. If |e| exceeds a preset safety threshold, an alarm is triggered; if it is within the threshold but not zero, when calculating the target command P{T+1} for the next cycle, the planned position is not used directly, but a compensation value is added, i.e., P'{T+1} = P_{T+1} - ke (k is the compensation coefficient). This closed loop of 'command-execution-feedback-compensation' can dynamically correct deviations caused by motor step loss, mechanical transmission backlash, or load disturbances, preventing error accumulation and ensuring the long-term positional accuracy and reliability of the embroidery machine. This is a fundamental advantage that traditional open-loop pulse control schemes cannot achieve.

[0041] The main controller, motion coprocessor, and XY axis drive processor constitute a three-level decoupled computing task architecture. The main controller is responsible for parsing embroidery pattern data and planning embroidery trajectory; the motion coprocessor is responsible for SPI bus communication, protocol encapsulation, and position feedback processing; and the XY axis drive processor is responsible for executing target absolute position commands and providing real-time actual position information feedback.

[0042] The three-tiered decoupled computing architecture is not simply a functional division, but a deep optimization tailored to the control characteristics of an embroidery machine. The main controller (such as a high-performance application processor) is freed to focus on upper-level pattern analysis and complex trajectory planning; dedicated motion coprocessors (such as FPGAs or dedicated motion control chips) efficiently handle high real-time SPI communication, protocol encapsulation, and position loop calculations; and XY-axis drive processors (such as servo drivers with position loops or integrated drive chips) focus on the lowest-level current loop, speed loop control, and high-frequency position sampling. This architecture allows each level of processor to select the most suitable and cost-effective chip for its task, avoiding the situation where excessively expensive processors are used to meet the most demanding real-time requirements. Simultaneously, the decoupling between levels reduces the coupling between system modules, improving system maintainability and upgradeability.

[0043] A preferred embodiment of the SPI bus-based XY frame shifting absolute position control system for an embroidery machine according to the present invention includes the following modules: The frame shifting control data generation module is used by the main controller to parse embroidery pattern data, perform trajectory prediction and motion curve planning, generate frame shifting control data containing target absolute position information, and store the frame shifting control data in the needle data cache. The frame shifting control data reading module is used by the motion coprocessor as the master device of SPI communication to read the current and subsequent frame shifting control data from the needle data buffer; A custom protocol frame sending module is used by the motion coprocessor to encapsulate the read frame-shifting control data into the data segment of the custom protocol frame to form the target absolute position instruction, and send the custom protocol frame to the XY axis drive processor as a slave device via the SPI bus; The frame-shifting module is used by the XY axis drive processor to receive and parse the custom protocol frame to obtain the target absolute position command, and drive the motor to perform the frame-shifting action based on the target absolute position command; The real-time actual position information feedback module is used to feed back the real-time actual position information of the motor to the motion coprocessor via the SPI bus after the XY axis drive processor completes the execution of the target absolute position command, or during the execution process. The position comparison module is used by the motion coprocessor to receive the real-time actual position information, compare the real-time actual position information with the target absolute position command, and perform position correction processing or abnormal alarm based on the deviation value.

[0044] In the frame-shifting control data generation module, the trajectory look-ahead and motion curve planning includes: dynamically calculating the frame-shifting speed increment based on the angle between consecutive stitch points, so as to achieve smooth acceleration and deceleration during the motion process.

[0045] In the custom protocol frame sending module, the data segment of the custom protocol frame includes a device bitmap field, a data field length field, and a parameter data field. Each bit of the device bitmap field maps to a slave device, used to dynamically indicate whether the corresponding device's data exists in the current frame, so as to realize on-demand adaptation of communication load. The parameter data field is composed of a group of device data units in sequence. Each group of device data units includes a device identifier byte and the parameter data structure corresponding to the device. The device bitmap field is 2 bytes long, with a total of 16 bits. Each bit corresponds to a physical or logical driver device. When the value of the bit is 1, it indicates that the data segment contains the data unit of the device. When the value of the bit is 0, it indicates that the data segment does not contain the data unit of the device. The frame structure of the custom protocol frame is as follows:

[0046] HC header: Frame header synchronization code, used to detect bus conflicts and distinguish data from different models.

[0047] Device bitmap: 2 bytes, 16 bits in total. Each bit is set to 1 to indicate that the device data information it represents exists. Each device has a predefined data structure. Through the device index field, the data of a certain device can be added or removed according to the current control needs. This allows for quick parsing of the data information of a certain device and also reduces the data of certain devices that do not need to be controlled at the moment, thereby improving communication efficiency.

[0048] Length len (data field length field): The length of the data field.

[0049] Data (parameter data field): The data segment has a 1-byte device number + the parameter data structure corresponding to that device (first device ID + first device data structure + ... + nth device ID + nth device data structure). CRC check: Cyclic Redundancy Check, ensuring the physical layer security of bus transmission.

[0050] The custom protocol frame, employing the aforementioned structure, offers core advantages in communication flexibility and efficiency. Through the 'device bitmap' field, the master device (motion coprocessor) can flexibly select which slave devices (such as X-axis and Y-axis drivers) to communicate with within a single data frame, achieving 'on-demand communication' and avoiding wasted bus bandwidth. When the number of axes in the system expands, only the bitmap bit depth and the corresponding 'device data unit' in the data segment need to be increased accordingly, demonstrating excellent scalability. Simultaneously, the 'HC header' is used for frame synchronization and machine type identification, enhancing compatibility and anti-interference capabilities between different systems; the 'CRC checksum' ensures the integrity of data transmission. This lightweight protocol design, compared to complex industrial Ethernet protocol stacks, significantly reduces the computational demands on the processor, making it possible to achieve high-performance motion control using general-purpose, low-cost microprocessors.

[0051] When the motion coprocessor communicates with the XY axis drive processor, it uses the NSS chip select signal of the SPI bus to achieve synchronous interpolation. Before the previous frame shifting action ends, the motion coprocessor preloads the target absolute position information of the next frame into the XY axis drive processor. When the spindle synchronization signal is received, the motion coprocessor controls the level transition of the NSS chip select signal to trigger the XY axis drive processor to switch synchronously and execute the new target absolute position command. The XY-axis drive processor has an internal instruction register. During non-NSS chip select signal switching cycles, the XY-axis drive processor executes the target absolute position instruction in the current instruction register. When the NSS chip select signal is triggered by a rising edge, the XY-axis drive processor synchronously switches the pre-loaded new target absolute position instruction to the instruction register and immediately begins execution.

[0052] Utilizing the NSS (Slave Select) signal line inherent in the SPI bus to achieve hardware-level synchronization is key to realizing high-precision multi-axis collaborative control. Its working principle can be analogous to a 'double-buffered' mechanism: before the previous stitch's frame-shifting action is finished, the motion coprocessor pre-transmits (preloads) the 'target absolute position instruction' for the next stitch into the cache of the XY-axis drive processor via the SPI data line. At this time, the drive processor continues to execute the instructions in the current instruction register. When the 'spindle synchronization signal' marking the stitch's movement cycle arrives, the motion coprocessor does not immediately send new data, but simply generates a rising edge (such as a falling edge) of the NSS chip select signal. This rising edge acts as a global hardware synchronization signal, simultaneously triggering all XY-axis drive processors to synchronously and instantaneously switch their internally preloaded new instructions to the instruction register and begin execution. This mechanism ensures that the frame-shifting actions on the X and Y axes can be started in strict synchronization and maintain precise timing alignment with the main axis (embroidery needle) action. It fundamentally avoids the problem of asynchrony between axes caused by software processing delays or communication timing jitter, which is crucial for ensuring the pattern accuracy under high-speed embroidery.

[0053] In the location comparison module, the comparison of the real-time actual location information with the target absolute location command adopts a two-way closed-loop verification mechanism, specifically as follows: The XY axis drive processor receives the target absolute position command in frame T and transmits the real-time actual position information of the motor at the time of frame T via the SPI bus in frame T+1. The motion coprocessor calculates the deviation between the transmitted real-time actual position information and the target absolute position command sent in frame T. If the deviation exceeds a preset threshold, position correction processing or an abnormal alarm is performed. The position correction process specifically involves superimposing a compensation value that is opposite to the deviation amount when calculating the target absolute position command for the next cycle.

[0054] The bidirectional closed-loop verification mechanism constructs a real-time, closed-loop position control circuit. Its 'bidirectional' nature is reflected in the fact that the motion coprocessor sends target commands to the drive processor (forward channel), and the drive processor sends the actual position back to the motion coprocessor (feedback channel). Its 'closed-loop' nature is reflected in the fact that the motion coprocessor compares the commands and feedback and compensates for any discrepancies.

[0055] Specifically, this mechanism operates in steps of communication frame periods (T frames). In frame T, the motion coprocessor sends the target position command P_T; the XY axis drive processor receives and executes it, and during or after execution, samples the encoder in real time to obtain the actual position A_T. In frame T+1, the drive processor sends A_T back as feedback data. Upon receiving this, the motion coprocessor immediately calculates the deviation e = P_T - A_T. If |e| exceeds a preset safety threshold, an alarm is triggered; if it is within the threshold but not zero, when calculating the target command P{T+1} for the next cycle, the planned position is not used directly, but a compensation value is added, i.e., P'{T+1} = P_{T+1} - ke (k is the compensation coefficient). This closed loop of 'command-execution-feedback-compensation' can dynamically correct deviations caused by motor step loss, mechanical transmission backlash, or load disturbances, preventing error accumulation and ensuring the long-term positional accuracy and reliability of the embroidery machine. This is a fundamental advantage that traditional open-loop pulse control schemes cannot achieve.

[0056] The main controller, motion coprocessor, and XY axis drive processor constitute a three-level decoupled computing task architecture. The main controller is responsible for parsing embroidery pattern data and planning embroidery trajectory; the motion coprocessor is responsible for SPI bus communication, protocol encapsulation, and position feedback processing; and the XY axis drive processor is responsible for executing target absolute position commands and providing real-time actual position information feedback.

[0057] The three-tiered decoupled computing architecture is not simply a functional division, but a deep optimization tailored to the control characteristics of an embroidery machine. The main controller (such as a high-performance application processor) is freed to focus on upper-level pattern analysis and complex trajectory planning; dedicated motion coprocessors (such as FPGAs or dedicated motion control chips) efficiently handle high real-time SPI communication, protocol encapsulation, and position loop calculations; and XY-axis drive processors (such as servo drivers with position loops or integrated drive chips) focus on the lowest-level current loop, speed loop control, and high-frequency position sampling. This architecture allows each level of processor to select the most suitable and cost-effective chip for its task, avoiding the situation where excessively expensive processors are used to meet the most demanding real-time requirements. Simultaneously, the decoupling between levels reduces the coupling between system modules, improving system maintainability and upgradeability.

[0058] In summary, the advantages of this invention are: 1. By establishing a fully digital communication link using the low-cost general-purpose SPI bus and utilizing its NSS signal to achieve multi-axis synchronization, the anti-interference capability and synchronization reliability of signal transmission are fundamentally improved. Simultaneously, a three-level decoupled architecture of the main controller, motion coprocessor, and drive processor is constructed. The motion coprocessor is dedicated to SPI communication and protocol processing, and a custom lightweight protocol including device bitmaps is designed to achieve on-demand communication. This significantly simplifies system complexity and reduces the requirements for main controller computing power and hardware costs. More importantly, the SPI bus enables closed-loop feedback and bidirectional verification of real-time actual position, dynamically calculating position deviations and compensating for them in subsequent instructions. This completely solves the problem of accumulated step loss errors caused by traditional open-loop pulse control, ultimately achieving an optimized balance between system cost and complexity while ensuring high precision and long-term operational reliability.

[0059] 2. Achieving high-precision real-time position feedback and closed-loop control improves embroidery quality and system reliability: The SPI bus is used as the communication medium, and its full-duplex characteristic provides a physical basis for real-time, bidirectional data interaction. The XY axis drive processor can feed back the real-time actual position information of the motor to the motion coprocessor, which can immediately compare it with the target command. Within the next frame cycle after the target command is issued, the system can obtain execution feedback and calculate the deviation, enabling the system to quickly detect and compensate for small position errors (such as superimposing reverse compensation values) or trigger abnormal alarms. This mechanism effectively suppresses the cumulative error caused by factors such as motor step loss, mechanical backlash, or load disturbance, ensuring the long-term accuracy and stability of frame positioning, which is directly related to the contour accuracy and overall quality of the embroidery pattern.

[0060] 3. Through hierarchical task decoupling and a dedicated coprocessor architecture, the system's real-time performance and computational efficiency are significantly optimized: The three-level computational task decoupling architecture, consisting of the main controller, motion coprocessor, and XY axis drive processor, professionally divides complex control tasks: the main controller focuses on high-level pattern analysis and trajectory planning; the motion coprocessor is dedicated to handling high-speed SPI communication, protocol encapsulation, and position data processing; and the drive processor focuses on low-level motor driving and position sampling. This decoupling avoids the processing bottlenecks and timing conflicts that may arise from concentrating all tasks on a single main control chip, enabling each part to work in parallel and efficiently. In particular, the dedicated motion coprocessor manages SPI communication and preprocessing, greatly reducing the interrupt burden on the main controller and ensuring high real-time performance and determinism of motion control commands and feedback information transmission, providing a solid system performance foundation for high-speed embroidery.

[0061] 4. Highly efficient and flexible multi-axis synchronous control was achieved using the SPI bus and a custom protocol frame: A custom protocol frame was designed based on the SPI bus. The device bitmap field in this frame structure allows dynamic indication of the slave device corresponding to the current frame data, realizing on-demand allocation of communication load and improving the utilization efficiency of bus bandwidth. More importantly, by cleverly utilizing the SPI NSS (chip select) signal as a hardware synchronization signal, combined with the instruction register inside the driver processor, the "preloading" and "synchronous trigger execution" of the frame shifting instruction were realized. When the main spindle synchronization signal arrives, the NSS level transition can trigger the synchronous switching of all axes and the execution of new position instructions. This ensures that in multi-axis linkage embroidery movements, the frame shifting of the XY axes can achieve precise hard synchronization with the main spindle (needle movement), effectively avoiding the problem of asynchronous movement caused by communication or processing delays. This is crucial for complex patterns and high-speed embroidery.

[0062] 5. The combination of absolute position control and intelligent trajectory planning enhances motion smoothness and system robustness: The core of the control command is the target's absolute position information, rather than the traditional pulse increment, making each frame of command independent and clear. The system does not rely on historical command sequences, resulting in stronger anti-interference capabilities. Even after a brief communication interruption, it can quickly locate the correct absolute coordinates. Simultaneously, during the trajectory planning stage, the speed increment is dynamically calculated based on the angle between consecutive stitch points, achieving smooth acceleration and deceleration during motion. This proactive planning avoids sudden speed changes, reduces mechanical shock and vibration during motor start-up, shutdown, and reversal, resulting in smoother operation, lower noise, extended service life of mechanical components, and the possibility of further increasing embroidery speed.

[0063] 6. Enhanced scalability and communication reliability: The custom protocol frame structure design offers excellent flexibility; data segments consist of parameter data fields, which in turn are composed of standardized "device data units" in sequence. Each unit contains a device identifier and a corresponding parameter structure. This modular design allows for the addition of new slave devices (such as other auxiliary axes) to the bus simply by following the same unit format, resulting in excellent scalability. Furthermore, the mechanism of using NSS signals for synchronous interpolation and instruction preloading, along with a rigorous "one-to-one" closed-loop verification process, together constitute a robust communication and execution guarantee mechanism. This minimizes the risk of control failure due to communication errors or timing discrepancies, thereby improving the reliability and fault tolerance of the entire control system.

[0064] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for absolute position control of XY frame shifting in an embroidery machine based on an SPI bus, characterized in that: Includes the following steps: Step S1: The main controller parses the embroidery pattern data, performs trajectory look-ahead and motion curve planning, generates frame shifting control data containing the absolute position information of the target, and stores the frame shifting control data in the needle data cache. Step S2: The motion coprocessor, acting as the master device for SPI communication, reads the current and subsequent frame shift control data from the needle data buffer. Step S3: The motion coprocessor encapsulates the read frame-shifting control data into the data segment of a custom protocol frame to form a target absolute position instruction, and sends the custom protocol frame to the XY axis drive processor, which is a slave device, via the SPI bus. Step S4: The XY axis drive processor receives and parses the custom protocol frame to obtain the target absolute position command, and drives the motor to perform the frame-shifting action based on the target absolute position command; Step S5: After the XY axis drive processor completes the execution of the target absolute position command, or during the execution process, it feeds back the real-time actual position information of the motor to the motion coprocessor via the SPI bus. Step S6: The motion coprocessor receives the real-time actual position information, compares the real-time actual position information with the target absolute position command, and performs position correction processing or abnormal alarm based on the deviation value.

2. The absolute position control method for XY frame shifting of an embroidery machine based on SPI bus as described in claim 1, characterized in that: In step S1, the trajectory look-ahead and motion curve planning includes: dynamically calculating the velocity increment of the frame movement based on the angle between consecutive stitch points, so as to achieve smooth acceleration and deceleration during the motion process.

3. The absolute position control method for XY frame shifting of an embroidery machine based on SPI bus as described in claim 1, characterized in that: In step S3, the data segment of the custom protocol frame includes a device bitmap field, a data field length field, and a parameter data field; each bit of the device bitmap field maps to a slave device, which is used to dynamically indicate whether there is data of the corresponding device in the current frame, so as to realize on-demand adaptation of communication load; the parameter data field is composed of a group of device data units in sequence, and each group of device data units includes a device identifier byte and the parameter data structure corresponding to the device that follows it. When the motion coprocessor communicates with the XY axis drive processor, it uses the NSS chip select signal of the SPI bus to achieve synchronous interpolation. Before the previous frame shifting action ends, the motion coprocessor preloads the target absolute position information of the next frame into the XY axis drive processor. When the spindle synchronization signal is received, the motion coprocessor controls the level transition of the NSS chip select signal to trigger the XY axis drive processor to switch synchronously and execute the new target absolute position command. The XY-axis drive processor has an internal instruction register. During non-NSS chip select signal switching cycles, the XY-axis drive processor executes the target absolute position instruction in the current instruction register. When the NSS chip select signal is triggered by a rising edge, the XY-axis drive processor synchronously switches the pre-loaded new target absolute position instruction to the instruction register and immediately begins execution.

4. The absolute position control method for XY frame shifting of an embroidery machine based on SPI bus as described in claim 1, characterized in that: In step S6, comparing the real-time actual location information with the target absolute location command using a two-way closed-loop verification mechanism specifically involves: The XY axis drive processor receives the target absolute position command in frame T and transmits the real-time actual position information of the motor at the time of frame T via the SPI bus in frame T+1. The motion coprocessor calculates the deviation between the transmitted real-time actual position information and the target absolute position command sent in frame T. If the deviation exceeds a preset threshold, position correction processing or an abnormal alarm is performed. The position correction process specifically involves superimposing a compensation value that is opposite to the deviation amount when calculating the target absolute position command for the next cycle.

5. The absolute position control method for XY frame shifting of an embroidery machine based on SPI bus as described in claim 1, characterized in that: The main controller, motion coprocessor, and XY axis drive processor constitute a three-level decoupled computing task architecture. The main controller is responsible for parsing embroidery pattern data and planning embroidery trajectory; the motion coprocessor is responsible for SPI bus communication, protocol encapsulation, and position feedback processing; and the XY axis drive processor is responsible for executing target absolute position commands and providing real-time actual position information feedback.

6. An absolute position control system for XY frame shifting of an embroidery machine based on an SPI bus, characterized in that: Includes the following modules: The frame shifting control data generation module is used by the main controller to parse embroidery pattern data, perform trajectory prediction and motion curve planning, generate frame shifting control data containing target absolute position information, and store the frame shifting control data in the needle data cache. The frame shifting control data reading module is used by the motion coprocessor as the master device of SPI communication to read the current and subsequent frame shifting control data from the needle data buffer; A custom protocol frame sending module is used by the motion coprocessor to encapsulate the read frame-shifting control data into the data segment of the custom protocol frame to form the target absolute position instruction, and send the custom protocol frame to the XY axis drive processor as a slave device via the SPI bus; The frame-shifting module is used by the XY axis drive processor to receive and parse the custom protocol frame to obtain the target absolute position command, and drive the motor to perform the frame-shifting action based on the target absolute position command; The real-time actual position information feedback module is used to feed back the real-time actual position information of the motor to the motion coprocessor via the SPI bus after the XY axis drive processor completes the execution of the target absolute position command, or during the execution process. The position comparison module is used by the motion coprocessor to receive the real-time actual position information, compare the real-time actual position information with the target absolute position command, and perform position correction processing or abnormal alarm based on the deviation value.

7. The absolute position control system for XY frame shifting of an embroidery machine based on an SPI bus as described in claim 6, characterized in that: In the frame-shifting control data generation module, the trajectory look-ahead and motion curve planning includes: dynamically calculating the frame-shifting speed increment based on the angle between consecutive stitch points, so as to achieve smooth acceleration and deceleration during the motion process.

8. The absolute position control system for XY frame shifting of an embroidery machine based on an SPI bus as described in claim 6, characterized in that: In the custom protocol frame sending module, the data segment of the custom protocol frame includes a device bitmap field, a data field length field, and a parameter data field; each bit of the device bitmap field maps to a slave device, which is used to dynamically indicate whether there is data of the corresponding device in the current frame, so as to realize on-demand adaptation of communication load; the parameter data field is composed of a group of device data units in sequence, and each group of device data units includes a device identifier byte and the parameter data structure corresponding to the device that follows it; When the motion coprocessor communicates with the XY axis drive processor, it uses the NSS chip select signal of the SPI bus to achieve synchronous interpolation. Before the previous frame shifting action ends, the motion coprocessor preloads the target absolute position information of the next frame into the XY axis drive processor. When the spindle synchronization signal is received, the motion coprocessor controls the level transition of the NSS chip select signal to trigger the XY axis drive processor to switch synchronously and execute the new target absolute position command. The XY-axis drive processor has an internal instruction register. During non-NSS chip select signal switching cycles, the XY-axis drive processor executes the target absolute position instruction in the current instruction register. When the NSS chip select signal is triggered by a rising edge, the XY-axis drive processor synchronously switches the pre-loaded new target absolute position instruction to the instruction register and immediately begins execution.

9. The absolute position control system for XY frame shifting of an embroidery machine based on an SPI bus as described in claim 6, characterized in that: In the location comparison module, the comparison of the real-time actual location information with the target absolute location command adopts a two-way closed-loop verification mechanism, specifically as follows: The XY axis drive processor receives the target absolute position command in frame T and transmits the real-time actual position information of the motor at the time of frame T via the SPI bus in frame T+1. The motion coprocessor calculates the deviation between the transmitted real-time actual position information and the target absolute position command sent in frame T. If the deviation exceeds a preset threshold, position correction processing or an abnormal alarm is performed. The position correction process specifically involves superimposing a compensation value that is opposite to the deviation amount when calculating the target absolute position command for the next cycle.

10. The absolute position control system for XY frame shifting of an embroidery machine based on an SPI bus as described in claim 6, characterized in that: The main controller, motion coprocessor, and XY axis drive processor constitute a three-level decoupled computing task architecture. The main controller is responsible for parsing embroidery pattern data and planning embroidery trajectory; the motion coprocessor is responsible for SPI bus communication, protocol encapsulation, and position feedback processing; and the XY axis drive processor is responsible for executing target absolute position commands and providing real-time actual position information feedback.