Disclosure of Invention
In order to solve the above problems, the present application proposes a method, an apparatus, a system, a device and a storage medium for calibrating encoders, wherein encoders with different mounting modes are calibrated.
According to a first aspect of embodiments of the present application, there is provided a calibration method of an encoder, applied to a controller, where the controller is connected to a photographing apparatus, a motor, and the encoder, respectively, the method including:
controlling the motor to perform N times of rotation operation, after each time of rotation operation of the motor, receiving a first rotation angle of the motor detected by the encoder, and controlling the shooting equipment to shoot the motor after the rotation operation to obtain a motor image, and determining a second rotation angle of the motor based on the motor image; wherein N is a positive integer greater than 1;
Generating a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles; the correspondence is used for calibrating the rotation angle detected by the encoder.
Preferably, the generating the correspondence between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles includes:
and carrying out linear interpolation calculation on the N first rotation angles and the N second rotation angles by using preset precision to obtain the corresponding relation between the rotation angles detected by the encoder and the second rotation angles.
Preferably, after generating the correspondence between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles, the method further includes:
and outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle under the condition that the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle meets the accuracy checking condition.
Preferably, the outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle when the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle meets the accuracy check condition includes:
Controlling the motor to rotate, after each rotation operation of the motor, receiving a first rotation angle of the motor detected by the encoder, determining a standard rotation angle corresponding to the first rotation angle according to the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle, and determining the standard rotation angle as an updated first rotation angle;
controlling the shooting equipment to shoot the motor after the rotating operation to obtain a motor image, and determining a second rotating angle of the motor based on the motor image;
and outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle under the condition that the difference value between the updated first rotation angle and the second rotation angle is not larger than a preset precision threshold value.
Preferably, the method further comprises:
and under the condition that the difference value between the updated first rotation angle and the updated second rotation angle is larger than a preset precision threshold value, reducing the rotation angle parameter for controlling the motor to rotate each time, and controlling the motor to rotate for N times according to the rotation angle parameter.
Preferably, the controller includes: the upper computer is connected with the motor driver; correspondingly, the motor is controlled to perform N times of rotation operation, after each rotation operation of the motor, a first rotation angle of the motor detected by the encoder is received, the shooting equipment is controlled to shoot the motor after the rotation operation, a motor image is obtained, and a second rotation angle of the motor is determined based on the motor image; according to the N first rotation angles and the N second rotation angles, generating a correspondence between the rotation angle detected by the encoder and a standard rotation angle, including:
The upper computer sends N rotation angle parameters to the motor driver so that the motor driver controls the motor to perform N rotation operations, and after each rotation operation of the motor, the first rotation angle of the motor detected by the encoder is received;
the upper computer controls the shooting equipment to shoot the motor after the rotating operation under the condition that the first rotating angle sent by the motor driver is received each time, so as to obtain a motor image, and determines a second rotating angle of the motor based on the motor image;
and the upper computer generates a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles.
Preferably, after the upper computer generates the correspondence between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles, the method further includes:
and storing the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle into the motor driver.
Preferably, a calibration support is installed on the motor shaft, so that when the motor rotates, the calibration support rotates along a plane, and accordingly, the control of the photographing device to photograph the motor after the rotation operation, to obtain a motor image, includes:
And controlling the optical axis of the shooting equipment to be perpendicular to the rotating plane of the calibration support to shoot the motor after the rotating operation, so as to obtain a motor image.
According to a second aspect of embodiments of the present application, there is provided a calibration device of an encoder, including:
the first control module is used for controlling the motor to perform N times of rotation operation, receiving a first rotation angle of the motor detected by the encoder after each time of rotation operation of the motor, controlling the shooting equipment to shoot the motor after the rotation operation to obtain a motor image, and determining a second rotation angle of the motor based on the motor image;
the second control module is used for generating a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles; the correspondence is used for calibrating the rotation angle detected by the encoder.
A third aspect of the present application provides a calibration system for an encoder, comprising: the device comprises a controller, shooting equipment, a motor, an encoder and a calibration bracket;
a calibration bracket is arranged on the motor rotating shaft so that the calibration bracket rotates along a plane when the motor rotates;
The controller is respectively in communication connection with the shooting equipment, the motor and the encoder;
the controller is used for realizing the calibration method of the encoder.
A fourth aspect of the present application provides an electronic device, comprising:
a memory and a processor;
the memory is connected with the processor and used for storing programs;
the processor is used for realizing the calibration method of the encoder by running the program in the memory.
A fifth aspect of the present application provides a storage medium having stored thereon a computer program which, when executed by a processor, implements the method of calibrating an encoder as described above.
One embodiment of the above application has the following advantages or benefits:
controlling the motor to perform N times of rotation operation, after each time of rotation operation of the motor, receiving a first rotation angle of the motor detected by the encoder, and controlling the shooting equipment to shoot the motor after the rotation operation to obtain a motor image, and determining a second rotation angle of the motor based on the motor image; and generating a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles. Therefore, the rotation angle detected by the encoder is calibrated according to the actual rotation angle of the motor determined by the shooting equipment by utilizing the corresponding relation, and the encoders in different installation modes can be calibrated without considering the encoders in different installation modes.
Detailed Description
The technical scheme of the embodiment of the application is suitable for being applied to various encoder calibration scenes, such as a tripod head motor scene and the like. By adopting the technical scheme of the embodiment of the application, the encoders with different mounting modes can be calibrated.
The technical scheme of the embodiment of the application can be exemplarily applied to hardware devices such as a processor, an electronic device, a server (comprising a cloud server) and the like, or packaged into a software program to be operated, and when the hardware device executes the processing procedure of the technical scheme of the embodiment of the application, or the software program is operated, the aim of calibrating the rotation angle detected by the encoder according to the actual rotation angle of the motor determined by the shooting device can be realized. The embodiment of the application only exemplary introduces a specific processing procedure of the technical scheme of the application, and does not limit a specific implementation form of the technical scheme of the application, and any technical implementation form capable of executing the processing procedure of the technical scheme of the application can be adopted by the embodiment of the application.
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
Exemplary method
FIG. 1 is a flow chart of a method of calibrating an encoder according to an embodiment of the present application. In an exemplary embodiment, a calibration method of an encoder is provided, which is applied to a controller, and the controller is respectively connected with a photographing apparatus 4, a motor 2 and the encoder, and includes:
s110, controlling the motor 2 to perform N times of rotation operation, after each rotation operation of the motor 2, receiving a first rotation angle of the motor 2 detected by the encoder, and controlling the shooting equipment 4 to shoot the motor 2 after the rotation operation to obtain a motor 2 image, and determining a second rotation angle of the motor 2 based on the motor 2 image; wherein N is a positive integer greater than 1;
s120, according to the N first rotation angles and the N second rotation angles, generating a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle; the correspondence is used for calibrating the rotation angle detected by the encoder.
The controller is communicatively connected to the photographing device 4, the motor 2 and the encoder, and the photographing device 4 is used for photographing the rotated motor 2, and alternatively, the photographing device 4 may be any device with a camera, such as a camera. The encoder is used for detecting the rotation angle of the motor 2, and the encoder may be mounted on an axis or off-axis, or may be directly mounted on a magnetic encoding chip, and the mounting mode of the encoder is not limited herein. Further, a calibration support 3 is mounted on the rotating shaft of the motor 2, so that the calibration support 3 rotates along a plane when the motor 2 rotates. Accordingly, the controller controls the optical axis of the photographing device 4 to be perpendicular to the rotation plane of the calibration support 3 to photograph the motor 2 after the rotation operation, so as to obtain an image of the motor 2. In this way, the photographing apparatus 4 is located right above the motor 2, so that the photographed image of the motor 2 is more realistic. The calibration stand 3 is not limited to any structure capable of showing a change in the rotation angle of the motor 2.
In this embodiment, as shown in fig. 2, a motor 2 and an encoder are disposed on a calibration platform 1, the encoder is connected with the motor 2, and a calibration bracket 3 is installed on a rotating shaft of the motor 2. The shooting device 4 is arranged on the calibration platform 1, the shooting device 4 is positioned right above the motor 2, and the optical axis of the shooting device 4 is perpendicular to the rotation plane of the calibration support 3. The controller may be provided at any location, which is wired or wirelessly connected to the photographing apparatus 4, the motor 2, and the encoder. Further, the controller at least comprises a motor 2 driver and can also be an upper computer. Alternatively, in the case that the controller includes a motor 2 driver and an upper computer, the motor 2 driver and the upper computer are connected in communication.
In step S110, the rotation operation is illustratively generated in response to the rotation angle parameter transmitted by the controller. The rotation angle parameter sent by the controller to the motor 2 may be randomly generated, or may be generated according to a specific rule. For example, N rotation angle parameters are progressively generated according to a preset step, if the step is Δθ, the rotation angle parameters are sequentially 0, θ,2θ,3θ, …,360, and N is 360/Δθ+1. The first rotation angle is used to represent the rotation angle of the motor 2 detected by the encoder, and the second rotation angle is used to represent the actual rotation angle of the motor 2.
Further, the encoder is aligned at 0 degrees with 0 degrees in the image of the motor 2 taken by the photographing device 4 before the encoder is calibrated. That is, a 0 degree parameter is transmitted to the motor 2 to control the photographing apparatus 4 to photograph the motor 2 under the 0 degree parameter, and the position of the calibration support 3 in the image of the motor 2 is determined to be 0 degree.
Specifically, the controller sends a rotation angle parameter to the motor 2, the motor 2 rotates according to the rotation angle parameter, and the motor 2 drives the calibration support 3 to rotate along the plane during rotation. The encoder detects the current rotation angle of the motor 2, i.e. the first rotation angle. And feeding back the first rotation angle to the controller. The controller controls the photographing device 4 to photograph the rotated motor 2 under the condition of receiving the first rotation angle, obtains an image of the motor 2, and feeds back the image of the motor 2 to the controller. The controller analyzes the image of the motor 2 to obtain the rotation angle of the motor 2 (i.e. the actual rotation angle of the motor 2) in the image of the motor 2, and takes the rotation angle as the second rotation angle.
It will be appreciated that the controller may compare the motor 2 image at the 0 degree parameter to the rotated motor 2 image to determine the second angle of rotation. As shown in fig. 3, a coordinate system may also be established on the plane of the calibration support 3 according to the end locus circle of the calibration support 3 and the center circle of the calibration support 3, so as to obtain the second rotation angle of the motor 2. It is also possible to identify the motor 2 image according to a prior art image identification model to determine the end of the calibration support 3 in the motor 2 image to determine the angle of rotation of the motor 2. The specific method of determining the rotation angle of the motor 2 from the image is not limited herein. Therefore, the problems of poor calibration effect and complex installation and debugging process caused by the difference of the installation precision of the encoders are avoided.
In step S120, the correspondence between the rotation angle detected by the encoder and the standard rotation angle is used for calibrating the rotation angle detected by the encoder, that is, the actual rotation angle of the motor 2 is determined in the correspondence according to the rotation angle detected by the encoder. The correspondence relationship may exist in a list form, may exist in a function form, or may exist in a curve form, and is not limited herein.
Specifically, since the first rotation angle detected by the encoder and the second rotation angle determined by the image of the motor 2 are output after each rotation operation of the motor 2. Therefore, after the controller transmits N rotation angle parameters to the motor 2 so that the motor 2 performs N rotation operations, N first rotation angles and N second rotation angles are obtained. The first rotation angle and the second rotation angle after each rotation operation are taken as one data point, namely (the first rotation angle and the second rotation angle), and thus N data points are obtained. Then, N data points may be used as the correspondence between the rotation angle detected by the encoder and the standard rotation angle. An encoder calibration curve can also be fitted according to the N data points and used as a correspondence between the rotation angle detected by the encoder and the standard rotation angle. And storing the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle into the controller, so that the subsequent calling of the corresponding relation is facilitated.
In the related art, the encoder chip calculates the current angle value by sensing the change of the surrounding magnetic field, but the encoder often has inconsistency in the installation process and the matching process with the magnet, and the problem of calculated angle drift occurs at this time. Based on this, in the technical solution of the present application, the motor 2 is controlled to perform N rotation operations, after each rotation operation of the motor 2, a first rotation angle of the motor 2 detected by the encoder is received, and the photographing device 4 is controlled to photograph the motor 2 after the rotation operation, so as to obtain an image of the motor 2, and a second rotation angle of the motor 2 is determined based on the image of the motor 2; wherein N is a positive integer greater than 1; and generating a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles. In this way, the above correspondence is used to calibrate the rotation angle detected by the encoder according to the actual rotation angle of the motor 2 determined by the photographing apparatus 4, and the encoders of different mounting modes are not required to be considered, so that the method has universality. Meanwhile, the problem of encoder angle drift can be solved.
In one embodiment, the generating the correspondence between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles includes:
And carrying out linear interpolation calculation on the N first rotation angles and the N second rotation angles by using preset precision to obtain the corresponding relation between the rotation angles detected by the encoder and the second rotation angles.
Illustratively, the preset accuracy represents an accuracy requirement for encoder calibration. The preset accuracy is an accuracy set in advance according to actual conditions, and is generally a numerical value greater than 0.1. Linear interpolation refers to the way in which the interpolation function is an interpolation of a first order polynomial.
Specifically, the first rotation angle and the second rotation angle after each rotation operation are taken as one data point, and thus, N data points are obtained. And performing linear interpolation calculation between every two adjacent data points according to preset precision to estimate interpolation data points between every two adjacent data points. The data points and the interpolated data points can be directly used as the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle. The encoder calibration curve may also be obtained by fitting every two adjacent data points and their interpolated data points. Therefore, the N first rotation angles and the N second rotation angles are subjected to linear interpolation correction according to the preset precision, so that the corresponding relation between the rotation angle detected by the output encoder and the standard rotation angle is more accurate.
For example, 360/Δθ+1 first rotation angles (0, θ,2θ,3θ, 360) and corresponding second rotation angles (0, α) are obtained1 ,α2 ,α3 …, 360), 360/Δθ+1 data points [ θ ] are obtainedi ,αi ](i=0, 1,2, …/Δθ+1). And (3) performing linear interpolation operation on two adjacent data points by using preset precision, wherein for any group of adjacent data points, the method specifically comprises the following steps of:
where y=step size/preset accuracy, n represents the nth data to be interpolated. n=0, 1,2 … …, y-2, y-1, y.
For example, if 0 and α1 =4.8°,θ1 Linear interpolation operation is carried out between 5 degrees, the step length is 5 degrees, the preset precision is 0.5 degrees, if y=10, 10 times of linear interpolation correction are needed between 0 and 5, and the corresponding interpolation data point is [0.5,0.48 ]],[1.0,0.96]……[4.5,4.32]。
In one embodiment, after the generating the correspondence between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles, the method further includes:
and outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle under the condition that the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle meets the accuracy checking condition.
Illustratively, the accuracy check condition is used to detect whether the corrected rotation angle of the encoder meets the accuracy requirement. The accuracy check condition can judge whether the difference value between the standard rotation angle and the actual rotation angle obtained through the searching of the corresponding relation meets a preset first threshold value, and if so, the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle is output. If the rotation angle is not satisfied, the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle is further calibrated. The preset first threshold may be set according to actual needs, which is not limited herein.
The accuracy verification condition may further be that two corresponding standard rotation angles are determined in the corresponding relation according to two adjacent first rotation angles detected by the encoder, a difference value between the two standard rotation angles is calculated to be a first difference value, a second difference value between the two adjacent first rotation angles is calculated, and if the difference value between the first difference value and the second difference value is within a preset accuracy range, the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle is output. If the difference between the first difference and the second difference is not within the preset precision range, the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle is further calibrated. The preset accuracy range may be set according to actual needs, which is not limited herein.
Therefore, the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle is further subjected to accuracy judgment, so that the output corresponding relation can be used for calibrating the encoder more accurately.
In one embodiment, the outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle when the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle satisfies the accuracy check condition includes:
controlling the motor 2 to rotate, after each rotation operation of the motor 2, receiving a first rotation angle of the motor 2 detected by the encoder, determining a standard rotation angle corresponding to the first rotation angle according to a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle, and determining the standard rotation angle as an updated first rotation angle;
controlling the shooting equipment 4 to shoot the motor 2 after the rotating operation to obtain a motor 2 image, and determining a second rotation angle of the motor 2 based on the motor 2 image;
and outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle under the condition that the difference value between the updated first rotation angle and the second rotation angle is not larger than a preset precision threshold value.
Specifically, a required target step length is set, and M rotation angle parameters are generated progressively according to the target step length, where M may be the same as N or different from N, and is not limited herein.
The controller sends a rotation angle parameter to the motor 2, the motor 2 rotates according to the rotation angle parameter, and the motor 2 drives the calibration support 3 to rotate along the plane during rotation. The encoder detects the current rotation angle of the motor 2, i.e. the first rotation angle. And feeding back the first rotation angle to the controller, and searching a standard rotation angle corresponding to the first rotation angle in the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle by the controller, and taking the standard rotation angle as an updated first rotation angle.
The controller controls the photographing device 4 to photograph the rotated motor 2 under the condition of receiving the first rotation angle, obtains an image of the motor 2, and feeds back the image of the motor 2 to the controller. The controller analyzes the image of the motor 2 to obtain the rotation angle of the motor 2 (i.e. the actual rotation angle of the motor 2) in the image of the motor 2, and takes the rotation angle as the second rotation angle.
And respectively calculating the difference value of each updated first rotation angle and the corresponding second rotation angle. Alternatively, it may be determined whether the difference is greater than a preset accuracy threshold. If all the difference values are not larger than the preset precision threshold value, the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle is indicated to meet the precision requirement, and therefore the corresponding relation is output. The preset precision threshold may be set according to actual needs, and is not limited herein. In this embodiment, the preset precision threshold is set according to the preset precision, that is, the preset precision threshold is the same as the preset precision value. Alternatively, an average value of all the differences may be taken, and whether the average value is greater than a preset precision threshold value is determined. If the detected rotation angle is not greater than the preset precision threshold, the corresponding relation between the detected rotation angle and the standard rotation angle of the encoder is indicated to meet the precision requirement, and therefore the corresponding relation is output.
Further, in the case that the difference between the updated first rotation angle and the second rotation angle is greater than a preset precision threshold, the rotation angle parameter for controlling the motor 2 to rotate each time is reduced, and the motor 2 is controlled to rotate N times according to the rotation angle parameter.
Specifically, if any updated difference value between the first rotation angle and the second rotation angle is greater than a preset precision threshold, it is indicated that the precision of the corresponding relationship between the rotation angle detected by the encoder and the standard rotation angle does not meet the requirement, and further correction is required. Accordingly, the preset step Δθ is reduced, and steps S110 to S120 are re-performed.
For example, when determining a data point greater than the preset precision threshold, the step size may be set to Δθ/2, and N rotation angle parameters are generated according to the progression of Δθ/2, where the rotation angle parameters are sequentially 0,0.5θ, θ,1.5θ,2θ, …,360, and N is 360/0.5θ+1. Re-executing the steps S110-S120 to obtain the corresponding relation between the rotation angle detected by the new encoder and the standard rotation angle aiming at the data point which is larger than the preset precision threshold, and judging whether the corresponding relation between the rotation angle detected by the new encoder and the standard rotation angle meets the precision verification condition or not again, and outputting the new corresponding relation if the corresponding relation meets the precision verification condition; if the corresponding relation does not meet the accuracy check condition, the step length is continuously reduced until the new corresponding relation is output to meet the accuracy check condition.
In one embodiment, the controller includes: the upper computer is connected with the motor 2 driver; accordingly, the motor 2 is controlled to perform N rotation operations, after each rotation operation of the motor 2, a first rotation angle of the motor 2 detected by the encoder is received, the shooting device 4 is controlled to shoot the motor 2 after the rotation operation, a motor 2 image is obtained, and a second rotation angle of the motor 2 is determined based on the motor 2 image; according to the N first rotation angles and the N second rotation angles, generating a correspondence between the rotation angle detected by the encoder and a standard rotation angle, including:
the upper computer sends N rotation angle parameters to the motor 2 driver so that the motor 2 driver controls the motor 2 to perform N rotation operations, and after each rotation operation of the motor 2, the upper computer receives a first rotation angle of the motor 2 detected by the encoder;
the upper computer controls the shooting equipment 4 to shoot the motor 2 after the rotating operation under the condition that the first rotating angle sent by the motor 2 driver is received each time, so as to obtain a motor 2 image, and determines a second rotating angle of the motor 2 based on the motor 2 image;
And the upper computer generates a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles.
Illustratively, as shown in fig. 4, the motor 2 drive is communicatively coupled to an upper computer on which an operator may directly operate. The upper computer is used for sending the rotation angle parameter to the motor 2 driver and receiving the first rotation angle measured by the encoder fed back by the motor 2 driver; and is further configured to receive the image of the motor 2 captured by the capturing device 4, and parse out a second rotation angle (i.e., an actual rotation angle) in the image of the motor 2.
The motor 2 driver is used for controlling the motor 2 to perform rotation operation and receiving the first rotation angle measured by the encoder. Therefore, the upper computer is responsible for calculating the second rotation angle, so that the calculation force of the driver is avoided, and the running efficiency of the driver is not affected before and after the encoder is calibrated.
Further, after the upper computer generates the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles, the method further includes:
and storing the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle into the motor 2 driver.
Specifically, the upper computer sends the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle to the motor 2 driver, and the motor 2 driver stores the corresponding relation in the memory. Therefore, the calibrated data are stored in the driving force FLASH in a data table mode, and when the driver operates, the actual angle value corresponding to the angle value detected by the encoder is obtained in a table look-up mode, so that redundant operation is avoided, and the operating efficiency of the driver of the motor 2 is ensured.
Further, a calibration support 3 is installed on a rotating shaft of the motor 2, so that the calibration support 3 rotates along a plane when the motor 2 rotates, and accordingly, the control of the photographing device 4 to photograph the motor 2 after the rotation operation, to obtain an image of the motor 2, includes:
and controlling the optical axis of the shooting device 4 to be perpendicular to the rotating plane of the calibration support 3 to shoot the motor 2 after the rotating operation, so as to obtain an image of the motor 2.
In the present embodiment, 1) the motor 2, the calibration stand 3, and the photographing device 4 are all provided on the calibration platform 1. Before the encoder is calibrated, the upper computer sends a 0-degree parameter to the motor 2 driver, so that the motor 2 driver feeds back the 0 degree detected by the encoder to the upper computer under the condition that the motor 2 driver controls the motor 2 to be at 0 degree, the upper computer controls the shooting device 4 (such as a camera) to shoot the motor 2 under the 0-degree parameter, the optical axis of the shooting device 4 is perpendicular to the rotating plane of the calibration support 3, and a shot picture is real and reliable, so that the calibration support 3 in an image of the motor 2 is an actual rotating position of the motor 2. The position of the calibration support 3 in the image of the motor 2 is thus determined to be 0 degrees. To achieve alignment of 0 degrees measured by the encoder with 0 degrees in the image of the motor 2 taken by the photographing device 4 in the upper computer.
2) The upper computer sends a preset step signal theta to the motor 2 driver, and the motor 2 driver controls the motor 2 to perform one-time rotation operation according to the preset step signal theta. The motor 2 driver receives the first rotation angle fed back by the decoder and feeds back the first rotation angle to the upper computer. The upper computer controls the shooting equipment 4 to shoot the motor 2 after the rotation operation to obtain a motor 2 image, the upper computer calculates the motor 2 image to obtain a second rotation angle alpha, and [ theta, alpha ] is stored in the upper computer FLASH to wait for use.
3) Repeating the operation of 2), and obtaining 360/delta theta+1 first rotation angles (0, theta, 2 theta, 3 theta, 360) and corresponding second rotation angles (0, alpha)1 ,α2 ,α3 …, 360) and stored in the FLASH of the host computer.
4) For group 360/Δθ+1 [ θ ] in 3)i ,αi ](i=0, 1,2, …/Δθ+1) performing linear interpolation operation, that is, performing linear interpolation operation on two adjacent data points with preset precision, to obtain interpolation data points between every two adjacent data points.
5) The data points obtained by linear interpolation are transmitted to a motor 2 driver after the check bits are added.
6) And the motor 2 driver writes the received data into the reserved FLASH space after passing the verification.
7) The upper computer controls the driver to restart.
8) The upper computer controls the calibrated motor 2 to repeatedly obtain 360/delta theta+1 groups [ theta ] according to the steps of 2) and 3)i ,αi ]Data. And calculate θi ,αi The difference between them, i.e. Δhi=θi -αi 。
9) If Δhi > precision is not satisfied, the unsatisfied requirements [ theta i, alpha i ] are selected, and the operations of 2) 3) 4) 5) 6) 7) 8) are repeated according to delta theta/2 step length, so as to further correct.
10 If Δhi < = precision, the process is ended, and as shown in fig. 5, a correspondence relationship between the rotation angle detected by the encoder and the standard rotation angle is generated. It should be noted that fig. 5 is only one example, and is not limited to this application, where the true angle is the second rotation angle, and the encoder angle to be calibrated is the first rotation angle.
Exemplary apparatus
Accordingly, fig. 6 is a schematic structural diagram of an encoder calibration device according to an embodiment of the present application. In an exemplary embodiment, there is provided a calibration apparatus of an encoder, including:
a first control module 610, configured to control the motor to perform N rotation operations, receive, after each rotation operation of the motor, a first rotation angle of the motor detected by the encoder, and control the photographing apparatus to photograph the motor after the rotation operation, obtain a motor image, and determine a second rotation angle of the motor based on the motor image;
The second control module 620 is configured to generate a corresponding relationship between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles; the correspondence is used for calibrating the rotation angle detected by the encoder.
In one embodiment, the second control module 620 is further configured to:
and carrying out linear interpolation calculation on the N first rotation angles and the N second rotation angles by using preset precision to obtain the corresponding relation between the rotation angles detected by the encoder and the second rotation angles.
In one embodiment, the apparatus further comprises:
and the verification module is used for outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle under the condition that the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle meets the accuracy verification condition.
In one embodiment, the verification module is further configured to:
controlling the motor to rotate, after each rotation operation of the motor, receiving a first rotation angle of the motor detected by the encoder, determining a standard rotation angle corresponding to the first rotation angle according to the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle, and determining the standard rotation angle as an updated first rotation angle;
Controlling the shooting equipment to shoot the motor after the rotating operation to obtain a motor image, and determining a second rotating angle of the motor based on the motor image;
and outputting the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle under the condition that the difference value between the updated first rotation angle and the second rotation angle is not larger than a preset precision threshold value.
In one embodiment, the verification module is further configured to:
and under the condition that the difference value between the updated first rotation angle and the updated second rotation angle is larger than a preset precision threshold value, reducing the rotation angle parameter for controlling the motor to rotate each time, and controlling the motor to rotate for N times according to the rotation angle parameter.
In one embodiment, the controller includes: the upper computer is connected with the motor driver; correspondingly, the motor is controlled to perform N times of rotation operation, after each rotation operation of the motor, a first rotation angle of the motor detected by the encoder is received, the shooting equipment is controlled to shoot the motor after the rotation operation, a motor image is obtained, and a second rotation angle of the motor is determined based on the motor image; according to the N first rotation angles and the N second rotation angles, generating a correspondence between the rotation angle detected by the encoder and a standard rotation angle, including:
The upper computer sends N rotation angle parameters to the motor driver so that the motor driver controls the motor to perform N rotation operations, and after each rotation operation of the motor, the first rotation angle of the motor detected by the encoder is received;
the upper computer controls the shooting equipment to shoot the motor after the rotating operation under the condition that the first rotating angle sent by the motor driver is received each time, so as to obtain a motor image, and determines a second rotating angle of the motor based on the motor image;
and the upper computer generates a corresponding relation between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles.
In one embodiment, after the upper computer generates the correspondence between the rotation angle detected by the encoder and the standard rotation angle according to the N first rotation angles and the N second rotation angles, the method further includes:
and storing the corresponding relation between the rotation angle detected by the encoder and the standard rotation angle into the motor driver.
In one embodiment, a calibration support is mounted on a motor shaft, so that when the motor rotates, the calibration support rotates along a plane, and accordingly, the control of the photographing device to photograph the motor after the rotation operation, to obtain a motor image, includes:
And controlling the optical axis of the shooting equipment to be perpendicular to the rotating plane of the calibration support to shoot the motor after the rotating operation, so as to obtain a motor image.
Fig. 7 is a schematic structural view of a calibration device of an encoder according to an embodiment of the present application. In an exemplary embodiment, there is also provided a calibration system of an encoder, including: the device comprises a controller, shooting equipment, a motor, an encoder and a calibration bracket;
a calibration bracket is arranged on the motor rotating shaft so that the calibration bracket rotates along a plane when the motor rotates;
the controller is respectively in communication connection with the shooting equipment, the motor and the encoder;
the controller implements any one of the encoder calibration methods provided in the embodiments described above.
The device provided in this embodiment belongs to the same application conception as the method provided in the foregoing embodiment of the present application, and may perform the method provided in any of the foregoing embodiments of the present application, and has the corresponding functional modules and beneficial effects of the execution method. Technical details not described in detail in this embodiment may be referred to the specific processing content of the method provided in the foregoing embodiment of the present application, and will not be described herein again.
Exemplary electronic device
Another embodiment of the present application further proposes an electronic device, referring to fig. 8, including:
a memory 800 and a processor 810;
wherein the memory 800 is connected to the processor 810, and is used for storing a program;
the processor 810 is configured to implement the method for calibrating the encoder disclosed in any of the above embodiments by executing the program stored in the memory 800.
Specifically, the electronic device may further include: a bus, a communication interface 820, an input device 830, and an output device 840.
Processor 810, memory 800, communication interface 820, input device 830, and output device 840 are interconnected by a bus. Wherein:
a bus may comprise a path that communicates information between components of a computer system.
The processor 810 may be a general-purpose processor, such as a general-purpose Central Processing Unit (CPU), microprocessor, etc., or may be an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present invention. But may also be a Digital Signal Processor (DSP), application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components.
Processor 810 may include a host processor, and may also include a baseband chip, modem, and the like.
The memory 800 stores programs for implementing the technical scheme of the present invention, and may also store an operating system and other key services. In particular, the program may include program code including computer-operating instructions. More specifically, memory 800 may include read-only memory (ROM), other types of static storage devices that may store static information and instructions, random access memory (random access memory, RAM), other types of dynamic storage devices that may store information and instructions, disk storage, flash, and the like.
The input device 830 may include means for receiving data and information entered by a user, such as a keyboard, mouse, camera, scanner, light pen, voice input device, touch screen, pedometer, or gravity sensor, among others.
Output device 840 may include means such as a display screen, printer, speakers, etc. that allow information to be output to a user.
Communication interface 820 may include a device such as an ethernet, radio Access Network (RAN), wireless Local Area Network (WLAN), etc. using any transceiver to communicate with other devices or communication networks.
The processor 810 executes programs stored in the memory 800 and invokes other devices that may be used to implement the various steps of any of the encoder calibration methods provided in the above-described embodiments of the present application.
Exemplary computer program product and storage Medium
In addition to the methods and apparatus described above, embodiments of the present application may also be a computer program product comprising computer program instructions which, when executed by a processor, cause the processor to perform steps in a method of calibrating an encoder according to various embodiments of the present application described in the "exemplary methods" section of the present specification.
The computer program product may write program code for performing the operations of embodiments of the present application in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server.
In addition, embodiments of the present application may also be a storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the method for calibrating an encoder according to various embodiments of the present application described in the above "exemplary method" section of the present application, and specific working contents of the electronic device and specific working contents of the computer program product and the computer program on the storage medium when the computer program is executed by the processor may refer to those of the above method embodiment, which are not repeated herein.
For the foregoing method embodiments, for simplicity of explanation, the methodologies are shown as a series of acts, but one of ordinary skill in the art will appreciate that the present application is not limited by the order of acts described, as some acts may, in accordance with the present application, occur in other orders or concurrently. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required in the present application.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described as different from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other. For the apparatus class embodiments, the description is relatively simple as it is substantially similar to the method embodiments, and reference is made to the description of the method embodiments for relevant points.
The steps in the method of each embodiment of the application can be sequentially adjusted, combined and deleted according to actual needs, and the technical features described in each embodiment can be replaced or combined.
The modules and sub-modules in the device and the terminal of the embodiments of the present application may be combined, divided, and deleted according to actual needs.
In the embodiments provided in the present application, it should be understood that the disclosed terminal, apparatus and method may be implemented in other manners. For example, the above-described terminal embodiments are merely illustrative, and for example, the division of modules or sub-modules is merely a logical function division, and there may be other manners of division in actual implementation, for example, multiple sub-modules or modules may be combined or integrated into another module, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or modules, which may be in electrical, mechanical, or other forms.
The modules or sub-modules illustrated as separate components may or may not be physically separate, and components that are modules or sub-modules may or may not be physical modules or sub-modules, i.e., may be located in one place, or may be distributed over multiple network modules or sub-modules. Some or all of the modules or sub-modules may be selected according to actual needs to achieve the purpose of the embodiment.
In addition, each functional module or sub-module in each embodiment of the present application may be integrated in one processing module, or each module or sub-module may exist alone physically, or two or more modules or sub-modules may be integrated in one module. The integrated modules or sub-modules may be implemented in hardware or in software functional modules or sub-modules.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software unit executed by a processor, or in a combination of the two. The software elements may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.