Signal calibration method and device of magnetic encoder, equipment and medium
By performing multiple calibrations on the magnetic encoder signal, including DC offset calibration and amplitude calibration, the problem of low signal calibration accuracy in the existing technology is solved, and higher motor position and speed stability is achieved.
Patent Information
- Application Number
- CN202411610657.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-01-24
AI Technical Summary
The existing magnetic encoder signal calibration methods have low accuracy and cannot effectively suppress fluctuations in motor position and speed.
By sampling the sine and cosine signals generated by the magnetic encoder respectively, perform DC offset calibration and amplitude calibration, determine the initial position value, and query the position compensation table for position calibration, achieving multiple calibrations to improve accuracy.
Improve signal calibration accuracy, effectively suppress the fluctuation of motor position and speed, and improve the control performance of the motor.
Smart Images

Figure CN119354255A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of encoder signal processing, and in particular to a signal calibration method, device, equipment and medium for a magnetic encoder. Background Art
[0002] During the rotation of the motor, the magnetic encoder generates phase-orthogonal sine and cosine signals through the magnetoresistive sensor, and the position value, i.e., the angle value, can be calculated based on the sine and cosine signals. The position value reflects the absolute position of the motor rotor. However, due to the existence of magnetization errors and installation errors (horizontal and vertical distances, eccentricity), the quality of the generated sine and cosine signals is easily deteriorated, resulting in a certain deviation in the calculated position value, which affects the control performance of the motor. In order to compensate for the error, the signal calibration is currently mostly carried out by means of drag calibration. However, the accuracy of the current signal calibration method is low, which is not conducive to suppressing position and speed fluctuations. Therefore, how to improve the accuracy of signal calibration has become a technical problem that needs to be solved urgently by those skilled in the art. Summary of the invention
[0003] The purpose of the present application is to provide a signal calibration method, device, equipment and computer-readable storage medium for a magnetic encoder, which can accurately calibrate the signal error of the magnetic encoder, improve the signal calibration accuracy, and help suppress position and speed fluctuations.
[0004] In order to solve the above technical problems, the present application provides a signal calibration method of a magnetic encoder, comprising:
[0005] The sine signal and the cosine signal generated by the magnetic encoder are sampled respectively to obtain a sine sampling value and a cosine sampling value;
[0006] Performing DC offset calibration on the sine sampling value, and performing DC offset calibration and amplitude calibration on the cosine sampling value;
[0007] Determine the initial position value according to the calibrated sine sampling value and the calibrated cosine sampling value;
[0008] Check whether the initial position value exists in the position value table;
[0009] If it exists, determine the position compensation value corresponding to the initial position value from the position compensation table; wherein, if the position compensation table is switched, query the position compensation table before the switching to obtain the first position compensation value; query the position compensation table after the switching to obtain the second position compensation value; and perform weighted summation of the first position compensation value and the second position compensation value according to the weights respectively corresponding to the position compensation tables before and after the switching to obtain the position compensation value corresponding to the initial position value;
[0010] The initial position value is calibrated according to the position compensation value.
[0011] In some embodiments, the performing DC offset calibration on the sinusoidal sampling values comprises:
[0012] Acquire multiple maximum values and multiple minimum values of the sinusoidal signal within the target number of rotations of the motor;
[0013] Determining a first DC offset value of the sinusoidal signal according to an average of a plurality of maximum values of the sinusoidal signal and an average of a plurality of minimum values of the sinusoidal signal;
[0014] A DC offset calibration is performed on the sinusoidal sampling value according to the first DC offset value.
[0015] In some embodiments, performing DC offset calibration and amplitude calibration on the cosine sampling value includes:
[0016] Acquire multiple maximum values and multiple minimum values of the sine signal within the target number of motor rotations, and multiple maximum values and multiple minimum values of the cosine signal within the target number of motor rotations;
[0017] Determining a first amplitude gain of the sinusoidal signal according to an average of a plurality of maximum values and an average of a plurality of minimum values of the sinusoidal signal;
[0018] Determine a second DC offset value and a second amplitude gain of the cosine signal according to an average of multiple maximum values of the cosine signal and an average of multiple minimum values of the cosine signal;
[0019] Performing a DC offset calibration on the cosine sampling value according to the second DC offset value;
[0020] According to the first amplitude gain and the second amplitude gain, amplitude calibration is performed on the cosine sampling value after the DC offset calibration.
[0021] In some embodiments, the number of revolutions of the motor is determined by the accumulated count of sector crossings; one revolution of the motor includes four sectors, when the motor rotates forward, it crosses each sector in turn, and the accumulated count of sector crossings increases by one; when the motor rotates reversely, it crosses each sector in turn, and the accumulated count of sector crossings decreases by one.
[0022] In some embodiments, the method further comprises:
[0023] If the initial position value does not exist in the position value table, query the position value table to obtain the target position value; the target position value includes a first target position value and a second target position value; the first target position value is smaller than the initial position value and is closest to the initial position value, and the second target position value is larger than the initial position value and is closest to the initial position value;
[0024] According to the target position value and the compensation value corresponding to the target position value, a position compensation value corresponding to the initial position value is obtained by linear interpolation.
[0025] In some embodiments, the method further comprises:
[0026] During the uniform rotation of the motor of the magnetic encoder and the motor of the photoelectric encoder, a plurality of position values of one rotation of the motor of the magnetic encoder and the motor of the photoelectric encoder are respectively collected;
[0027] Converting the collected position value of the motor of the photoelectric encoder into a position value corresponding to the resolution of the magnetic encoder to obtain a first converted position value;
[0028] Converting the first converted position value into a position value corresponding to the same rotation direction as the motor of the magnetic encoder to obtain a second converted position value;
[0029] Calculate the difference between the position value of the motor of the magnetic encoder collected at the same sampling point and the second converted position value to obtain a position compensation value;
[0030] The position compensation table is obtained according to the position compensation value.
[0031] In some embodiments, there are multiple position compensation tables, each of which corresponds to an applicable speed range, and the speed ranges corresponding to the position compensation tables are different; the weights corresponding to the position compensation tables before and after switching are determined based on the actual speed and the speed ranges corresponding to the position compensation tables before and after switching.
[0032] In order to solve the above technical problems, the present application also provides a signal calibration device for a magnetic encoder, comprising:
[0033] The sampling module is used to sample the sine signal and cosine signal generated by the magnetic encoder to obtain a sine sampling value and a cosine sampling value;
[0034] A first calibration module, used for performing a DC offset calibration on the sine sampling value, and performing a DC offset calibration and an amplitude calibration on the cosine sampling value;
[0035] A determination module, used to determine an initial position value according to a calibrated sine sampling value and a calibrated cosine sampling value;
[0036] A first query module, used for querying whether the initial position value exists in the position value table;
[0037] a second query module, for determining, from a position compensation table, a position compensation value corresponding to the initial position value, if any; wherein, if a position compensation table switch occurs, querying the position compensation table before the switch to obtain a first position compensation value; querying the position compensation table after the switch to obtain a second position compensation value; and performing a weighted summation of the first position compensation value and the second position compensation value according to the weights respectively corresponding to the position compensation tables before and after the switch to obtain a position compensation value corresponding to the initial position value;
[0038] The second calibration module is used to perform position calibration on the initial position value according to the position compensation value.
[0039] In order to solve the above technical problems, the present application also provides a signal calibration device for a magnetic encoder, comprising:
[0040] Memory for storing computer programs;
[0041] A processor is used to implement the steps of the signal calibration method of the magnetic encoder as described above when executing the computer program.
[0042] In order to solve the above technical problems, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the signal calibration method of the magnetic encoder as described above are implemented.
[0043] The signal calibration method of the magnetic encoder provided in the present application performs DC bias calibration on the sampling values of the sine signal generated by the magnetic encoder, performs DC bias calibration and amplitude calibration on the sampling values of the cosine signal generated by the magnetic encoder, and performs position-drag calibration again on the initial position value calculated according to the calibrated sampling value, thereby realizing multiple calibrations and improving calibration accuracy. Moreover, when performing position-drag calibration, if the position compensation table is switched, the position compensation table before the switch and the position compensation table after the switch are queried, and the position compensation value queried from the position compensation table before the switch and the position compensation value queried from the position compensation table after the switch are combined to obtain the position compensation value of the initial position value, thereby avoiding sudden changes in position values and improving calibration accuracy.
[0044] The signal calibration device, equipment and computer-readable storage medium of the magnetic encoder provided in this application all have the above-mentioned technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the prior art and the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 A schematic flow chart of a signal calibration method for a magnetic encoder provided in an embodiment of the present application;
[0047] Figure 2 A schematic diagram of linear interpolation provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of a magnetic encoder calibration system provided in an embodiment of the present application;
[0049] Figure 4 A schematic diagram of a signal calibration device for a magnetic encoder provided in an embodiment of the present application;
[0050] Figure 5 A schematic diagram of a signal calibration device for a magnetic encoder provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The core of this application is to provide a signal calibration method, device, equipment and computer-readable storage medium for a magnetic encoder, which can accurately calibrate the signal error of the magnetic encoder, improve the signal calibration accuracy, and help suppress position and speed fluctuations.
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0053] Please refer to Figure 1 , Figure 1 A schematic diagram of a signal calibration method for a magnetic encoder provided in an embodiment of the present application, referring to Figure 1 As shown, the method includes:
[0054] S101: Sample the sine signal and cosine signal generated by the magnetic encoder respectively to obtain sine sampling values and cosine sampling values.
[0055] S102: Perform a DC offset calibration on the sine sampling value, and perform a DC offset calibration and an amplitude calibration on the cosine sampling value.
[0056] S103: Determine the initial position value according to the calibrated sine sampling value and the calibrated cosine sampling value.
[0057] DC bias calibration and amplitude calibration are to calibrate the zero bias and amplitude asymmetry caused by installation deviation and hardware circuit influence.
[0058] In some embodiments, the performing DC offset calibration on the sinusoidal sampling values comprises:
[0059] Acquire multiple maximum values and multiple minimum values of the sinusoidal signal within the target number of rotations of the motor;
[0060] Determining a first DC offset value of the sinusoidal signal according to an average of a plurality of maximum values of the sinusoidal signal and an average of a plurality of minimum values of the sinusoidal signal;
[0061] A DC offset calibration is performed on the sinusoidal sampling value according to the first DC offset value.
[0062] according to The first DC offset value of the sinusoidal signal is calculated. represents the first DC offset value of the sinusoidal signal, and They represent the mean of the maximum and minimum values of the sinusoidal signal respectively.
[0063] The sampling value of the sinusoidal signal, ie, the sinusoidal sampling value, is subtracted from the first DC offset value of the sinusoidal signal to implement DC offset calibration of the sinusoidal sampling value.
[0064] When the motor rotates multiple times, the magnetic encoder can output sinusoidal signals with multiple signal cycles. The DC offset of the sampling value of the sinusoidal signal is calibrated according to the average of the maximum and minimum values of the sinusoidal signal in multiple signal cycles, which can improve the accuracy of the calibration.
[0065] In some embodiments, performing DC offset calibration and amplitude calibration on the cosine sampling value includes:
[0066] Acquire multiple maximum values and multiple minimum values of the sine signal within the target number of motor rotations, and multiple maximum values and multiple minimum values of the cosine signal within the target number of motor rotations;
[0067] Determining a first amplitude gain of the sinusoidal signal according to an average of a plurality of maximum values and an average of a plurality of minimum values of the sinusoidal signal;
[0068] Determine a second DC offset value and a second amplitude gain of the cosine signal according to an average of multiple maximum values of the cosine signal and an average of multiple minimum values of the cosine signal;
[0069] Performing a DC offset calibration on the cosine sampling value according to the second DC offset value;
[0070] According to the first amplitude gain and the second amplitude gain, amplitude calibration is performed on the cosine sampling value after the DC offset calibration.
[0071] according to The second DC offset value of the cosine signal is calculated. represents the second DC offset value of the cosine signal, and They represent the mean of the maximum and minimum values of the cosine signal respectively.
[0072] The second DC offset value of the cosine signal is subtracted from the sampled value of the cosine signal to implement DC offset calibration for the sampled value of the cosine signal.
[0073] When the motor rotates multiple times, the magnetic encoder can output cosine signals of multiple signal periods. The DC offset calibration of the sampling value of the cosine signal is performed according to the average of the maximum value and the average of the minimum value of the cosine signal in multiple signal periods, which can improve the accuracy of the calibration.
[0074] according to The first amplitude gain of the sinusoidal signal is calculated. Represents the first amplitude gain of the sinusoidal signal.
[0075] according to The second amplitude gain of the cosine signal is calculated. Represents the second amplitude gain of the cosine signal.
[0076] according to The amplitude of the cosine sampling value after DC offset calibration is calibrated. is the cosine sampling value after DC offset calibration, is the cosine sampling value after amplitude calibration.
[0077] The amplitude of the cosine sampling value is calibrated according to the average of the extreme values (including the maximum value and the minimum value) of the sine signal and the cosine signal in multiple signal cycles, so that the amplitudes of the cosine and sine are consistent, which can improve the accuracy of the calibration.
[0078] In some embodiments, the number of revolutions of the motor is determined by the accumulated count of sector crossings; one revolution of the motor includes four sectors, when the motor rotates forward, it crosses each sector in turn, and the accumulated count of sector crossings increases by one; when the motor rotates reversely, it crosses each sector in turn, and the accumulated count of sector crossings decreases by one.
[0079] During the motor rotation process of the magnetic encoder, the sinusoidal signal generated by the magnetic encoder is sampled, and the maximum and minimum values of the sinusoidal signal are found by comparing the current sampling value with the previous sampling value, until the number of revolutions of the motor reaches the target number of revolutions. During the process of the motor rotating the target number of revolutions, a sinusoidal signal with multiple signal cycles can be generated, so the maximum and minimum values of the sinusoidal signal in each signal cycle can be found. The number of signal cycles is related to the target number of revolutions. For example, if the motor rotates one revolution to generate a sinusoidal signal with one signal cycle, then the motor rotates M revolutions (the target number of revolutions is M) and can generate a sinusoidal signal with M signal cycles.
[0080] Similarly, during the rotation of the motor of the magnetic encoder, the cosine signal generated by the magnetic encoder is sampled, and by comparing the current sampling value with the previous sampling value, the maximum and minimum values of the cosine signal are found until the number of revolutions of the motor reaches the target number of revolutions. During the process of the motor rotating the target number of revolutions, a cosine signal of multiple signal cycles can be generated, so the maximum and minimum values of the cosine signal in each signal cycle can be found. The number of signal cycles is related to the target number of revolutions. For example, if the motor rotates one circle to generate a cosine signal of one signal cycle, then the motor rotates M circles (the target number of revolutions is M) and can generate a cosine signal of M signal cycles.
[0081] The number of revolutions of the motor is determined by the accumulated count of sector crossings; one revolution of the motor includes four sectors, namely the first sector, the second sector, the third sector and the fourth sector. The first sector corresponds to "00" composed of two square wave signals, the second sector corresponds to "01" composed of two square wave signals, the third sector corresponds to "11" composed of two square wave signals, and the fourth sector corresponds to "10" composed of two square wave signals. Whenever each sector is crossed in sequence, the accumulated count of sector crossing is increased by one.
[0082] For example, the motor rotates forward one circle, and sequentially crosses from the first sector to the second sector, from the second sector to the third sector, from the third sector to the fourth sector, and from the fourth sector to the first sector, that is, the "00" composed of two square wave signals changes to "01", from "01" to "11", from "11" to "10", and from "10" to "00". Then, every time it sequentially crosses from the first sector to the second sector, from the second sector to the third sector, from the third sector to the fourth sector, and from the fourth sector to the first sector, the sector crossing cumulative count is increased by one. Then, the number of revolutions of the motor can be determined based on the sector crossing cumulative count.
[0083] In this embodiment, one rotation of the motor is divided into four sectors, and the number of rotations of the motor is counted according to the sector crossing situation, so that the number of rotations of the motor can be accurately counted.
[0084] S104: Check whether the initial position value exists in the position value table.
[0085] S105: If it exists, determine the position compensation value corresponding to the initial position value from the position compensation table; wherein, if the position compensation table switches, query the position compensation table before the switching to obtain the first position compensation value; query the position compensation table after the switching to obtain the second position compensation value; and perform weighted summation of the first position compensation value and the second position compensation value according to the weights corresponding to the position compensation tables before and after the switching to obtain the position compensation value corresponding to the initial position value.
[0086] S106: Perform position calibration on the initial position value according to the position compensation value.
[0087] After the DC bias calibration and amplitude calibration, the position calibration is further performed to calibrate the delay and other errors. The position calibration is based on a high-precision photoelectric encoder. The photoelectric encoder is connected to the calibrated magnetic encoder through a coupling. The position value table records multiple position values of the sampled magnetic encoder motor for one revolution. The position compensation table records the difference between the position value of the sampled magnetic encoder motor and the position value of the photoelectric encoder motor sampled at the same sampling point.
[0088] After obtaining the initial position value, query whether the initial position value exists in the position value table. If it exists, it indicates that the position compensation value corresponding to the initial position value exists in the position compensation table. Then, the position compensation value corresponding to the initial position value is determined by querying the position compensation table, and the corresponding position compensation value is subtracted from the initial position value to obtain the calibrated position value.
[0089] Among them, if the position compensation table switches, for example, the position compensation table switches due to a change in the rotational speed, or the position compensation table switches due to a change in the rotation direction, then the position compensation table before the switch is queried to obtain a first position compensation value; the position compensation table after the switch is queried to obtain a second position compensation value; and according to the weights corresponding to the position compensation tables before and after the switch, the first position compensation value and the second position compensation value are weightedly summed to obtain the position compensation value corresponding to the initial position value.
[0090] The sum of the weights corresponding to the position compensation tables before and after the switching is 1.
[0091] Among them, in some embodiments, there are multiple position compensation tables, each of which corresponds to an applicable speed range, and the speed ranges corresponding to each position compensation table are different; the weights corresponding to the position compensation tables before and after switching are determined based on the actual speed and the speed ranges corresponding to the position compensation tables before and after switching.
[0092] The actual speed can be subtracted from the upper limit of the speed range applicable to the position compensation table before switching to obtain a first difference. The lower limit of the speed range applicable to the position compensation table after switching can be subtracted from the upper limit of the speed range applicable to the position compensation table before switching to obtain a second difference. The first difference is divided by the second difference to obtain the weight corresponding to the position compensation table before switching. 1 minus the weight corresponding to the position compensation table before switching can obtain the weight corresponding to the position compensation table after switching. Dynamically determining the weight of the position compensation table according to the actual speed can obtain a more accurate and reasonable weight value.
[0093] In some embodiments, it also includes:
[0094] If the initial position value does not exist in the position value table, query the position value table to obtain the target position value; the target position value includes a first target position value and a second target position value; the first target position value is smaller than the initial position value and is closest to the initial position value, and the second target position value is larger than the initial position value and is closest to the initial position value;
[0095] According to the target position value and the compensation value corresponding to the target position value, a position compensation value corresponding to the initial position value is obtained by linear interpolation.
[0096] refer to Figure 2 As shown, when the initial position value does not exist in the position value table, according to Get the position compensation value corresponding to the initial position value.
[0097] Among them, Pos1 and Pos2 are the first target position value and the second target position value respectively, Comp1 and Comp2 are the position compensation table corresponding to the first target position and the position compensation value corresponding to the second target position value respectively, PosOrg is the initial position value, and CompOrg is the position compensation value corresponding to the initial position value.
[0098] In this embodiment, when there is no initial position value in the position table, a position compensation value corresponding to the initial position value is determined by linear interpolation based on known position values and compensation values, so that a more accurate and reasonable position compensation value can be obtained, thereby improving the calibration accuracy.
[0099] In some embodiments, it also includes:
[0100] During the uniform rotation of the motor of the magnetic encoder and the motor of the photoelectric encoder, a plurality of position values of one rotation of the motor of the magnetic encoder and the motor of the photoelectric encoder are respectively collected;
[0101] Converting the collected position value of the motor of the photoelectric encoder into a position value corresponding to the resolution of the magnetic encoder to obtain a first converted position value;
[0102] Converting the first converted position value into a position value corresponding to the same rotation direction as the motor of the magnetic encoder to obtain a second converted position value;
[0103] Calculate the difference between the position value of the motor of the magnetic encoder collected at the same sampling point and the second converted position value to obtain a position compensation value;
[0104] The position compensation table is obtained according to the position compensation value.
[0105] The magnetic encoder and the photoelectric encoder are connected through a coupling, and the motor of the photoelectric encoder can drive the motor of the magnetic encoder to rotate. During the uniform rotation of the motors of the magnetic encoder and the photoelectric encoder, the position values of the motors of the magnetic encoder and the photoelectric encoder are collected at each sampling point. The sampling points are spaced at the same interval.
[0106] The position value of the motor of the high-resolution photoelectric encoder is converted to the resolution of the magnetic encoder. Then, the converted position value of the motor of the photoelectric encoder is converted into a position value with the same rotation direction as the motor of the magnetic encoder.
[0107] For example, if the resolution of the magnetic encoder is q and the resolution of the photoelectric encoder is P, the motor position value of the high-resolution photoelectric encoder is converted to the number of bits of the resolution of the magnetic encoder by shifting right (the number of shifts is pq). q Subtract the converted position value of the motor of the photoelectric encoder as the reference position value, i.e., the second converted position value. Calculate the difference between the position value of the motor of the magnetic encoder collected at the same sampling point and the second converted position value to obtain the position compensation value corresponding to the position value of the motor of the magnetic encoder.
[0108] refer to Figure 3 As shown, a specific implementation is described below:
[0109] The power line is connected to the photoelectric encoder, and the motor of the photoelectric encoder drives the motor of the magnetic encoder to rotate. The driver simultaneously collects the position values output by the magnetic encoder and the photoelectric encoder. When collecting the position value, you can select a specific speed within a different speed range to collect the position value of the motor of the magnetic encoder and the motor of the photoelectric encoder for one turn of forward and reverse rotation. For example, select to collect the position value of the motor of the magnetic encoder and the motor of the photoelectric encoder for one turn of forward and reverse rotation at a certain speed within the range of 0 to 500 rpm at low speed, and the position value of the motor of the magnetic encoder and the motor of the photoelectric encoder for one turn of forward and reverse rotation at a certain speed within the range of 500 to 1500 rpm and 1500 to 3000 rpm at medium and high speed.
[0110] Find the maximum and minimum values of the sine and cosine signals, and perform DC offset calibration on the sampled values of the sine signal according to the maximum and minimum values of the sine and cosine signals, and perform DC offset calibration and amplitude calibration on the sampled values of the cosine signal. In order to ensure that the maximum and minimum values of the sine and cosine signals can be sampled, the motor rotation speed of the magnetic encoder should not be too fast, preferably less than 500 rpm. Therefore, the motor of the photoelectric encoder and the motor of the magnetic encoder are rotated at low speed for a period of time to complete the DC offset calibration and amplitude calibration.
[0111] The update frequency of the DC bias value and amplitude gain is 2 revolutions of the motor. Two square wave signals are used to determine whether the motor has rotated 2 revolutions. The two square wave signals can be combined into "00", "01", "11" and "10", and one revolution of the motor is divided into 4 sectors, representing the first sector, the second sector, the third sector and the fourth sector respectively. The number of revolutions can be obtained by accumulating the count across sectors.
[0112] After DC bias calibration and amplitude calibration, the initial position value is obtained through arc tangent analysis, and the initial position value is further calibrated. The specific calibration process is as follows:
[0113] When the motor rotates at a constant speed, collect N position values of the motor of the magnetic encoder and the motor of the photoelectric encoder for one rotation. The motor of the magnetic encoder is dragged to rotate by the motor of the high-precision photoelectric encoder, and the motor of the photoelectric encoder is driven by the driver to rotate at a specific speed (for example, ±500 rpm, ±1500 rpm, ±3000 rpm), and collect N positions of the motor of the magnetic encoder and the motor of the photoelectric encoder in a constant speed time period. It should be noted that the increment of the adjacent position values collected cannot exceed the threshold value Y, usually the threshold value Y = the resolution of the magnetic encoder * 2 / N, otherwise the sampling is judged to have failed.
[0114] The difference between the position value of the motor of the magnetic encoder and the position value of the motor of the photoelectric encoder is calculated to obtain N position compensation values. Then the driver communicates with the magnetic encoder to write the position value of the motor of the magnetic encoder and the corresponding position compensation value into the magnetic encoder to obtain a position value table and a position compensation table, and the two tables correspond one to one.
[0115] Before calculating the difference between the position value of the motor of the magnetic encoder and the position value of the motor of the photoelectric encoder, the position value of the motor of the photoelectric encoder is first converted into a value with the same resolution as the magnetic encoder, and then converted into a value with the same direction as the motor of the magnetic encoder. Finally, the position value of the motor of the magnetic encoder is subtracted from the position value of the motor of the photoelectric encoder after the conversion to obtain a position compensation value.
[0116] According to the initial position value before compensation, the corresponding position compensation value in the position compensation table is searched, and then the initial position value is subtracted from the corresponding position compensation value. For the initial position value that does not appear in the table, it is calculated by linear interpolation based on the known position value and the position compensation value.
[0117] In the rated motor speed range of -3000~3000 rpm, different position compensation tables need to be found for calibration. For example, the position compensation table at 500 rpm can be used in the speed range of 0~500 rpm, the position compensation table at 1500 rpm can be used in the speed range of 500~1500 rpm, and the position compensation table at 3000 rpm can be used in the speed range of 1500~3000 rpm.
[0118] Among them, at the speed switching boundary, if the compensation values of the position compensation tables at different speeds differ too much, the position value is prone to mutation, that is, the speed fluctuation will suddenly increase. Therefore, when switching different position compensation tables, a buffer zone can be added to set weights q1 and q2 for the two position compensation table values before and after the switch, where q1+q2=1. Determine the position compensation value based on the two position compensation tables before and after the switch and their weights. When switching forward and reverse, position mutations may also occur. At this time, a buffer zone can also be drawn to set weights q1 and q2 for the two position compensation table values before and after the switch, where q1+q2=1. Determine the position compensation value based on the two position compensation tables before and after the switch and their weights. To make a smooth transition and eliminate mutations.
[0119] In summary, the signal calibration method of the magnetic encoder provided in the present application performs DC bias calibration on the sampling values of the sine signal generated by the magnetic encoder, performs DC bias calibration and amplitude calibration on the sampling values of the cosine signal generated by the magnetic encoder, and performs position-drag calibration again on the initial position value calculated according to the calibrated sampling value, thereby achieving multiple calibrations and improving calibration accuracy. In addition, when performing position-drag calibration, if the position compensation table is switched, the position compensation table before the switch and the position compensation table after the switch are queried, and the position compensation value queried from the position compensation table before the switch and the position compensation value queried from the position compensation table after the switch are combined to obtain the position compensation value of the initial position value, which can avoid sudden changes in position values and improve calibration accuracy.
[0120] The present application also provides a signal calibration device for a magnetic encoder. The device described below can be referred to in correspondence with the method described above. Figure 4 , Figure 4 A schematic diagram of a position calibration device for a magnetic encoder provided in an embodiment of the present application, combined with Figure 4 As shown, the device comprises:
[0121] The sampling module 10 is used to sample the sine signal and the cosine signal generated by the magnetic encoder to obtain a sine sampling value and a cosine sampling value;
[0122] A first calibration module 20, used for performing a DC offset calibration on the sine sampling value, and performing a DC offset calibration and an amplitude calibration on the cosine sampling value;
[0123] A determination module 30, configured to determine an initial position value according to the calibrated sine sampling value and the calibrated cosine sampling value;
[0124] A first query module 40 is used to query whether the initial position value exists in the position value table;
[0125] A second query module 50 is used to determine the position compensation value corresponding to the initial position value from the position compensation table if it exists; wherein, if the position compensation table is switched, the position compensation table before the switching is queried to obtain the first position compensation value; the position compensation table after the switching is queried to obtain the second position compensation value; and the first position compensation value and the second position compensation value are weightedly summed according to the weights respectively corresponding to the position compensation tables before and after the switching to obtain the position compensation value corresponding to the initial position value;
[0126] The second calibration module 60 is used to perform position calibration on the initial position value according to the position compensation value.
[0127] Based on the above embodiment, as a specific implementation, the first calibration module 20 includes:
[0128] A first acquisition unit, used for acquiring a plurality of maximum values and a plurality of minimum values of the sinusoidal signal within a target number of rotations of the motor;
[0129] A first determining unit, configured to determine a first DC offset value of the sinusoidal signal according to an average of a plurality of maximum values of the sinusoidal signal and an average of a plurality of minimum values of the sinusoidal signal;
[0130] The first calibration unit is used to perform a DC offset calibration on the sinusoidal sampling value according to the first DC offset value.
[0131] Based on the above embodiment, as a specific implementation, the first calibration module 20 includes:
[0132] A second acquisition unit is used to acquire multiple maximum values and multiple minimum values of the sine signal within the target number of motor rotations, and multiple maximum values and multiple minimum values of the cosine signal within the target number of motor rotations;
[0133] A second determining unit, configured to determine a first amplitude gain of the sinusoidal signal according to an average of a plurality of maximum values and an average of a plurality of minimum values of the sinusoidal signal;
[0134] a third determining unit, configured to determine a second DC offset value and a second amplitude gain of the cosine signal according to an average of a plurality of maximum values of the cosine signal and an average of a plurality of minimum values of the cosine signal;
[0135] A second calibration unit, configured to perform a DC offset calibration on the cosine sampling value according to the second DC offset value;
[0136] The third calibration unit is used to perform amplitude calibration on the cosine sampling value after DC offset calibration according to the first amplitude gain and the second amplitude gain.
[0137] On the basis of the above embodiment, as a specific implementation method, the number of revolutions of the motor is determined by the accumulated count of sector crossings; one revolution of the motor includes four sectors, when the motor rotates forward, it crosses each sector in turn, and the accumulated count of sector crossings is increased by one; when the motor rotates reversely, it crosses each sector in turn, and the accumulated count of sector crossings is decreased by one.
[0138] Based on the above embodiment, as a specific implementation method, it also includes:
[0139] A third query module is used to query the position value table to obtain a target position value if the initial position value does not exist in the position value table; the target position value includes a first target position value and a second target position value; the first target position value is smaller than the initial position value and is closest to the initial position value, and the second target position value is larger than the initial position value and is closest to the initial position value;
[0140] The linear interpolation module is used to obtain the position compensation value corresponding to the initial position value by linear interpolation according to the target position value and the compensation value corresponding to the target position value.
[0141] Based on the above embodiment, as a specific implementation method, it also includes:
[0142] An acquisition module, used for respectively acquiring a plurality of position values of the motor of the magnetic encoder and the motor of the photoelectric encoder during a uniform rotation of the motor of the magnetic encoder and the motor of the photoelectric encoder;
[0143] A first conversion module, used to convert the collected position value of the motor of the photoelectric encoder into a position value corresponding to the resolution of the magnetic encoder to obtain a first converted position value;
[0144] A second conversion module, used to convert the first conversion position value into a position value corresponding to the same rotation direction as the motor of the magnetic encoder, to obtain a second conversion position value;
[0145] A calculation module, used for calculating the difference between the position value of the motor of the magnetic encoder collected at the same sampling point and the second converted position value, to obtain a position compensation value;
[0146] A table building module is used to obtain the position compensation table according to the position compensation value.
[0147] On the basis of the above embodiments, as a specific implementation method, there are multiple position compensation tables, each of which corresponds to an applicable speed range, and the speed ranges corresponding to the position compensation tables are different; the weights corresponding to the position compensation tables before and after switching are determined based on the actual speed and the speed ranges corresponding to the position compensation tables before and after switching.
[0148] The present application also provides a signal calibration device for a magnetic encoder, referring to Figure 5 As shown, the device includes a memory 1 and a processor 2 .
[0149] Memory 1, used for storing computer programs;
[0150] Processor 2 is used to execute the computer program to implement the following steps:
[0151] The sine signal and cosine signal generated by the magnetic encoder are sampled respectively to obtain sine sampling values and cosine sampling values; the sine sampling values are DC bias calibrated, and the cosine sampling values are DC bias calibrated and amplitude calibrated; the initial position value is determined according to the calibrated sine sampling value and the calibrated cosine sampling value; the position value table is queried whether the initial position value exists; if so, the position compensation value corresponding to the initial position value is determined from the position compensation table; wherein, if the position compensation table is switched, the position compensation table before the switching is queried to obtain a first position compensation value; the position compensation table after the switching is queried to obtain a second position compensation value; according to the weights corresponding to the position compensation tables before and after the switching, the first position compensation value and the second position compensation value are weightedly summed to obtain the position compensation value corresponding to the initial position value; the initial position value is position calibrated according to the position compensation value.
[0152] For an introduction to the equipment provided in this application, please refer to the above method embodiments, and this application will not go into details here.
[0153] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps can be implemented:
[0154] The sine signal and cosine signal generated by the magnetic encoder are sampled respectively to obtain sine sampling values and cosine sampling values; the sine sampling values are DC bias calibrated, and the cosine sampling values are DC bias calibrated and amplitude calibrated; the initial position value is determined according to the calibrated sine sampling value and the calibrated cosine sampling value; the position value table is queried whether the initial position value exists; if so, the position compensation value corresponding to the initial position value is determined from the position compensation table; wherein, if the position compensation table is switched, the position compensation table before the switching is queried to obtain a first position compensation value; the position compensation table after the switching is queried to obtain a second position compensation value; according to the weights corresponding to the position compensation tables before and after the switching, the first position compensation value and the second position compensation value are weightedly summed to obtain the position compensation value corresponding to the initial position value; the initial position value is position calibrated according to the position compensation value.
[0155] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0156] For an introduction to the computer-readable storage medium provided in this application, please refer to the above method embodiment, and this application will not go into details here.
[0157] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the devices, equipment, and computer-readable storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0158] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0159] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0160] The signal calibration method, device, equipment and computer-readable storage medium of the magnetic encoder provided by the present application are described in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A signal calibration method for a magnetic encoder, characterized in that: include: The sine signal and the cosine signal generated by the magnetic encoder are sampled respectively to obtain a sine sampling value and a cosine sampling value; Performing DC offset calibration on the sine sampling value, and performing DC offset calibration and amplitude calibration on the cosine sampling value; Determine the initial position value according to the calibrated sine sampling value and the calibrated cosine sampling value; Check whether the initial position value exists in the position value table; If it exists, determine the position compensation value corresponding to the initial position value from the position compensation table; wherein, if the position compensation table is switched, query the position compensation table before the switching to obtain the first position compensation value; query the position compensation table after the switching to obtain the second position compensation value; and perform weighted summation of the first position compensation value and the second position compensation value according to the weights respectively corresponding to the position compensation tables before and after the switching to obtain the position compensation value corresponding to the initial position value; The initial position value is calibrated according to the position compensation value.
2. The signal calibration method of the magnetic encoder according to claim 1, characterized in that: The DC offset calibration of the sinusoidal sampling value comprises: Acquire multiple maximum values and multiple minimum values of the sinusoidal signal within the target number of rotations of the motor; Determining a first DC offset value of the sinusoidal signal according to an average of a plurality of maximum values of the sinusoidal signal and an average of a plurality of minimum values of the sinusoidal signal; A DC offset calibration is performed on the sinusoidal sampling value according to the first DC offset value.
3. The signal calibration method of the magnetic encoder according to claim 1, characterized in that: The performing of DC offset calibration and amplitude calibration on the cosine sampling value comprises: Acquire multiple maximum values and multiple minimum values of the sine signal within the target number of motor rotations, and multiple maximum values and multiple minimum values of the cosine signal within the target number of motor rotations; Determining a first amplitude gain of the sinusoidal signal according to an average of a plurality of maximum values and an average of a plurality of minimum values of the sinusoidal signal; Determine a second DC offset value and a second amplitude gain of the cosine signal according to an average of multiple maximum values of the cosine signal and an average of multiple minimum values of the cosine signal; Performing a DC offset calibration on the cosine sampling value according to the second DC offset value; According to the first amplitude gain and the second amplitude gain, amplitude calibration is performed on the cosine sampling value after the DC offset calibration.
4. The signal calibration method of a magnetic encoder according to any one of claims 2 to 3, characterized in that: The number of revolutions of the motor is determined by the accumulated count of sector crossings; one revolution of the motor includes four sectors. When the motor rotates forward, it crosses each sector in turn, and the accumulated count of sector crossings increases by one; when the motor rotates reversely, it crosses each sector in turn, and the accumulated count of sector crossings decreases by one.
5. The signal calibration method of the magnetic encoder according to claim 1, characterized in that: The method further comprises: If the initial position value does not exist in the position value table, query the position value table to obtain the target position value; the target position value includes a first target position value and a second target position value; the first target position value is smaller than the initial position value and is closest to the initial position value, and the second target position value is larger than the initial position value and is closest to the initial position value; According to the target position value and the compensation value corresponding to the target position value, a position compensation value corresponding to the initial position value is obtained by linear interpolation.
6. The signal calibration method of a magnetic encoder according to claim 1, characterized in that: The method further comprises: During the uniform rotation of the motor of the magnetic encoder and the motor of the photoelectric encoder, a plurality of position values of one rotation of the motor of the magnetic encoder and the motor of the photoelectric encoder are respectively collected; Converting the collected position value of the motor of the photoelectric encoder into a position value corresponding to the resolution of the magnetic encoder to obtain a first converted position value; Converting the first converted position value into a position value corresponding to the same rotation direction as the motor of the magnetic encoder to obtain a second converted position value; Calculate the difference between the position value of the motor of the magnetic encoder collected at the same sampling point and the second converted position value to obtain a position compensation value; The position compensation table is obtained according to the position compensation value.
7. The signal calibration method of a magnetic encoder according to claim 1, characterized in that: There are multiple position compensation tables, each of which corresponds to an applicable speed range, and the speed ranges corresponding to the position compensation tables are different; the weights corresponding to the position compensation tables before and after switching are determined based on the actual speed and the speed ranges corresponding to the position compensation tables before and after switching.
8. A signal calibration device for a magnetic encoder, characterized in that: include: The sampling module is used to sample the sine signal and cosine signal generated by the magnetic encoder to obtain a sine sampling value and a cosine sampling value; A first calibration module, used for performing a DC offset calibration on the sine sampling value, and performing a DC offset calibration and an amplitude calibration on the cosine sampling value; A determination module, used to determine an initial position value according to a calibrated sine sampling value and a calibrated cosine sampling value; A first query module, used for querying whether the initial position value exists in the position value table; a second query module, for determining, from a position compensation table, a position compensation value corresponding to the initial position value, if any; wherein, if a position compensation table switch occurs, querying the position compensation table before the switch to obtain a first position compensation value; querying the position compensation table after the switch to obtain a second position compensation value; and performing a weighted summation of the first position compensation value and the second position compensation value according to the weights respectively corresponding to the position compensation tables before and after the switch to obtain a position compensation value corresponding to the initial position value; The second calibration module is used to perform position calibration on the initial position value according to the position compensation value.
9. A signal calibration device for a magnetic encoder, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the signal calibration method of the magnetic encoder as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the signal calibration method of the magnetic encoder according to any one of claims 1 to 7 are implemented.