A method and system for changing colors on an embroidery machine
By incorporating a combination of magnetic switches and magnetic encoders into the embroidery machine, along with emergency power supply and health monitoring via lithium batteries, the problems of color-changing errors and power outages in traditional embroidery machines have been solved, achieving higher color-changing accuracy and reliability, and improving the quality of embroidery products.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FUZHOU HUICHUANG INTELLIGENT CONTROL TECHNOLOGY CO LTD
- Filing Date
- 2024-09-06
- Publication Date
- 2026-07-31
AI Technical Summary
Traditional embroidery machine color-changing methods suffer from cumulative errors, color-changing deviations caused by assembly errors, and data loss after power outages, affecting reliability and efficiency, making it difficult to guarantee the accuracy and quality of embroidery products.
Four magnetic switches are installed in the embroidery machine to detect the motor rotation angle at 90° intervals. Combined with a magnetic encoder and a microcontroller, real-time calibration and compensation are performed. Lithium batteries are used for emergency power supply and health monitoring, automatic reset and data storage to improve the accuracy and reliability of color changing.
It effectively avoids cumulative errors, improves the accuracy and efficiency of color changing, ensures data continuity during power fluctuations, and enhances the quality and reliability of embroidery products.
Smart Images

Figure CN119083064B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embroidery machine technology, and in particular to a method and system for changing colors in an embroidery machine. Background Technology
[0002] Embroidery machines, also known as computerized embroidery machines, are the most advanced embroidery machinery of our time. They enable traditional hand embroidery to be completed at high speed and efficiency, and can also achieve the requirements of "multi-layer, multi-functional, uniform and perfect" that hand embroidery cannot achieve. They are electromechanical products that embody a variety of high-tech features. As computerized embroidery replaces hand embroidery, computerized embroidery machines will become the main type of machine in the embroidery industry.
[0003] To ensure the aesthetic appeal of embroidery products, multiple colors are typically used to represent different objects, thus requiring the use of various colors of embroidery thread. During operation, the position of the embroidery needles on the color-changing rod needs to be adjusted so that the needles threaded with different colors of embroidery thread are in the working position when needed, i.e., to perform the color-changing operation.
[0004] Traditionally, color changing on embroidery machines involves a motor-driven transmission mechanism that moves a color-changing rod. A magnetic encoder detects the rod's displacement, essentially measuring the number of rotations of the transmission mechanism and converting it into the displacement distance. However, this traditional method has the following drawbacks:
[0005] 1. Errors are inevitable during the detection process of magnetic encoders. As these errors accumulate, the embroidery needle will gradually deviate from the preset working position. 2. Assembly errors are inevitable during the assembly process of embroidery machines. Traditionally, the initial positioning operation of the color-changing rod needs to be performed manually every time the embroidery machine is powered on. This is time-consuming and labor-intensive, which affects the color-changing efficiency of the embroidery machine. 3. When the embroidery machine is suddenly powered off, the magnetic encoder will lose its operating data, which will prevent the machine from continuing its previous work when the power is restored, thus affecting the reliability of the color-changing of the embroidery machine.
[0006] Therefore, how to provide a method and system for color changing in embroidery machines to improve the accuracy, efficiency, and reliability of color changing and enhance the quality of embroidery products has become an urgent technical problem to be solved. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a method and system for changing colors in embroidery machines, thereby improving the accuracy, efficiency and reliability of color changing in embroidery machines and improving the quality of embroidery products.
[0008] In a first aspect, the present invention provides a method for changing colors on an embroidery machine, comprising the following steps:
[0009] Step S1: Install four magnetic switches at 90° intervals in the color-changing device of the embroidery machine to detect the rotation angle of the motor;
[0010] Step S2: Based on the magnetic switch, set the initial position of the motor, move the color-changing rod in the color-changing device by one stroke, and calibrate the rotation angle sensed by the magnetic encoder;
[0011] Step S3: After the embroidery machine is powered on, a reset operation is performed based on the initial position. The motor is driven to run based on the input embroidery work file, and the color-changing rod is moved in conjunction with it to put the corresponding embroidery needle in the working position.
[0012] Step S4: During the operation of the motor, the microcontroller detects the first moving distance of the color-changing rod in real time through the magnetic switch, and detects the second moving distance of the color-changing rod in real time through the magnetic encoder, and calculates the distance error between the first moving distance and the second moving distance.
[0013] Step S5: Based on the distance error, the microcontroller calibrates and compensates the second moving distance by querying the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder.
[0014] Step S6: When the power switching circuit detects that the external power module has lost power, it simultaneously switches to the lithium battery for emergency power supply.
[0015] Step S7: The microcontroller stores the embroidery work file and the rotation angle sensed by the magnetic encoder into the EEPROM memory. When the external power module restores power, it reads the embroidery work file and the rotation angle from the EEPROM memory to continue the work.
[0016] Step S8: The microcontroller performs health monitoring on the lithium battery.
[0017] Furthermore, step S1 also includes: calibrating the displacement distance of the color-changing rod when the motor rotates 90°, and using it as the calibration distance;
[0018] In step S2, setting the initial position of the motor based on the magnetic switch specifically involves:
[0019] The initial position of the motor can be set based on one of the magnetic switches, or based on two adjacent magnetic switches.
[0020] Furthermore, step S3 specifically includes:
[0021] After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. It then obtains the embroidery work file, which is input through the human-machine interface or communication module and contains at least the embroidery trajectory, embroidery points, the corresponding embroidery needle number, and the embroidery thread color. Based on the embroidery work file, the microcontroller drives the motor to operate and moves the color-changing rod to position the corresponding embroidery needle in the working position.
[0022] Furthermore, step S4 specifically includes:
[0023] During motor operation, the microcontroller detects the first moving distance of the color-changing rod through four magnetic switches. Based on the moving time spent moving the first moving distance, the microcontroller detects the rotation angle of the motor in real time through the magnetic encoder, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first moving distance and the second moving distance.
[0024] Furthermore, step S6 specifically includes:
[0025] When the power switching circuit detects a power failure in the external power module through a voltage sensor, it switches to the lithium battery for emergency power supply via ATS.
[0026] Step S8 specifically involves:
[0027] The microcontroller monitors the health of the lithium battery through a pre-trained health status estimation model and generates a lithium battery health monitoring report. When the lithium battery health monitoring report indicates that there is a health risk, the lithium battery health monitoring report is displayed on the screen and pushed to the pre-associated management terminal in real time through the communication module.
[0028] The health status estimation model is constructed based on a vector transformation unit, attention unit, sampling unit, and linear projection unit connected in sequence.
[0029] The attention unit includes three Transformer layers;
[0030] The vector conversion unit is used to convert charging and discharging data into feature vectors.
[0031] The sampling unit is used to perform average sampling and maximum value sampling on the output of the attention unit;
[0032] The linear projection unit is used to perform linear calculations on the output of the sampling unit, thereby obtaining the predicted value of the health status estimation model.
[0033] Secondly, the present invention provides a color-changing system for an embroidery machine, comprising the following modules:
[0034] The magnetic switch setting module is used to set four magnetic switches at 90° intervals in the color changing device of the embroidery machine to detect the rotation angle of the motor.
[0035] The initial state calibration module is used to calibrate the rotation angle sensed by the magnetic encoder when the color-changing rod in the color-changing device moves one stroke based on the initial position of the motor set by the magnetic switch.
[0036] The color-changing module is used to perform a reset operation based on the initial position after the embroidery machine is powered on, drive the motor to run based on the input embroidery work file, and move the color-changing rod to the working position so that the corresponding embroidery needle is in the working position.
[0037] The distance error calculation module is used to calculate the distance error between the first moving distance and the second moving distance of the color-changing rod in real time by the microcontroller through the magnetic switch and the magnetic encoder during the operation of the motor.
[0038] The distance error application module is used by the microcontroller to calibrate and compensate the second moving distance based on the distance error by looking up the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder.
[0039] The emergency power supply module is used to switch to the lithium battery for emergency power supply when the power switching circuit detects that the external power module has lost power.
[0040] The work continuation module is used by the microcontroller to store the embroidery work file and the rotation angle sensed by the magnetic encoder into the EEPROM memory. When the external power module restores power, it reads the embroidery work file and the rotation angle from the EEPROM memory to continue the work.
[0041] The lithium battery health monitoring module is used by a microcontroller to monitor the health of lithium batteries.
[0042] Furthermore, the magnetic switch setting module is also used to: calibrate the displacement distance of the color-changing rod when the motor rotates 90°, and use it as the calibration distance;
[0043] In the initial state calibration module, the initial position setting of the motor based on the magnetic switch specifically involves:
[0044] The initial position of the motor can be set based on one of the magnetic switches, or based on two adjacent magnetic switches.
[0045] Furthermore, the color-changing module is specifically used for:
[0046] After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. It then obtains the embroidery work file, which is input through the human-machine interface or communication module and contains at least the embroidery trajectory, embroidery points, the corresponding embroidery needle number, and the embroidery thread color. Based on the embroidery work file, the microcontroller drives the motor to operate and moves the color-changing rod to position the corresponding embroidery needle in the working position.
[0047] Furthermore, the distance error calculation module is specifically used for:
[0048] During motor operation, the microcontroller detects the first moving distance of the color-changing rod through four magnetic switches. Based on the moving time spent moving the first moving distance, the microcontroller detects the rotation angle of the motor in real time through the magnetic encoder, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first moving distance and the second moving distance.
[0049] Furthermore, the emergency power supply module is specifically used for:
[0050] When the power switching circuit detects a power failure in the external power module through a voltage sensor, it switches to the lithium battery for emergency power supply via ATS.
[0051] The lithium battery health monitoring module is specifically used for:
[0052] The microcontroller monitors the health of the lithium battery through a pre-trained health status estimation model and generates a lithium battery health monitoring report. When the lithium battery health monitoring report indicates that there is a health risk, the lithium battery health monitoring report is displayed on the screen and pushed to the pre-associated management terminal in real time through the communication module.
[0053] The health status estimation model is constructed based on a vector transformation unit, attention unit, sampling unit, and linear projection unit connected in sequence.
[0054] The attention unit includes three Transformer layers;
[0055] The vector conversion unit is used to convert charging and discharging data into feature vectors.
[0056] The sampling unit is used to perform average sampling and maximum value sampling on the output of the attention unit;
[0057] The linear projection unit is used to perform linear calculations on the output of the sampling unit, thereby obtaining the predicted value of the health status estimation model.
[0058] The advantages of this invention are:
[0059] 1. Four magnetic switches are set at 90° intervals in the color-changing device of the embroidery machine to detect the motor rotation angle. The initial position of the motor is set based on the magnetic switches, and the color-changing rod in the color-changing device moves one stroke. The rotation angle sensed by the magnetic encoder is calibrated. After the embroidery machine is powered on, a reset operation is performed based on the initial position. The motor is driven to run based on the input embroidery work file, which in turn moves the color-changing rod to position the corresponding embroidery needle in the working position. During motor operation, the microcontroller detects the first movement distance of the color-changing rod in real time through the magnetic switches and the second movement distance in real time through the magnetic encoder. The distance error between the first and second movement distances is calculated. Based on the distance error, the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder is consulted to calibrate and compensate for the second movement distance. When the power switching circuit detects a power failure of the external power module, it simultaneously switches to the lithium battery for emergency power supply. The microcontroller stores the embroidery work file and the rotation angle of multiple revolutions in the EEPROM memory. When the module regains power, it reads the embroidery work file and rotation angle from the EEPROM memory to continue the work, while the microcontroller monitors the lithium battery's health. Specifically, based on four equally spaced magnetic switches, the second movement distance detected by the magnetic encoder is continuously calibrated and compensated with a 90° motor rotation cycle to avoid cumulative errors. After the embroidery machine is powered on, the microcontroller automatically controls the motor to perform a reset operation based on the initial position, eliminating the need for manual operation as in traditional methods. By setting up a power switching circuit and lithium battery, when the power switching circuit detects a power failure in the external power module, it switches to the lithium battery for emergency power supply. The microcontroller stores the embroidery work file and rotation angle in the EEPROM memory. When the external power module regains power, the microcontroller can read the embroidery work file and rotation angle from the EEPROM memory to continue the work, preventing data loss due to power failure. Ultimately, this greatly improves the accuracy, efficiency, and reliability of the embroidery machine's color changing, and significantly enhances the quality of the embroidered products.
[0060] 2. By calibrating the displacement distance of the color-changing rod when the motor rotates 90°, the rotation angle sensed by the magnetic encoder is calibrated when the color-changing rod in the color-changing device moves one stroke. The four magnetic switches are set at equal intervals, that is, 90° apart from each other. The sensing data of the magnetic switches and the magnetic encoder can be converted into the displacement distance of the color-changing rod, and then the movement distance can be calibrated and compensated, which effectively improves the accuracy of color changing of the embroidery machine.
[0061] 3. After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. No manual reset is required. The embroidery machine can be put into operation immediately after automatic reset upon power-on, effectively improving the efficiency of color changing.
[0062] 4. During motor operation, the microcontroller uses four magnetic switches to detect the first moving distance of the color-changing rod. Based on the time taken to move the first moving distance, the magnetic encoder detects the rotation angle of the motor in real time during the moving time, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first and second moving distances. With a motor rotation of 90° as the cycle, the second moving distance is continuously calibrated and compensated based on the distance error. That is, every time the motor rotates 90°, the first and second moving distances are calculated once for distance calibration and compensation, avoiding cumulative errors and effectively improving the accuracy of color changing in the embroidery machine.
[0063] 5. When the voltage sensor detects that the external power module has lost power, the power switching circuit switches to the lithium battery for emergency power supply via ATS. This ensures that the lithium battery can seamlessly connect and avoids data loss due to the microcontroller's inability to save relevant data, which would affect subsequent embroidery work. This greatly improves the reliability of the embroidery machine's color changing function.
[0064] 6. The lithium battery health is monitored and a lithium battery health monitoring report is generated through a pre-trained health status estimation model. When the lithium battery health monitoring report indicates a health risk, the report is displayed on the screen and pushed to the management terminal in real time. This allows for real-time monitoring of the lithium battery's health status, preventing the lithium battery from failing to supply power in the event of a sudden power outage and avoiding data loss due to the microcontroller's inability to save relevant data, which would affect subsequent embroidery work. This greatly improves the reliability of the embroidery machine's color changing capabilities. Attached Figure Description
[0065] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0066] Figure 1 This is a flowchart of a color-changing method for an embroidery machine according to the present invention.
[0067] Figure 2 This is a schematic diagram of the structure of a color-changing system for an embroidery machine according to the present invention.
[0068] Figure 3 This is a schematic diagram of the hardware architecture of the present invention.
[0069] Figure 4 This is a schematic diagram of the arrangement of the magnetic switch and magnetic encoder of the present invention. Detailed Implementation
[0070] The technical solution in this application embodiment has the following general idea: Based on four equally spaced magnetic switches, the second moving distance detected by the magnetic encoder is continuously calibrated and compensated with a motor rotation period of 90° to avoid cumulative errors; after the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position, eliminating the need for manual operation as in the past; in the event of a power failure, the system automatically switches to lithium battery for emergency power supply, while the microcontroller stores the embroidery work file and the rotation angle in the EEPROM memory. When the external power module restores power, the microcontroller can read the embroidery work file and the rotation angle from the EEPROM memory to continue the work, avoiding the loss of relevant data due to power failure, thereby improving the accuracy, efficiency, and reliability of the embroidery machine's color changing and enhancing the quality of the embroidery products.
[0071] Please refer to Figures 1 to 4 As shown, a preferred embodiment of the color-changing method for an embroidery machine according to the present invention includes the following steps:
[0072] Step S1: Install four magnetic switches at 90° intervals in the color-changing device of the embroidery machine to detect the rotation angle of the motor;
[0073] Step S2: Based on the magnetic switch, set the initial position of the motor, move the color-changing rod in the color-changing device by one stroke, and calibrate the rotation angle sensed by the magnetic encoder;
[0074] Step S3: After the embroidery machine is powered on, a reset operation is performed based on the initial position. The motor is driven to run based on the input embroidery work file, and the color-changing rod is moved in conjunction with it to put the corresponding embroidery needle in the working position.
[0075] Step S4: During the operation of the motor, the microcontroller detects the first moving distance of the color-changing rod in real time through the magnetic switch, and detects the second moving distance of the color-changing rod in real time through the magnetic encoder, and calculates the distance error between the first moving distance and the second moving distance.
[0076] Step S5: Based on the distance error, the microcontroller calibrates and compensates the second moving distance by querying the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder.
[0077] Step S6: When the power switching circuit detects that the external power module has lost power, it simultaneously switches to the lithium battery for emergency power supply.
[0078] Step S7: The microcontroller stores the embroidery work file and the rotation angle sensed by the magnetic encoder into the EEPROM memory. When the external power module restores power, it reads the embroidery work file and the rotation angle from the EEPROM memory to continue the work.
[0079] Step S8: The microcontroller performs health monitoring on the lithium battery.
[0080] Step S1 further includes: calibrating the displacement distance of the color-changing rod when the motor rotates 90°, and using it as the calibration distance;
[0081] In step S2, setting the initial position of the motor based on the magnetic switch specifically involves:
[0082] The initial position of the motor can be set based on one of the magnetic switches, or based on two adjacent magnetic switches.
[0083] By calibrating the displacement distance of the color-changing rod when the motor rotates 90°, and calibrating the rotation angle sensed by the magnetic encoder when the color-changing rod in the color-changing device moves one stroke, and by setting the four magnetic switches at equal intervals (i.e., 90° apart), the sensing data of the magnetic switches and the magnetic encoder can be converted into the displacement distance of the color-changing rod, thereby calibrating and compensating for the movement distance, effectively improving the accuracy of color changing in the embroidery machine.
[0084] Step S3 specifically involves:
[0085] After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. It then obtains the embroidery work file, which is input through the human-machine interface or communication module and contains at least the embroidery trajectory, embroidery points, the corresponding embroidery needle number, and the embroidery thread color. Based on the embroidery work file, the microcontroller drives the motor to operate and moves the color-changing rod to position the corresponding embroidery needle in the working position.
[0086] After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. No manual reset is required from the operator. The embroidery machine can be put into operation immediately after automatic reset upon power-on, effectively improving the efficiency of color changing.
[0087] Step S4 specifically involves:
[0088] During motor operation, the microcontroller detects the first moving distance of the color-changing rod through four magnetic switches. Based on the moving time spent moving the first moving distance, the microcontroller detects the rotation angle of the motor in real time through the magnetic encoder, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first moving distance and the second moving distance.
[0089] During motor operation, the microcontroller uses four magnetic switches to detect the first moving distance of the color-changing rod. Based on the time taken to move the first moving distance, the magnetic encoder detects the rotation angle of the motor in real time during the moving time, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first and second moving distances. With a motor rotation of 90° as the cycle, the second moving distance is continuously calibrated and compensated based on the distance error. That is, every time the motor rotates 90°, the first and second moving distances are calculated for distance calibration and compensation to avoid cumulative errors and effectively improve the accuracy of color changing in the embroidery machine.
[0090] Step S6 specifically involves:
[0091] When the power switching circuit detects a power failure in the external power module through a voltage sensor, it switches to the lithium battery for emergency power supply via ATS.
[0092] When the voltage sensor detects a power failure in the external power module, the power switching circuit switches to the lithium battery via ATS for emergency power supply. This ensures seamless connection of the lithium battery and prevents data loss due to the microcontroller's inability to save relevant data, which would affect subsequent embroidery work. This greatly improves the reliability of color changing in the embroidery machine.
[0093] Step S8 specifically involves:
[0094] The microcontroller monitors the health of the lithium battery through a pre-trained health status estimation model and generates a lithium battery health monitoring report. When the lithium battery health monitoring report indicates that there is a health risk, the lithium battery health monitoring report is displayed on the screen and pushed to the pre-associated management terminal in real time through the communication module.
[0095] The lithium battery health is monitored by a pre-trained health status estimation model, and a lithium battery health monitoring report is generated. When the lithium battery health monitoring report indicates a health risk, the report is displayed on the screen and pushed to the management terminal in real time. This allows for real-time monitoring of the lithium battery's health status, preventing the lithium battery from failing to supply power in the event of a sudden power outage. It also prevents data loss due to the microcontroller's inability to save relevant data, which could affect subsequent embroidery work and greatly improve the reliability of the embroidery machine's color changing capabilities.
[0096] The health status estimation model is constructed based on a vector transformation unit (Embedding), an attention unit, a sampling unit (Meanpooling & MaxPooling), and a linear projection unit (Linera) connected in sequence.
[0097] The attention unit includes three Transformer layers, which greatly improves the expressive power of the model; that is, the health status estimation model is created based on Transformer.
[0098] The mathematical representation of the Transformer layer is:
[0099]
[0100] Z2=FFN(Z)=max(0,ZW1+b1)W2+b2;
[0101] Where Q, K, and V are identical matrices with a shape of [3, 128]; d k The first parameter is the square root of 128; FFN() is a linear projection layer that ultimately transforms the [500, 128] matrix into a [500, 256] matrix; Z represents the output value of the Attention function, which is a [500, 128] matrix; Z2 represents the output value of the FFN function, which is a [500, 256] matrix; W1 represents the first parameter matrix, which has a shape of [128, 256]; W2 represents the second parameter matrix, which has a shape of [128, 256]; b1 represents the first bias vector of length 500; b2 represents the second bias vector of length 500.
[0102] The vector conversion unit is used to convert charging and discharging data into feature vectors.
[0103] The sampling unit is used to perform average sampling and maximum sampling on the output of the attention unit, mathematically represented as:
[0104]
[0105] in, Represents the convolution window; x kpq This represents the original values within the convolution window; the matrices calculated using this formula are concatenated and finally transformed into a matrix shape of [500, 128].
[0106] The linear projection unit is used to perform linear calculations on the output of the sampling unit to obtain the predicted value of the health state estimation model, which is mathematically expressed as:
[0107] Y = LN(Z3) = Z3W + b;
[0108] The data sampled from the upper layer has a shape of [500, 128]. The data is then stretched into a 1-dimensional vector by a straightening method, and finally transformed into a matrix shape of [1].
[0109] The training process of the health status estimation model is as follows:
[0110] A large amount of lithium battery charging and discharging data is acquired, and the charging and discharging data is segmented based on a preset duration threshold to obtain a dataset. The objective optimization function of the health status estimation model is set, and the health status estimation model is trained using the dataset. During the training process, the predicted values of the health status estimation model are constrained by the objective optimization function.
[0111] The formula for the objective optimization function is:
[0112] F(x)=sigmoid(x)*(x high -x low )+x low ;
[0113] sigmoid(x) = 1 / (1 + exp(-x));
[0114] Where F(x) represents the objective function; sigmoid(x) represents the activation function, used to map x to the range of 0 to 1; x high Indicates the upper limit of the constraint; x low The lower bound is defined; exp() represents an exponential function with the natural constant e as the base.
[0115] A health status estimation model is created using Transformer. The model has a simple structure. The vector transformation unit of the health status estimation model converts the charging and discharging data into feature vectors, which are then input into the attention unit. The attention unit captures the features of the feature vectors, and the sampling unit performs average sampling and maximum sampling on the output of the attention unit. In other words, feature extraction is automatically performed using deep learning methods instead of traditional manual feature extraction. This not only captures the feature representation of long-term series better, but also reduces the model development time. Furthermore, since deep learning fits the algorithm from a large amount of charging and discharging data, it has better generalization ability than traditional methods, which greatly improves the accuracy and generalization ability of lithium battery health status estimation, and thus greatly improves the reliability of embroidery machine color changing.
[0116] A preferred embodiment of the color-changing system for an embroidery machine according to the present invention includes the following modules:
[0117] The magnetic switch setting module is used to set four magnetic switches at 90° intervals in the color changing device of the embroidery machine to detect the rotation angle of the motor.
[0118] The initial state calibration module is used to calibrate the rotation angle sensed by the magnetic encoder when the color-changing rod in the color-changing device moves one stroke based on the initial position of the motor set by the magnetic switch.
[0119] The color-changing module is used to perform a reset operation based on the initial position after the embroidery machine is powered on, drive the motor to run based on the input embroidery work file, and move the color-changing rod to the working position so that the corresponding embroidery needle is in the working position.
[0120] The distance error calculation module is used to calculate the distance error between the first moving distance and the second moving distance of the color-changing rod in real time by the microcontroller through the magnetic switch and the magnetic encoder during the operation of the motor.
[0121] The distance error application module is used by the microcontroller to calibrate and compensate the second moving distance based on the distance error by looking up the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder.
[0122] The emergency power supply module is used to switch to the lithium battery for emergency power supply when the power switching circuit detects that the external power module has lost power.
[0123] The work continuation module is used by the microcontroller to store the embroidery work file and the rotation angle sensed by the magnetic encoder into the EEPROM memory. When the external power module restores power, it reads the embroidery work file and the rotation angle from the EEPROM memory to continue the work.
[0124] The lithium battery health monitoring module is used by a microcontroller to monitor the health of lithium batteries.
[0125] The magnetic switch setting module is also used to: calibrate the displacement distance of the color-changing rod when the motor rotates 90°, and use it as the calibration distance;
[0126] In the initial state calibration module, the initial position setting of the motor based on the magnetic switch specifically involves:
[0127] The initial position of the motor can be set based on one of the magnetic switches, or based on two adjacent magnetic switches.
[0128] By calibrating the displacement distance of the color-changing rod when the motor rotates 90°, and calibrating the rotation angle sensed by the magnetic encoder when the color-changing rod in the color-changing device moves one stroke, and by setting the four magnetic switches at equal intervals (i.e., 90° apart), the sensing data of the magnetic switches and the magnetic encoder can be converted into the displacement distance of the color-changing rod, thereby calibrating and compensating for the movement distance, effectively improving the accuracy of color changing in the embroidery machine.
[0129] The color-changing module is specifically used for:
[0130] After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. It then obtains the embroidery work file, which is input through the human-machine interface or communication module and contains at least the embroidery trajectory, embroidery points, the corresponding embroidery needle number, and the embroidery thread color. Based on the embroidery work file, the microcontroller drives the motor to operate and moves the color-changing rod to position the corresponding embroidery needle in the working position.
[0131] After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. No manual reset is required from the operator. The embroidery machine can be put into operation immediately after automatic reset upon power-on, effectively improving the efficiency of color changing.
[0132] The distance error calculation module is specifically used for:
[0133] During motor operation, the microcontroller detects the first moving distance of the color-changing rod through four magnetic switches. Based on the moving time spent moving the first moving distance, the microcontroller detects the rotation angle of the motor in real time through the magnetic encoder, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first moving distance and the second moving distance.
[0134] During motor operation, the microcontroller uses four magnetic switches to detect the first moving distance of the color-changing rod. Based on the time taken to move the first moving distance, the magnetic encoder detects the rotation angle of the motor in real time during the moving time, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first and second moving distances. With a motor rotation of 90° as the cycle, the second moving distance is continuously calibrated and compensated based on the distance error. That is, every time the motor rotates 90°, the first and second moving distances are calculated for distance calibration and compensation to avoid cumulative errors and effectively improve the accuracy of color changing in the embroidery machine.
[0135] The emergency power supply module is specifically used for:
[0136] When the power switching circuit detects a power failure in the external power module through a voltage sensor, it switches to the lithium battery for emergency power supply via ATS.
[0137] When the voltage sensor detects a power failure in the external power module, the power switching circuit switches to the lithium battery via ATS for emergency power supply. This ensures seamless connection of the lithium battery and prevents data loss due to the microcontroller's inability to save relevant data, which would affect subsequent embroidery work. This greatly improves the reliability of color changing in the embroidery machine.
[0138] The lithium battery health monitoring module is specifically used for:
[0139] The microcontroller monitors the health of the lithium battery through a pre-trained health status estimation model and generates a lithium battery health monitoring report. When the lithium battery health monitoring report indicates that there is a health risk, the lithium battery health monitoring report is displayed on the screen and pushed to the pre-associated management terminal in real time through the communication module.
[0140] The lithium battery health is monitored by a pre-trained health status estimation model, and a lithium battery health monitoring report is generated. When the lithium battery health monitoring report indicates a health risk, the report is displayed on the screen and pushed to the management terminal in real time. This allows for real-time monitoring of the lithium battery's health status, preventing the lithium battery from failing to supply power in the event of a sudden power outage. It also prevents data loss due to the microcontroller's inability to save relevant data, which could affect subsequent embroidery work and greatly improve the reliability of the embroidery machine's color changing capabilities.
[0141] The health status estimation model is constructed based on a vector transformation unit (Embedding), an attention unit, a sampling unit (Meanpooling & MaxPooling), and a linear projection unit (Linera) connected in sequence.
[0142] The attention unit includes three Transformer layers, which greatly improves the expressive power of the model; that is, the health status estimation model is created based on Transformer.
[0143] The mathematical representation of the Transformer layer is:
[0144]
[0145] Z2=FFN(Z)=max(0,ZW1+b1)W2+b2;
[0146] Where Q, K, and V are identical matrices with a shape of [3, 128]; d k The first parameter is the square root of 128; FFN() is a linear projection layer that ultimately transforms the [500, 128] matrix into a [500, 256] matrix; Z represents the output value of the Attention function, which is a [500, 128] matrix; Z2 represents the output value of the FFN function, which is a [500, 256] matrix; W1 represents the first parameter matrix, which has a shape of [128, 256]; W2 represents the second parameter matrix, which has a shape of [128, 256]; b1 represents the first bias vector of length 500; b2 represents the second bias vector of length 500.
[0147] The vector conversion unit is used to convert charging and discharging data into feature vectors.
[0148] The sampling unit is used to perform average sampling and maximum sampling on the output of the attention unit, mathematically represented as:
[0149]
[0150] in, Represents the convolution window; x kpq This represents the original values within the convolution window; the matrices calculated using this formula are concatenated and finally transformed into a matrix shape of [500, 128].
[0151] The linear projection unit is used to perform linear calculations on the output of the sampling unit to obtain the predicted value of the health state estimation model, which is mathematically expressed as:
[0152] Y = LN(Z3) = Z3W + b;
[0153] The data sampled from the upper layer has a shape of [500, 128]. The data is then stretched into a 1-dimensional vector by a straightening method, and finally transformed into a matrix shape of [1].
[0154] The training process of the health status estimation model is as follows:
[0155] A large amount of lithium battery charging and discharging data is acquired, and the charging and discharging data is segmented based on a preset duration threshold to obtain a dataset. The objective optimization function of the health status estimation model is set, and the health status estimation model is trained using the dataset. During the training process, the predicted values of the health status estimation model are constrained by the objective optimization function.
[0156] The formula for the objective optimization function is:
[0157] F(x)=sigmoid(x)*(x high -x low )+x low ;
[0158] sigmoid(x) = 1 / (1 + exp(-x));
[0159] Where F(x) represents the objective function; sigmoid(x) represents the activation function, used to map x to the range of 0 to 1; x high Indicates the upper limit of the constraint; x low The lower bound is defined; exp() represents an exponential function with the natural constant e as the base.
[0160] A health status estimation model is created using Transformer. The model has a simple structure. The vector transformation unit of the health status estimation model converts the charging and discharging data into feature vectors, which are then input into the attention unit. The attention unit captures the features of the feature vectors, and the sampling unit performs average sampling and maximum sampling on the output of the attention unit. In other words, feature extraction is automatically performed using deep learning methods instead of traditional manual feature extraction. This not only captures the feature representation of long-term series better, but also reduces the model development time. Furthermore, since deep learning fits the algorithm from a large amount of charging and discharging data, it has better generalization ability than traditional methods, which greatly improves the accuracy and generalization ability of lithium battery health status estimation, and thus greatly improves the reliability of embroidery machine color changing.
[0161] In summary, the advantages of this invention are as follows:
[0162] 1. Four magnetic switches are set at 90° intervals in the color-changing device of the embroidery machine to detect the motor rotation angle. The initial position of the motor is set based on the magnetic switches, and the color-changing rod in the color-changing device moves one stroke. The rotation angle sensed by the magnetic encoder is calibrated. After the embroidery machine is powered on, a reset operation is performed based on the initial position. The motor is driven to run based on the input embroidery work file, which in turn moves the color-changing rod to position the corresponding embroidery needle in the working position. During motor operation, the microcontroller detects the first movement distance of the color-changing rod in real time through the magnetic switches and the second movement distance in real time through the magnetic encoder. The distance error between the first and second movement distances is calculated. Based on the distance error, the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder is consulted to calibrate and compensate for the second movement distance. When the power switching circuit detects a power failure of the external power module, it simultaneously switches to the lithium battery for emergency power supply. The microcontroller stores the embroidery work file and the rotation angle of multiple revolutions in the EEPROM memory. When the module regains power, it reads the embroidery work file and rotation angle from the EEPROM memory to continue the work, while the microcontroller monitors the lithium battery's health. Specifically, based on four equally spaced magnetic switches, the second movement distance detected by the magnetic encoder is continuously calibrated and compensated with a 90° motor rotation cycle to avoid cumulative errors. After the embroidery machine is powered on, the microcontroller automatically controls the motor to perform a reset operation based on the initial position, eliminating the need for manual operation as in traditional methods. By setting up a power switching circuit and lithium battery, when the power switching circuit detects a power failure in the external power module, it switches to the lithium battery for emergency power supply. The microcontroller stores the embroidery work file and rotation angle in the EEPROM memory. When the external power module regains power, the microcontroller can read the embroidery work file and rotation angle from the EEPROM memory to continue the work, preventing data loss due to power failure. Ultimately, this greatly improves the accuracy, efficiency, and reliability of the embroidery machine's color changing, and significantly enhances the quality of the embroidered products.
[0163] 2. By calibrating the displacement distance of the color-changing rod when the motor rotates 90°, the rotation angle sensed by the magnetic encoder is calibrated when the color-changing rod in the color-changing device moves one stroke. The four magnetic switches are set at equal intervals, that is, 90° apart from each other. The sensing data of the magnetic switches and the magnetic encoder can be converted into the displacement distance of the color-changing rod, and then the movement distance can be calibrated and compensated, which effectively improves the accuracy of color changing of the embroidery machine.
[0164] 3. After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. No manual reset is required. The embroidery machine can be put into operation immediately after automatic reset upon power-on, effectively improving the efficiency of color changing.
[0165] 4. During motor operation, the microcontroller uses four magnetic switches to detect the first moving distance of the color-changing rod. Based on the time taken to move the first moving distance, the magnetic encoder detects the rotation angle of the motor in real time during the moving time, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first and second moving distances. With a motor rotation of 90° as the cycle, the second moving distance is continuously calibrated and compensated based on the distance error. That is, every time the motor rotates 90°, the first and second moving distances are calculated once for distance calibration and compensation, avoiding cumulative errors and effectively improving the accuracy of color changing in the embroidery machine.
[0166] 5. When the voltage sensor detects that the external power module has lost power, the power switching circuit switches to the lithium battery for emergency power supply via ATS. This ensures that the lithium battery can seamlessly connect and avoids data loss due to the microcontroller's inability to save relevant data, which would affect subsequent embroidery work. This greatly improves the reliability of the embroidery machine's color changing function.
[0167] 6. The lithium battery health is monitored and a lithium battery health monitoring report is generated through a pre-trained health status estimation model. When the lithium battery health monitoring report indicates a health risk, the report is displayed on the screen and pushed to the management terminal in real time. This allows for real-time monitoring of the lithium battery's health status, preventing the lithium battery from failing to supply power in the event of a sudden power outage and avoiding data loss due to the microcontroller's inability to save relevant data, which would affect subsequent embroidery work. This greatly improves the reliability of the embroidery machine's color changing capabilities.
[0168] 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 of changing colours in an embroidery machine, characterized in that: Includes the following steps: Step S1: Install four magnetic switches at 90° intervals in the color-changing device of the embroidery machine to detect the rotation angle of the motor; Step S2: Based on the magnetic switch, set the initial position of the motor, move the color-changing rod in the color-changing device by one stroke, and calibrate the rotation angle sensed by the magnetic encoder; Step S3: After the embroidery machine is powered on, a reset operation is performed based on the initial position. The motor is driven to run based on the input embroidery work file, and the color-changing rod is moved in conjunction with it to put the corresponding embroidery needle in the working position. Step S4: During the operation of the motor, the microcontroller detects the first moving distance of the color-changing rod in real time through the magnetic switch, and detects the second moving distance of the color-changing rod in real time through the magnetic encoder, and calculates the distance error between the first moving distance and the second moving distance. Step S5: Based on the distance error, the microcontroller calibrates and compensates the second moving distance by querying the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder. With the motor rotating 90° as the cycle, the second moving distance detected by the magnetic encoder is continuously calibrated and compensated. That is, every time the motor rotates 90°, the first moving distance and the second moving distance are calculated once to perform distance calibration and compensation, so as to avoid cumulative error and effectively improve the accuracy of color changing of the embroidery machine. Step S6: When the power switching circuit detects that the external power module has lost power, it simultaneously switches to the lithium battery for emergency power supply. Step S7: The microcontroller stores the embroidery work file and the rotation angle sensed by the magnetic encoder into the EEPROM memory. When the external power module restores power, it reads the embroidery work file and the rotation angle from the EEPROM memory to continue the work. Step S8: The microcontroller performs health monitoring on the lithium battery.
2. The color changing method of an embroidery machine according to claim 1, characterized in that: Step S1 further includes: calibrating the displacement distance of the color-changing rod when the motor rotates 90°, and using it as the calibration distance; In step S2, setting the initial position of the motor based on the magnetic switch specifically involves: The initial position of the motor can be set based on one of the magnetic switches, or based on two adjacent magnetic switches.
3. The embroidery machine color changing method of claim 1, wherein: Step S3 specifically involves: After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. It then obtains the embroidery work file, which is input through the human-machine interface or communication module and contains at least the embroidery trajectory, embroidery points, the corresponding embroidery needle number, and the embroidery thread color. Based on the embroidery work file, the microcontroller drives the motor to operate and moves the color-changing rod to position the corresponding embroidery needle in the working position.
4. The embroidery machine color changing method of claim 1, wherein: Step S4 specifically involves: During motor operation, the microcontroller detects the first moving distance of the color-changing rod through four magnetic switches. Based on the moving time spent moving the first moving distance, the microcontroller detects the rotation angle of the motor in real time through the magnetic encoder, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first moving distance and the second moving distance.
5. The embroidery machine color changing method of claim 1, wherein: Step S6 specifically involves: When the power switching circuit detects a power failure in the external power module through a voltage sensor, it switches to the lithium battery for emergency power supply via ATS. Step S8 specifically involves: The microcontroller monitors the health of the lithium battery through a pre-trained health status estimation model and generates a lithium battery health monitoring report. When the lithium battery health monitoring report indicates that there is a health risk, the lithium battery health monitoring report is displayed on the screen and pushed to the pre-associated management terminal in real time through the communication module. The health status estimation model is constructed based on a vector transformation unit, attention unit, sampling unit, and linear projection unit connected in sequence. The attention unit includes three Transformer layers; The vector conversion unit is used to convert charging and discharging data into feature vectors. The sampling unit is used to perform average sampling and maximum value sampling on the output of the attention unit; The linear projection unit is used to perform linear calculations on the output of the sampling unit, thereby obtaining the predicted value of the health status estimation model.
6. A change colour system for an embroidery machine characterised in that: Includes the following modules: The magnetic switch setting module is used to set four magnetic switches at 90° intervals in the color changing device of the embroidery machine to detect the rotation angle of the motor. The initial state calibration module is used to calibrate the rotation angle sensed by the magnetic encoder when the color-changing rod in the color-changing device moves one stroke based on the initial position of the motor set by the magnetic switch. The color-changing module is used to perform a reset operation based on the initial position after the embroidery machine is powered on, drive the motor to run based on the input embroidery work file, and move the color-changing rod to the working position so that the corresponding embroidery needle is in the working position. The distance error calculation module is used to calculate the distance error between the first moving distance and the second moving distance of the color-changing rod in real time by the microcontroller through the magnetic switch and the magnetic encoder during the operation of the motor. The distance error application module is used by the microcontroller to calibrate and compensate the second moving distance based on the distance error by looking up the correspondence table between the absolute needle position of the embroidery needle and the rotation angle sensed by the magnetic encoder. With the motor rotating 90° as the cycle, the second moving distance detected by the magnetic encoder is continuously calibrated and compensated. That is, every time the motor rotates 90°, the first moving distance and the second moving distance are calculated once to perform distance calibration and compensation, so as to avoid cumulative error and effectively improve the accuracy of color changing of the embroidery machine. The emergency power supply module is used to switch to the lithium battery for emergency power supply when the power switching circuit detects that the external power module has lost power. The work continuation module is used by the microcontroller to store the embroidery work file and the rotation angle sensed by the magnetic encoder into the EEPROM memory. When the external power module restores power, it reads the embroidery work file and the rotation angle from the EEPROM memory to continue the work. The lithium battery health monitoring module is used by a microcontroller to monitor the health of lithium batteries.
7. The embroidery machine color-changing system as described in claim 6, characterized in that: The magnetic switch setting module is also used to: calibrate the displacement distance of the color-changing rod when the motor rotates 90°, and use it as the calibration distance; In the initial state calibration module, the initial position setting of the motor based on the magnetic switch specifically involves: The initial position of the motor can be set based on one of the magnetic switches, or based on two adjacent magnetic switches.
8. An embroidery machine colour change system as claimed in claim 6, characterised in that: The color-changing module is specifically used for: After the embroidery machine is powered on, the microcontroller controls the motor to automatically perform a reset operation based on the initial position. It then obtains the embroidery work file, which is input through the human-machine interface or communication module and contains at least the embroidery trajectory, embroidery points, the corresponding embroidery needle number, and the embroidery thread color. Based on the embroidery work file, the microcontroller drives the motor to operate and moves the color-changing rod to position the corresponding embroidery needle in the working position.
9. An embroidery machine colour change system as claimed in claim 6, characterised in that: The distance error calculation module is specifically used for: During motor operation, the microcontroller detects the first moving distance of the color-changing rod through four magnetic switches. Based on the moving time spent moving the first moving distance, the microcontroller detects the rotation angle of the motor in real time through the magnetic encoder, converts the rotation angle into the second moving distance of the color-changing rod, and calculates the distance error between the first moving distance and the second moving distance.
10. An embroidery machine colour change system as claimed in claim 6, characterised in that: The emergency power supply module is specifically used for: When the power switching circuit detects a power failure in the external power module through a voltage sensor, it switches to the lithium battery for emergency power supply via ATS. The lithium battery health monitoring module is specifically used for: The microcontroller monitors the health of the lithium battery through a pre-trained health status estimation model and generates a lithium battery health monitoring report. When the lithium battery health monitoring report indicates that there is a health risk, the lithium battery health monitoring report is displayed on the screen and pushed to the pre-associated management terminal in real time through the communication module. The health status estimation model is constructed based on a vector transformation unit, attention unit, sampling unit, and linear projection unit connected in sequence. The attention unit includes three Transformer layers; The vector conversion unit is used to convert charging and discharging data into feature vectors. The sampling unit is used to perform average sampling and maximum value sampling on the output of the attention unit; The linear projection unit is used to perform linear calculations on the output of the sampling unit, thereby obtaining the predicted value of the health status estimation model.