An encoder detection method, apparatus and storage medium
Patent Information
- Application Number
- CN202610948233.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-29
- Publication Date
- 2026-08-28
AI Technical Summary
本发明旨在解决现有伺服电机编码器检测过程中存在的人工依赖程度高、检测效率低、相位判定不准确、多型号参数容易混淆、检测结果缺乏可追溯记录等问题,提供一种编码器检测方法、装置及存储介质,以实现伺服电机编码器核心指标的自动化检测、标准化比对和快速质量筛选
1、本发明能够自动完成编码器线数、电气相位和霍尔相位的检测及比对判定,减少人工测量和人工调试,提高检测效率。
Smart Images

Figure CN122652281A_ABST
Abstract
Description
[Technical Field] This invention relates to the field of servo motor production and testing technology, and in particular to an encoder testing method, device and storage medium. [Background Technology] During the production, assembly, and factory testing of servo motors, the encoder line count, electrical phase, and Hall phase are key parameters affecting the motor's operational stability, positioning accuracy, and commutation accuracy. If the actual encoder line count differs from the design line count, or if the electrical phase or Hall phase deviates from the design requirements, it can easily lead to motor vibration, inaccurate commutation, and positioning deviations, and in severe cases, may even cause damage to the motor or driver.
[0003] Existing servo motor detection methods typically have the following shortcomings: First, the number of encoder lines largely depends on manual measurement, reading, or input, resulting in low detection efficiency and a high risk of measurement or input errors.
[0004] Secondly, electrical phase and Hall phase detection often rely on manual debugging, which is difficult and time-consuming, and the detection accuracy is easily affected by the operator's experience.
[0005] Third, the existing testing process lacks unified parameter comparison rules, making it difficult to standardize the comparison between actual testing parameters and preset design requirements, and also making it difficult to output clear pass or fail results in a timely manner.
[0006] Fourth, in the scenario of mixed production of multiple servo motor models, design parameters need to be switched frequently. Manual switching can easily lead to confusion of model parameters, which in turn can cause misjudgment in testing.
[0007] Fifth, the lack of a unified mechanism for recording and responding to anomalies during the testing process makes it difficult to quickly pinpoint the source of problems in non-conforming products, and also hinders subsequent quality review and production process optimization. [Summary of the Invention] To overcome the aforementioned problems, this invention proposes an encoder testing method, device, and storage medium that can effectively solve these issues. This invention aims to address the problems existing in current servo motor encoder testing processes, such as high reliance on manual labor, low testing efficiency, inaccurate phase determination, easy confusion of parameters across different models, and lack of traceable records for testing results. It provides an encoder testing method, device, and storage medium to achieve automated testing, standardized comparison, and rapid quality screening of core servo motor encoder indicators.
[0009] The present invention provides a technical solution to the above-mentioned technical problems: an encoder detection method is provided, applied to the servo motor production detection process, comprising the following steps: S1. Establish and store a design requirement parameter library. The design requirement parameter library stores corresponding preset design indicators according to the motor model. The preset design indicators include at least the encoder line count standard value, electrical phase standard value and allowable deviation range, and Hall phase standard value and allowable deviation range. S2. Connect the motor to be tested to the testing device, initialize the testing device and perform module self-test, load the design requirement parameter library, and call the corresponding preset design indicators according to the model of the motor to be tested. S3. Control the motor to be tested to rotate at a preset low speed under no-load for at least one revolution; S4. During the rotation of the motor under test, the A-phase signal, B-phase signal, Z-phase signal output by the encoder and the U-phase signal, V-phase signal, W-phase signal output by the Hall sensor are synchronously acquired. The transition edges of the A-phase signal, B-phase signal, Z-phase signal, U-phase signal, V-phase signal and W-phase signal are all captured by input through the same time base, and synchronous timing data containing the transition time, transition edge type, count value and signal status are generated. S5. Perform validity checks on the synchronization timing data. If there are any issues such as missing Z-phase signal, abnormal repetition of Z-phase signal, abnormal phase sequence of A-phase and B-phase signals, illegal UVW state, abnormal UVW commutation sequence, illegal UVW state at the Z-phase signal trigger time, or insufficient rotation count, output an abnormal or unqualified result and end the current detection process. The validity checks on the synchronization timing data include: The Z-phase signal appears exactly once during one revolution; The phase sequence of phase A and phase B signals is matched with the preset rotation direction; The UVW status is always in one of the six valid states; The UVW state transition sequence conforms to the pre-stored UVW six-state commutation table; The UVW state corresponding to the Z-phase signal trigger moment is a valid state; The number of rotations meets the preset requirements; The synchronization timing data is considered valid only when all conditions are met; if any condition is not met, the synchronization timing data is considered invalid, and an abnormal or unqualified result is output. S6. When the synchronous timing data is valid, further determine whether the UVW state corresponding to the Z-phase signal trigger time is a valid state; the valid state is one of the six valid states defined by the UVW six-state commutation table; when the UVW state corresponding to the Z-phase signal trigger time is an invalid state, output the detection anomaly result and end the current detection process; when the UVW state corresponding to the Z-phase signal trigger time is a valid state, firstly, determine the rotation direction of the motor under test based on the transition order of the A-phase signal and the B-phase signal; when the actual rotation direction is opposite to the preset rotation direction, correct the quadruple frequency counting direction, or output the rotation direction anomaly result; calculate the actual encoder line count based on the A-phase signal and the B-phase signal, calculate the actual electrical phase based on the Z-phase signal, the A-phase signal, the B-phase signal, the number of motor pole pairs and the preset electrical phase detection benchmark, and calculate the actual Hall phase based on the Z-phase signal, the UVW six-state commutation table and the Hall commutation edge; S7. Compare the actual encoder line count, actual electrical phase, and actual Hall phase with the corresponding preset design parameters respectively; S8. When the actual encoder line count matches the standard encoder line count, the actual electrical phase is within the corresponding allowable deviation range, and the actual Hall phase is within the corresponding allowable deviation range, the motor under test is deemed to be qualified. When any one of these conditions fails to meet the corresponding preset design specifications, the motor under test is deemed to be unqualified, and the unqualified parameters and deviation values are recorded. S9. Output the test results and store the test records. The test records shall include at least the motor model, test time, actual encoder line count, actual electrical phase, actual Hall phase, comparison results, and reasons for non-compliance.
[0010] Preferably, the design requirement parameter library also stores the number of motor pole pairs, preset rotation direction, UVW state reference value at the Z-phase signal trigger time, electrical phase detection reference, Hall phase angle type, UVW six-state commutation table, parameter comparison rules, anomaly judgment criteria, and detection recording strategy; the electrical phase detection reference includes at least one of the specified edge of the A-phase signal, the specified edge of the B-phase signal, the Z-phase signal, or the specified Hall commutation edge.
[0011] Preferably, in step S2, the model of the motor to be tested is selected by the operator through the display module, or automatically matched by the testing device after reading the model parameters in the servo motor driver through the communication configuration module; when the manually selected motor model is inconsistent with the read model parameters, the testing device outputs a model abnormality prompt and suspends the testing.
[0012] Preferably, in step S3, the preset low speed is no more than 50 r / min; during the low-speed no-load rotation of the motor to be tested, the detection device monitors the rotation speed, and when the rotation speed fluctuation exceeds the preset speed fluctuation threshold, it outputs an abnormal speed result and stops the current test.
[0013] Preferably, in step S4, the A-phase signal, B-phase signal, Z-phase signal, U-phase signal, V-phase signal, and W-phase signal are respectively connected to the input capture channel of the same microprocessor or the input capture channel of the same synchronous timer. The count value corresponding to each transition edge is latched by the same hardware timer and written into the same timing buffer according to the timestamp order. The synchronization error between signals is no greater than 1μs, and each transition edge is uniformly written into the same timing buffer after being captured to ensure the uniqueness and order of the timestamp.
[0014] Preferably, in step S6, the actual encoder line count is obtained by using a quadruple frequency counting method on both sides of the A-phase and B-phase signals. The rising edge, falling edge, rising edge, and falling edge of the A-phase signal, the B-phase signal, and the Z-phase signal are counted respectively. At the same time, the quadruple frequency count values are stored in the same timing buffer according to the timestamp order to ensure strict synchronization of the A-phase, B-phase, and Z-phase count values. Let the total number of quadruple frequency counts corresponding to one revolution of the motor under test be N4. Then the actual encoder line count L satisfies: L = N4 / 4. The actual encoder line count L should also satisfy the verification relationship with the single edge pulse count NA of the A-phase signal, that is: L = NA.
[0015] Preferably, step S6 further includes a single-edge verification step for the A-phase signal. The verification step is located after the quadruple frequency counting and before the actual encoder line count output: the number of single-edge pulses NA of the A-phase signal within one revolution of the motor under test is counted. When N4 / 4 is consistent with NA, N4 / 4 is used as the actual encoder line count; when N4 / 4 is inconsistent with NA, an encoder signal abnormality result is output.
[0016] Preferably, in step S7, when comparing the actual electrical phase and the actual Hall phase, the angle deviation between the actual phase and the corresponding standard value is first normalized to the range of -180° to 180°. The normalization formula is: when the deviation is >180°, the deviation = deviation -360°; when the deviation is <-180°, the deviation = deviation +360°. Then, it is determined whether the absolute value of the normalized angle deviation is within the corresponding allowable deviation range.
[0017] The present invention also provides an encoder detection device for performing the encoder detection method described above, the encoder detection device comprising: The drive control module is used to control the motor under test to run at low speed under no-load and to coordinate the testing process; The encoder signal acquisition module is used to acquire the A-phase signal, B-phase signal and Z-phase signal output by the encoder; The Hall signal acquisition module is used to acquire the U-phase signal, V-phase signal and W-phase signal output by the Hall sensor; The calculation and identification module is used to calculate the actual encoder line count, actual electrical phase, and actual Hall phase based on the synchronously acquired signal. The calculation and identification module also includes a data validity verification unit, which is used to verify whether the synchronous timing data meets the preset validity conditions before calculation, including Z signal integrity verification, UVW state legality verification, and AB phase sequence matching verification. The parameter matching and calibration module is used to call the preset design indicators and compare the actual encoder line count, actual electrical phase and actual Hall phase with the corresponding preset design indicators to generate a qualified or unqualified judgment result. The storage module is used to store the design requirement parameter library, the UVW state reference value at the Z-phase signal trigger time, the detection algorithm, parameter comparison rules, anomaly judgment criteria, and detection records. The timing buffer module is used to write the transition edges of each signal into the same timing buffer according to a unified timestamp, ensuring that the synchronization error between signals is no greater than 1μs.
[0018] The display and alarm module is used to display the detection process, detection results and abnormal information, and to issue an alarm when the detection fails. A power supply module is used to supply power to the encoder detection device.
[0019] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the encoder detection method and performs a verification step on the legality of the UVW state at the Z-phase signal triggering time before calculating the actual Hall phase.
[0020] Compared with the prior art, the encoder detection method, apparatus and storage medium of the present invention have the following advantages: 1. This invention can automatically complete the detection and comparison of encoder line count, electrical phase and Hall phase, reducing manual measurement and manual debugging, and improving detection efficiency.
[0021] 2. This invention uses the same hardware timer, the same sampling clock, and the same timestamp to synchronously acquire ABZ and UVW signals, which can reduce phase errors caused by signal asynchrony and improve the accuracy of electrical phase and Hall phase detection.
[0022] 3. This invention stores preset design indicators according to motor model through a design requirement parameter library, which can quickly adapt to the mixed production of multiple servo motor models and reduce the risk of misjudgment caused by confusion of model parameters.
[0023] 4. Before calculating actual parameters, this invention sets up a synchronous timing data validity judgment, which can identify problems such as Z-phase signal abnormality, A / B phase sequence abnormality, UVW illegal state, UVW commutation sequence abnormality, and avoid making incorrect judgments based on invalid signals.
[0024] 5. The present invention adopts the judgment rule of "item-by-item comparison, and only products that pass all items are judged as qualified", which can clearly distinguish between qualified and unqualified products, and record the unqualified parameters and deviation values, which facilitates subsequent investigation.
[0025] 6. This invention can automatically record complete data for each test, making the testing process traceable and facilitating quality review, fault analysis, and production process optimization.
[0026] 7. This invention does not require structural modifications to existing servo motors and encoders, and can be directly integrated into the testing stage of existing servo motor production lines, making it highly practical. [Attached Image Description] Figure 1 This is a block diagram of the overall structure of the encoder detection device of the present invention; Figure 2 This is a flowchart illustrating the overall encoder detection process of the present invention. Figure 3 This is a schematic diagram of encoder line count detection and comparison according to the present invention; Figure 4 This is a schematic diagram of electrical phase and Hall phase detection and comparison according to the present invention.
Detailed Implementation Methods
[0029] It should be noted that in the embodiments of the present invention, all directional indications (such as up, down, left, right, front, back, etc.) are limited to relative positions on the specified view, rather than absolute positions.
[0030] Furthermore, in this invention, descriptions involving "first," "second," etc., are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0031] This invention provides an encoder detection method, comprising the following steps.
[0032] First, a design requirement parameter library is pre-established. This library stores corresponding preset design indicators according to the motor model. These preset design indicators include standard values for encoder line count, standard values and allowable deviation ranges for electrical phase, and standard values and allowable deviation ranges for Hall phase. Furthermore, the design requirement parameter library also stores the number of motor pole pairs, preset rotation direction, UVW state reference values at the Z-phase signal trigger time, electrical phase detection reference, Hall phase angle type, UVW six-state commutation table, parameter comparison rules, anomaly judgment criteria, and detection recording strategies.
[0033] Next, the motor to be tested is connected to the testing device. After powering on, the testing device completes self-tests of each module and loads the design requirement parameter library. Operators can select the motor model to be tested via the display module. The testing device can also read the model parameters or preset design parameters from the servo motor driver via the communication configuration module and call the preset design specifications for the corresponding motor model. When the manually selected model does not match the read model, the testing device outputs a model error message and pauses the testing to avoid misjudgment due to model parameter confusion.
[0034] Next, the drive control module outputs a low-speed drive signal to control the motor under test to rotate at a preset low speed under no-load for at least one revolution. Preferably, the preset low speed is no more than 50 r / min to avoid signal distortion caused by high-speed operation, while ensuring complete acquisition of encoder signals and Hall signals.
[0035] Then, the encoder signal acquisition module synchronously acquires the A-phase, B-phase, and Z-phase signals output by the encoder, while the Hall signal acquisition module synchronously acquires the U-phase, V-phase, and W-phase signals output by the Hall sensor. The A-phase, B-phase, Z-phase, U-phase, V-phase, and W-phase signals are respectively connected to the same microprocessor's input capture channel or a synchronous timer input capture channel. The same hardware timer latches the count values corresponding to each transition edge and writes them into the same timing buffer in timestamp order, thus forming synchronous timing data. The synchronous timing data includes at least the transition time, transition edge type, count value, and signal state.
[0036] Subsequently, the calculation and identification module first performs a validity check on the synchronization timing data. When there are situations such as missing Z-phase signal, abnormal repetition of Z-phase signal, abnormal phase sequence of A-phase and B-phase signals, illegal UVW state, abnormal UVW commutation sequence, illegal UVW state at the Z-phase signal trigger time, or insufficient rotation count, the detection device outputs a detection abnormality or unqualified result and terminates the current detection process; the validity check of the synchronization timing data includes: The Z-phase signal appears exactly once during one revolution; The phase sequence of phase A and phase B signals is matched with the preset rotation direction; The UVW status is always in one of the six valid states; The UVW state transition sequence conforms to the pre-stored UVW six-state commutation table; The UVW state corresponding to the Z-phase signal trigger moment is a valid state; The number of rotations meets the preset requirements; The synchronization timing data is considered valid only when all conditions are met; if any condition is not met, the synchronization timing data is considered invalid, and an abnormal or unqualified result is output.
[0037] When the synchronization timing data is valid, it is further determined whether the UVW state corresponding to the Z-phase signal trigger time is a valid state; the valid state is one of the six valid states defined by the UVW six-state commutation table; when the UVW state corresponding to the Z-phase signal trigger time is an invalid state, an abnormal detection result is output and the current detection process ends; when the UVW state corresponding to the Z-phase signal trigger time is a valid state, firstly, the rotation direction of the motor under test is determined according to the transition relationship between the A-phase signal and the B-phase signal; when the actual rotation direction is opposite to the preset rotation direction, the quadruple frequency counting direction is corrected, or an abnormal rotation direction result is output; the calculation and recognition module calculates the actual encoder line count, actual electrical phase, and actual Hall phase based on the collected signals.
[0038] The actual encoder line count is obtained by counting the quadruple frequency of both phase A and phase B signals. If the total number of quadruple frequency counts corresponding to one revolution of the motor under test is N4, then the actual encoder line count L = N4 / 4. The detection device can also verify the count using a single edge count of the phase A signal. If the single edge count result of the phase A signal is inconsistent with the quadruple frequency count conversion result, an abnormal encoder signal result is output.
[0039] The actual electrical phase is calculated using the Z-phase signal trigger position as the mechanical zero-position reference, based on the fourth harmonic count value of the event corresponding to the preset electrical phase detection reference, the number of motor pole pairs, and the total number of fourth harmonic counts per revolution. Let the fourth harmonic count value of the event corresponding to the preset electrical phase detection reference be C, the total number of fourth harmonic counts per revolution be N4, and the number of motor pole pairs be P. Then, the mechanical angle θm relative to the Z-phase signal is 360° × C / N4, and the corresponding electrical angle θe is θe = P × θm, modulo 360°. This yields the actual electrical phase, which is then compared with the standard electrical phase value and allowable deviation range.
[0040] The actual Hall phase is calculated jointly using the UVW six-state commutation table, the Hall commutation edge, and the Z-phase signal trigger time. Specifically, the calculation and identification module identifies the Hall commutation edge based on the pre-stored UVW six-state commutation table, captures the Z-phase signal trigger time, reads the UVW state corresponding to the Z-phase signal trigger time, and determines the target Hall commutation edge. Let the fourth harmonic count value corresponding to the Z-phase signal trigger time be CZ, the fourth harmonic count value corresponding to the target Hall commutation edge be CH, and the total fourth harmonic count in one revolution be N4. Then, the mechanical angle difference θh between the Z-phase signal and the target Hall commutation edge is 360° × |CH - CZ| / N4. When the Hall phase angle type in the design requirement parameter library is a mechanical angle, θh is used as the actual Hall phase; when the Hall phase angle type is an electrical angle, P × θh modulo 360° is used as the actual Hall phase.
[0041] Next, the parameter matching and calibration module compares the actual encoder line count, actual electrical phase, and actual Hall phase with the preset design specifications item by item. If the actual encoder line count matches the standard value, the actual electrical phase is within the corresponding allowable deviation range, and the actual Hall phase is within the corresponding allowable deviation range, then the motor under test is deemed to have passed the test; if any item does not meet the corresponding preset design specifications, then the motor under test is deemed to have failed the test, and the unqualified parameters and deviation values are recorded.
[0042] Finally, the display and alarm module outputs the test results. When the test is passed, a pass indicator and all actual parameters are displayed; when the test fails, a fail indicator, the failed parameters, and the deviation value are displayed, and an audible and visual alarm is triggered. The storage module automatically records the motor model, test time, actual parameters, comparison results, and reasons for failure, for subsequent quality review, troubleshooting, and production process optimization.
[0043] The present invention also provides an encoder detection device, including a drive control module, an encoder signal acquisition module, a Hall signal acquisition module, a calculation and recognition module, a parameter matching and calibration module, a storage module, a communication configuration module, a display and alarm module, and a power supply module.
[0044] The drive control module outputs drive signals to control the motor under test to run at low speed under no-load, and coordinates the execution of the testing process by various modules. Preferably, the drive control module uses an STM32G431 microprocessor.
[0045] The encoder signal acquisition module is connected to the encoder of the motor under test. It is used to acquire A-phase signals, B-phase signals and Z-phase signals, and to isolate, filter, shape or amplify the acquired signals.
[0046] The Hall signal acquisition module is connected to the Hall sensor of the motor under test to acquire U-phase, V-phase and W-phase signals, and to perform level conversion, differential reception, filtering and shaping or signal conditioning on the acquired signals.
[0047] The calculation and recognition module is connected to the encoder signal acquisition module and the Hall signal acquisition module respectively, and is used to complete the detection and calculation of encoder line count, electrical phase and Hall phase.
[0048] The parameter matching and calibration module is connected to the calculation and identification module, storage module, communication configuration module, and display and alarm module, respectively. It is used to call the design requirement parameter library, compare the actual detection parameters with the preset design indicators, and generate the detection judgment result.
[0049] The storage module uses non-volatile memory to store the design requirement parameter library, detection algorithms, parameter comparison rules, anomaly judgment criteria, and detection records. The non-volatile memory can be Flash or EEPROM.
[0050] The communication configuration module is used to read the preset design parameters in the servo motor driver and to synchronously transmit the detection results and actual parameters to the production line management system.
[0051] The display and alarm module includes a display screen and an audible and visual alarm unit. The display screen is used to show the testing progress, motor model, preset design specifications, actual testing parameters, pass or fail results, and reasons for failure. The audible and visual alarm unit is used to issue an audible and visual prompt when the test fails.
[0052] The power module provides a stable power supply for the testing device and the connected motor under test, and has overvoltage, overcurrent and short-circuit protection functions.
[0053] The present invention also provides a computer-readable storage medium storing a computer program for implementing the above-described encoder detection method. When executed by a processor, the computer program is capable of loading a design requirement parameter library, system initialization, model matching, low-speed drive control, synchronous acquisition of ABZ and UVW signals, generation of synchronous timing data, anomaly detection, actual parameter calculation, parameter comparison and judgment, result output, anomaly alarm, and storage of detection records.
[0054] Please see Figures 1 to 4 The present invention will be further described below with reference to specific embodiments.
[0055] In this embodiment, the A-phase signal, B-phase signal, and Z-phase signal are three signals output by the encoder. The A-phase signal and B-phase signal are quadrature pulse signals, and the Z-phase signal is a zero-position pulse signal. The U-phase signal, V-phase signal, and W-phase signal are three commutation signals output by the Hall sensor. CW represents the clockwise rotation direction, and CCW represents the counterclockwise rotation direction. The electrical phase can be defined as the electrical angle of a specified detection reference event relative to the mechanical zero position of the Z-phase signal, according to design requirements. The Hall phase can be defined as the mechanical angle difference or electrical angle difference between the Z-phase signal and the target Hall commutation edge, according to design requirements.
[0056] like Figure 1 As shown, the encoder detection device includes a drive control module, an encoder signal acquisition module, a Hall signal acquisition module, a calculation and recognition module, a parameter matching and calibration module, a storage module, a communication configuration module, a display and alarm module, and a power supply module.
[0057] The drive control module uses an STM32G431 microprocessor with a main frequency ranging from 168MHz to 170MHz. This module outputs drive signals to control the motor under test to run at low speed under no-load conditions, and controls the encoder signal acquisition module and Hall signal acquisition module to perform synchronous acquisition. The STM32G431 microprocessor is equipped with input capture channels and a hardware timer. The transition edges of the A-phase, B-phase, Z-phase, U-phase, V-phase, and W-phase signals are captured by the input capture channels, and the same hardware timer provides the time reference.
[0058] The encoder signal acquisition module is connected to the encoder of the motor under test and is used to acquire the A-phase, B-phase, and Z-phase signals output by the encoder. In this embodiment, the encoder signal acquisition module includes a high-speed optocoupler isolation circuit, a filtering circuit, a shaping circuit, and an amplification circuit. The acquisition frequency is not less than 1MHz, and it can support A / B phase quadrature pulse acquisition and Z-phase pulse capture.
[0059] The Hall signal acquisition module is connected to the Hall sensor of the motor under test and is used to acquire the U-phase, V-phase, and W-phase signals output by the Hall sensor. The Hall signal acquisition module includes at least one of the following: a level conversion circuit, a differential receiving circuit, a filtering and shaping circuit, and a signal conditioning circuit, to adapt to digital levels, open collector, differential, or conditioned Hall signals.
[0060] The calculation and identification module is connected to the encoder signal acquisition module and the Hall signal acquisition module respectively, and is used to calculate the actual encoder line count, actual electrical phase and actual Hall phase based on the acquired ABZ signal and UVW signal.
[0061] The parameter matching and calibration module is connected to the calculation and identification module, storage module, communication configuration module, and display and alarm module, respectively. The parameter matching and calibration module calls the design requirement parameter library in the storage module and compares the actual parameters output by the calculation and identification module with the corresponding preset design indicators to generate a pass or fail judgment result.
[0062] The storage module uses non-volatile memory, preferably Flash memory or EEPROM. The storage module stores the design requirement parameter library, detection algorithms, parameter comparison rules, anomaly judgment criteria, and detection records. The design requirement parameter library can store preset design specifications for at least 10 common servo motor models.
[0063] The communication configuration module can use an RS485 communication interface with a communication rate of 115200bps. This module is used to read preset design parameters from the servo motor driver and to upload the test results and actual parameters to the production line management system.
[0064] The display and alarm module includes a display screen and an audible and visual alarm unit. The display screen can be a 2.4-inch LCD screen, used to display preset design parameters, actual test parameters, test progress, and judgment results. The audible and visual alarm unit can include LED lights and a buzzer, with adjustable alarm volume, and is triggered when the test fails or an abnormality occurs.
[0065] The power module uses a 24V DC input and outputs stable 5V and 12V voltages. It features overvoltage, overcurrent, and short-circuit protection to ensure long-term stable operation of the detection device.
[0066] In one implementation, the calculation identification module and the parameter matching and calibration module can be implemented by the same processor executing different program segments; in another implementation, the calculation identification module and the parameter matching and calibration module can also be implemented by independent processing circuits or independent control units.
[0067] like Figure 2 As shown, the encoder detection method provided in this embodiment includes the following steps.
[0068] S1. Establish a design requirement parameter library.
[0069] A design requirement parameter library is pre-established in the storage module. The design requirement parameter library stores the corresponding encoder line count standard value, electrical phase standard value and allowable deviation range, Hall phase standard value and allowable deviation range according to the motor model. It also stores the number of motor pole pairs, preset rotation direction, electrical phase detection benchmark, Hall phase angle type, UVW six-state commutation table, parameter comparison rules, anomaly judgment criteria, and detection recording strategy.
[0070] The electrical phase detection reference can be at least one of the specified edge of the A-phase signal, the specified edge of the B-phase signal, the Z-phase signal, or the specified Hall commutation edge. The Hall phase angle type can be a mechanical angle or an electrical angle.
[0071] S2. System initialization and model matching.
[0072] Connect the motor to be tested to the encoder testing device. After the testing device is powered on, the drive control module completes self-tests of each module and loads the design requirement parameter library from the storage module. Operators can select the motor model to be tested through the display and alarm modules, and the encoder testing device automatically calls up the preset design specifications corresponding to that model.
[0073] In an optional implementation, the communication configuration module reads the model parameters or design parameters from the servo motor driver and provides the reading results to the parameter matching and calibration module. If the manually selected model does not match the read model, the display and alarm module outputs a model anomaly prompt, and the detection device suspends detection to avoid misjudgment due to model parameter confusion.
[0074] S3, Low-speed motor operation control.
[0075] The drive control module outputs a low-speed drive signal, causing the motor under test to rotate at least one revolution under no-load at a speed not exceeding 50 r / min. Preferably, the motor under test rotates one revolution under no-load at a speed of 30 r / min, corresponding to a data acquisition time of approximately 2 seconds. Using low-speed no-load rotation can improve signal acquisition stability and avoid signal distortion caused by high-speed operation.
[0076] During rotation, the detection device can also monitor the rotation speed. When the rotation speed fluctuation exceeds a preset speed fluctuation threshold, the detection device outputs an abnormal rotation speed result and stops the current detection.
[0077] S4. Simultaneous acquisition of multiple signals.
[0078] The encoder signal acquisition module synchronously acquires the A-phase, B-phase, and Z-phase signals output by the encoder; the Hall signal acquisition module synchronously acquires the U-phase, V-phase, and W-phase signals output by the Hall sensor.
[0079] The ABZ and UVW signals use the same hardware timer and the same system timestamp to record the transition times. The sampling clocks for all signals originate from the same source, and the synchronization error between signals is no greater than 1μs. Furthermore, each transition edge is captured and written to the same timing buffer to ensure the uniqueness and order of the timestamps. After each transition edge is captured by the input capture channel, the input capture results are written to the same timing buffer in timestamp order, thereby generating synchronization timing data. This synchronization timing data includes the transition time, transition edge type, count value, and signal state for each signal.
[0080] S5. Validity judgment of synchronous timing data.
[0081] Before calculating the actual parameters, the calculation and recognition module first checks the validity of the synchronized time-series data. If any of the following situations occur, the detection device will output a detection abnormality or detection failure result: The Z-phase signal is lost during one rotation. The Z-phase signal repeats abnormally during one rotation. The phase sequence of phase A and phase B signals does not match the preset rotation direction; UVW status is 000 or 111; The UVW state transition sequence does not conform to the pre-stored UVW six-state commutation table; The interval between adjacent Hall effect commutations exceeds the preset range; The number of rotations is less than one full revolution; The results of the fourth-frequency counting are inconsistent with the results of the single-edge counting verification of the A-phase signal.
[0082] If the synchronized timing data is valid, proceed to the actual parameter detection and calculation step.
[0083] S6, Actual encoder line count detection.
[0084] The calculation and recognition module employs a quadruple frequency counting method with both A and B phases, separately acquiring the rising edge, falling edge, rising edge, and falling edge of the A-phase signal, and performing unified counting. Simultaneously, the quadruple frequency count values are stored in the same timing buffer according to timestamp order to ensure strict synchronization of the A-phase, B-phase, and Z-phase count values. After the motor under test rotates one revolution, assuming the total number of quadruple frequency counts for one revolution is N4, the actual encoder line count L = N4 / 4. The actual encoder line count L should also satisfy the verification relationship with the single-edge pulse count NA of the A-phase signal, i.e., L = NA.
[0085] In another embodiment, the calculation and identification module also supports a single-edge counting mode for the A-phase signal. In this mode, the number of single-edge pulses NA of the A-phase signal collected after one revolution of the motor under test is the actual encoder line count. To improve detection reliability, when both double-edge quadruple-frequency counting results and the single-edge counting results of the A-phase signal are obtained simultaneously, the detection device determines whether N4 / 4 and NA are consistent. If they are consistent, N4 / 4 is used as the actual encoder line count; if they are inconsistent, an encoder signal abnormality result is output.
[0086] S7, Actual electrical phase detection.
[0087] The calculation and identification module first determines the rotation direction of the motor under test based on the transition order of the A-phase signal and the B-phase signal. If the actual rotation direction is consistent with the preset rotation direction, the electrical phase calculation continues; if the actual rotation direction is opposite to the preset rotation direction, the direction of the quadruple frequency counting is corrected, or an abnormal rotation direction result is output.
[0088] During calculation, the trigger position of the Z-phase signal is used as the mechanical zero-position reference, and the fourth harmonic count value C corresponding to the event of the preset electrical phase detection reference is obtained. Assuming the total number of fourth harmonic counts per revolution is N4, and the number of pole pairs of the motor is P, then the mechanical angle θm of this event relative to the Z-phase signal satisfies: θm = 360° × C / N4.
[0089] The electrical angle θe corresponding to this event satisfies: θe = P × θm, and take the modulus of 360°.
[0090] The calculation and identification module determines the actual electrical phase based on the electrical angle θe. The parameter matching and calibration module compares the actual electrical phase with the standard electrical phase value in the design requirement parameter library. During the comparison, the angular deviation between the actual electrical phase and the standard electrical phase value is first normalized to the range of -180° to 180°. The normalization formula is: when the deviation > 180°, deviation = deviation - 360°; when the deviation < -180°, deviation = deviation + 360°. Then, it is determined whether the absolute value of the angular deviation is within the allowable deviation range of the electrical phase.
[0091] S8, Actual Hall Phase Detection.
[0092] The calculation and recognition module identifies the Hall commutation edge based on the pre-stored UVW six-state commutation table, captures the trigger time of the Z-phase signal, reads the UVW state corresponding to the trigger time of the Z-phase signal, and determines the target Hall commutation edge. The target Hall commutation edge can be the Hall commutation edge specified in the design requirement parameter library, or it can be the Hall commutation edge closest to the trigger time of the Z-phase signal.
[0093] Let the fourth harmonic count value corresponding to the trigger moment of the Z-phase signal be CZ, the fourth harmonic count value corresponding to the commutation edge of the target Hall be CH, and the total fourth harmonic count value in one revolution be N4. Then the mechanical angle difference θh between the Z-phase signal and the commutation edge of the target Hall satisfies: θh=360°×|CH-CZ| / N4.
[0094] When the Hall phase angle type in the design requirement parameter library is mechanical angle, θh is used as the actual Hall phase; when the Hall phase angle type in the design requirement parameter library is electrical angle, P×θh is modulo 360° and used as the actual Hall phase, where P is the number of motor pole pairs.
[0095] The parameter matching and calibration module compares the actual Hall phase with the standard Hall phase value. During the comparison, the angular deviation between the actual Hall phase and the standard Hall phase value is first normalized to the range of -180° to 180°, and then it is determined whether the absolute value of the angular deviation is within the allowable deviation range of the Hall phase.
[0096] S9. Parameter comparison and qualification judgment.
[0097] The parameter matching and calibration module compares the actual encoder line count, actual electrical phase, and actual Hall phase with the preset design specifications of the corresponding model in the design requirement parameter library.
[0098] If the actual encoder line count matches the standard encoder line count, the actual electrical phase is within the allowable deviation range of the electrical phase, and the actual Hall phase is within the allowable deviation range of the Hall phase, then the motor under test is deemed to have passed the test.
[0099] If any of the actual encoder line count, actual electrical phase, or actual Hall phase does not meet the corresponding preset design specifications, the motor under test is deemed unqualified, and the unqualified parameters and deviation values are recorded simultaneously.
[0100] S10. Result Output and Exception Handling.
[0101] When the test is passed, the display and alarm module will show a "pass" sign, along with the motor model, preset design specifications, and various actual parameters.
[0102] When a test fails, the display and alarm module shows a "Fail" label, the failed parameters, and the deviation value, and triggers an audible and visual alarm. Staff can then troubleshoot or reassemble the motor based on the cause of the failure, and subsequently repeat the testing process.
[0103] When an anomaly is detected, the display and alarm module shows the anomaly type, such as missing Z-phase signal, illegal UVW state, abnormal AB phase sequence, or abnormal speed, and triggers a prompt message so that staff can quickly locate the source of the anomaly.
[0104] S11. Inspection Records and Review.
[0105] The storage module automatically records the motor model, inspection time, actual encoder lines, actual electrical phase, actual Hall phase, comparison results, and reasons for non-compliance in this inspection. Inspection records can be uploaded to the production line management system via the communication configuration module or exported via an external storage device for subsequent quality review, troubleshooting, and production process optimization.
[0106] Taking the Model 2 servo motor as an example, the standard value of the encoder line count for this model of motor is preset to 8192 lines in the design requirement parameter library. The standard electrical phase relationship is that when the motor is running CCW, the A phase signal leads the B phase signal. The standard electrical phase value is 15° with an allowable deviation of ±2°. The standard Hall phase value is 30° with an allowable deviation of ±2°.
[0107] During testing, the Model 2 motor is connected to the encoder testing device. After the testing device is powered on, the STM32G431 microprocessor completes self-tests of each module and loads the design requirement parameter library. The operator selects "Model 2" on the display screen, and the testing device automatically calls the preset design specifications for that model and displays "Initialization complete, waiting for testing".
[0108] The drive control module controls the Model 2 motor to rotate one revolution under no-load at a speed of 30 r / min. The encoder signal acquisition module synchronously acquires the A-phase, B-phase, and Z-phase signals, while the Hall signal acquisition module synchronously acquires the U-phase, V-phase, and W-phase signals. After filtering, shaping, and conditioning, the acquired signals are captured by the same hardware timer and written to the same timing buffer.
[0109] The calculation and recognition module counts the total number of four-fold frequency counters corresponding to one revolution of the motor under test, which is 32768. Therefore, the actual encoder line count is 32768 / 4 = 8192 lines. The module further determines that the A-phase signal leads the B-phase signal during the motor's CCW operation based on the transition timing of the A-phase and B-phase signals, and calculates the actual electrical phase as 14.8°. Simultaneously, the module captures the trigger moment of the Z-phase signal, reads the Hall state at that moment as U-phase high, V-phase low, and W-phase high, and calculates the actual Hall phase as 30.9° based on the target Hall commutation edge.
[0110] The parameter matching and calibration module performs a comparison: the actual encoder line count of 8192 lines matches the preset standard value of 8192 lines; during motor CCW operation, the A-phase signal leads the B-phase signal, and the actual electrical phase of 14.8° is within the range of 13° to 17°; the actual Hall phase of 30.9° is within the range of 28° to 32°. Therefore, all three parameters meet the design requirements, and the model 2 motor is deemed to have passed the test. The display screen shows "Test Passed" and simultaneously displays all actual parameters, while the storage module automatically records the test data.
[0111] If the actual encoder line count of another motor under test is 8000 lines, while the standard line count for the corresponding model is 8192 lines, then even if the actual electrical phase and actual Hall phase meet the requirements, the parameter matching and calibration module will still determine that the motor fails the test. The display screen will show "Fail," the failure parameter being the encoder line count with a deviation of -192 lines, and an audible and visual alarm will be triggered.
[0112] If the actual Hall phase of another motor under test is 34.9°, while the allowable range of Hall phase is 28° to 32°, the parameter matching and calibration module determines that the motor is unqualified. The display shows the unqualified parameter as Hall phase with a deviation of +4.9°, and records the reason for the unqualified result.
[0113] In this embodiment, the computer program for implementing the encoder detection method described above is stored in a 16GB Flash memory, which embeds the control unit of the encoder detection device. When the STM32G431 microprocessor executes the computer program, it automatically completes the following tasks: loading the design requirement parameter library, system initialization, model matching, low-speed drive control, synchronous acquisition of ABZ and UVW signals, generation of synchronous timing data, anomaly detection, actual parameter detection and calculation, parameter comparison and judgment, output of detection results, audible and visual alarm control, and storage of detection records.
[0114] When a new motor model is added, the design requirements parameters for the new model can be written to the Flash memory via a USB interface, RS485 interface, or other communication interface. These design requirements parameters include the standard values for encoder line count, electrical phase standard values and allowable deviation ranges, Hall phase standard values and allowable deviation ranges, motor pole pairs, preset rotation direction, electrical phase detection reference, and a UVW six-state commutation table. The detection device can update the design requirements parameter library without disassembly.
[0115] The test records can be exported via external USB flash drive, portable hard drive, or communication interface for production quality review, fault cause analysis, and production process optimization.
[0116] The computer-readable storage medium is not limited to Flash memory, but may also be ROM, RAM, EEPROM, hard disk, optical disk, USB flash drive, portable hard disk, or other storage medium capable of storing programs and being read and executed by a processor.
[0117] This invention is not limited to the embodiments described above. Based on actual production needs, the preset indicators, motor operating speed, acquisition frequency, communication interface type, display screen specifications, alarm methods, and storage medium formats in the design requirement parameter library can be adjusted. As long as the technical approach of this invention—pre-setting design requirements, acquiring synchronous signals from the same source, detecting actual parameters, comparing and judging each item, and tracing detection records—is adopted, it should fall within the protection scope of this invention.
Claims
1. An encoder testing method, applied in the production and testing process of servo motors, characterized in that, Includes the following steps: S1. Establish and store a design requirement parameter library. The design requirement parameter library stores corresponding preset design indicators according to the motor model. The preset design indicators include at least the standard value of encoder line count, the standard value of electrical phase and the allowable deviation range, and the standard value of Hall phase and the allowable deviation range. S2. Connect the motor to be tested to the testing device, initialize the testing device and perform module self-test, load the design requirement parameter library, and call the corresponding preset design indicators according to the model of the motor to be tested. S3. Control the motor to be tested to rotate at a preset low speed under no-load for at least one revolution; S4. During the rotation of the motor under test, the A-phase signal, B-phase signal, Z-phase signal output by the encoder and the U-phase signal, V-phase signal, W-phase signal output by the Hall sensor are synchronously acquired. The transition edges of the A-phase signal, B-phase signal, Z-phase signal, U-phase signal, V-phase signal and W-phase signal are all captured by input through the same time base, and synchronous timing data containing the transition time, transition edge type, count value and signal status are generated. S5. Perform validity checks on the synchronization timing data. If there are any issues such as missing Z-phase signal, abnormal repetition of Z-phase signal, abnormal phase sequence of A-phase and B-phase signals, illegal UVW state, abnormal UVW commutation sequence, illegal UVW state at the Z-phase signal trigger time, or insufficient rotation count, output an abnormal or unqualified result and end the current detection process. The validity checks on the synchronization timing data include: The Z-phase signal appears exactly once during one revolution; The phase sequence of phase A and phase B signals is matched with the preset rotation direction; The UVW status is always in one of the six valid states; The UVW state transition sequence conforms to the pre-stored UVW six-state commutation table; The UVW state corresponding to the Z-phase signal trigger moment is a valid state; The number of rotations meets the preset requirements; The synchronization timing data is considered valid only when all conditions are met; if any condition is not met, the synchronization timing data is considered invalid, and an abnormal or unqualified result is output. S6. When the synchronous timing data is valid, further determine whether the UVW state corresponding to the Z-phase signal trigger time is a valid state; the valid state is one of the six valid states defined by the UVW six-state commutation table; when the UVW state corresponding to the Z-phase signal trigger time is an invalid state, output the detection anomaly result and end the current detection process; when the UVW state corresponding to the Z-phase signal trigger time is a valid state, firstly, determine the rotation direction of the motor under test based on the transition order of the A-phase signal and the B-phase signal; when the actual rotation direction is opposite to the preset rotation direction, correct the quadruple frequency counting direction, or output the rotation direction anomaly result; calculate the actual encoder line count based on the A-phase signal and the B-phase signal, calculate the actual electrical phase based on the Z-phase signal, the A-phase signal, the B-phase signal, the number of motor pole pairs and the preset electrical phase detection benchmark, and calculate the actual Hall phase based on the Z-phase signal, the UVW six-state commutation table and the Hall commutation edge; S7. Compare the actual encoder line count, actual electrical phase, and actual Hall phase with the corresponding preset design parameters respectively; S8. When the actual encoder line count matches the standard encoder line count, the actual electrical phase is within the corresponding allowable deviation range, and the actual Hall phase is within the corresponding allowable deviation range, the motor under test is deemed to be qualified. When any one of these conditions fails to meet the corresponding preset design specifications, the motor under test is deemed to be unqualified, and the unqualified parameters and deviation values are recorded. S9. Output the test results and store the test records. The test records shall include at least the motor model, test time, actual encoder line count, actual electrical phase, actual Hall phase, comparison results, and reasons for non-compliance.
2. The encoder detection method as described in claim 1, characterized in that, The design requirement parameter library also stores the number of motor pole pairs, preset rotation direction, UVW state reference value at the Z-phase signal trigger time, electrical phase detection reference, Hall phase angle type, UVW six-state commutation table, parameter comparison rules, anomaly judgment criteria, and detection recording strategy; the electrical phase detection reference includes at least one of the specified edge of the A-phase signal, the specified edge of the B-phase signal, the Z-phase signal, or the specified Hall commutation edge.
3. The encoder detection method as described in claim 1, characterized in that, In step S2, the model of the motor to be tested is selected by the operator through the display module, or automatically matched by the testing device after reading the model parameters in the servo motor driver through the communication configuration module; when the manually selected motor model is inconsistent with the read model parameters, the testing device outputs a model abnormality prompt and suspends the testing.
4. The encoder detection method as described in claim 1, characterized in that, In step S3, the preset low speed is no more than 50 r / min; during the low-speed no-load rotation of the motor to be tested, the detection device monitors the rotation speed, and when the rotation speed fluctuation exceeds the preset speed fluctuation threshold, it outputs an abnormal speed result and stops the current test.
5. The encoder detection method as described in claim 1, characterized in that, In step S4, the A-phase signal, B-phase signal, Z-phase signal, U-phase signal, V-phase signal, and W-phase signal are respectively connected to the input capture channel of the same microprocessor or the input capture channel of the same synchronous timer. The count value corresponding to each transition edge is latched by the same hardware timer and written into the same timing buffer according to the timestamp order. The synchronization error between signals is no more than 1μs, and each transition edge is uniformly written into the same timing buffer after being captured to ensure the uniqueness and order of the timestamp.
6. The encoder detection method as described in claim 1, characterized in that, In step S6, the actual encoder line count is obtained by using a quadruple frequency counting method on both sides of the A-phase and B-phase signals. The rising edge, falling edge, rising edge, and falling edge of the A-phase signal, the B-phase signal, and the Z-phase signal are counted respectively. At the same time, the quadruple frequency count values are stored in the same timing buffer according to the timestamp order to ensure strict synchronization of the A-phase, B-phase, and Z-phase count values. Let the total number of quadruple frequency counts corresponding to one revolution of the motor under test be N4. Then the actual encoder line count L satisfies: L = N4 / 4. The actual encoder line count L should also satisfy the verification relationship with the single edge pulse count NA of the A-phase signal, that is: L = NA.
7. The encoder detection method as described in claim 6, characterized in that, Step S6 further includes a single-edge verification step for the A-phase signal. This verification step is located after the quadruple frequency counting and before the actual encoder line count output: the number of single-edge pulses NA of the A-phase signal within one revolution of the motor under test is counted. When N4 / 4 is consistent with NA, N4 / 4 is used as the actual encoder line count; when N4 / 4 is inconsistent with NA, an encoder signal abnormality result is output.
8. The encoder detection method as described in claim 1, characterized in that, In step S7, when comparing the actual electrical phase and the actual Hall phase, the angle deviation between the actual phase and the corresponding standard value is first normalized to the range of -180° to 180°. The normalization formula is: when the deviation is >180°, the deviation = deviation -360°; when the deviation is <-180°, the deviation = deviation +360°. Then, it is determined whether the absolute value of the normalized angle deviation is within the corresponding allowable deviation range.
9. An encoder detection device, characterized in that, For performing the encoder detection method according to any one of claims 1 to 8, the encoder detection device comprises: The drive control module is used to control the motor under test to run at low speed under no-load and to coordinate the testing process; The encoder signal acquisition module is used to acquire the A-phase signal, B-phase signal and Z-phase signal output by the encoder; The Hall signal acquisition module is used to acquire the U-phase signal, V-phase signal and W-phase signal output by the Hall sensor; The calculation and identification module is used to calculate the actual encoder line count, actual electrical phase, and actual Hall phase based on the synchronously acquired signal. The calculation and identification module also includes a data validity verification unit, which is used to verify whether the synchronous timing data meets the preset validity conditions before calculation, including Z signal integrity verification, UVW state legality verification, and AB phase sequence matching verification. The parameter matching and calibration module is used to call the preset design indicators and compare the actual encoder line count, actual electrical phase and actual Hall phase with the corresponding preset design indicators to generate a qualified or unqualified judgment result. The storage module is used to store the design requirement parameter library, the UVW state reference value at the Z-phase signal trigger time, the detection algorithm, parameter comparison rules, anomaly judgment criteria, and detection records. The timing buffer module is used to write the transition edges of each signal into the same timing buffer according to a unified timestamp, ensuring that the synchronization error between signals is no greater than 1μs. The display and alarm module is used to display the testing process, test results and abnormal information, and to issue an alarm when the test fails. A power supply module is used to supply power to the encoder detection device.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the encoder detection method according to any one of claims 1 to 8, and performs a verification step on the legality of the UVW state at the Z-phase signal triggering time before calculating the actual Hall phase.
