Calibration method and electronic device, error compensation method and system, and storage medium
Patent Information
- Application Number
- CN202610948958.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-26
- Publication Date
- 2026-10-09
AI Technical Summary
然而,在实际应用中,位置传感的输出信号会不可避免地引入误差
[0018]本申请的有益效果:上述方案,通过同步获取信号质量较高的参考位置传感器的输出作为基准,能够准确获取待标定传感器的真实误差分布,从而为后续对待标定位置传感器的高精度标定提供可靠的数据基础,利用初始权重矩阵与待标定传感器输出角度结合来确定第二角度差,构建了基于信号谐波的误差预测机制,使得能够以紧凑的参数形式与预测复杂的周期性位置误差对应,提高对周期性误差的存储资源的占用率,通过计算第一角度差与第二角度差之间的差异作为误差损失,并以此为目标对初始权重矩阵进行多轮迭代更新,实现了误差标定流程的自适应优化,使得预测的周期性位置误差对应的权重矩阵能够逐步收敛并逼近真实误差,提高了标定的精度和鲁棒性,最终获取的目标权重矩阵能够用于后续已标定位置传感器的误差补偿,有效抵消周期性位置误差,从而提升已标定位置传感器在实际应用中的测量精度,且节约计算资源。
Smart Images

Figure CN122881608A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of position sensor processing technology, and in particular to a calibration method and electronic device, an error compensation method and system, and a storage medium. Background Technology
[0002] Position sensors (such as rotary transformers, magnetic encoders, and optical encoders) are core sensors for achieving precision motion control in fields such as industrial automation, robotics, and high-end equipment. Their measurement accuracy directly determines the overall performance of the system. With the development of intelligent manufacturing and precision engineering, the accuracy requirements for position encoders are increasing. However, in practical applications, errors are inevitably introduced into the output signal of position sensors. Among these errors, periodic position error is one of the main factors affecting absolute accuracy. The characteristic of periodic position error is that its magnitude changes periodically with the sensor position. It mainly originates from the non-ideal nature of the mechanical structure (such as installation eccentricity, shaft wobble) or the inherent characteristics of the sensing principle (such as magnetic field harmonic distortion, optical grid marking error).
[0003] Therefore, effectively calibrating and compensating for these periodic errors has become a key technical challenge in improving the practical accuracy of position sensors. Based on this, an effective calibration method for position sensors is urgently needed. Summary of the Invention
[0004] The main technical problem addressed by this application is to provide a calibration method and electronic device, an error compensation method and system, and a storage medium that can improve the efficiency and accuracy of calibrating position sensors, thereby improving the accuracy of the signals output by the calibrated position sensors.
[0005] To address the aforementioned technical problems, this application adopts the following technical solution: a calibration method for a position sensor, wherein the position sensor to be calibrated and a reference position sensor are connected via a rotation axis and can rotate relative to the rotation axis. The calibration method includes: simultaneously acquiring a first sample angle output by the position sensor to be calibrated and a second sample angle output by the reference position sensor, wherein the signal quality of the second sample angle is higher than that of the first sample angle; determining a first angle difference based on the difference between the first and second sample angles; determining a second angle difference based on an initial weight matrix and the second sample angle, wherein the initial weight matrix characterizes the influence of signal harmonics on the angle signal output by the position sensor to be calibrated; determining an error loss based on the difference between the first and second angle differences; and updating the initial weight matrix multiple times with the goal of minimizing the error loss until the updated target weight matrix meets the update requirements, wherein the target weight matrix is used for error compensation of the calibrated position sensor.
[0006] In some embodiments, the initial weight matrix includes initial weights corresponding to several target harmonic orders; the step of determining the second angle difference based on the initial weight matrix and the second sample angle includes: using the function value of the preset function corresponding to each target harmonic order as the candidate function value of each target harmonic order; and obtaining the second angle difference based on the initial weights corresponding to each target harmonic order and the candidate function values of each target harmonic order.
[0007] In some embodiments, the preset function corresponding to the target harmonic order includes a preset sine function and a preset cosine function corresponding to the target harmonic order; the candidate function value of the target harmonic order includes a candidate sine function value and a candidate cosine function value; and the initial weight corresponding to the target harmonic order includes an initial sine weight and an initial cosine weight under the target harmonic order. The step of obtaining the second angle difference based on the initial weights corresponding to each target harmonic order and the candidate function values of each target harmonic order includes: using the product between the initial sine weight of each target harmonic order and the candidate sine function value of the corresponding target harmonic order as the sine harmonic error of the corresponding target harmonic order; using the product between the initial cosine weight of each target harmonic order and the candidate sine function value of the corresponding target harmonic order as the cosine harmonic error of the corresponding target harmonic order; and using the sum of the sine harmonic error and the cosine harmonic error of each target harmonic order as the second angle difference.
[0008] In some embodiments, before the step of using the function value of the preset function corresponding to each target harmonic order as the candidate function value of each target harmonic order, the calibration method of the position sensor further includes: obtaining the harmonic amplitude of the first angle difference in a plurality of preset harmonic orders, wherein the number of preset harmonic orders is greater than or equal to the number of target harmonic orders; and for each preset harmonic order, in response to the harmonic amplitude of the preset harmonic order being greater than an amplitude threshold, using the preset harmonic order as the target harmonic order.
[0009] In some embodiments, the step of updating the initial weight matrix in multiple rounds with the goal of minimizing error loss until the updated target weight matrix meets the update requirements includes: performing the following steps for each round of updating the initial weight matrix: obtaining the weight matrix to be updated and the candidate loss for the current update round, wherein the candidate loss is the error loss determined based on the weight matrix to be updated; when the current update round is the first update round, the weight matrix to be updated represents the initial weight matrix; or, when the current update round is not the first update round, the weight matrix to be updated represents the updated weight matrix of the previous update round; determining the weight update value for the current update round based on the candidate loss and the weight matrix to be updated; and using the sum of the weight matrix to be updated and the weight update value as the updated weight matrix for the current update round; wherein the updated weight matrix of the last update round is taken as the target weight matrix.
[0010] To solve the above-mentioned technical problems, another technical solution adopted in this application is: providing a calibration device for a position sensor, wherein the position sensor to be calibrated and a reference position sensor are connected by a rotation axis and can rotate relative to the rotation axis. The calibration device for the position sensor includes: an acquisition module, a first determination module, a second determination module, a third determination module, and an update module; the acquisition module is used to simultaneously acquire a first sample angle output by the position sensor to be calibrated and a second sample angle output by the reference position sensor, wherein the signal quality of the second sample angle is higher than that of the first sample angle; the first determination module is used to determine a first angle difference based on the difference between the first sample angle and the second sample angle; the second determination module is used to determine a second angle difference based on an initial weight matrix and the second sample angle, wherein the initial weight matrix characterizes the influence of signal harmonics on the angle signal output by the position sensor to be calibrated; the third determination module is used to determine the error loss based on the difference between the first angle difference and the second angle difference; the update module is used to update the initial weight matrix multiple times with the goal of reducing the error loss until the updated target weight matrix meets the update requirements, wherein the target weight matrix is used for error compensation of the calibrated position sensor.
[0011] To solve the above-mentioned technical problems, another technical solution adopted in this application is to provide an electronic device, including a memory and a processor, wherein the memory stores program instructions, and the processor retrieves program instructions from the memory to execute the above-mentioned calibration method for the position sensor.
[0012] To solve the above-mentioned technical problems, another technical solution adopted in this application is: an error compensation method for a position sensor. The error compensation method for a position sensor includes: acquiring the angle to be compensated of the calibrated position sensor and the reference angle corresponding to the angle to be compensated, wherein the reference angle represents a preset angle corresponding to the angle to be compensated, or a compensated angle at a historical signal acquisition time before the current signal acquisition time of the angle to be compensated, wherein the historical signal acquisition time is separated from the current signal acquisition time by one signal acquisition cycle; and performing error compensation on the angle to be compensated according to the target weight matrix and the reference angle to obtain the compensated angle, wherein the target weight matrix is obtained based on the above-mentioned calibration method for the position sensor.
[0013] In some embodiments, the step of performing error compensation on the angle to be compensated based on the target weight matrix and the reference angle to obtain the compensated angle includes: determining the target angle difference between the angle to be compensated and the reference angle based on the target weight matrix and the reference angle; and taking the difference between the angle to be compensated and the target angle difference as the compensated angle.
[0014] In some embodiments, the target weight matrix includes target weights corresponding to several target harmonic orders; the step of determining the target angle difference between the angle to be compensated and the reference angle based on the target weight matrix and the reference angle includes: taking the function value of the preset function corresponding to each target harmonic order as the target function value of the corresponding target harmonic order; and obtaining the target angle difference according to the target weights corresponding to each target harmonic order and the target function values of the corresponding target harmonic orders.
[0015] To solve the above-mentioned technical problems, another technical solution adopted in this application is: providing an error compensation device for a position sensor. The error compensation device for a position sensor includes: an acquisition module and a compensation module; the acquisition module is used to acquire the angle to be compensated of the calibrated position sensor and the reference angle corresponding to the angle to be compensated, the reference angle representing a preset angle corresponding to the angle to be compensated, or the compensated angle at a historical signal acquisition time before the current signal acquisition time of the angle to be compensated, the historical signal acquisition time and the current signal acquisition time being separated by one signal acquisition cycle; the compensation module is used to perform error compensation on the angle to be compensated according to the target weight matrix and the reference angle to obtain the compensated angle, the target weight matrix being obtained based on the above-mentioned calibration method of the position sensor.
[0016] To solve the above-mentioned technical problems, another technical solution adopted in this application is: to provide an error compensation system for a position sensor, the error compensation system for a position sensor including: a calibrated position sensor; a memory storing program instructions; a processor connected to the calibrated position sensor and the memory respectively; the processor retrieving program instructions from the memory to execute the above-mentioned error compensation method for the position sensor.
[0017] To solve the above-mentioned technical problems, another technical solution adopted in this application is: to provide a computer-readable storage medium including program data, which, when executed by a processor, is used to implement the calibration method of the position sensor and / or the error compensation method of the position sensor.
[0018] The beneficial effects of this application are as follows: The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for the subsequent high-precision calibration of the position sensor. By combining the initial weight matrix with the output angle of the sensor to be calibrated to determine the second angle difference, an error prediction mechanism based on signal harmonics is constructed, which can correspond to the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first angle difference and the second angle difference as the error loss, and using this as the target to perform multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved, so that the weight matrix corresponding to the predicted periodic position error can gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for error compensation of the calibrated position sensor, effectively offsetting the periodic position error, thereby improving the measurement accuracy of the calibrated position sensor in practical applications and saving computing resources. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein: Figure 1 This is a first flowchart illustrating an exemplary embodiment of the calibration method for a position sensor shown in this application; Figure 2 This is a schematic diagram of an exemplary embodiment of the calibration system for a position sensor shown in this application; Figure 3 This is a second flowchart illustrating an exemplary embodiment of the calibration method for a position sensor shown in this application; Figure 4 This is a third flowchart illustrating an exemplary embodiment of the calibration method for a position sensor shown in this application; Figure 5a This is a schematic diagram illustrating the effect of an exemplary embodiment of the relationship between the first sample angle and the second sample angle shown in this application; Figure 5b This is a schematic diagram illustrating the effect of an exemplary embodiment of the first angular difference shown in this application; Figure 5c This is a schematic diagram illustrating the effect of an exemplary embodiment of the harmonic amplitude shown in this application; Figure 5dThis is a flowchart illustrating another exemplary embodiment of the calibration method for a position sensor shown in this application; Figure 6a This is a schematic flowchart of an exemplary embodiment of the error compensation method for a position sensor shown in this application; Figure 6b This is a flowchart illustrating another exemplary embodiment of the error compensation method for a position sensor shown in this application; Figure 7 This is a schematic diagram of the structure of an embodiment of the calibration device for the position sensor of this application; Figure 8 This is a schematic diagram of an embodiment of the error compensation device for the position sensor of this application; Figure 9 This is a schematic diagram of the structure of an embodiment of the electronic device provided in this application; Figure 10 This is a schematic diagram of an embodiment of the position sensor error compensation system provided in this application; Figure 11 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are only for explaining this application and not for limiting it. Furthermore, it should be noted that, for ease of description, only the parts related to this application are shown in the accompanying drawings, not all structures. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0021] First, it's important to note that in practical applications, the periodic error of position sensors is one of the main factors affecting positional accuracy. Periodic error refers to a stable error value that repeats with each rotation of the measured object, existing between the angle output by the position sensor and the actual physical angle of the object. This error primarily stems from the non-ideal nature of the mechanical structure or the inherent characteristics of the sensing principle. Therefore, effectively calibrating and compensating for this type of periodic error is a pressing problem in the field of position sensors.
[0022] Based on this, embodiments of this application propose a calibration method and system, an error compensation method and system, and a storage medium. By using the angle acquired by a reference position sensor as a reference angle for position sensor calibration, the influence of rotational speed on calibration accuracy can be reduced. For details, please refer to... Figure 1 , Figure 1This is a first flowchart illustrating an exemplary embodiment of the calibration method for a position sensor shown in this application.
[0023] The entity executing the location sensor calibration method can be a terminal device, a server, or other processing device. The terminal device can be a user equipment (UE), computer, mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. The entity executing the location sensor calibration method can also be a location sensor calibration device. In some possible implementations, the location sensor calibration method can be implemented by a processor calling computer-readable instructions stored in memory.
[0024] Specifically, the position sensor to be calibrated and the reference position sensor are connected by a rotating shaft and can rotate relative to the rotating shaft. The calibration method of the position sensor in this embodiment includes the following steps: S11: Simultaneously acquire the first sample angle output by the position sensor to be calibrated and the second sample angle output by the reference position sensor.
[0025] The calibration method for the aforementioned position sensors involves position sensors including a position sensor to be calibrated, a reference position sensor, and a calibrated position sensor. The position sensor to be calibrated and the reference position sensor are used to acquire angle signals at the same location. The signal quality of the angle signal acquired by the reference position sensor is higher than that of the angle signal acquired by the position sensor to be calibrated; signal quality can refer to the accuracy of the angle. The calibrated position sensor represents a position sensor whose initial weight matrix has been iteratively updated. The calibrated position sensor can be the aforementioned position sensor to be calibrated whose initial weight matrix has been iteratively updated, or a different position sensor of the same model as the position sensor to be calibrated. For several identical locations, the angle signal acquired by the position sensor to be calibrated is the first sample angle, and the angle signal acquired by the reference position sensor is the second sample angle. The signal quality of the second sample angle is higher than that of the first sample angle. "Several" can be one or more. The first sample angle includes a first sub-angle acquired by the position sensor to be calibrated at several sampling locations. The second sample angle includes a second sub-angle acquired by the reference position sensor at a corresponding sampling location synchronized with the position sensor to be calibrated. For example, a position sensor is used to collect the rotational position of a motor. The aforementioned sampling positions can be at least one motor position during the rotation process of a motor that rotates synchronously with the position sensor to be calibrated.
[0026] Depend on Figure 2As can be seen, the reference position sensor and the position sensor to be calibrated are connected by a rotating shaft and can rotate relative to the rotating shaft. The signal acquisition device acquires the reference angle (i.e., the second sample angle) of the reference position sensor and the angle to be calibrated (i.e., the first sample angle) of the position sensor to be calibrated. The original angle geometry information can be obtained by inputting a preset trigonometric function into the angle to be calibrated. For example, the reference position sensor and the position sensor to be calibrated can be rigidly connected by a rotating shaft so that the reference position sensor and the position sensor to be calibrated rotate synchronously with the same angular velocity and the same angular position, thereby acquiring the angle at the same position of the motor. The second sample angle and the first sample angle synchronously acquired by the calibration device of the position sensor are the different information acquired by the reference position sensor and the position sensor to be calibrated at the same position.
[0027] The first sample angle refers to the angle output by the position sensor to be calibrated. Inputting this angle into a preset trigonometric function yields the angle's geometric information. The second sample angle refers to the angle sensed by the reference position sensor. Inputting this angle into a preset trigonometric function also yields the angle's geometric information. For example, the reference position sensor is a high-precision position sensor, and the second sample angle it acquires can be considered the true value or ideal position signal, used to assist in calculating the actual error with high accuracy.
[0028] The angular geometric information refers to the relationship between angles and side lengths in a figure established by a certain graphic, such as the relationship between angles and the ratios of any two sides in a right triangle. The position sensor to be calibrated is the position sensor awaiting calibration in this embodiment. Due to manufacturing or material errors, installation and assembly errors, or signal processing and electrical errors, the first sample angle output by the position sensor to be calibrated may deviate from the second sample angle. Therefore, it is necessary to measure this error and correct the first sample angle accordingly, so that the final angle output by the position sensor to be calibrated, or the angular geometric information obtained by inputting a preset trigonometric function, is as close as possible to the angle or the true angular geometric information. For example, the position sensor to be calibrated can be a rotary transformer, a magnetic encoder, an optical encoder, etc.
[0029] The first sample angle represents the angle acquired by the position sensor to be calibrated at several sampling positions within a corresponding sampling period. The first sub-angle represents the angle acquired by the position sensor to be calibrated at any sampling position within a corresponding sampling period. The second sample angle represents the angle acquired by the reference position sensor at several sampling positions within a corresponding sampling period. The second sub-angle represents the angle acquired by the reference position sensor at any sampling position within a corresponding sampling period. In some application scenarios, S11 above can be: synchronously acquiring the first sample angle of the position sensor to be calibrated and the second sample angle output by the reference position sensor within at least one sampling period, and grouping them according to the same sampling positions within each sampling period to obtain several sample angle groups, each sample angle group including the first sub-angle and the second sub-angle belonging to the same sampling position within the same sampling period. The sampling period represents the signal acquisition period corresponding to one revolution of the motor that rotates synchronously with the position sensor. In other application scenarios, S11 above can be: the position sensor to be calibrated and the reference position sensor acquire the first sub-angle and the second sub-angle at each sampling position, and use them as the sample angle group corresponding to that sampling position within each sampling period, until multiple groups of sample angles for at least one sampling period are acquired.
[0030] S12: Determine the first angle difference based on the difference between the first sample angle and the second sample angle.
[0031] The first angle difference characterizes the actual measurement error between the position sensor to be calibrated and the reference position sensor, and is used to reflect the true measurement deviation of the sensor to be calibrated at the corresponding sampling position.
[0032] The first sample angle includes at least one first sub-angle acquired by the position sensor to be calibrated at at least one sampling position within the corresponding sampling period. The second sample angle includes at least one second sub-angle acquired by the reference position sensor at at least one sampling position within the corresponding sampling period.
[0033] In some application scenarios, S12 above can be: in response to the number of first sub-angles being equal to one and the number of second sub-angles being equal to one, the difference between the first sub-angle and the second sub-angle is taken as the first angle difference. In other application scenarios, the first angle difference includes several first sub-angle differences corresponding to sampling positions. S12 above can be: in response to the number of first sub-angles being greater than a preset number and the number of second sub-angles being greater than a preset number, the difference between the first sub-angle and the second sub-angle in the same sample angle group is taken as the first sub-angle difference of the corresponding sampling position.
[0034] S13: Determine the second angle difference based on the initial weight matrix and the second sample angle.
[0035] The initial weight matrix characterizes the influence of signal harmonics on the angle signal output by the position sensor to be calibrated. The initial weight matrix includes initial weights for several signal frequency types, each initial weight representing the influence of harmonic errors of each harmonic order on the angle signal output by the position sensor to be calibrated. The second angle difference characterizes the prediction error between the position sensor to be calibrated and the reference position sensor, i.e., the prediction deviation between the estimated first sample angle and the second sample angle. For example, the second angle difference is a virtual error estimate, calculated by the interaction of the initial weight matrix and the second sample angle (or a harmonic basis function vector constructed based on the second sample angle). The elements in the initial weight matrix represent the contribution coefficients of different order harmonics (such as first, second, etc.) to the total error between the position sensor to be calibrated (output angle signal to be calibrated) and the reference position sensor (output reference angle signal) at any given motor position.
[0036] In some application scenarios, S13 above can be: inputting the initial weight matrix and the second sample angle into a preset error prediction function to obtain the error prediction function value, and using the error prediction function value as the second angle difference. The preset error prediction function represents the correlation between the initial weight matrix, the second sample angle, and the prediction error.
[0037] In other application scenarios, the second sample angle includes several second sub-angles corresponding to the sampling positions; S13 above can be: inputting the initial weight matrix and the second sub-angles corresponding to each sampling position into a preset error prediction function to obtain the error prediction function value, and using the corresponding error prediction function value as the second sub-angle difference of the corresponding sampling position.
[0038] S14: Determine the error loss based on the difference between the first angle difference and the second angle difference.
[0039] Error loss characterizes the difference between the actual error and the predicted error of the angle signal output by the position sensor to be calibrated and the angle signal output by the reference position sensor.
[0040] In some application scenarios, S14 above can be: using the difference between the first angle difference and the second angle difference as the error loss.
[0041] In other application scenarios, the first angle difference includes first sub-angle differences corresponding to several sampling positions; the second angle difference includes second sub-angle differences corresponding to several sampling positions; S14 above can be: for each sampling position within each sampling cycle, the difference between the first sub-angle difference and the corresponding second sub-angle difference of the corresponding sampling position is used as the error sub-loss of the corresponding sampling position. The error sub-loss characterizes the difference between the true error and the predicted error of the position sensor to be calibrated and the reference position sensor at each sampling position within any sampling cycle. Statistical processing is performed on the error sub-loss corresponding to each sampling position to obtain the above-mentioned error loss. Statistical processing can be averaging, weighted averaging, or standard deviation processing, etc.
[0042] S15: Update the initial weight matrix in multiple rounds with the goal of minimizing error loss until the target weight matrix obtained by the update meets the update requirements.
[0043] The target weight matrix is used for error compensation of calibrated position sensors.
[0044] Generally, a larger error loss indicates a greater difference between the first and second sample angles, and vice versa. Therefore, to reduce the difference between the first and second sample angles, the initial weight matrix is updated with the goal of minimizing the error loss, so that the second sample angle approaches the first sample angle. For example, by minimizing this error loss, iterative methods such as gradient descent or least mean squares are used to update the elements (initial weights) in the initial weight matrix. After multiple rounds of training, a converged target weight matrix is obtained. This process allows the virtual error (i.e., the aforementioned second angle difference) constructed from the weight matrix and the angle signal output by the sensor to be calibrated to gradually approach the true error. The final target weight matrix accurately describes the periodic error characteristics of the sensor to be calibrated.
[0045] In some application scenarios, a subset of sample angle groups from all sample angle groups are used as training data for the current update round. S12 can be: processing each sample angle group separately, and using the difference between the first and second sub-angles in each sample angle group as the first sub-angle difference of the corresponding sample angle group; S13 can be: determining the second sub-angle difference corresponding to each sample angle group based on the weight matrix to be updated in the current update round and the second sub-angles in each sample angle group; S14 can be: using the difference between the first and second sub-angle differences corresponding to the same sample angle group as the error sub-loss; and weighting and averaging the error sub-losses to obtain the error loss for the current update round, which is then used to update the weight matrix to be updated in the current update round. In other application scenarios, each sample angle group in all sample angle groups is used as the training data for the current update round, and the sample angle group used in the current update round is the current sample angle group; S12 above can be: the difference between the first sub-angle and the second sub-angle in the current sample angle group is used as the first sub-angle difference of the current sample angle group; S13 above can be: the second sub-angle difference corresponding to the current sample angle group is determined according to the weight matrix to be updated in the current update round and the second sub-angle in the current sample angle group; S14 above can be: the difference between the first sub-angle difference and the second sub-angle difference corresponding to the current sample angle group is used as the error sub-loss to which the current sample angle group belongs; the weight matrix to be updated in the current update round is updated with the error sub-loss to which the current sample angle group belongs.
[0046] The target weight matrix refers to the final weight matrix that meets the requirements, that is, the error loss between the target weight matrix and the first sample angle meets the requirements, for example, the error loss can be less than or equal to the error threshold. After obtaining the target weight matrix, the position sensor to be calibrated, or a position sensor of the same model as the position sensor to be calibrated, becomes a calibrated position sensor. The actual error of the calibrated position sensor at different positions can be calculated using the target weight matrix, and error compensation can be performed using the actual error to obtain a more accurate position signal.
[0047] In some application scenarios, after S15 above, the angle to be compensated, collected by the calibrated position sensor at any motor position, is compensated using a target weight matrix to obtain the compensated angle. It can be understood that the difference between the compensated angle and the angle to be compensated approaches or is equal to the periodic error corresponding to the aforementioned motor position.
[0048] The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for subsequent high-precision calibration of the sensor. It utilizes the initial weight matrix combined with the output angle of the sensor to be calibrated to determine the second angle difference, constructing an error prediction mechanism based on signal harmonics. This allows for the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first and second angle differences as the error loss, and using this as the target for multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved. This enables the weight matrix corresponding to the predicted periodic position errors to gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for subsequent error compensation of calibrated position sensors, effectively offsetting periodic position errors, thereby improving the measurement accuracy of calibrated position sensors in practical applications and saving computational resources.
[0049] In some embodiments, the initial weight matrix includes initial weights corresponding to several preset harmonic orders. The preset harmonic orders represent the complete order of the angular signal in spatial harmonics. Each element in the initial weight matrix corresponds to a preset harmonic order, and each element in the initial weight matrix is an initial weight, which corresponds to the preset harmonic order. The values of the initial weights corresponding to different preset harmonic orders can be equal or unequal.
[0050] Specifically, S13 above can be: using the function values of preset functions corresponding to each preset harmonic order of the second sample angle as candidate function values for each preset harmonic order. The second angle difference is obtained based on the initial weights corresponding to each preset harmonic order and the candidate function values for each preset harmonic order. Each preset harmonic order corresponds to at least one preset trigonometric function. The preset trigonometric function can be a preset sine function, a preset cosine function, a tangent function, etc., or it can be a variation of the preset sine or cosine function, which can be flexibly set according to the accuracy of the calibration method. Specifically, for each preset harmonic order, the product between the initial weights corresponding to that preset harmonic order and the corresponding candidate function value is used as the angle difference corresponding to that preset harmonic order.
[0051] Specifically, the candidate function values for each preset harmonic order include the candidate function values for each second sub-angle across all preset harmonic orders. Specifically, for each second sub-angle, the function value of the preset function corresponding to the second sub-angle in each preset harmonic order is used as the candidate function value for that second sub-angle in each preset harmonic order. For each preset harmonic order, the product of the initial weight corresponding to that preset harmonic order and the corresponding candidate function value is used as the angle difference corresponding to that preset harmonic order. The summation of the angle differences for each second sub-angle across all preset harmonic orders is used as the second angle difference.
[0052] Please see Figure 3 , Figure 3 This is a second flowchart illustrating an exemplary embodiment of the calibration method for a position sensor shown in this application.
[0053] In some embodiments, the initial weight matrix includes initial weights corresponding to a plurality of target harmonic orders. The plurality of target harmonic orders characterize at least a portion of the spatial harmonic orders of the angular signal. The number of target harmonic orders is less than or equal to the number of preset harmonic orders. The plurality of target harmonic orders includes at least a portion of the preset harmonic orders. The above S13 may include the following steps: S31 and S32.
[0054] S31: Use the function value of the preset function corresponding to the second sample angle at each target harmonic order as the candidate function value for each target harmonic order.
[0055] The preset function can be a preset trigonometric function related to a preset sine function and / or a preset cosine function. The preset trigonometric function can be obtained by directly substituting the second sub-angle into the preset sine function, or by substituting the product of the preset multiple corresponding to the target harmonic order and the second sub-angle into the preset sine function, directly substituting the second sub-angle into the preset cosine function, or by substituting the product of the preset multiple corresponding to the target harmonic order and the second sub-angle into the preset cosine function. The order value of the target harmonic order is equal to the preset multiple corresponding to the target harmonic order. For example, if the order value of the target harmonic order is 1, then the preset multiple corresponding to the target harmonic order is 1.
[0056] The candidate function value of the target harmonic order represents the function value when the second sub-angle corresponding to each sampling position in the second sample angle is substituted into the preset function corresponding to the target harmonic order.
[0057] S32: Based on the initial weights corresponding to each target harmonic order and the candidate function values of each target harmonic order, the second angle difference is obtained.
[0058] Specifically, the candidate function values for each preset harmonic order include the candidate function values for each second sub-angle in at least a portion of the preset harmonic orders. Specifically, for each second sub-angle, the function value of the preset function corresponding to each target harmonic order is used as the candidate function value for that second sub-angle in each target harmonic order. For each target harmonic order, the product of the initial weight corresponding to that target harmonic order and the corresponding candidate function value is used as the angle difference corresponding to that target harmonic order. The summation of the angle differences for each second sub-angle across all target harmonic orders is used as the second angle difference.
[0059] In some embodiments, prior to S31, the calibration method for the position sensor may further include the following steps: obtaining the harmonic amplitude values of the first angle difference at several preset harmonic orders. For each preset harmonic order, in response to the harmonic amplitude value of the preset harmonic order being greater than an amplitude threshold, the preset harmonic order is taken as the target harmonic order.
[0060] The number of preset harmonic orders is greater than or equal to the number of target harmonic orders. The first sample angle includes the first sub-angles acquired by the position sensor to be calibrated at each sampling position within at least one sampling period. The second sample angle includes the second sub-angles acquired by the reference position sensor at each sampling position within at least one sampling period. The first angle difference includes the difference between the first sub-angles and the corresponding second sub-angles acquired by the position sensor to be calibrated and the reference position sensor at each sampling position within at least one sampling period. The amplitude threshold is a preset harmonic amplitude, dynamically set according to the accuracy of the calibration method. The amplitude threshold is a preset judgment boundary used to distinguish the harmonic order corresponding to the effective error signal from the harmonic order corresponding to noise or small flatness errors.
[0061] The harmonic amplitudes of several preset harmonic orders characterize the harmonic amplitudes of the first sub-angle and the corresponding second sub-angle acquired at each sampling position within at least one sampling period by the position sensor to be calibrated and the reference position sensor at each preset harmonic order. That is, the harmonic amplitudes of several preset harmonic orders characterize the harmonic amplitudes of the first angle difference at all preset harmonic orders.
[0062] Specifically, obtaining the harmonic amplitude of the first angle difference at several preset harmonic orders can be achieved by: obtaining the angle difference between the first sub-angle and the corresponding second sub-angle acquired at each sampling position of the position sensor to be calibrated and the reference position sensor at each preset harmonic order within at least one sampling period, and obtaining the sub-harmonic amplitude of the angle difference at each preset harmonic order within each sampling period. Each sampling period corresponds to a sub-harmonic amplitude at each preset harmonic order; the sub-harmonic amplitudes at each preset harmonic order are accumulated or averaged at the corresponding preset harmonic order to obtain the harmonic amplitude at each preset harmonic order. For example, after obtaining the sub-harmonic amplitudes at each preset harmonic order within two sampling periods, the sub-harmonic amplitudes belonging to the same preset harmonic order in the two sub-harmonic amplitudes are averaged to obtain the final harmonic amplitude at that preset harmonic order.
[0063] At least a portion of the preset harmonic orders are selected as target harmonic orders by analyzing the harmonic amplitudes at each preset harmonic order. Specifically, if the harmonic amplitude of a preset harmonic order is greater than an amplitude threshold, the preset harmonic order is selected as a target harmonic order. If the harmonic amplitude of a preset harmonic order is less than or equal to the amplitude threshold, the preset harmonic order is discarded.
[0064] It can be assumed that by filtering the target harmonic order through the harmonic amplitude values at all preset harmonic orders by the first angle difference, the initial weights of only a small number of harmonic orders that contribute significantly to the actual error between the position sensor to be calibrated and the reference position sensor can be updated, thereby improving calibration efficiency. Furthermore, the subsequent target weight matrix only uses the weights corresponding to the selected target harmonic orders, thereby improving the accuracy of subsequent angle compensation.
[0065] In some embodiments, the preset function corresponding to the target harmonic order includes a preset sine function and a preset cosine function corresponding to the target harmonic order; the candidate function value of the target harmonic order includes a candidate sine function value and a candidate cosine function value; and the initial weight corresponding to the target harmonic order includes an initial sine weight and an initial cosine weight under the target harmonic order. S32 described above may include the following steps: multiplying the initial sine weight of each target harmonic order by the candidate sine function value of the corresponding target harmonic order as the sine harmonic error of the corresponding target harmonic order; multiplying the initial cosine weight of each target harmonic order by the candidate sine function value of the corresponding target harmonic order as the cosine harmonic error of the corresponding target harmonic order; and summing the sine harmonic error and the cosine harmonic error of each target harmonic order as the second angle difference.
[0066] The preset sine function is a trigonometric function related to the sine function and corresponding to the target harmonic order. It represents the functional relationship between the product of the preset multiple corresponding to the target harmonic order and the second sub-angle, which is then substituted into the sine function. The candidate sine function value of the target harmonic order represents the function value obtained by substituting the product of the preset multiple corresponding to the target harmonic order and the second sub-angle into the sine function.
[0067] The preset cosine function is a trigonometric function related to the cosine function and corresponding to the target harmonic order. It represents the functional relationship between the preset multiple corresponding to the target harmonic order and the product of the second sub-angle, which is then substituted into the cosine function. The candidate cosine function value of the target harmonic order represents the function value obtained by substituting the preset multiple corresponding to the target harmonic order and the second sub-angle into the cosine function.
[0068] Specifically, for each target harmonic order, the following steps are performed: In response to a target harmonic order of 0, the candidate sine function value and / or candidate cosine function value corresponding to the 0th order are set to 1. In response to a target harmonic order greater than 0, the function value obtained by substituting the product of the preset multiple corresponding to the target harmonic order and the second sub-angle into the sine function is used as the candidate sine function value; in response to a target harmonic order greater than 0, the function value obtained by substituting the product of the preset multiple corresponding to the target harmonic order and the second sub-angle into the cosine function is used as the candidate cosine function value. The initial weight matrix includes the initial weights corresponding to each target harmonic order, and each initial weight includes the weight of the sine component (initial sine weight) and the weight of the cosine component (initial cosine weight) under the corresponding target harmonic order.
[0069] Specifically, S32 above can be: for each sampling position, perform the following steps: each sampling position corresponds to a second sub-angle; for each sampling position, the product of the initial sine weights of each target harmonic order and the candidate sine function value of the second sub-angle in the corresponding target harmonic order is used as the sine harmonic error of the second sub-angle in the corresponding target harmonic order. The product of the initial cosine weights of each target harmonic order and the candidate sine function value of the second sub-angle in the corresponding target harmonic order is used as the cosine harmonic error of the second sub-angle in the corresponding target harmonic order. For the second sub-angle, the sum of its sine harmonic error and cosine harmonic error in each target harmonic order is used as the second sub-angle difference corresponding to the second sub-angle.
[0070] Specifically, the second angle difference includes the second sub-angle difference obtained by summing the sinusoidal harmonic error and the cosine harmonic error of each target harmonic order for each second sub-angle. S14 above can be: taking the difference between the first sub-angle difference corresponding to the same sampling position within the same sampling period as the second sub-angle and the second sub-angle difference corresponding to the second sub-angle as the error sub-loss corresponding to the same sampling position within the same sampling period for the second sub-angle; and performing statistical processing on the error sub-loss corresponding to all sampling positions within all sampling periods to obtain the aforementioned error loss.
[0071] Please see Figure 4 , Figure 4 This is a third flowchart illustrating an exemplary embodiment of the calibration method for a position sensor shown in this application.
[0072] In some embodiments, S15 above may include the following steps: performing each round of updates to the initial weight matrix as follows Figure 3 The steps shown are: S41, S42, and S43. S41: Obtain the weight matrix to be updated and the candidate loss for the current update round. S42: Determine the weight update value for the current update round based on the candidate loss and the weight matrix to be updated. S43: Use the sum of the weight matrix to be updated and the weight update value as the updated weight matrix for the current update round.
[0073] The weight matrix to be updated refers to the weight matrix waiting to be updated in each update round. The candidate loss refers to the error loss determined based on the weight matrix to be updated in each update round. When the current update round is the first update round, the weight matrix to be updated is the initial weight matrix, and the candidate loss can be the error loss determined based on the initial weight matrix. When the current update round is not the first update round, the weight matrix to be updated is the updated weight matrix from the previous update round, and the candidate loss can be the error loss determined based on the updated weight matrix from the previous update round. Specifically, for each non-first update round, after obtaining the weight matrix to be updated, a processing logic similar to S13 above is executed: a new second angle difference is determined based on the weight matrix to be updated and the second sample angle; a processing logic similar to S14 above is executed: a new error loss is determined based on the difference between the first angle difference and the new second angle difference, and the new error loss is used as the candidate loss for the current update round.
[0074] The updated weight value is used to correct the weight matrix to be updated. For example, the updated weight value of the weight matrix to be updated can be determined based on the candidate loss and the weight matrix to be updated. In some embodiments, the candidate loss can be used to weight the second angle difference or a new second angle difference to obtain the updated weight value. In other embodiments, a preset learning rate can be obtained, which can be obtained through trial and error; the candidate loss can be used to weight the second angle difference or a new second angle difference to obtain a weighted value; and the product of the preset learning rate and the weighted value is determined as the updated weight value.
[0075] The updated weight matrix refers to the weight matrix whose parameters have been updated in the current update round. In some embodiments, the sum of the weight matrix to be updated and the weight update value of the current update round can be determined as the updated weight matrix. In other embodiments, the product of the weight matrix to be updated and the weight update value of the current update round can also be determined as the updated weight matrix. In still other embodiments, other parameter correction methods can be used to combine the weight matrix to be updated and the weight update value of the current update round; these are not specifically limited here.
[0076] The last update round refers to the last update round. In some embodiments, the last update round can be determined based on the updated weight matrix under that update round, where the candidate loss meets a preset requirement, such as the candidate loss being less than an error threshold. In other embodiments, the last update round can be the number of rounds in that update round being greater than or equal to a preset round threshold. In some application scenarios, after S43 above, the following steps are performed in the current update round: Perform processing logic similar to S13 above, determine the final second angle difference under the current update round based on the updated weight matrix and the second sample angle; perform processing logic similar to S14 above, determine the final error loss under the current update round based on the difference between the first angle difference and the final second angle difference; if the final error loss under the current update round is less than or equal to the error loss threshold, then the current update round is determined to be the last update round. The error loss threshold can be 0. If the final error loss under the current update round is greater than the error loss threshold, then the current update round is determined to be a non-last update round, and the final error loss under the current update round is used as the candidate loss for the next update round.
[0077] For example, synchronous implementation such as Figure 2The signal acquisition of the position sensor to be calibrated and the reference position sensor shown yields first sample angles and second sample angles at several sampling positions. Specifically, the first sample angle includes the first sub-angle at each sampling position, and the second sample angle includes the second sub-angle at each sampling position. The first angle difference includes the difference between the first sub-angle and the second sub-angle at each sampling position. The process of calculating the first sub-angle difference for the corresponding sampling position for the first sub-angle and the second sub-angle at the same sampling position satisfies the following formula:
[0078] First, the position signal corresponding to the first sub-angle output by the position sensor to be calibrated is simultaneously acquired. The position signal corresponding to the second sub-angle output by the high-precision reference position sensor. The first sub-angle difference at this sampling position, i.e., the true error, can be expressed as: .like Figure 5a As shown, the vertical axis represents the motor angle within the motor's rotation cycle. The specific values correspond to the first sample angle of the position sensor to be calibrated at the corresponding sampling position and the second sample angle of the reference position sensor at the corresponding sampling position. The horizontal axis represents the sampling time corresponding to any sampling position within the signal acquisition / sampling cycle. Figure 5a This reflects the correlation between the first and second sample angles corresponding to each sampling position within any sampling period. For the position sensor to be calibrated, the ordinate corresponding to the sampling time of any sampling position within its specific sampling period represents the first sub-angle corresponding to that sampling position; for the reference position sensor, the ordinate corresponding to the sampling time of any sampling position within its specific sampling period represents the second sub-angle corresponding to that sampling position. For example... Figure 5b As shown, the vertical axis represents the difference between the first sub-angle and the second sub-angle at any sampling position within a specific sampling period (the difference between the first sub-angles); the horizontal axis represents the sampling time corresponding to any sampling position within the signal acquisition period / sampling period.
[0079] Then, the reference position signal of the second sub-angle at any sampling position. Calculate the virtual error signal (i.e., the second sub-angle difference in the second angle difference mentioned above). Assume that the first sub-angle difference corresponds to any sampling position. It contains multiple harmonic errors of different orders, including 0th (DC), 1st, 2nd...kth order components. Then, the second sub-angle difference corresponding to any sampling position... The following formula can be used for calculation:
[0080] in, This represents the second sub-angle difference corresponding to any sampling position; This represents the second sub-angle at the corresponding sampling position, which is acquired by the reference position sensor at the corresponding sampling position. It is a 1-column, 2k+1-row matrix used to calculate the function value of the second sub-angle under a preset function; K represents different harmonic orders. The matrix corresponding to the candidate function values of the second sub-angle under each preset harmonic order can be expressed as follows:
[0081] in, It can be a function value matrix, where each term is about the second sub-angle. The function has the following terms: the first term represents the 0th harmonic (DC); the second and third terms represent the cosine and sine components of the 1st harmonic (i.e., candidate sine and cosine function values of the second sub-angle at the first harmonic order); and the nth and n-1th terms represent the cosine and sine components of the kth harmonic (i.e., candidate sine and cosine function values of the second sub-angle at the kth harmonic order). It is important to note that during the error calibration phase... Parameters (angles) used to calculate sine and cosine of each order The reference position signal (i.e., the second sub-angle) is collected by the reference position sensor at each of the above sampling positions. The weight matrix (initial weight matrix or weight matrix to be updated) can be referenced in the following formula:
[0082] in, It is a 2k+1 column weight matrix (e.g., the initial weight matrix or the weight matrix to be updated), where each element represents a weight coefficient, along with the candidate sine function value for the sine component and the candidate cosine function value for the cosine component at each harmonic order. One-to-one correspondence.
[0083] In other application scenarios, after acquiring the first sub-angle difference corresponding to each sampling position within at least one sampling period, the harmonic amplitude corresponding to each preset harmonic order (also known as the frequency order) can be obtained, such as... Figure 5c As shown, when the amplitude of the sub-harmonic to which the preset harmonic order belongs is greater than the amplitude threshold, the preset harmonic order is taken as the target harmonic order.
[0084] For example, such as Figure 5d As shown, the process of determining the error loss during multiple rounds of updating the weight matrix of the position sensor to be calibrated can be referenced by the following formula:
[0085] Among them, the actual error is calculated. With virtual error The following error between This is used for updating the weight coefficients in the weight matrix. Specifically, This can represent the first angle difference mentioned above, that is, the angle difference matrix corresponding to the first sub-difference value between the first sub-angle and the second sub-angle at each sampling position. This can represent the second angle difference mentioned above, which is the angle difference matrix corresponding to the second sub-angle difference obtained from the initial weight matrix at each sampling position. This represents the aforementioned error loss, which includes the sub-loss of error corresponding to each sampling position; specifically, it can be obtained by calculating the difference between the first sub-angle difference and the second sub-angle difference corresponding to the same sampling position. Then, the initial weight matrix is updated multiple times with the goal of minimizing the error loss, until the updated target weight matrix meets the update requirements. The specific calculation process for any update round of the initial weight matrix can be referred to the following formula:
[0086] in, The updated weight matrix represents the current update round; This represents the weight matrix to be updated in the current update round. It is the learning rate, which can be obtained through trial and error. This represents the aforementioned error loss, which includes the error sub-loss corresponding to each sampling position. The function value matrix represents the function value obtained by substituting the second angle difference corresponding to at least one sampling position into a preset function. In some application scenarios, a portion of the sample angle groups in all sample angle groups are used as training data for the current update round. S12 can be: processing each sample angle group separately, and taking the difference between the first sub-angle and the second sub-angle in each sample angle group as the first sub-angle difference of the corresponding sample angle group; S13 can be: determining the second sub-angle difference corresponding to each sample angle group based on the weight matrix to be updated in the current update round and the second sub-angle in each sample angle group; S14 can be: taking the difference between the first sub-angle difference and the second sub-angle difference corresponding to the same sample angle group as the error sub-loss; and weighting and averaging the error sub-losses to obtain the error loss of the current update round to update the weight matrix to be updated in the current update round. In other application scenarios, each sample angle group in all sample angle groups is used as the training data for the current update round, and the sample angle group used in the current update round is called the current sample angle group. S12 above can be: using the difference between the first sub-angle and the second sub-angle in the current sample angle group as the first sub-angle difference of the current sample angle group; S13 above can be: determining the second sub-angle difference corresponding to the current sample angle group based on the weight matrix to be updated in the current update round and the second sub-angle in the current sample angle group; S14 above can be: using the difference between the first sub-angle difference and the second sub-angle difference corresponding to the current sample angle group as the error sub-loss of the current sample angle group; and updating the weight matrix to be updated in the current update round using the error sub-loss of the current sample angle group. It is understood that the error loss... The number of error sub-losses and the number of elements in the function value matrix can be determined based on the number of sample angle groups corresponding to the training data in the current update round, which will not be elaborated here. The weight update can be iteratively based on the Least Mean Square (LMS) algorithm. It can be understood that, after executing S11 above, the position sensor to be calibrated and the reference position sensor each collect several sets of sample angle groups at a sampling position. Each sample angle group includes the first sub-angle of the position sensor to be calibrated and the second sub-angle of the reference position sensor at that sampling position, and constructs the first angle difference corresponding to each set of sample angle groups.
[0087] When the encoder (such as a position sensor: a position sensor to be calibrated and a reference position sensor) rotates at a relatively uniform speed, the above process will adjust the weight matrix. The process involves updates and iterations. Virtual errors are considered during the process. It will gradually approach the actual error. That is, following error It will gradually converge to 0. Meanwhile, the weight matrix... The weights or coefficients corresponding to each element in the matrix converge to relatively stable values, and the target weights in the final target weight matrix will be used for error compensation in real-time measurement.
[0088] The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for subsequent high-precision calibration of the sensor. It utilizes the initial weight matrix combined with the output angle of the sensor to be calibrated to determine the second angle difference, constructing an error prediction mechanism based on signal harmonics. This allows for the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first and second angle differences as the error loss, and using this as the target for multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved. This enables the weight matrix corresponding to the predicted periodic position errors to gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for subsequent error compensation of calibrated position sensors, effectively offsetting periodic position errors, thereby improving the measurement accuracy of calibrated position sensors in practical applications and saving computational resources.
[0089] Please see Figure 6a , Figure 6a This is a schematic flowchart of an exemplary embodiment of the position sensor error compensation method shown in this application. Specifically, the position sensor error compensation method of this embodiment includes the following steps: S61 and S62.
[0090] S61: Obtain the angle to be compensated from the calibrated position sensor and the reference angle corresponding to the angle to be compensated.
[0091] The reference angle represents a preset angle corresponding to the angle to be compensated, or a compensated angle from a historical signal acquisition time prior to the current signal acquisition time of the angle to be compensated. The historical signal acquisition time is separated from the current signal acquisition time by one signal acquisition cycle. The calibrated position sensor can be a position sensor to be calibrated processed by the above-described position sensor calibration method, or a position sensor to be calibrated of the same model. The angle to be compensated represents the angle acquired by the calibrated position sensor at any motor position. The preset angle corresponding to the angle to be compensated represents the second sub-angle acquired by the reference position sensor at the motor position corresponding to the angle to be compensated in the above-described position sensor calibration method, or a compensated angle obtained by error compensation of a historical angle acquired at the motor position corresponding to the angle to be compensated in the previous signal acquisition cycle.
[0092] Specifically, S61 can be as follows: in response to the angle to be compensated being an angle signal acquired by a calibrated position sensor in the first signal acquisition cycle, the second sub-angle acquired by the reference position sensor at the motor position to which the angle to be compensated belongs in the calibration method of the position sensor is used as the reference angle corresponding to the angle to be compensated; in response to the angle to be compensated being an angle signal acquired by a calibrated position sensor in a period other than the first signal acquisition cycle, the compensated angle obtained by error compensation of the historical angle acquired in the previous signal acquisition cycle at the motor position to which the angle to be compensated belongs is used as the reference angle corresponding to the angle to be compensated.
[0093] S62: Perform error compensation on the angle to be compensated based on the target weight matrix and the reference angle to obtain the compensated angle.
[0094] The target weight matrix is obtained based on the calibration method of the position sensor described above. The target weight matrix is a set of weight coefficients determined by an iterative learning algorithm during the calibration phase. It represents the mapping relationship between the periodic error signal and the position signal, and its dimension is determined by the harmonic order contained in the error to be compensated. The compensated angle represents the angle to be compensated after error compensation. During the compensation phase, the system obtains the current angle to be compensated. If the historical compensated angle is used as a reference, the virtual error signal at the current moment is calculated based on the ideal position signal after removing the error at the previous moment, combined with the target weight matrix. This virtual error signal is then subtracted from the angle to be compensated to obtain the compensated angle at the current moment. This compensated angle is then used as the reference angle for the next moment in the calculation. For example, the target weight matrix can be set to include DC components, sine and cosine terms of the first harmonic, and sine and cosine terms of the second harmonic to cover the main periodic error components.
[0095] In some application scenarios, S62 above can be: inputting the target weight matrix, the reference angle, and the angle to be compensated into a preset error compensation function to obtain the error compensation function value, and using the error compensation function value as the compensated angle. The preset error compensation function represents the correlation between the target weight matrix, the reference angle, and the angle to be compensated.
[0096] In practical implementation, when the sensor is stationary or rotating at low speed, the system can still maintain online updates of the error model based on preset angles or historically compensated angles, ensuring the continuity of the compensation effect. Through this closed-loop feedback-based compensation mechanism, using historically compensated angles as a benchmark, the true position trajectory can be reflected more accurately, avoiding the accumulation of deviations when errors are reproduced due to the use of original signals containing errors, thereby achieving high-precision real-time error elimination.
[0097] In some embodiments, S62 may include the following steps: determining the target angle difference between the angle to be compensated and the reference angle based on the target weight matrix and the reference angle; and using the difference between the angle to be compensated and the target angle difference as the compensated angle.
[0098] The target angle difference characterizes the angle difference between the angle to be compensated, determined based on the target weight matrix and the reference angle, and the reference angle.
[0099] In some applications, the target weight matrix and the angle to be compensated are input into a preset error prediction function to obtain the error prediction function value, which is then used as the target angle difference. In other applications, the target weight matrix includes target weights corresponding to several target harmonic orders. Based on the harmonic order selection instruction, at least some harmonic orders are selected from several target harmonic orders as the final harmonic orders; the function value of the preset function corresponding to each final harmonic order is used as the target function value for that final harmonic order. The target angle difference is obtained based on the target weights and target function values for each final harmonic order. The harmonic order selection instruction can be generated based on the user's selection of several target harmonic orders, or it can be based on the sorting of the harmonic amplitudes of the angle signals of each motor position acquired in the previous signal acquisition cycle, selected from high to low.
[0100] In some embodiments, the target weight matrix includes target weights corresponding to several target harmonic orders. The step of determining the target angle difference between the angle to be compensated and the reference angle based on the target weight matrix and the reference angle includes: using the function value of a preset function corresponding to each target harmonic order as the target function value for that target harmonic order; and obtaining the target angle difference based on the target weights and target function values for each target harmonic order.
[0101] The preset functions corresponding to the target harmonic order include preset sine and preset cosine functions. The target function value of the target harmonic order includes target sine and target cosine function values. The target weights corresponding to the target harmonic order include target sine and target cosine weights for that harmonic order. For each target harmonic order associated with the reference angle, the following steps can be performed: The product of the target sine weights and the target sine function value of each target harmonic order is taken as the sine harmonic error of that target harmonic order. The product of the target cosine weights and the target sine function value of each target harmonic order is taken as the cosine harmonic error of that target harmonic order. The sum of the sine and cosine harmonic errors of each target harmonic order is taken as the target angle difference.
[0102] The preset sine function is a trigonometric function related to the sine function and corresponding to the target harmonic order. It represents the functional relationship between the product of the preset multiple corresponding to the target harmonic order and the reference angle, which is then substituted into the sine function. The target sine function value of the target harmonic order represents the function value obtained by substituting the product of the preset multiple corresponding to the target harmonic order and the reference angle into the sine function.
[0103] The preset cosine function is a trigonometric function related to the cosine function and corresponding to the target harmonic order. It represents the functional relationship between the product of the preset multiple corresponding to the target harmonic order and the reference angle, which is then substituted into the cosine function. The target cosine function value of the target harmonic order represents the function value obtained by substituting the product of the preset multiple corresponding to the target harmonic order and the reference angle into the cosine function.
[0104] Specifically, for each target harmonic order associated with the reference angle, the following steps are performed: In response to a target harmonic order of 0, the target sine function value and / or target cosine function value corresponding to the 0th order are set to 1. In response to a target harmonic order greater than 0, the function value obtained by substituting the product of the preset multiple corresponding to the target harmonic order and the reference angle into the sine function is used as the target sine function value; in response to a target harmonic order greater than 0, the function value obtained by substituting the product of the preset multiple corresponding to the target harmonic order and the reference angle into the cosine function is used as the target cosine function value. The target weight matrix includes target weights corresponding to each target harmonic order, and each target weight includes the weight of the sine component (target sine weight) and the weight of the cosine component (target cosine weight) under the corresponding target harmonic order.
[0105] Specifically, S32 above can be: for each sampling position, perform the following steps: each sampling position corresponds to a reference angle; for each sampling position, the product of the target sine weights of each target harmonic order and the target sine function value of the reference angle in the corresponding target harmonic order is taken as the sinusoidal harmonic error of the reference angle in the corresponding target harmonic order. The product of the target cosine weights of each target harmonic order and the target sine function value of the reference angle in the corresponding target harmonic order is taken as the cosine harmonic error of the reference angle in the corresponding target harmonic order. For the reference angle, the sum of its sinusoidal harmonic errors and cosine harmonic errors in each target harmonic order is taken as the target angle difference corresponding to the reference angle.
[0106] For example, such as Figure 6bAs shown, in the error compensation stage of this application, the calibrated position sensor acquires the angle to be compensated for any motor position. The target weight matrix, updated iteratively using the aforementioned position sensor calibration method, is then used to compensate for the angle to be compensated, resulting in the compensated angle. Specifically, the process of determining the target angle difference between the angle to be compensated and the reference angle based on the target weight matrix and the reference angle can be referred to in the following formula:
[0107] Among them, calculation Parameters used The reference angle is the compensated angle obtained by compensating the same motor position in the previous calculation cycle in some application scenarios. This represents the difference in the angle of the aforementioned target. It is a target weight matrix with 1 column and 2k+1 rows. For specific limitations, please refer to the details of the initial weight matrix in the calibration phase described above. T represents transpose. In some embodiments, the function value... and target weight matrix The configuration of each item can be based on the actual error of the calibrated position sensor during the calibration phase (i.e., the first angle difference mentioned above). The harmonic components are configured specifically. For example, assuming the position sensor has been calibrated, the first angle difference during the calibration phase... The spectrum such as Figure 5c As shown, the harmonic amplitudes at f1, f2, and f6 are significantly higher than those of other harmonic orders, indicating that the error of the calibrated position sensor is mainly contributed by these harmonic orders. Based on this, in constructing the function value matrix... and target weight matrix In this case, only the sine and cosine basis function terms corresponding to f1, f2, and f6, as well as the target sine and target cosine weights of the corresponding harmonic orders, can be retained to determine the subsequent target angle difference. For other harmonic orders that have little impact on the overall error, their influence can be ignored, thereby effectively reducing computational complexity.
[0108] Specifically, The matrix representing the candidate function values of the reference angle at each target harmonic order can be expressed as follows:
[0109] in, It can be a function value matrix, where each term is about a reference angle. The function has the first term representing the 0th harmonic (DC), the second and third terms representing the cosine and sine components of the 1st harmonic (i.e., the target sine and cosine function values of the reference angle under the first harmonic order), and the nth and n-1th terms representing the cosine and sine components of the kth harmonic (i.e., the target sine and cosine function values of the reference angle under the kth harmonic order).
[0110] In S62 above: after obtaining the target angle difference Then, the process of canceling the error signal from the error signal to obtain the ideal position signal can be referred to the following formula:
[0111] in, This represents the ideal position signal corresponding to the angle to be compensated, i.e., the compensated angle. This represents the angle that needs to be compensated. The target angle difference is determined by the target weight matrix and the reference angle. It can be understood that the obtained ideal position signal (compensated angle) no longer contains periodic position errors. In the next calculation cycle or the next signal acquisition cycle, the current compensated angle will be used as the compensated historical angle associated with the corresponding acquisition position / motor position (i.e., as the reference angle for the next calculation cycle), participating in the calculation of the next calculation cycle to form a complete closed loop.
[0112] The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for subsequent high-precision calibration of the sensor. It utilizes the initial weight matrix combined with the output angle of the sensor to be calibrated to determine the second angle difference, constructing an error prediction mechanism based on signal harmonics. This allows for the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first and second angle differences as the error loss, and using this as the target for multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved. This enables the weight matrix corresponding to the predicted periodic position errors to gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for subsequent error compensation of calibrated position sensors, effectively offsetting periodic position errors, thereby improving the measurement accuracy of calibrated position sensors in practical applications and saving computational resources.
[0113] Please see Figure 7 , Figure 7 This is a schematic diagram of an embodiment of the calibration device for the position sensor of this application.
[0114] A calibration device 70 for a position sensor connects a position sensor to be calibrated (not shown) and a reference position sensor (not shown) via a rotation axis and is rotatable relative to the rotation axis. The calibration device includes: an acquisition module 71, a first determination module 72, a second determination module 73, a third determination module 74, and an update module 75. The acquisition module 71 synchronously acquires a first sample angle output by the position sensor to be calibrated and a second sample angle output by the reference position sensor, wherein the signal quality of the second sample angle is higher than that of the first sample angle. The first determination module 72 determines a first angle difference based on the difference between the first and second sample angles. The second determination module 73 determines a second angle difference based on an initial weight matrix and the second sample angle; the initial weight matrix characterizes the influence of signal harmonics on the angle signal output by the position sensor to be calibrated. The third determination module 74 determines the error loss based on the difference between the first and second angle differences. The update module 75 performs multiple rounds of updates to the initial weight matrix with the goal of minimizing the error loss until the updated target weight matrix meets the update requirements; the target weight matrix is used for error compensation of the calibrated position sensor.
[0115] For details on the functions performed by each module, please refer to the calibration method for the position sensor; these details will not be repeated here.
[0116] The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for subsequent high-precision calibration of the sensor. It utilizes the initial weight matrix combined with the output angle of the sensor to be calibrated to determine the second angle difference, constructing an error prediction mechanism based on signal harmonics. This allows for the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first and second angle differences as the error loss, and using this as the target for multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved. This enables the weight matrix corresponding to the predicted periodic position errors to gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for subsequent error compensation of calibrated position sensors, effectively offsetting periodic position errors, thereby improving the measurement accuracy of calibrated position sensors in practical applications and saving computational resources.
[0117] Please see Figure 8 , Figure 8 This is a schematic diagram of an embodiment of the error compensation device for the position sensor of this application.
[0118] The error compensation method device 80 for a position sensor includes: an acquisition module 81 and a compensation module 82; the acquisition module 81 is used to acquire the angle to be compensated of the calibrated position sensor and the reference angle corresponding to the angle to be compensated, the reference angle representing a preset angle corresponding to the angle to be compensated, or the compensated angle at a historical signal acquisition time before the current signal acquisition time of the angle to be compensated, the historical signal acquisition time being one signal acquisition cycle apart from the current signal acquisition time; the compensation module 82 is used to perform error compensation on the angle to be compensated according to the target weight matrix and the reference angle to obtain the compensated angle, the target weight matrix being obtained based on the above-mentioned calibration method for the position sensor.
[0119] For details on the functions performed by each module, please refer to the error compensation method for the position sensor; these details will not be repeated here.
[0120] The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for subsequent high-precision calibration of the sensor. It utilizes the initial weight matrix combined with the output angle of the sensor to be calibrated to determine the second angle difference, constructing an error prediction mechanism based on signal harmonics. This allows for the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first and second angle differences as the error loss, and using this as the target for multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved. This enables the weight matrix corresponding to the predicted periodic position errors to gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for subsequent error compensation of calibrated position sensors, effectively offsetting periodic position errors, thereby improving the measurement accuracy of calibrated position sensors in practical applications and saving computational resources.
[0121] To implement the position sensor calibration method of the above embodiments, this application proposes another electronic device, please refer to [link / reference needed]. Figure 9 , Figure 9This is a schematic diagram of an embodiment of the electronic device of this application. The electronic device 90 includes a memory 91 and a processor 92. The processor 92 is used to execute program instructions stored in the memory 91 to implement the steps in the above-described position sensor calibration method embodiment. In a specific implementation scenario, the electronic device 90 may include, but is not limited to, a microcomputer or a server. In addition, the electronic device 90 may also include mobile devices such as laptops and tablets, which are not limited here. Exemplarily, the electronic device 90 may be a signal acquisition device. In some application scenarios, the processor 92 is connected to the position sensor to be calibrated (not shown) and a reference position sensor (not shown) to implement the steps in the above-described position sensor calibration method embodiment.
[0122] Specifically, processor 92 controls itself and memory 91 to implement the steps in the above-described position sensor calibration method embodiment. Processor 92 can also be referred to as a CPU (Central Processing Unit). Processor 92 may be an integrated circuit chip with signal processing capabilities. Processor 92 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 92 can be implemented using integrated circuit chips.
[0123] To implement the position sensor error compensation method of the above embodiments, this application proposes another position sensor error compensation system, please refer to [link / reference needed]. Figure 10 , Figure 10 This is a schematic diagram of an embodiment of the position sensor error compensation system provided in this application.
[0124] The position sensor error compensation system 1000 includes a memory 1010, a processor 1020, and a calibrated position sensor 1030. The processor 1020 is connected to the calibrated position sensor 1030 and the memory 1010, respectively. The memory 1010 and the processor 1020 are coupled.
[0125] The memory 1010 is used to store program data, and the processor 1020 is used to execute the program data to implement the position sensor error compensation method of the above embodiment.
[0126] In this embodiment, the processor 1020 can also be referred to as a CPU (Central Processing Unit). The processor 1020 may be an integrated circuit chip with signal processing capabilities. The processor 1020 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor, or the processor 1020 can be any conventional processor.
[0127] The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for subsequent high-precision calibration of the sensor. It utilizes the initial weight matrix combined with the output angle of the sensor to be calibrated to determine the second angle difference, constructing an error prediction mechanism based on signal harmonics. This allows for the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first and second angle differences as the error loss, and using this as the target for multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved. This enables the weight matrix corresponding to the predicted periodic position errors to gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for subsequent error compensation of calibrated position sensors, effectively offsetting periodic position errors, thereby improving the measurement accuracy of calibrated position sensors in practical applications and saving computational resources.
[0128] Please see Figure 11 , Figure 11 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 110 stores program instructions 1101 thereon. When the program instructions 1101 are executed by a processor, they implement the steps in the calibration method embodiment of any of the above-described position sensors and / or the steps in the error compensation method embodiment of any of the above-described position sensors.
[0129] The above scheme, by synchronously acquiring the output of a reference position sensor with high signal quality as a benchmark, can accurately obtain the true error distribution of the sensor to be calibrated, thus providing a reliable data foundation for subsequent high-precision calibration of the sensor. It utilizes the initial weight matrix combined with the output angle of the sensor to be calibrated to determine the second angle difference, constructing an error prediction mechanism based on signal harmonics. This allows for the prediction of complex periodic position errors in a compact parameter form, improving the utilization rate of storage resources for periodic errors. By calculating the difference between the first and second angle differences as the error loss, and using this as the target for multiple rounds of iterative updates to the initial weight matrix, adaptive optimization of the error calibration process is achieved. This enables the weight matrix corresponding to the predicted periodic position errors to gradually converge and approach the true error, improving the calibration accuracy and robustness. The final target weight matrix can be used for subsequent error compensation of calibrated position sensors, effectively offsetting periodic position errors, thereby improving the measurement accuracy of calibrated position sensors in practical applications and saving computational resources.
[0130] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0131] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0132] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0133] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0134] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0135] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
[0136] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus. The term "and / or" is merely a description of the association of related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, "many" in this document means two or more. In addition, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of elements, such as including at least one of A, B, and C, and may mean including any one or more elements selected from the set consisting of A, B, and C.
Claims
1. A calibration method for a position sensor, characterized in that, The position sensor to be calibrated and the reference position sensor are connected by a rotating shaft and can rotate relative to the rotating shaft. The calibration method of the position sensor includes: Simultaneously acquire the first sample angle output by the position sensor to be calibrated and the second sample angle output by the reference position sensor, wherein the signal quality of the second sample angle is higher than that of the first sample angle; The first angle difference is determined based on the difference between the first sample angle and the second sample angle; The second angle difference is determined based on the initial weight matrix and the second sample angle. The initial weight matrix characterizes the degree of influence of signal harmonics on the angle signal output by the position sensor to be calibrated. The error loss is determined based on the difference between the first angle difference and the second angle difference; The initial weight matrix is updated multiple times with the goal of reducing the error loss, until the updated target weight matrix meets the update requirements. The target weight matrix is used for error compensation of the calibrated position sensor.
2. The calibration method according to claim 1, characterized in that, The initial weight matrix includes initial weights corresponding to several target harmonic orders; The step of determining the second angle difference based on the initial weight matrix and the second sample angle includes: The function values of the preset functions corresponding to the second sample angle at each target harmonic order are used as candidate function values for each target harmonic order. The second angle difference is obtained based on the initial weights corresponding to each target harmonic order and the candidate function values of each target harmonic order.
3. The calibration method according to claim 2, characterized in that, The preset function corresponding to the target harmonic order includes a preset sine function and a preset cosine function corresponding to the target harmonic order. The candidate function value of the target harmonic order includes the candidate sine function value and the candidate cosine function value of the target harmonic order. The initial weight corresponding to the target harmonic order includes the initial sine weight and the initial cosine weight under the target harmonic order. The step of obtaining the second angle difference based on the initial weights corresponding to each target harmonic order and the candidate function values of each target harmonic order includes: The product of the initial sinusoidal weight of each target harmonic order and the candidate sinusoidal function value of the corresponding target harmonic order is taken as the sinusoidal harmonic error of the corresponding target harmonic order. The product of the initial cosine weight of each target harmonic order and the candidate sine function value of the corresponding target harmonic order is taken as the cosine harmonic error of the corresponding target harmonic order. The sum of the sinusoidal harmonic error and the cosine harmonic error of each target harmonic order is taken as the second angle difference.
4. The calibration method according to claim 2, characterized in that, Before the step of using the function values of the preset functions corresponding to the second sample angle at each target harmonic order as candidate function values for each target harmonic order, the method further includes: Obtain the harmonic amplitude values of the first angle difference at several preset harmonic orders, wherein the number of preset harmonic orders is greater than or equal to the number of target harmonic orders; For each preset harmonic order, in response to the harmonic amplitude of the preset harmonic order being greater than the amplitude threshold, the preset harmonic order is taken as the target harmonic order.
5. The calibration method according to claim 1, characterized in that, The step of updating the initial weight matrix in multiple rounds with the goal of minimizing the error loss until the updated target weight matrix meets the update requirements includes: Each round of updates to the initial weight matrix performs the following steps: Obtain the weight matrix to be updated and the candidate loss for the current update round, wherein the candidate loss is the error loss determined based on the weight matrix to be updated; when the current update round is the first update round, the weight matrix to be updated represents the initial weight matrix; or, when the current update round is not the first update round, the weight matrix to be updated represents the updated weight matrix of the previous update round. Based on the candidate loss and the weight matrix to be updated, determine the weight update value for the current update round; The sum of the weight matrix to be updated and the weight update value is taken as the updated weight matrix of the current update round; The target weight matrix is the updated weight matrix of the last update round.
6. An error compensation method for a position sensor, characterized in that, The error compensation method for the position sensor includes: Obtain the angle to be compensated from the calibrated position sensor and the reference angle corresponding to the angle to be compensated. The reference angle represents a preset angle corresponding to the angle to be compensated, or a compensated angle at a historical signal acquisition time before the current signal acquisition time of the angle to be compensated. The historical signal acquisition time is separated from the current signal acquisition time by one signal acquisition cycle. Error compensation is performed on the angle to be compensated based on the target weight matrix and the reference angle to obtain the compensated angle. The target weight matrix is obtained based on the calibration method of the position sensor according to any one of claims 1 to 5.
7. The error compensation method according to claim 6, characterized in that, The step of performing error compensation on the angle to be compensated based on the target weight matrix and the reference angle to obtain the compensated angle includes: Based on the target weight matrix and the reference angle, the target angle difference between the angle to be compensated and the reference angle is determined; The difference between the angle to be compensated and the target angle is taken as the compensated angle.
8. The error compensation method according to claim 7, characterized in that, The target weight matrix includes target weights corresponding to several target harmonic orders; The step of determining the target angle difference between the angle to be compensated and the reference angle based on the target weight matrix and the reference angle includes: The function value of the preset function corresponding to each target harmonic order of the reference angle is taken as the target function value of the corresponding target harmonic order; The target angle difference is obtained based on the target weights corresponding to each target harmonic order and the target function values of the corresponding target harmonic orders.
9. An electronic device, characterized in that, The electronic device includes: It includes: a memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the calibration method of the position sensor as described in any one of claims 1-5.
10. An error compensation system for a position sensor, characterized in that, include: The position sensor has been calibrated; The memory stores program instructions. A processor is connected to the calibrated position sensor and the memory, respectively, and the processor retrieves program instructions from the memory to execute the error compensation method for the position sensor as described in any one of claims 6-8.
11. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they are used to implement the calibration method of the position sensor as described in any one of claims 1-5 and / or the error compensation method of the position sensor as described in any one of claims 6-8.