An abnormality detection method and device for a stepper motor, equipment, and storage medium
Patent Information
- Application Number
- CN202611137385.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-09-29
AI Technical Summary
因此,传统方式只能标记豁口边沿的数量进行粗略描述,无法感知单个豁口内部的细微位移,不能判断步进电机在单个豁口范围内的具体位置变化,从而导致步进电机的异常检测不连续,异常提醒不够及时
[0019]与现有技术相比,本发明的有益效果在于,通过在光电传感器检测到的传感信号表征由遮光区跳变为透光区且维持指定时长时,判定检测到豁口前沿,则根据电机驱动脉冲模拟计算步进电机相对豁口前沿的第一实时位移,当第一实时位移达到豁口宽度的一半时,获取当前时间戳并标记为当前插值周期的起始点,根据电机驱动脉冲模拟计算步进电机在当前插值周期内的第二实时位移;若当前插值周期内的第二实时位移大于相邻豁口间距且差值大于指定参数,输出异常提醒信号;能够以豁口的真实边沿脉冲作为位置校准锚点,根据实时输入的电机驱动脉冲,在两个豁口的间隔区间内做线性插值,实时模拟步进电机在单个豁口范围内的连续位移估算值,结合真实的相邻豁口间距进行异常检测,从而可以保证步进电机的异常检测的连续性,进而提高异常提醒的及时性。
Smart Images

