Motor positioning method, device, storage medium and electronic equipment
By controlling the rotation of the lidar motor to zero position and adjusting the speed in real time, the problems of low manual positioning efficiency and low accuracy are solved, and efficient and accurate motor positioning is achieved.
Patent Information
- Application Number
- CN202410733067.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2044-06-06
AI Technical Summary
In the prior art, motor positioning relies on manual implementation, and there are problems such as high labor costs, low efficiency and varying accuracy.
By controlling the motor to rotate to zero when obtaining the initial target value, the target rotation direction of the motor is determined based on the target value and zero position, and the rotation speed is adjusted in real time to achieve precise positioning.
On the premise of ensuring positioning accuracy, shorten the positioning time, improve positioning efficiency, and improve the accuracy of motor positioning.
Smart Images

Figure CN118707534B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of laser radar, and in particular to a motor positioning method, device, storage medium and electronic equipment. Background Art
[0002] LiDAR is a radar that emits laser beams to detect the position, speed and other characteristic quantities of a target. LiDAR emits lasers to illuminate the target and receives its echo, thereby obtaining information such as the distance, direction and height from the target to the electromagnetic wave emission point. The prism and galvanometer in the LiDAR are very important for the propagation path of the laser. The prism and galvanometer can be adjusted by the corresponding motors. The prism motor and the galvanometer motor are both important components in the LiDAR. Therefore, during the calibration process of the LiDAR, the prism motor and the galvanometer motor need to be calibrated. Calibration of the motor involves precise positioning of the motor. Currently, motor positioning relies on manual work, which has problems such as high labor costs, low efficiency and low accuracy. Summary of the invention
[0003] An object of the present invention is to provide a motor positioning method, device, storage medium and electronic device to at least partially improve the above-mentioned problem.
[0004] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0005] In a first aspect, an embodiment of the present invention provides a motor positioning method, the method comprising: when an initial first target value is obtained, controlling the motor to rotate to a zero position; determining the target rotation direction of the motor based on the first target value and the zero position; determining the current target speed of the motor based on the first target value, a real-time value of an encoder of the motor, and the target rotation direction; controlling the rotation of the motor based on the current target speed and the target rotation direction until the positioning of the first target value is completed, and the completion of the positioning of the first target value means that the length of the interval between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to a first preset value.
[0006] Based on this, the motor speed is controlled in real time during the positioning process to shorten the positioning time and improve the positioning efficiency while ensuring the positioning accuracy. And based on the shortest rotation distance from the zero position to the first target value in the target rotation direction, the positioning efficiency can also be improved.
[0007] Optionally, before determining the target rotation direction of the motor based on the first target value and the zero position, the method further includes: if the first target value is greater than or equal to a one-circle value of the encoder, adjusting the first target value based on the one-circle value so that the adjusted first target value is greater than or equal to 0 and less than the one-circle value; wherein the one-circle value corresponds to a count value of the encoder when the motor rotates one circle.
[0008] By adjusting the first target value to be greater than or equal to 0 and less than one circle value, the accuracy of the subsequent determination of the rotation direction and rotation speed can be guaranteed, which is conducive to accurate and rapid completion of positioning. Based on this, the accuracy of the subsequent determination of the target rotation direction and rotation speed can be guaranteed, further ensuring the accuracy of positioning.
[0009] Optionally, the step of determining the target rotation direction of the motor based on the first target value and the zero position includes: determining whether the difference between the first target value and the zero position is less than a half-circle value, wherein the half-circle value corresponds to a count value of the encoder when the motor rotates half a circle; if so, determining that the target rotation direction is forward rotation; if not, determining that the target rotation direction is reverse rotation.
[0010] Based on this, the target rotation direction can be determined to ensure the efficiency of motor positioning.
[0011] Optionally, the step of determining the current target speed of the motor based on the first target value, the real-time value of the encoder of the motor and the target rotation direction includes: determining a first target rotation length based on the first target value, the real-time value of the encoder of the motor and the target rotation direction, wherein the first target rotation length is the length of the interval between the real-time value of the encoder and the first target value along the target rotation direction; when the first target rotation length is greater than a second preset value, determining the current target speed based on the first target rotation length; when the first target rotation length is less than or equal to the second preset value and greater than the first preset value, using the first fixed speed as the current target speed.
[0012] Based on this, the target speed can be set flexibly, so as to take into account both the accuracy and efficiency of the positioning results.
[0013] Optionally, when the first target rotation length is greater than a second preset value, the current target rotation speed is the product of the first target rotation length and a preset coefficient.
[0014] Optionally, the formula for the first target rotation length is:
[0015] Position3=Position1-Position2;
[0016] Position4=ABS(Position3), ABS(Position3)≤Position0÷2;
[0017] Position4=Position0-ABS(Position3), ABS(Position3)>Position0÷2;
[0018] Among them, Position1 represents the first target value, Position2 represents the real-time value of the encoder of the motor, Position4 represents the first target rotation length, Position0 represents one circle value, and ABS() represents the absolute value function.
[0019] Optionally, the first preset value matches the first fixed rotation speed, thereby ensuring that positioning can be completed accurately.
[0020] Optionally, the step of controlling the motor to rotate to zero position includes: controlling the motor to rotate in an open loop; and determining that the motor rotates to zero position when a zero position signal transmitted by the encoder is obtained. By monitoring the zero position signal, ensuring that the motor rotates to zero position accurately is beneficial to the accuracy of subsequent control.
[0021] Optionally, the method further includes: receiving a first target value transmitted by a host computer.
[0022] Optionally, after the motor is controlled to rotate to the zero position, the method further includes: when a new second target value is obtained, determining the target rotation direction of the motor based on the second target value and the current value of the encoder; determining the current target speed of the motor based on the second target value, the real-time value of the encoder of the motor and the target rotation direction; controlling the rotation of the motor based on the current target speed and the target rotation direction until the positioning of the second target value is completed, and completing the positioning of the second target value means that the interval length between the real-time value of the encoder and the second target value along the target rotation direction is less than or equal to a first preset value.
[0023] After obtaining the initial first target value and controlling the motor to rotate to zero position, a new second target value may be received during the process of controlling the motor to rotate toward the first target value. Based on this, the motor positioning can be accurately completed when the target value changes.
[0024] In a second aspect, an embodiment of the present invention provides a motor positioning device, the device comprising:
[0025] The first processing unit is used to control the motor to rotate to a zero position when an initial first target value is obtained;
[0026] The first processing unit is further used to determine a target rotation direction of the motor based on the first target value and a zero position;
[0027] The first processing unit is further used to determine a current target speed of the motor based on the first target value, a real-time value of an encoder of the motor, and the target rotation direction;
[0028] The second processing unit is used to control the rotation of the motor based on the current target speed and the target rotation direction until the positioning of the first target value is completed. Completing the positioning of the first target value means that the interval length between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to a first preset value.
[0029] In a third aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, and the computer program implements the above method when executed by a processor.
[0030] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising: a processor and a memory, wherein the memory is used to store one or more programs; when the one or more programs are executed by the processor, the above method is implemented.
[0031] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope of the present invention. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0033] Figure 1 A schematic diagram of the structure of an electronic device provided by the present invention;
[0034] Figure 2 A communication system block diagram provided by the present invention;
[0035] Figure 3 One of the flow charts of the motor positioning method provided by the present invention;
[0036] Figure 4 The second flowchart of the motor positioning method provided by the present invention;
[0037] Figure 5 The third flowchart of the motor positioning method provided by the present invention;
[0038] Figure 6 A fourth flow chart of the motor positioning method provided by the present invention;
[0039] Figure 7 A unit schematic diagram of the motor positioning device provided by the present invention.
[0040] In the figure: 10 - processor; 11 - memory; 12 - bus; 13 - communication interface; 100 - motor controller; 200 - host computer; 300 - motor; 501 - first processing unit; 502 - second processing unit. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0042] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but only represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0044] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0045] In the description of the present invention, it should be noted that the terms "upper", "lower", "inside", "outside", etc. indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings, or are directions or positional relationships in which the product of the invention is usually placed when in use. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as a limitation on the present invention.
[0046] In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "disposed" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0047] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0048] The prism and galvanometer in the laser radar are very important for the propagation path of the laser, and the prism and galvanometer can be adjusted by the corresponding motors. In the laser radar, the prism motor and the galvanometer motor are both important components. Therefore, in the laser radar calibration process, the prism motor and the galvanometer motor need to be calibrated. In order to solve the current problem that the motor positioning relies on manual implementation, and there are problems such as high labor cost, low efficiency and low precision, the present invention provides a motor positioning method, which can be but not limited to positioning the prism motor and the galvanometer motor, and can be but not limited to the motor controller in the laser radar.
[0049] The embodiment of the present invention provides an electronic device, which may be a motor controller in a laser radar, or a mobile phone, a computer, or a server connected to a motor, or a laser radar including a click controller. Figure 1 , a schematic diagram of the structure of an electronic device. The electronic device includes a processor 10, a memory 11, and a bus 12. The processor 10 and the memory 11 are connected via the bus 12, and the processor 10 is used to execute an executable module stored in the memory 11, such as a computer program.
[0050] The processor 10 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the motor positioning method can be completed by the hardware integrated logic circuit in the processor 10 or the instructions in the form of software. The above-mentioned processor 10 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0051] The memory 11 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0052] The bus 12 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus. Figure 1 Although only one bidirectional arrow is used in the figure, it does not mean that there is only one bus 12 or only one type of bus 12 .
[0053] The memory 11 is used to store programs, such as programs corresponding to the motor positioning device. The motor positioning device includes at least one software function module that can be stored in the memory 11 in the form of software or firmware or fixed in the operating system (OS) of the electronic device. After receiving the execution instruction, the processor 10 executes the program to implement the motor positioning method.
[0054] Possibly, the electronic device provided by the embodiment of the present invention further includes a communication interface 13. The communication interface 13 is connected to the processor 10 via a bus.
[0055] Please refer to Figure 2 , Figure 2 The communication system block diagram provided by the present invention. The host computer 200, the motor controller 100 and the motor 300 are connected in sequence. Specifically, the motor controller 100 can be connected to the host computer 200 through the communication interface 13 (serial port). The motor controller 100 can also be connected to the encoder (also called the position encoder) in the motor 300. The motor (including the prism motor and the galvanometer motor) in the present invention can be but is not limited to a permanent magnet brushless synchronous motor with an incremental encoder. When the motor rotates forward, the encoder value (also called the position encoder AB count value) increases, and when the motor rotates reversely, the encoder value decreases.
[0056] It should be understood that Figure 1 The structure shown is only a schematic diagram of a portion of the electronic device. The electronic device may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0057] A motor positioning method provided by an embodiment of the present invention can be applied to but not limited to Figure 1 For detailed procedures, please refer to the electronic equipment shown in Figure 3 The motor positioning method includes: S102, S104, S105, S106, S107 and S108, which are described in detail as follows.
[0058] S102, when the initial first target value is obtained, controlling the motor to rotate to zero position.
[0059] The first target value is a target count value relative to an encoder of the motor.
[0060] S104, determining a target rotation direction of the motor based on the first target value and the zero position.
[0061] The target rotation direction is forward rotation or reverse rotation, and the rotation distance from the zero position to the first target value based on the target rotation direction is the shortest.
[0062] S105, determining a current target rotation speed of the motor based on the first target value, the real-time value of the encoder of the motor, and the target rotation direction.
[0063] S106, controlling the rotation of the motor based on the current target speed and target rotation direction.
[0064] S107, obtaining the real-time value of the motor encoder.
[0065] S108, determining whether the first target value has been located. If yes, then the process ends; if no, then S105 is repeated.
[0066] Completing the positioning of the first target value means that the interval length between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to a first preset value, and the value of the first preset value can be but is not limited to 2.
[0067] It should be noted that the real-time value of the motor's encoder can be continuously obtained at preset periodic intervals. After each acquisition of the real-time value of the motor's encoder, S108 needs to be executed. If the positioning of the first target value is not completed, S105 needs to be repeated to determine the new current target speed, so that the motor speed can be controlled in real time during the positioning process. Under the premise of ensuring positioning accuracy, the positioning time can be shortened as much as possible.
[0068] In summary, the present invention provides a motor positioning method, including: when the initial first target value is obtained, controlling the motor to rotate to zero position; determining the target rotation direction of the motor based on the first target value and the zero position; determining the current target speed of the motor based on the first target value, the real-time value of the motor encoder and the target rotation direction; controlling the motor rotation based on the current target speed and the target rotation direction until the first target value is positioned, and the positioning of the first target value is completed when the interval length between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to the first preset value. Real-time control of the motor speed during the positioning process can shorten the positioning time as much as possible and improve the positioning efficiency while ensuring the positioning accuracy.
[0069] exist Figure 3 On the basis of how to further ensure the accuracy of positioning, the embodiment of the present invention also provides an optional implementation method, please refer to Figure 4 , before determining the target rotation direction of the motor based on the first target value and the zero position in S104, the motor positioning method also includes: S103, which is specifically described as follows.
[0070] S103: If the first target value is greater than or equal to the one-turn value of the encoder, adjust the first target value based on the one-turn value so that the adjusted first target value is greater than or equal to 0 and less than the one-turn value.
[0071] Among them, one circle value corresponds to the count value of the encoder when the motor rotates one circle (from the zero position).
[0072] When the motor encoder is a 1000-line incremental encoder, the AB count value of the encoder is 4000 when the motor rotates one circle, that is, the value of one circle is 4000.
[0073] Regarding how to adjust the first target value in S103, the embodiment of the present invention further provides an optional implementation method, please refer to the following, the formula for the adjusted first target value is:
[0074] T1 = T0 + n × Position0;
[0075] Wherein, T1 represents the first target value after adjustment, T0 represents the first target value before adjustment, Position0 represents a circle value, n is an integer (positive or negative), and 0≤T1<Position0.
[0076] By adjusting the first target value to be greater than or equal to 0 and less than one circle value, the accuracy of the subsequent determination of the rotation direction and rotation speed can be guaranteed, which is conducive to accurate and rapid positioning.
[0077] exist Figure 3 On the basis of how to determine the target rotation direction to ensure the efficiency of motor positioning, the embodiment of the present invention also provides an optional implementation method, please refer to the following. S104, the step of determining the target rotation direction of the motor based on the first target value and the zero position includes: S104-1, S104-2 and S104-3, which are specifically described as follows.
[0078] S104-1, determine whether the difference between the first target value and the zero position is less than the half-circle value. If yes, execute S104-2; if not, execute S104-3.
[0079] Among them, the half-turn value corresponds to the count value of the encoder when the motor rotates half a turn, and the half-turn value is half of the one-turn value.
[0080] It should be noted that when the difference between the first target value and the zero position is less than half a circle, it means that when rotating in the forward direction, the rotation distance from the zero position to the first target value is the shortest. When the difference between the first target value and the zero position is greater than half a circle, it means that when rotating in the reverse direction, the rotation distance from the zero position to the first target value is the shortest. When the two are equal, either forward rotation or reverse rotation is possible.
[0081] Taking a circle value of 4000 as an example, when the first target value is 1000, when rotating in the forward direction, the rotation distance from the zero position to the first target value is the shortest, that is, the first target rotation length is 1000; when the first target value is 2500, when rotating in the reverse direction, the rotation distance from the zero position to the first target value is the shortest, that is, the first target rotation length is 1500.
[0082] S104-2, determining that the target rotation direction is forward rotation.
[0083] S104-3, then determine that the target rotation direction is reverse rotation.
[0084] exist Figure 3 On the basis of how to flexibly set the target speed so as to take into account both the accuracy of the positioning result and the positioning efficiency, the present invention also provides an optional implementation method, please refer to the following. S105, the step of determining the current target speed of the motor based on the first target value, the real-time value of the motor encoder and the target rotation direction, includes: S105-1, S105-2 and S105-3, which are specifically described as follows.
[0085] S105-1, determining a first target rotation length based on the first target value, the real-time value of the motor encoder, and the target rotation direction.
[0086] The first target rotation length is the interval length between the real-time value of the encoder and the first target value along the target rotation direction.
[0087] Optionally, the formula for the first target rotation length is:
[0088] Position3=Position1-Position2;
[0089] Position4=ABS(Position3), ABS(Position3)≤Position0÷2;
[0090] Position4=Position0-ABS(Position3), ABS(Position3)>Position0÷2;
[0091] Among them, Position1 represents the first target value, Position2 represents the real-time value of the motor encoder, Position4 represents the first target rotation length, Position0 represents one circle value, and ABS() represents the absolute value function.
[0092] To further illustrate the relationship between the first target value, the encoder real-time value, the first target rotation length, and the rotation direction, please refer to the following Table 1.
[0093] Position1 Position2 Rotation direction Position 4 1000 0 Positive 1000 2500 0 Reverse 1500
[0094] Table 1
[0095] S105-2, when the first target rotation length is greater than a second preset value, determining a current target rotation speed based on the first target rotation length.
[0096] When the first target rotation length is greater than the second preset value, the value of the current target rotation speed may be the product of the first target rotation length and the preset coefficient. The second preset value may be, but is not limited to, 100, the value of the preset coefficient may be, but is not limited to, 0.1, and the unit corresponding to the rotation speed is rpm. Flexible setting of the rotation speed at this stage can shorten the time to the target position, and at the same time, the rotation speed transitions smoothly, so that the motor runs smoothly.
[0097] S105-3, when the first target rotation length is less than or equal to the second preset value and greater than the first preset value, the first fixed rotation speed is used as the current target rotation speed.
[0098] If the current target speed is set based on the first target rotation length, the current target speed will continue to decrease, which will increase the time to reach the target position. In this stage, by setting the speed to a fixed speed, the situation where the speed will become slower and slower is avoided, thereby shortening the time to reach the target position.
[0099] The value of the first fixed rotation speed may be but is not limited to 5 rpm.
[0100] It should be noted that when the motor rotates at the first fixed speed, the real-time value of the motor encoder will still be obtained in real time to determine whether the positioning of the first target value is completed. When the interval length between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to the first preset value, it is determined that the positioning of the first target value is completed. At this time, the speed can be set to 0, but because there will be inertia when the motor rotates at the first fixed speed, the motor will continue to rotate toward the first target value, and the two will be closer.
[0101] In an optional embodiment, the first preset value matches the first fixed speed. When the first fixed speed is larger, the inertia is larger, and the rotation distance is longer after the speed is set to 0, so the first preset value can be larger, and when the first fixed speed is smaller, the first preset value is smaller.
[0102] exist Figure 2 On the basis of how to control the motor to rotate to zero position to ensure the accuracy of subsequent control, the embodiment of the present invention also provides an optional implementation method, please refer to the following. The step of controlling the motor to rotate to zero position includes; S102-1 and S102-2, which are specifically described as follows.
[0103] S102-1, control the motor to rotate in open loop.
[0104] The speed of the open-loop rotation may be but is not limited to 20 rpm.
[0105] S102-2, when the zero position signal transmitted by the encoder is obtained, it is determined that the motor rotates to the zero position.
[0106] Among them, the zero position signal is also called the z signal.
[0107] When the motor rotates to the zero position, the encoder generates a zero position signal and transmits it to the motor controller. When the motor controller obtains the zero position signal transmitted by the encoder, it determines that the motor rotates to the zero position.
[0108] Regarding how to obtain the first target value, the embodiment of the present invention also provides an optional implementation method, please refer to Figure 5 , the motor positioning method also includes: S101, which is specifically described as follows.
[0109] S101, receiving a first target value transmitted by a host computer.
[0110] Optionally, the host computer sends a first target position instruction to the motor controller, where the first target position instruction includes a first target value.
[0111] In an optional implementation, when positioning is completed, the motor controller may feed back a completed instruction to a host computer via a serial port.
[0112] In one possible scenario, after obtaining the initial first target value and controlling the motor to rotate to zero, a new second target value may be received during the process of controlling the motor to rotate toward the first target value. In this case, regarding how to accurately complete the motor positioning when the target value changes, the embodiment of the present invention also provides an optional implementation method, please refer to Figure 6 The motor positioning method also includes: S111, S112, S113, S114 and S115, which are described in detail as follows.
[0113] S111, when a new second target value is obtained, determining a target rotation direction of the motor based on the second target value and a current value of the encoder.
[0114] Optionally, regarding how to determine the target rotation direction of the motor based on the second target value and the current value of the encoder when a new second target value is obtained, the embodiment of the present invention also provides an optional implementation method, please refer to the following.
[0115] Get the difference between the second target value and the current value of the encoder (Position6).
[0116] The current value of the encoder is the real-time value of the encoder at the moment when the second target value is obtained.
[0117] Determine whether Position6≤-Position0÷2 or 0≤Position6Position0÷2 is true.
[0118] If either of the two conditions holds true, the target rotation direction is determined to be forward rotation.
[0119] If neither of the two conditions is true, the target rotation direction is determined to be reverse rotation.
[0120] S112, determining a current target rotation speed of the motor based on the second target value, the real-time value of the motor encoder, and the target rotation direction.
[0121] Optionally, the second target rotation length is determined based on the second target value, the real-time value of the encoder of the motor and the target rotation direction, wherein the second target rotation length is the interval length between the real-time value of the encoder and the first target value along the target rotation direction.
[0122] Optionally, the formula for the second target rotation length is:
[0123] Position6=Position5-Position2;
[0124] Position7=ABS(Position6),ABS(Position6)≤Position0÷2;
[0125] Position7=Position0-ABS(Position6), ABS(Position6)>Position0÷2;
[0126] Among them, Position5 represents the second target value, Position2 represents the real-time value of the motor encoder, Position7 represents the second target rotation length, Position0 represents one circle value, and ABS() represents the absolute value function.
[0127] To further illustrate the relationship between the second target value, the encoder real-time value, the second target rotation length, and the rotation direction, please refer to Table 2 below.
[0128] Position 5 Position2 Rotation direction Position7 2000 1000 Positive 1000 500 1000 Reverse 500 3500 1000 Reverse 1500 500 3500 Positive 1000 500 2600 Positive 1900
[0129] Table 2
[0130] When the second target rotation length is greater than the second preset value, the current target rotation speed is determined based on the second target rotation length.
[0131] When the second target rotation length is less than or equal to the second preset value and greater than the first preset value, the first fixed rotation speed is used as the current target rotation speed.
[0132] S113, controlling the rotation of the motor based on the current target speed and target rotation direction.
[0133] S114, obtaining the real-time value of the motor encoder.
[0134] S115, determining whether the positioning of the second target value is completed. If not, repeating S112; if yes, ending.
[0135] Completing the positioning of the second target value means that the length of the interval between the real-time value of the encoder and the second target value along the target rotation direction is less than or equal to the first preset value.
[0136] See also Figure 7 , Figure 7 An embodiment of the present invention provides a motor positioning device. Optionally, the motor positioning device is applied to the electronic device described above.
[0137] The motor positioning device includes: a first processing unit 501 and a second processing unit 502 .
[0138] The first processing unit 501 is used to control the motor to rotate to zero position when the initial first target value is obtained;
[0139] The first processing unit 501 is further configured to determine a target rotation direction of the motor based on the first target value and the zero position;
[0140] The first processing unit 501 is further configured to determine a current target rotation speed of the motor based on the first target value, a real-time value of an encoder of the motor, and the target rotation direction;
[0141] The second processing unit 502 is used to control the rotation of the motor based on the current target speed and the target rotation direction until the positioning of the first target value is completed. Completing the positioning of the first target value means that the interval length between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to a first preset value.
[0142] Optionally, the first processing unit 501 may execute the above-mentioned S101-S105, S107-S108, S111-S112 and S114-S115, and the second processing unit 502 may execute the above-mentioned S106 and S113.
[0143] It should be noted that the motor positioning device provided in this embodiment can execute the method flow shown in the above method flow embodiment to achieve the corresponding technical effect. For the sake of brief description, for parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above embodiment.
[0144] The embodiment of the present invention further provides a storage medium, which stores computer instructions and programs, and when the computer instructions and programs are read and run, the motor positioning method of the above embodiment is executed. The storage medium may include a memory, a flash memory, a register, or a combination thereof.
[0145] The following provides an electronic device, which can be a central control system of a laser radar or a motor controller in a laser radar, or a computer device connected to a laser radar, such as a mobile phone, a driving computer, and a server, etc. The electronic device can also be a laser radar. Figure 1 As shown, the above motor positioning method can be implemented; specifically, the electronic device includes: a processor 10, a memory 11, and a bus 12. The processor 10 can be a CPU. The memory 11 is used to store one or more programs. When the one or more programs are executed by the processor 10, the motor positioning method of the above embodiment is executed.
[0146] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection circle of the present invention.
[0147] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered in all respects as exemplary and non-restrictive, and the scope of the invention is defined by the appended claims rather than the above description, and it is intended that the meaning and all variations within the scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
Claims
1. A motor positioning method, characterized in that: The method comprises: When the initial first target value is obtained, the motor is controlled to rotate to zero position; determining a target rotation direction of the motor based on the first target value and a zero position; Determining a current target speed of the motor based on the first target value, a real-time value of an encoder of the motor, and the target rotation direction; Controlling the rotation of the motor based on the current target speed and the target rotation direction until the positioning of the first target value is completed, wherein the positioning of the first target value is completed when the interval length between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to a first preset value; The step of determining the target rotation direction of the motor based on the first target value and the zero position includes: determining whether the difference between the first target value and the zero position is less than a half-circle value, wherein the half-circle value corresponds to the count value of the encoder when the motor rotates half a circle; if so, determining that the target rotation direction is forward rotation; if not, determining that the target rotation direction is reverse rotation.
2. The motor positioning method according to claim 1, characterized in that: Before determining the target rotation direction of the motor based on the first target value and the zero position, the method further includes: If the first target value is greater than or equal to a one-turn value of the encoder, adjusting the first target value based on the one-turn value so that the adjusted first target value is greater than or equal to 0 and less than the one-turn value; The one-turn value corresponds to the count value of the encoder when the motor rotates one turn.
3. The motor positioning method according to claim 1, characterized in that: The step of determining the current target speed of the motor based on the first target value, the real-time value of the encoder of the motor, and the target rotation direction comprises: Determine a first target rotation length based on the first target value, the real-time value of the encoder of the motor, and the target rotation direction, wherein the first target rotation length is the length of an interval between the real-time value of the encoder and the first target value along the target rotation direction; When the first target rotation length is greater than a second preset value, determining the current target rotation speed based on the first target rotation length; When the first target rotation length is less than or equal to the second preset value and greater than the first preset value, the first fixed rotation speed is used as the current target rotation speed.
4. The motor positioning method according to claim 3, characterized in that: When the first target rotation length is greater than a second preset value, the current target rotation speed is the product of the first target rotation length and a preset coefficient.
5. The motor positioning method according to claim 3, characterized in that: The formula for the first target rotation length is: Position3=Position1-Position2; Position4=ABS(Position3), ABS(Position3)≤Position0÷2; Position4=Position0-ABS(Position3), ABS(Position3)>Position0÷2; Among them, Position1 represents the first target value, Position2 represents the real-time value of the encoder of the motor, Position4 represents the first target rotation length, Position0 represents one circle value, and ABS() represents the absolute value function.
6. The motor positioning method according to claim 3, characterized in that: The first preset value matches the first fixed rotation speed.
7. The motor positioning method according to claim 1, characterized in that: The step of controlling the motor to rotate to zero position comprises: Controlling the motor to rotate in an open loop; When the zero position signal transmitted by the encoder is acquired, it is determined that the motor rotates to the zero position.
8. The motor positioning method according to claim 1, characterized in that: The method further comprises: Receive the first target value transmitted by the host computer.
9. The motor positioning method according to claim 1, characterized in that: After the control motor rotates to the zero position, the method further includes: When a new second target value is obtained, determining a target rotation direction of the motor based on the second target value and a current value of the encoder; Determining a current target speed of the motor based on the second target value, a real-time value of an encoder of the motor, and the target rotation direction; The motor rotation is controlled based on the current target speed and the target rotation direction until the second target value is positioned. Completing the positioning of the second target value means that the interval length between the real-time value of the encoder and the second target value along the target rotation direction is less than or equal to a first preset value.
10. A motor positioning device, characterized in that: The device comprises: The first processing unit is used to control the motor to rotate to a zero position when an initial first target value is obtained; The first processing unit is further used to determine a target rotation direction of the motor based on the first target value and a zero position; The first processing unit is further used to determine a current target speed of the motor based on the first target value, a real-time value of an encoder of the motor, and the target rotation direction; The second processing unit is used to control the rotation of the motor based on the current target speed and the target rotation direction until the positioning of the first target value is completed, and the positioning of the first target value is completed when the interval length between the real-time value of the encoder and the first target value along the target rotation direction is less than or equal to a first preset value; The method of determining the target rotation direction of the motor based on the first target value and the zero position includes: determining whether the difference between the first target value and the zero position is less than a half-circle value, wherein the half-circle value corresponds to a count value of the encoder when the motor rotates half a circle; if so, determining that the target rotation direction is forward rotation; if not, determining that the target rotation direction is reverse rotation.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
12. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store one or more programs; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Method for automatically positioning main shaft during roller exchange of finishing mill
CN102463263A
Servo motor control method and system
CN109546922A
Encoder-based turntable rotation control method and control system
CN116639531A