Motor position calculation method, system and device and readable storage medium
By standardizing the feedback data of the servo system and managing multiple revolutions, the development and maintenance challenges of different feedback types were solved, high-precision motor position calculation was achieved, and the scalability and positioning accuracy of the system were improved.
Patent Information
- Application Number
- CN202511839817.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-02-17
AI Technical Summary
In existing technologies, servo drives and encoders have different protocols, resolutions, and timing characteristics, which means that control systems need to write separate parsing and processing logic for each type of feedback, increasing development costs and maintenance complexity, and also causing problems such as data overflow, position jumps, and power-off retention.
A three-layer abstract architecture of "channel object - conversion table object - motor object" is adopted to standardize the encapsulation and conversion of feedback data. Combined with incremental accumulation algorithm and multi-turn management strategy, the 32-bit feedback data is dynamically expanded to 64-bit actual position. The status of the two highest bits of the feedback value is monitored in real time to achieve continuous update and accurate judgment of position.
It reduces the complexity of code development and maintenance, improves the scalability and positioning accuracy of the system, eliminates position jump and drift problems, and ensures the reliability and accuracy of high-performance motion control.
Smart Images

Figure CN121546971A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of numerical control servo control and signal processing technology, specifically relating to a method, system, device, and readable storage medium for calculating motor position. Background Technology
[0002] With the diversified development of automated equipment and CNC systems, it has become the norm for different types of servo drives and feedback methods to coexist in the same control system.
[0003] Because different servo drives and encoders have different protocols, resolutions, and timing characteristics, control systems often need to write separate parsing and processing logic for each type of feedback. As the scale of equipment increases, this approach leads to problems such as high development costs, complex maintenance, and asynchronous latency.
[0004] In addition, existing technologies generally suffer from the following problems in motor position management: First, the overflow problem of 32-bit feedback data: During long-stroke or continuous rotational motion, the 32-bit feedback data output by the encoder may wrap around multiple times, causing the actual position calculated by the servo system to jump; Second, the power-off retention and continuity problem: When the system is powered off, multiple values are lost, and after power-on, it is impossible to determine whether the motor moved and generated data overflow during the power-off period, thus causing the position to drift after power-on; Finally, the overflow problem of rotating axes running for a long time: For axes that can rotate indefinitely (such as spindles, C-axis, etc.), the position value will increase infinitely over time, thus affecting the accuracy of calculation and the display range, and eventually leading to the overflow of position data.
[0005] Therefore, in order to address the above-mentioned technical problems, it is necessary to provide a method, system, device, and readable storage medium for calculating motor position.
[0006] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention
[0007] The purpose of this invention is to provide a method, system, device and readable storage medium for calculating motor position, which can eliminate the risk of position jump caused by data overflow and ensure high-precision positioning.
[0008] To achieve the above objectives, a specific embodiment of the present invention provides the following technical solution:
[0009] Firstly, this invention provides a method for calculating the position of a motor, applicable to multi-source feedback scenarios, which includes:
[0010] Acquire feedback data and the initial number of motor revolutions, wherein the initial number of motor revolutions represents the cumulative number of times the feedback data of the motor has experienced numerical overflow and rewind during the historical process before entering the online state;
[0011] Based on the initial number of revolutions and the feedback data obtained for the first time upon entering the online state, the initial actual position of the motor is calculated.
[0012] Based on subsequent feedback data, the actual position of the motor is updated until the motor enters an offline state.
[0013] In one or more embodiments of the present invention, the method further includes standardizing the acquired feedback data, specifically including:
[0014] Construct a channel object to encapsulate the raw feedback data emitted by the feedback source, wherein the channel object corresponds one-to-one with the feedback source;
[0015] Configure a transformation table object for each of the aforementioned channel objects. The transformation table object is used to standardize the raw feedback data in the corresponding channel based on preset rules, so as to output standardized feedback data.
[0016] In one or more embodiments of the present invention, the method further includes:
[0017] Record the values of the most significant and second-most significant bits of the feedback data;
[0018] If the values of the highest and second highest bits of the feedback data change from 01 to 10, then the number of multiple revolutions is incremented by one;
[0019] If the values of the highest and second-highest bits of the feedback data change from 10 to 01, then the number of multiple revolutions decreases by one.
[0020] In one or more embodiments of the present invention, the method further includes:
[0021] Record the number of revolutions the motor makes when it enters offline mode and the last feedback data before entering offline mode;
[0022] If the highest and second-highest bits of the last feedback data before entering the offline state are 01, and the highest and second-highest bits of the first feedback data obtained when entering the online state next time are 10, then the number of multiple cycles is incremented by one.
[0023] If the highest and second-highest bits of the last feedback data before entering the offline state are 10, and the highest and second-highest bits of the first feedback data obtained when entering the online state are 01, then the number of multiple cycles is reduced by one.
[0024] In one or more embodiments of the present invention, the formula for calculating the initial actual position of the motor based on the initial number of revolutions and the first acquired feedback data is as follows:
[0025]
[0026] in, This refers to the actual position of the motor. For multiple laps; This is the first piece of feedback data obtained; The number of bits for the motor position; The number of bits in the feedback data.
[0027] In one or more embodiments of the present invention, the actual position of the motor is updated based on subsequent feedback data, including:
[0028] Obtain the previously received feedback data and the calculated actual position of the motor;
[0029] The difference between the current feedback data and the previously received feedback data is calculated, and the sum of the difference and the previously calculated actual motor position is the current actual motor position.
[0030] In one or more embodiments of the present invention, if the motor corresponds to a continuously rotating shaft, the method further includes...
[0031] When the preset conditions are met, a modulo operation is performed on the multi-turn value of the motor to obtain a new number of multi-turns; wherein, the modulo is related to the rotation angle of the rotating shaft corresponding to one rotation of the motor.
[0032] In a second aspect, the present invention provides a motor position calculation system, comprising:
[0033] The acquisition module is used to acquire feedback data and the initial number of motor revolutions. The initial number of motor revolutions represents the cumulative number of times the feedback data of the motor has experienced numerical overflow and rewind during the historical process before entering the online state.
[0034] The calculation module is used to calculate the initial actual position of the motor based on the initial number of revolutions and the feedback data obtained for the first time when entering the online state.
[0035] The update module is used to update the actual position of the motor based on subsequent feedback data until the motor enters an offline state.
[0036] Thirdly, the present invention provides a computer device comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the motor position calculation method by executing the computer instructions.
[0037] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the motor position calculation method described above.
[0038] Compared with existing technologies, the motor position calculation method provided by this invention has the following technical advantages:
[0039] 1) By constructing a three-layer abstract architecture of "channel object - conversion table object - motor object", this invention standardizes and encapsulates feedback data from different sources and protocols, such as bus type and pulse type. This eliminates the need for the control system to write specific drivers and parsing logic for each type of hardware, significantly reducing the complexity of code development and maintenance, and improving the system's scalability and rapid adaptation capability to different encoder protocols.
[0040] 2) This invention employs an incremental accumulation algorithm to dynamically expand the 32-bit feedback data into a 64-bit actual position, and combines this with intelligent monitoring of the two highest-valued bits of the feedback value to identify and update the overflow count in real time and accurately. This enables the system to obtain continuous, non-jumping actual positions during long-stroke operation or continuous rotation of the motor, laying a reliable data foundation for high-performance motion control.
[0041] 3) Through a multi-cycle management strategy of dynamic maintenance during online operation, instantaneous saving during power failure, and intelligent correction after power-on, the system can accurately determine whether displacement or overflow occurs during power failure, thereby restoring the actual position value that is completely consistent with the physical position after power-on. This eliminates the "position drift" problem caused by data loss in traditional methods and greatly improves the absolute positioning accuracy and repeatability of the system. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is a schematic diagram illustrating an implementation scenario of the motor position calculation method in one embodiment of the present invention;
[0044] Figure 2 This is a flowchart of a motor position calculation method in one embodiment of the present invention;
[0045] Figure 3 This is a structural block diagram of a motor position calculation system according to another embodiment of the present invention;
[0046] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0047] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.
[0048] Unless otherwise expressly stated, throughout the specification and claims, the term "comprising" or its variations such as "including" or "comprises" shall be understood to include the stated elements or components without excluding other elements or other components.
[0049] Please refer to Figure 1 The diagram shows an application scenario of the click position calculation method provided by the present invention under one embodiment. The scenario specifically includes: motor 101, feedback source 102, and server 103.
[0050] Specifically, motor 101 is the controlled object, such as the feed axis motor of a CNC machine tool or the joint servo motor of a robot.
[0051] Feedback source 102 is coaxially connected to motor 101 or coupled through a transmission mechanism to detect the angular position or angular velocity of the motor rotor in real time. Feedback source 102 can be an absolute encoder, incremental encoder, rotary transformer, etc., and its output signal can be a digital bus signal (such as EtherCAT, PROFINET), analog signal, or pulse sequence.
[0052] Server 103 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. This embodiment of the invention does not limit this. Server 103 communicates with field devices (such as gateways and drives) connected to feedback source 102 via a network (such as industrial Ethernet or 5G) to receive raw feedback data. It then applies the motor position calculation method of this invention to calculate and update the position.
[0053] In one embodiment of the present invention, a user terminal may also be provided to provide users with a user interface for configuring custom parameters necessary for implementing the present invention and / or displaying the implementation process of the solution. The user terminal may be equipped with computer software programs that match the motor position calculation method provided by this method; the user terminal may include, but is not limited to, portable electronic devices or wearable electronic devices such as desktop computers (PCs), smartphones, handheld computers, tablet computers, personal digital assistants (PDAs), etc., and the embodiments of the present invention do not impose any limitations on the above.
[0054] Please refer to Figure 2 The diagram shown illustrates a flowchart of motor position calculation according to an embodiment of the present invention. The motor position calculation method specifically includes the following steps:
[0055] S201: Obtain feedback data and initial motor revolutions;
[0056] First, in embodiments of the present invention, the feedback data can refer to the raw digital signal representing the instantaneous relative position of the motor or shaft, directly generated by a position sensor mounted on the motor or mechanical shaft. It is typically a signed integer with a finite bit width, its numerical range is discrete, and it changes periodically with the rotation of the motor or the movement of the shaft. The position sensor may include, but is not limited to, photoelectric encoders, magnetic encoders, etc.; the bit width of the feedback data can be dynamically adjusted based on corresponding encoder parameters, and the embodiments of the present invention do not impose limitations on this.
[0057] It should be noted that this invention can be widely applied to multi-feedback source scenarios. Specifically, the system supports multiple feedback path configurations, allowing multiple feedback sources to act on the same motor simultaneously, or enabling multiple motors to share the same feedback source. This design allows the system to be flexibly adapted and expanded according to the needs of actual application scenarios, thereby achieving a more efficient and reliable feedback mechanism in complex control environments.
[0058] In the aforementioned multi-feedback source scenarios, due to differences in communication protocols, resolutions, and timing characteristics among different servo drives and encoders, traditional control systems often require writing separate parsing and processing logic for each feedback type. As the scale of equipment increases, this approach not only leads to high development costs and complex maintenance but may also cause problems such as inconsistent data latency and poor system synchronization.
[0059] To address the aforementioned challenges, after acquiring feedback data, this invention also provides a standardized processing method for data from multiple feedback sources, thereby resolving the development and maintenance difficulties caused by the heterogeneity of feedback devices in servo systems. Specifically, this involves establishing an independent channel object for each physical feedback source, which encapsulates the source's original feedback data, channel number, current value, and other information, thus providing a unified access interface for the upper layer.
[0060] It should be noted that data acquisition can be based on different methods depending on the type of feedback source. For example, in a specific embodiment, if the feedback source is a bus communication type, the channel data is uploaded from the driver via the corresponding bus protocol; if the feedback source is a pulse type, data is efficiently transferred from the encoder sampling register via DMA.
[0061] Building upon this foundation, the system introduces configurable conversion table objects to adapt to the protocols and signal characteristics of different encoders. Each conversion table can be bound to a channel object and, based on predefined configurations, performs operations such as protocol parsing, byte order conversion, resolution scaling, digital filtering, and error compensation on the raw data in the channel object. Ultimately, the conversion table outputs unified, standardized feedback data for direct use by the motor control object.
[0062] By separating the channel object from the conversion table object, the system can flexibly adapt to various feedback devices without modifying the underlying driver code, simply by configuring different conversion tables. This significantly improves code reusability, achieves modularization and generalization of feedback processing logic, reduces the development and maintenance costs of multi-feedback source systems, and enhances system scalability and data consistency.
[0063] On the other hand, the number of turns mentioned in this invention can be used to represent the cumulative number of times the feedback data of the motor has experienced numerical overflow and wrapback during its historical process. Overflow and wrapback is the phenomenon that feedback data with a finite bit width continues to increase at its maximum value or continues to decrease at its minimum value, exceeding the representation range, causing the value to suddenly jump to the limit value in the opposite direction.
[0064] S202: Based on the initial number of revolutions and the feedback data obtained for the first time, the initial actual position of the motor is calculated;
[0065] In an exemplary embodiment of the present invention, the formula for calculating the initial actual position of the motor based on the initial number of revolutions and the first acquired feedback data can be:
[0066]
[0067] in, This refers to the actual position of the motor. This is the initial number of laps; This is the first piece of feedback data obtained; The number of bits for the motor position; The number of bits in the feedback data.
[0068] It should be noted that the initial number of revolutions in this invention can represent the cumulative number of numerical overflows and loops that occurred during the historical process before entering the online state. In one embodiment, when transitioning from the online state to the offline state, the last updated number of revolutions can be saved, and when transitioning from the offline state to the online state again, the most recently saved number of revolutions can be directly used as the initial number of revolutions for calculating the actual position of the motor.
[0069] However, under certain operating conditions, if the motor is passively rotated due to external forces while the system is offline, the position sensor readings will continuously change. This change may cause feedback value overflow, and the system will be unable to detect and update the corresponding multi-turn count value in a timely manner. If this problem is not addressed, a significant deviation will occur between the feedback and the actual position after the system re-enters the online state, thus affecting the accuracy of control and the stability of the system.
[0070] Based on this, the present invention also provides another implementation method for obtaining an initial number of revolutions after entering the online state, in order to overcome the perception problem of overflow of feedback values in the offline state. Specifically, it includes: recording the number of revolutions when the motor enters the offline state and the last feedback data before entering the offline state; if the highest and second-highest bits of the last feedback data before entering the offline state are 01, and the highest and second-highest bits of the first feedback data obtained when entering the online state again are 10, then the number of revolutions is incremented by one; if the highest and second-highest bits of the last feedback data before entering the offline state are 10, and the highest and second-highest bits of the first feedback data obtained when entering the online state again are 01, then the number of revolutions is decremented by one.
[0071] It should be noted that motor feedback data is typically treated as a signed binary integer. Taking 32-bit feedback data as an example, the range it can represent is... arrive The two largest digits of the feedback value can be 11, 10, 01, or 00. The different values corresponding to the highest and second-highest digits represent the position of the representable region on the number line. 01, representing the two largest digits, contains larger positive numbers, and its representable range extends to the left end. The right end is the positive maximum value. The highest two digits of 10 contain negative numbers with large absolute values; the left end of the representable interval is the minimum negative value. The right end is - .
[0072] Furthermore, positive overflow means that when the value increases from the maximum positive value, it will suddenly jump to the maximum negative value, that is, the highest bit of the feedback data will jump from 01 to 10; negative overflow means that when the value decreases from the maximum negative value, it will suddenly jump to the maximum positive value, that is, the highest bit of the feedback data will jump from 10 to 01.
[0073] S203: Based on subsequent feedback data, update the actual position of the motor until the motor enters an offline state.
[0074] It should be noted that the feedback data can be generated by the aforementioned position sensor based on a preset time interval, and the specific setting of the time interval is not limited in this embodiment of the invention. In an exemplary embodiment, when the system is online, the actual position of the motor is updated based on subsequent feedback data, including: acquiring the previously received feedback data and the calculated actual position of the motor; calculating the difference between the current feedback data and the previously received feedback data, and the sum of the difference and the previously calculated actual position of the motor is the current actual position of the motor.
[0075] Since clicking to run is continuous in online mode, the actual position parameters of the motor at various moments can be dynamically updated based on the above implementation method. This strategy for updating the motor's real-time position can be expressed by the formula:
[0076]
[0077] in, The number of bits for the motor position; The number of bits in the feedback data; This represents the current actual position of the motor; This is the initial number of laps; This is the feedback data currently being acquired; This is the actual position of the motor obtained from the previous calculation; This is the feedback data that was previously received.
[0078] It should be noted that even when updating the actual position of the motor using multi-turn values is not required in the online state, it is still necessary to record the number of overflow rewinds of the feedback data and update the multi-turn values so that the historical position can be accurately aligned when entering the online state again.
[0079] Similar to the detection of multiple revolutions in the offline state described above, in one embodiment, while the system updates the actual position of the motor based on the feedback value in the online state, the motor position calculation method of the present invention further includes: recording the values of the highest and second highest bits of the feedback data; if the values of the highest and second highest bits of the feedback data change from 01 to 10, then the number of multiple revolutions is incremented by one; if the values of the highest and second highest bits of the feedback data change from 10 to 01, then the number of multiple revolutions is decremented by one.
[0080] It should also be noted that for axes that can rotate infinitely (such as spindles or robot wrist joints), regardless of the storage width used, theoretically, the multi-turn value will become extremely large over time, eventually causing other calculation modules in the software to overflow or display abnormalities. Therefore, in the specific case of continuously rotating axes, this invention also provides another implementation method to compress the size of the multi-turn value within a certain time interval without changing the actual angle of the axis.
[0081] This implementation method specifically includes: when a preset condition is met, performing a modulo operation on the multi-turn value of the motor to obtain a new number of multi-turns; wherein, the modulo is related to the rotation angle of the rotating shaft corresponding to one rotation of the motor.
[0082] Understandably, for a rotating shaft, the key factor is its actual angle (0~360 degrees), not the number of rotations of the motor. Based on this embodiment, the module can first be determined as the number of full rotations of the motor required for the rotating shaft to rotate exactly 360 degrees. Once the preset update time point is reached, the modulus calculation is performed:
[0083]
[0084] Where M is the number of full rotations of the motor that allows the rotating shaft to rotate exactly 360 degrees; N is the number of rotations before the update. This is the updated number of laps.
[0085] Based on this implementation method, the number of rotations under the rotating shaft can always be limited to a certain value. Within the specified range, the risk of exceeding the storage limit is avoided, while the angle information of the axis is perfectly preserved.
[0086] It should also be noted that the preset conditions may include, but are not limited to: reaching a preset time interval, and / or entering an offline state; and / or exceeding a preset threshold range for multiple laps, etc., and the embodiments of the present invention do not impose any restrictions on this.
[0087] Furthermore, in a specific embodiment, the modulus M can be derived in the following manner:
[0088] Assuming the motor's position feedback resolution is (0≤n≤32), representing the count number fed back by the encoder for one revolution of the motor; the numerator and denominator of the lead screw pitch of the shaft are respectively Screw pitch This represents the angle the rotating shaft rotates by in one revolution of the motor; the feedback position of the motor is... Therefore, based on the multi-lap value and The calculated actual positions of the motors, after being converted into angles, should be equal, that is:
[0089]
[0090] Equivalent to:
[0091]
[0092] Will Reduce to a reduced fraction Then the necessary and sufficient condition for the above equation to hold is:
[0093]
[0094] in
[0095]
[0096] Specifically, when the lead screw pitch The settings satisfy:
[0097]
[0098] Pick
[0099]
[0100] That is, when When set to the number of motor revolutions corresponding to one rotation of the shaft, the multi-revolution value is... right The actual angle of the rotation axis before and after taking the mold can remain unchanged.
[0101] Please refer to Figure 3 As shown, based on the same inventive concept as the aforementioned motor position calculation method, one embodiment of the present invention provides a motor position calculation system 300, including: an acquisition module 301, a calculation module 302, and an update module 303.
[0102] It should be noted that the motor position calculation method of this embodiment can be applied to the motor position calculation system 300 of this embodiment. The motor position calculation system 300 can be configured on a terminal. The terminal may include, but is not limited to, a PC (Personal Computer), a PDA (Tablet PC), a smartphone, a smart wearable device, etc.
[0103] Specifically, the acquisition module 301 is used to acquire feedback data and the initial number of motor revolutions. The initial number of motor revolutions is used to represent the cumulative number of times the feedback data of the motor has experienced numerical overflow and rewind during the historical process before entering the online state.
[0104] The calculation module 302 is used to calculate the initial actual position of the motor based on the initial number of revolutions and the feedback data obtained for the first time when entering the online state.
[0105] The update module 303 is used to update the actual position of the motor based on subsequent feedback data until the motor enters an offline state.
[0106] Please refer to Figure 4 As shown, embodiments of the present invention also provide an electronic device 400, which includes at least one processor 401, a memory 402 (e.g., non-volatile memory), a memory 403, and a communication interface 404, wherein the at least one processor 401, the memory 402, the memory 403, and the communication interface 404 are connected together via an internal bus 405. The at least one processor 401 is used to invoke at least one program instruction stored or encoded in the memory 402, so that the at least one processor 401 performs various operations and functions of the motor position calculation method described in the various embodiments of this specification.
[0107] In the embodiments of this specification, electronic device 400 may include, but is not limited to: personal computer, server computer, workstation, desktop computer, laptop computer, notebook computer, mobile electronic device, smartphone, tablet computer, cellular phone, personal digital assistant (PDA), handheld device, messaging device, wearable electronic device, consumer electronic device, etc.
[0108] This invention also provides a computer-readable medium carrying computer-executable instructions. When executed by a processor, these instructions can be used to implement various operations and functions of the motor position calculation method described in the various embodiments of this specification.
[0109] The computer-readable medium in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0110] In this invention, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.
[0111] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0112] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, systems, and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0113] The foregoing description of specific exemplary embodiments of the invention is for illustrative and explanatory purposes. These descriptions are not intended to limit the invention to the precise forms disclosed, and it will be apparent that many changes and variations can be made in accordance with the foregoing teachings. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to implement and utilize various different exemplary embodiments of the invention, as well as various different choices and variations. The scope of the invention is intended to be defined by the claims and their equivalents.
[0114] It will be apparent to those skilled in the art that the present 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 its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0115] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A method for motor position calculation applied to a multi-source feedback scenario, characterized in that, The method comprises the following steps: acquiring feedback data and an initial multiple number of turns of a motor, the initial multiple number of turns being used to represent a cumulative number of times of numerical overflow wraparound of the feedback data of the motor in a historical process before the motor enters an online state this time; calculating an initial actual position of the motor based on the initial multiple number of turns and the feedback data acquired for the first time when the motor enters the online state this time; updating the actual position of the motor based on subsequent feedback data until the motor enters an offline state.
2. The method of claim 1, wherein The method further comprises standardizing the acquired feedback data, specifically comprising the following steps: constructing a channel object for encapsulating original feedback data sent by a feedback source, the channel object corresponding to the feedback source in a one-to-one manner; configuring a conversion table object for each channel object, the conversion table object being used to standardize the original feedback data in the corresponding channel based on a preset rule to output standardized feedback data.
3. The method of claim 1, wherein The method further comprises the following steps: recording values of the highest bit and the second highest bit of the feedback data; if the values of the highest bit and the second highest bit of the feedback data change from 01 to 10, the multiple number of turns is increased by 1; if the values of the highest bit and the second highest bit of the feedback data change from 10 to 01, the multiple number of turns is decreased by 1.
4. The method of claim 1, wherein The method further comprises the following steps: recording the multiple number of turns when the motor enters the offline state and the last feedback data before entering the offline state; if the values of the highest bit and the second highest bit of the last feedback data before entering the offline state are 01 and the values of the highest bit and the second highest bit of the first acquired feedback data when entering the online state next time are 10, the multiple number of turns is increased by 1; if the values of the highest bit and the second highest bit of the last feedback data before entering the offline state are 10 and the values of the highest bit and the second highest bit of the first acquired feedback data when entering the online state next time are 01, the multiple number of turns is decreased by 1.
5. The method of claim 1, wherein The formula for calculating the initial actual position of the motor based on the initial multiple number of turns and the feedback data acquired for the first time is as follows: wherein, is the actual position of the motor; is the number of turns; is the first acquired feedback data; is the number of bits of the motor position; is the number of bits of the feedback data.
6. The method of claim 1, wherein updating the actual position of the motor based on subsequent feedback data comprises the following steps: acquiring the last received feedback data and the calculated actual position of the motor; calculating a difference between the current feedback data and the last received feedback data, and the sum of the difference and the last calculated actual position of the motor is the current actual position of the motor.
7. The method of claim 1, wherein If the motor corresponds to a continuous rotating shaft, the method further comprises the following steps: when a preset condition is reached, performing a modulo operation on the multiple number of turns of the motor to acquire a new multiple number of turns, wherein the modulus is associated with a rotating angle of the rotating shaft corresponding to one rotation of the motor.
8. A motor position calculation system characterized by comprising: The method comprises the following steps: an acquiring module, configured to acquire feedback data and an initial multiple number of turns of a motor, the initial multiple number of turns being used to represent a cumulative number of times of numerical overflow wraparound of the feedback data of the motor in a historical process before the motor enters an online state this time; a calculating module, configured to calculate an initial actual position of the motor based on the initial multiple number of turns and the feedback data acquired for the first time when the motor enters the online state this time; an updating module, configured to update the actual position of the motor based on subsequent feedback data until the motor enters an offline state.
9. A computer device, comprising: The method comprises the following steps: A memory and a processor, which are connected in communication with each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the motor position calculation method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for causing a computer to perform the motor position calculation method of any one of claims 1-7.