Figure CN122844696A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automation control technology, specifically to a method and device for detecting abnormalities in a stepper motor, an electronic device, and a storage medium. Background Technology
[0002] In vitro diagnostic (IVD) instruments rely heavily on stepper motors and their transmission mechanisms to achieve high-precision automated operation. Although IVD instruments consist of multiple modules such as optics, liquid circuits, and temperature control, the stepper motor, as the core of the mechanical transmission system, runs through the entire testing process and is responsible for the precise movement and quantitative addition of samples and reagents.
[0003] In traditional open-loop stepper motor control systems, the controller cannot know whether the motor has actually executed the command. By introducing a displacement encoder, the actual displacement of the stepper motor is converted into a digital signal by measuring the angular displacement of the motor shaft and the linear displacement of the load end. This signal can not only be used for actual position feedback of the stepper motor, but also for the detection of abnormalities in the stepper motor and its transmission mechanism, including abnormalities such as missed steps, stalled rotor, and mechanical failures.
[0004] Encoders on the market generally refer to complete sensors that integrate code scales, code disks, light sources, sensing circuits, and signal processing circuits. They are packaged at the factory and can directly output standard digital signals, so they have high accuracy, fast feedback response, and are compatible with various industrial control systems. However, the overall procurement cost is high, and deploying multiple stepper motors in batches will bring significant cost pressure.
[0005] Simple code disks and code rulers are inexpensive and suitable for large-scale use. However, code disks and code rulers are merely encoding structures with coded lines; they lack integrated sensing and signal processing circuits and cannot independently output usable signals. Users need to add external circuitry to complete signal conversion, eliminating the premium of whole-machine packaging and significantly reducing costs. This makes them suitable for large-scale batch use in multi-axis equipment. IVD equipment often uses this method due to the large number of stepper motors.
[0006] The core coding structure of coding components such as code disks and code rulers features alternating light-transmitting and light-blocking lines. Specifically, this involves machining physically perforated openings in an opaque substrate at equal intervals. The effective light-transmitting area inside these openings is the light-transmitting area, while the opaque substrate area outside the openings is the light-blocking area. This alternating arrangement of light-transmitting and light-blocking areas creates an alternating light path opening and closing structure, allowing the photoelectric sensor to capture changes in light intensity as the component moves.
[0007] In engineering applications, the edge of the notch is located at the physical boundary between the light-transmitting and light-blocking areas, a crucial location for photoelectric sensors to capture changes in light intensity. Traditionally, the actual displacement of the stepper motor is quantified by detecting the number of notch edges using a photoelectric sensor. However, a single notch is a complete light-transmitting area through which light can pass stably, and the output level of the photoelectric sensor remains constant, without pulse transitions. Level transitions, forming photoelectric pulse signals, are only triggered at the two physical edges of the notch, such as when moving from the light-blocking area into the light-transmitting area and vice versa. Therefore, traditional methods can only provide a rough description by marking the number of notch edges, failing to detect subtle displacements within a single notch and unable to determine the specific positional changes of the stepper motor within the range of a single notch. This results in discontinuous anomaly detection and untimely anomaly alerts. Summary of the Invention
[0008] To address the aforementioned shortcomings, the present invention aims to provide a method, device, electronic equipment, and storage medium for detecting abnormalities in stepper motors, which can ensure the continuity of abnormality detection and thus improve the timeliness of abnormality alerts.
[0009] The first aspect of this invention discloses a method for detecting anomalies in a stepper motor, comprising: When the stepper motor starts running, the sensing signal detected by the photoelectric sensor is acquired in real time; When the sensing signal characterization changes from the light-blocking area to the light-transmitting area and remains there for a specified duration, it is determined that the leading edge of the notch has been detected, and the first real-time displacement of the stepper motor relative to the leading edge of the notch is calculated based on the real-time input motor drive pulse. When the first real-time displacement of the stepper motor reaches half the width of the notch, the current timestamp is obtained and marked as the starting point of the current interpolation period; The second real-time displacement of the stepper motor within the current interpolation period is calculated based on the real-time input motor drive pulses. If the second real-time displacement within the current interpolation period is greater than the distance between adjacent gaps and the difference is greater than a specified parameter, a first abnormality alert signal is output.
[0010] In some embodiments, after obtaining the current timestamp and marking it as the start point of the current interpolation period, the method further includes: Obtain the second real-time displacement of the stepper motor, which is simulated and calculated based on the real-time input motor drive pulses during the previous interpolation period; If the second real-time displacement in the previous interpolation period is less than the distance between adjacent gaps and the difference is greater than the specified parameter, a second abnormality alert signal is output.
[0011] In some embodiments, the first real-time displacement of the stepper motor relative to the leading edge of the notch is calculated based on real-time input motor drive pulses, including: The direction of motor movement at the current moment when the leading edge of the notch is detected is used as a reference direction for latching; Monitor the real-time direction of motor movement; The real-time motion direction is compared with the reference motion direction to obtain a comparison result; Based on the comparison result, the first counter is controlled to accumulate the motor drive pulses input in real time to obtain the first drive pulse count, and the first drive pulse count is used as the first real-time displacement of the stepper motor relative to the front edge of the notch.
[0012] In some embodiments, controlling a first counter to accumulate the real-time input motor drive pulses based on the comparison result to obtain a first drive pulse count includes: If the comparison result shows that the real-time motion direction is the same as the reference motion direction, control the first counter to increase the count according to the number of motor pulses input in real time; If the comparison result shows that the real-time motion direction is opposite to the reference motion direction, control the first counter to decrease the count according to the number of motor pulses input in real time; The number recorded by the first counter is determined as the first drive pulse count.
[0013] In some embodiments, the second real-time displacement of the stepper motor within the current interpolation period is calculated based on the real-time input motor drive pulses, including: The second number of driving pulses is calculated by accumulating the motor drive pulses input in real time within the current interpolation period, and the second number of driving pulses is used as the second real-time displacement of the stepper motor within the current interpolation period.
[0014] A second aspect of this invention discloses an anomaly detection device for a stepper motor, comprising: The sensing unit is used to acquire the sensing signal detected by the photoelectric sensor in real time when the stepper motor is in the running state. The determination unit is used to determine that a notch front edge has been detected when the sensing signal characterization changes from a light-blocking area to a light-transmitting area and remains so for a specified duration. The first interpolation unit is used to simulate and calculate the first real-time displacement of the stepper motor relative to the front edge of the notch based on the real-time input motor drive pulse when it is determined that the front edge of the notch has been detected. A marking unit is used to obtain the current timestamp and mark it as the starting point of the current interpolation period when the first real-time displacement of the stepper motor reaches half of the notch width. The second interpolation unit is used to simulate and calculate the second real-time displacement of the stepper motor in the current interpolation period based on the real-time input motor drive pulses. The first anomaly detection unit is used to output a first anomaly alert signal when the second real-time displacement within the current interpolation period is greater than the distance between adjacent gaps and the difference is greater than a specified parameter.
[0015] In some embodiments, the apparatus further includes: The acquisition unit is used to acquire the second real-time displacement of the stepper motor calculated based on the real-time input motor drive pulses in the previous interpolation period after the marking unit acquires the current timestamp and marks it as the start point of the current interpolation period. The second anomaly detection unit is used to output a second anomaly alert signal when the second real-time displacement in the previous interpolation period is less than the distance between adjacent gaps and the difference is greater than the specified parameter.
[0016] In some embodiments, the first interpolation unit includes: The latching subunit is used to latch the motor motion direction at the current moment when the front edge of the gap is detected as a reference motion direction when it is determined that the front edge of the gap has been detected. The monitoring subunit is used to monitor the real-time direction of the motor's movement. The comparison subunit is used to compare the real-time motion direction with the reference motion direction to obtain a comparison result; The accumulation subunit is used to control the first counter to accumulate the real-time input motor drive pulses to obtain the first drive pulse count based on the comparison result. The first determining subunit is used to take the first number of driving pulses as the first real-time displacement of the stepper motor relative to the leading edge of the notch.
[0017] A third aspect of the present invention discloses an electronic device, including a memory storing executable program code and a processor coupled to the memory; the processor calls the executable program code stored in the memory to execute the stepper motor anomaly detection method disclosed in the first aspect.
[0018] A fourth aspect of the present invention discloses a computer-readable storage medium storing a computer program, wherein the computer program causes a computer to execute the stepper motor anomaly detection method disclosed in the first aspect.
[0019] Compared with the prior art, the beneficial effects of the present invention are as follows: when the sensing signal detected by the photoelectric sensor changes from a light-blocking area to a light-transmitting area and remains so for a specified duration, it is determined that a notch leading edge has been detected. Then, the first real-time displacement of the stepper motor relative to the notch leading edge is calculated based on the motor drive pulse. When the first real-time displacement reaches half the width of the notch, the current timestamp is obtained and marked as the starting point of the current interpolation period. The second real-time displacement of the stepper motor within the current interpolation period is calculated based on the motor drive pulse. If the second real-time displacement within the current interpolation period is greater than the distance between adjacent notches and the difference is greater than a specified parameter, an abnormality reminder signal is output. The present invention can use the actual edge pulse of the notch as the position calibration anchor point, and perform linear interpolation within the interval between two notches based on the real-time input motor drive pulse to simulate the continuous displacement estimate of the stepper motor within a single notch range in real time. Combined with the actual distance between adjacent notches, abnormality detection is performed, thereby ensuring the continuity of abnormality detection of the stepper motor and improving the timeliness of abnormality reminders. Attached Figure Description
[0020] Figure 1 This is a schematic diagram of the architecture of a stepper motor anomaly detection system disclosed in an embodiment of the present invention; Figure 2 This is a flowchart of an abnormality detection method for a stepper motor disclosed in an embodiment of the present invention; Figure 3 This is a coordinate diagram of a stepper motor moving from left to right, as disclosed in an embodiment of the present invention. Figure 4 This is a coordinate diagram of a stepper motor moving from right to left, as disclosed in an embodiment of the present invention. Figure 5 This is a schematic diagram of the structure of a stepper motor anomaly detection device disclosed in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention; Figure 7 This is a schematic diagram of the structure of a computer device disclosed in an embodiment of the present invention.
[0021] Explanation of reference numerals in the attached figures: 10. Encoding structure; 20. Photoelectric sensor; 30. Controller; 40. Notch; 501. Sensing unit; 502. Decision unit; 503. First interpolation unit; 504. Marking unit; 505. Second interpolation unit; 506. First anomaly detection unit; 601. Memory; 602. Processor. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0023] In some of the processes described in the specification, claims, and accompanying drawings of this invention, multiple operations appearing in a specific order are included. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The operation numbers, such as 110, 120, etc., are merely used to distinguish different operations and do not themselves represent any execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.
[0024] It will be understood by those skilled in the art that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0025] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by those skilled in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Throughout the description, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0027] For a better understanding of this invention, please refer to [link / reference]. Figure 1 This invention discloses an abnormality detection system for a stepper motor. The system includes a coding structure 10 with coded markings, a photoelectric sensor 20, and a controller 30. The coding structure 10 includes an opaque substrate and multiple notches 40 formed on the opaque substrate. The multiple notches 40 are arranged at equal intervals. The effective light-transmitting area inside the notches 40 is the light-transmitting area, and the opaque substrate area outside the notches 40 is the light-blocking area. The light-transmitting area and the light-blocking area form an alternating light path on / off structure. The coding structure 10 is fixed. The photoelectric sensor 20 is disposed on the transmission mechanism of the stepper motor. The photoelectric sensor 20 can move with the transmission mechanism above the light path on / off structure. The light path on / off structure is located within the detection range of the photoelectric sensor 20. The photoelectric sensor 20 and the controller 30 are electrically connected or wirelessly connected. Figure 1 The encoding structure 10 takes a code disk as an example, but a code ruler can also be used in other embodiments. The controller 30 can be configured as a field-programmable gate array (FPGA) module or a microcontroller unit (MCU).
[0028] Please see Figure 2 This invention discloses a method for detecting anomalies in a stepper motor. The method can be executed by an electronic device such as a computer, laptop, or tablet, or by a stepper motor anomaly detection device embedded in the electronic device; this invention does not limit this to any particular device. The stepper motor anomaly detection device can be integrated with the controller of the electronic device or can be set up independently.
[0029] like Figure 2 As shown, the method includes the following steps 110-150: 110. When the stepper motor is running, the sensing signal detected by the photoelectric sensor is acquired in real time.
[0030] In this embodiment of the invention, when the photoelectric sensor detects a light-blocking area, its output sensing signal is a high level (1); when the photoelectric sensor detects a light-transmitting area, its output sensing signal is a low level (0). When the photoelectric sensor moves with the stepper motor's transmission mechanism to the two edges of the notch, a level transition occurs, forming a photoelectric pulse signal. When a falling edge is detected, transitioning from a high level (1) to a low level (0), it indicates that the object detected by the photoelectric sensor has changed from a light-blocking area to a light-transmitting area.
[0031] The voltage levels corresponding to the light-blocking and light-transmitting areas can be set according to actual needs. For example, in some other possible embodiments, the voltage level corresponding to the light-blocking area can be set to a low level (0), while the voltage level corresponding to the light-transmitting area can be set to a high level (1). Correspondingly, when a rising edge is detected, transitioning from a low level (0) to a high level (1), it indicates that the object being detected by the photoelectric sensor has changed from the light-blocking area to the light-transmitting area.
[0032] 120. When the sensor signal changes from the shaded area to the transparent area and remains there for a specified duration, it is determined that the leading edge of the notch has been detected. The first real-time displacement of the stepper motor relative to the leading edge of the notch is calculated based on the real-time input motor drive pulse.
[0033] It should be noted that the two edges of the notch include the leading edge and the trailing edge. The leading edge refers to the edge entering the notch, which is the boundary between the shading area and the notch. The trailing edge refers to the edge leaving the notch, which is the boundary between the notch and the next shading area. When the sensor signal is detected to jump from the shading area to the light-transmitting area and then back to the shading area, the resulting photoelectric pulse signal is determined to be caused by mechanical vibration and is not processed. Because the sampling frequency of the photoelectric sensor is much higher than the motor's operating frequency, the photoelectric sensor has collected many sensing signals within the time interval of one microstep of motor movement. If a high level changes to a low level and then immediately returns to a high level, the motor will at most move one microstep. Normally, any change should only be a high level changing to a low level. A high-to-low change followed by a high change back to a high level can be identified as mechanical vibration.
[0034] In this embodiment of the invention, two checks are performed to ensure that the generated photoelectric pulse signal is valid: one is to exclude mechanical jitter, and the other is to check the motor status. If the motor is not running, this signal will also be ignored. Only when the stepper motor is running, and the sensor signal transitions from the shaded area to the transparent area and remains in the transparent area for a specified duration, is the generated photoelectric pulse signal determined to be a valid signal. That is, it is confirmed that the photoelectric sensor has detected the leading edge of the notch, and then the real-time coordinate value of the stepper motor relative to the leading edge of the notch, i.e., the first real-time displacement, can be calculated.
[0035] During the process of simulating and calculating the first real-time displacement of the stepper motor relative to the leading edge of the notch based on the real-time input motor drive pulse, if the latest sensing signal detected by the photoelectric sensor changes from the light-transmitting area to the light-blocking area, it is determined that the previous photoelectric pulse signal has ended. Whether it ends normally or due to jitter, the simulation and calculation of the first real-time displacement of the stepper motor is stopped, and the process jumps to step 110 to wait for the photoelectric sensor to move to the next leading edge of the notch.
[0036] In this embodiment of the invention, the first real-time displacement of the stepper motor relative to the leading edge of the notch is quantified by the number of motor drive pulses. Further, the simulation calculation of the first real-time displacement of the stepper motor relative to the leading edge of the notch based on the real-time input motor drive pulses may include the following steps 1201-1204: 1201. The direction of motor motion at the current moment when the front edge of the gap is detected is used as the reference direction for latching.
[0037] 1202. Monitor the real-time direction of motor movement.
[0038] 1203. Compare the real-time motion direction with the reference motion direction to obtain the comparison results.
[0039] 1204. Based on the comparison results, control the first counter to accumulate the real-time input motor drive pulses to obtain the first drive pulse count, and use the first drive pulse count as the first real-time displacement of the stepper motor relative to the front edge of the notch.
[0040] If the comparison result shows that the real-time motion direction is the same as the reference motion direction, the first counter is controlled to increase the count according to the number of motor pulses input in real time. If the comparison result shows that the real-time motion direction is opposite to the reference motion direction, the first counter is controlled to decrease the count according to the number of motor pulses input in real time. The number recorded by the first counter is determined as the first drive pulse count.
[0041] 130. When the first real-time displacement of the stepper motor reaches half the width of the notch, obtain the current timestamp and mark it as the starting point of the current interpolation period.
[0042] In this embodiment of the invention, the notch width can be quantified according to the equivalent number of stepper motor pulses. Considering that there are many types of stepper motor transmission mechanisms, such as rotary grippers, translational grippers, etc., the notch width and the spacing between adjacent notches of the code rulers or code disks matched with different types of transmission mechanisms are different, so they can all be converted into different pulse counts for description.
[0043] For example, if the notch width is 4mm, and the stepper motor moves a distance of 4mm in 400 pulses, then the first theoretical number of driving pulses corresponding to the notch width is 400. As another example, if the distance between the centers of two adjacent notches is 10mm, and the stepper motor moves a distance of 1000 pulses in 10mm, then the second theoretical number of driving pulses corresponding to the distance between adjacent notches is 1000.
[0044] As an optional implementation, in this embodiment of the invention, the first theoretical number of driving pulses corresponding to the notch width and the second theoretical number of driving pulses corresponding to the spacing between adjacent notches can be pre-marked. Specifically, the implementation can be as follows: control the stepper motor to run at a constant speed, control the photoelectric sensor to continuously collect data to determine a first interval containing a first preset number of notch widths, count the total number of driving pulses issued by the controller within the first interval, and divide the total number of driving pulses within the first interval by the first preset number to obtain the average value, which is the first theoretical number of driving pulses corresponding to a single notch width.
[0045] Similarly, the stepper motor is controlled to run at a constant speed, and the photoelectric sensor is controlled to continuously collect data to determine a second interval containing a second preset number of adjacent notch spacings. The total number of drive pulses issued by the controller within the second interval is counted, and the average value obtained by dividing the total number of drive pulses within the second interval by the second preset number is the second theoretical number of drive pulses corresponding to a single adjacent notch spacing. The first preset number and the second preset number can be the same or different, for example, both can be set to 100. By continuously collecting data from multiple notch intervals and calculating the average pulse value, the processing error of a single notch can be offset.
[0046] Furthermore, the motor can be calibrated repeatedly in both directions a specified number of times, and the average of all calibration results can be taken as the final calibration value to eliminate system deviations caused by backlash. This calibration method relies entirely on real photoelectric feedback data, and its accuracy is much higher than that calculated theoretically using step angle and mechanical transmission ratio alone, which can significantly reduce the error of subsequent interpolation estimation.
[0047] Therefore, when identifying whether the first real-time displacement of the stepper motor relative to the leading edge of the notch reaches half the width of the notch, a quantitative comparison can be made based on the number of motor drive pulses. For example, when the number of the first drive pulses of the stepper motor reaches half the first theoretical number of drive pulses corresponding to the width of the notch, it is determined that the stepper motor has moved to the middle position of the notch. This middle position of the notch is a flag used to identify the start point of the current interpolation cycle and the end point of the previous interpolation cycle. Compared with the traditional method of using the leading edge of the notch as the starting point of the detection cycle, this invention uses the middle position of the notch, where the level signal is relatively stable, as the starting point of the detection cycle, which can improve detection stability and thus improve the accuracy of anomaly detection.
[0048] 140. Calculate the second real-time displacement of the stepper motor within the current interpolation period based on the real-time input motor drive pulses.
[0049] The second real-time displacement is specifically the real-time coordinate value of the stepper motor relative to the middle position of the previous notch. In this embodiment of the invention, the second real-time displacement, like the first real-time displacement, is also quantified using the number of motor drive pulses. Specifically, the second drive pulse count is calculated by accumulating the motor drive pulses input in real time within the current interpolation period, and this second drive pulse count is used as the second real-time displacement of the stepper motor within the current interpolation period. In practical applications, a second counter can be set to count the second real-time displacement. At the beginning of the current interpolation period, the second counter is forcibly cleared to zero. During the motor operation within the current interpolation period, for each motor drive pulse received, the count of the second counter is incremented by 1. Then, the second real-time displacement of the stepper motor within the current interpolation period is estimated in real time based on the count result of the second counter.
[0050] As an optional implementation, during the process of accumulating the second drive pulse count of the stepper motor within the current interpolation period, if a change in the stepper motor's direction of movement is detected—for example, the stepper motor moves to the left and then changes direction to the right, or moves to the right and then changes direction to the left—then the second drive pulse count is reversed based on the second theoretical drive pulse count corresponding to the adjacent notch spacing. Specifically, the length of the interpolation period set in this invention is one adjacent notch spacing, meaning the interpolation period is located between the middle positions of two adjacent notches, with a flag on each side. Therefore, when the motor's direction of movement changes, the flag corresponding to its second real-time displacement should also be changed.
[0051] For example, such as Figures 3 to 4 As shown, the distance between the two flags corresponds to 1000 pulses. The motor moves from left to right. After detecting the left flag 1, it starts accumulating the number of second drive pulses in the current interpolation period and moves forward 200 pulses. At this time, the coordinate relative to the left flag 1 is 200. If the movement direction of the stepper motor changes from the original direction to the opposite direction and then starts moving from right to left, it needs to be converted to the coordinate relative to the right flag 2. That is, the second drive pulse count is reversed to 1000-200=800, which means that after reversal, the number of second drive pulses accumulated by the stepper motor in the interpolation period is 800.
[0052] By detecting whether the stepper motor's movement direction has reversed, the detection can be ensured to be unaffected by the reversal of the structural movement direction, thus ensuring the continuity of detection while improving detection accuracy.
[0053] 150. If the second real-time displacement within the current interpolation period is greater than the distance between adjacent gaps and the difference is greater than the specified parameter, output the first abnormality alert signal.
[0054] Here, the difference refers to the difference between the second real-time displacement and the distance between adjacent gaps. The specified parameter can be regarded as the sensitivity of error identification and can be adjusted according to the actual situation of the structure.
[0055] Further, optionally, after performing step 130 and before performing step 140, the following steps 131-132 may also be performed: 131. Obtain the second real-time displacement of the stepper motor calculated based on the real-time input motor drive pulses during the previous interpolation period.
[0056] 132. If the second real-time displacement in the previous interpolation period is less than the distance between adjacent gaps and the difference is greater than the specified parameter, output a second abnormality warning signal.
[0057] It should be noted that at the end of each interpolation cycle, the accumulated second real-time displacement obtained throughout the entire interpolation cycle can be stored. When the photoelectric sensor detects the leading edge of the notch at the current moment, it marks the start of the current interpolation cycle. Then, the second real-time displacement of the entire previous interpolation cycle can be read for anomaly analysis, and an anomaly alert message will be output when an anomaly occurs. If the second real-time displacement in the previous interpolation cycle is within a preset threshold range, it is determined that there is no anomaly, the second counter is forcibly cleared, the accumulated interpolation error of the previous interpolation cycle is eliminated, and the estimation loop of the next interpolation cycle begins, ensuring the accuracy and stability of long-term operation. The preset threshold range refers to the allowable error range, such as being greater than the distance between adjacent notches and the difference less than a specified parameter, or less than the distance between adjacent notches and the difference less than a specified parameter.
[0058] As can be seen, by implementing the embodiments of the present invention, using the actual edge pulse of the notch as the position calibration anchor point, and performing linear interpolation within the interval between two notches based on the real-time input motor drive pulse, the continuous displacement estimation value of the stepper motor within a single notch range is simulated in real time. Combined with the actual spacing between adjacent notches, anomaly detection is performed, thereby ensuring the continuity of stepper motor anomaly detection and improving the timeliness of anomaly alerts. The position anchor point of the present invention comes from the actual sensing data of the photoelectric sensor, avoiding long-term cumulative errors. The estimated position within a single interpolation cycle can be compared with the control command in real time, quickly identifying step loss and jamming anomalies within the interval, fully meeting the basic anomaly detection requirements.
[0059] like Figure 5 As shown, this embodiment of the invention also discloses an anomaly detection device for a stepper motor, including a sensing unit 501, a judgment unit 502, a first interpolation unit 503, a marking unit 504, a second interpolation unit 505, and a first anomaly detection unit 506, wherein... The sensing unit 501 is used to acquire the sensing signal detected by the photoelectric sensor in real time when the stepper motor is running. The determination unit 502 is used to determine that a notch front edge has been detected when the sensing signal characterization changes from a light-blocking area to a light-transmitting area and remains so for a specified duration. The first interpolation unit 503 is used to simulate and calculate the first real-time displacement of the stepper motor relative to the front edge of the notch based on the real-time input motor drive pulse when it is determined that the front edge of the notch has been detected. The marking unit 504 is used to obtain the current timestamp and mark it as the starting point of the current interpolation period when the first real-time displacement of the stepper motor reaches half of the notch width. The second interpolation unit 505 is used to simulate and calculate the second real-time displacement of the stepper motor in the current interpolation period based on the real-time input motor drive pulses. The first anomaly detection unit 506 is used to output a first anomaly alert signal when the second real-time displacement in the current interpolation period is greater than the distance between adjacent gaps and the difference is greater than a specified parameter.
[0060] As an optional implementation, the stepper motor fault detection device also includes the following units (not shown): The acquisition unit is used to acquire the second real-time displacement of the stepper motor calculated based on the real-time input motor drive pulses in the previous interpolation period after the marking unit 504 acquires the current timestamp and marks it as the start point of the current interpolation period. The second anomaly detection unit is used to output a second anomaly alert signal when the second real-time displacement in the previous interpolation period is less than the distance between adjacent gaps and the difference is greater than a specified parameter.
[0061] As an optional implementation, the first interpolation unit 503 includes the following sub-units (not shown): The latching subunit is used to latch the motor motion direction at the current moment when the leading edge of the gap is detected as a reference motion direction when it is determined that the leading edge of the gap has been detected. The monitoring subunit is used to monitor the real-time direction of the motor's movement. The comparison sub-unit is used to compare the real-time motion direction with the reference motion direction to obtain the comparison result; The accumulation subunit is used to control the first counter to accumulate the real-time input motor drive pulses based on the comparison result to obtain the first drive pulse count; The first determining subunit is used to take the first number of driving pulses as the first real-time displacement of the stepper motor relative to the leading edge of the notch.
[0062] Furthermore, the accumulation subunit is specifically used to control the first counter to increase the count according to the number of motor pulses input in real time when the comparison result shows that the real-time motion direction is the same as the reference motion direction; and to control the first counter to decrease the count according to the number of motor pulses input in real time when the comparison result shows that the real-time motion direction is opposite to the reference motion direction; and to determine the number recorded by the first counter as the first drive pulse number.
[0063] As an optional implementation, the second interpolation unit 505 includes the following sub-units (not shown): The accumulator subunit is used to accumulate and calculate the second number of motor drive pulses by accumulating the motor drive pulses input in real time within the current interpolation period. The second determining subunit is used to take the second number of driving pulses as the second real-time displacement of the stepper motor in the current interpolation period.
[0064] Further optionally, the second interpolation unit 505 also includes a reversal processing subunit (not shown), which is used to reverse the second drive pulse count if a change in the movement direction of the stepper motor is detected during the accumulation calculation of the second drive pulse count of the stepper motor in the current interpolation period by the accumulation subunit. This reversal is performed based on the second theoretical drive pulse count corresponding to the spacing between adjacent notches.
[0065] like Figure 6 As shown, this embodiment of the invention also discloses an electronic device, including a memory 601 storing executable program code and a processor 602 coupled to the memory 601; The processor 602 calls the executable program code stored in the memory 601 to execute the stepper motor anomaly detection method described in the above embodiments.
[0066] like Figure 7 As shown in the illustration, this invention also discloses a computer device. This computer device includes a processor, memory, network interface, display screen, and input device connected via a system bus. The processor in this computer design provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device stores relevant data for a stepper motor anomaly detection method. The network interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the stepper motor anomaly detection method described in the above embodiments.
[0067] This invention also discloses a computer-readable storage medium storing a computer program that causes a computer to execute the stepper motor anomaly detection method described in the above embodiments. The storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device, etc.
[0068] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0069] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0070] The embodiments described above are merely examples of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.
Claims
1. A method for detecting anomalies in a stepper motor, characterized in that, include: When the stepper motor starts running, the sensing signal detected by the photoelectric sensor is acquired in real time; When the sensing signal characterization changes from the light-blocking area to the light-transmitting area and remains there for a specified duration, it is determined that the leading edge of the notch has been detected, and the first real-time displacement of the stepper motor relative to the leading edge of the notch is calculated based on the real-time input motor drive pulse. When the first real-time displacement of the stepper motor reaches half the width of the notch, the current timestamp is obtained and marked as the starting point of the current interpolation period; The second real-time displacement of the stepper motor within the current interpolation period is calculated based on the real-time input motor drive pulses. If the second real-time displacement within the current interpolation period is greater than the distance between adjacent gaps and the difference is greater than a specified parameter, a first abnormality alert signal is output.
2. The abnormality detection method for a stepper motor according to claim 1, characterized in that, After obtaining the current timestamp and marking it as the starting point of the current interpolation period, the method further includes: Obtain the second real-time displacement of the stepper motor, which is simulated and calculated based on the real-time input motor drive pulses during the previous interpolation period; If the second real-time displacement in the previous interpolation period is less than the distance between adjacent gaps and the difference is greater than the specified parameter, a second abnormality alert signal is output.
3. The abnormality detection method for a stepper motor according to claim 1, characterized in that, The first real-time displacement of the stepper motor relative to the leading edge of the notch is calculated based on the real-time input motor drive pulses, including: The direction of motor movement at the current moment when the leading edge of the notch is detected is used as a reference direction for latching; Monitor the real-time direction of motor movement; The real-time motion direction is compared with the reference motion direction to obtain a comparison result; Based on the comparison result, the first counter is controlled to accumulate the motor drive pulses input in real time to obtain the first drive pulse count, and the first drive pulse count is used as the first real-time displacement of the stepper motor relative to the front edge of the notch.
4. The abnormality detection method for a stepper motor according to claim 3, characterized in that, Based on the comparison results, the first counter is controlled to accumulate the real-time input motor drive pulses to obtain the first drive pulse count, including: If the comparison result shows that the real-time motion direction is the same as the reference motion direction, control the first counter to increase the count according to the number of motor pulses input in real time; If the comparison result shows that the real-time motion direction is opposite to the reference motion direction, control the first counter to decrease the count according to the number of motor pulses input in real time; The number recorded by the first counter is determined as the first drive pulse count.
5. The method for detecting abnormalities in a stepper motor according to any one of claims 1 to 4, characterized in that, The second real-time displacement of the stepper motor within the current interpolation period is calculated based on the real-time input motor drive pulses, including: The second number of driving pulses is calculated by accumulating the motor drive pulses input in real time within the current interpolation period, and the second number of driving pulses is used as the second real-time displacement of the stepper motor within the current interpolation period.
6. A stepper motor anomaly detection device, characterized in that, include: The sensing unit is used to acquire the sensing signal detected by the photoelectric sensor in real time when the stepper motor is in the running state. The determination unit is used to determine that a notch front edge has been detected when the sensing signal characterization changes from a light-blocking area to a light-transmitting area and remains so for a specified duration. The first interpolation unit is used to simulate and calculate the first real-time displacement of the stepper motor relative to the front edge of the notch based on the real-time input motor drive pulse when it is determined that the front edge of the notch has been detected. A marking unit is used to obtain the current timestamp and mark it as the starting point of the current interpolation period when the first real-time displacement of the stepper motor reaches half of the notch width. The second interpolation unit is used to simulate and calculate the second real-time displacement of the stepper motor in the current interpolation period based on the real-time input motor drive pulses. The first anomaly detection unit is used to output a first anomaly alert signal when the second real-time displacement within the current interpolation period is greater than the distance between adjacent gaps and the difference is greater than a specified parameter.
7. The abnormality detection device for a stepper motor according to claim 6, characterized in that, The device further includes: The acquisition unit is used to acquire the second real-time displacement of the stepper motor calculated based on the real-time input motor drive pulses in the previous interpolation period after the marking unit acquires the current timestamp and marks it as the start point of the current interpolation period. The second anomaly detection unit is used to output a second anomaly alert signal when the second real-time displacement in the previous interpolation period is less than the distance between adjacent gaps and the difference is greater than the specified parameter.
8. The abnormality detection device for a stepper motor according to claim 6 or 7, characterized in that, The first interpolation unit includes: The latching subunit is used to latch the motor motion direction at the current moment when the front edge of the gap is detected as a reference motion direction when it is determined that the front edge of the gap has been detected. The monitoring subunit is used to monitor the real-time direction of the motor's movement. The comparison subunit is used to compare the real-time motion direction with the reference motion direction to obtain a comparison result; The accumulation subunit is used to control the first counter to accumulate the real-time input motor drive pulses to obtain the first drive pulse count based on the comparison result. The first determining subunit is used to take the first number of driving pulses as the first real-time displacement of the stepper motor relative to the leading edge of the notch.
9. An electronic device, characterized in that, It includes a memory storing executable program code and a processor coupled to the memory; the processor calls the executable program code stored in the memory to execute the stepper motor anomaly detection method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program causes a computer to perform the stepper motor anomaly detection method according to any one of claims 1 to 5.