Encoder data reading method, system, storage medium and electronic device

By decoding and judging encoder feedback information in FPGA and ARM processors, the encoder protocol compatibility problem in the single-axis servo system is solved, the motor rotor position information is accurately acquired, and the system versatility and terminal application efficiency are improved.

CN115657514BActive Publication Date: 2025-09-12重庆智能机器人研究院
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211144180.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-20
Publication Date
2025-09-12
Estimated Expiration
2042-09-20

AI Technical Summary

Technical Problem

In a single-axis servo system, the motor control system needs to be compatible with multiple encoder protocols. Existing technologies lead to reduced application complexity and terminal experience, and the mismatch in the number of feedback data frames from different encoders leads to position data errors.

Method used

By sending data read instructions in the FPGA, decoding the encoder feedback information, determining whether the first frame data matches the instruction, obtaining the motor rotor position information, and judging the ID command consistency in the ARM processor, data accuracy and reliability are ensured.

Benefits of technology

It realizes data reading compatible with multiple encoders, improves the versatility of the servo system and terminal application efficiency, and ensures the accuracy and reliability of the motor rotor position information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115657514B_ABST
    Figure CN115657514B_ABST
Patent Text Reader

Abstract

The present invention relates to an encoder data reading method, system, storage medium, and electronic device. The method comprises: sending a data reading instruction for obtaining motor rotor position information of a motor to be controlled to an encoder corresponding to the motor to be controlled; upon receiving feedback information sent by the encoder, decoding the feedback information using a decoding method corresponding to the encoder to obtain decoded data; determining whether the first frame data in the decoded data matches the data reading instruction to obtain a first judgment result; and when the first judgment result is yes, obtaining motor rotor position information for controlling the motor to be controlled from the decoded data. While being compatible with data reading methods of multiple encoders, the present invention also ensures the accuracy and reliability of obtaining motor rotor position information, thereby improving the versatility of the servo system and the application efficiency of the terminal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of encoders and motor control, and in particular to an encoder data reading method, system, storage medium and electronic equipment. Background Art

[0002] In a single-axis servo system, the FPGA has the characteristic of serial-to-parallel conversion to increase the communication rate, and the motor control system has a high degree of real-time positioning of the rotor position, so the encoder data is read by the FPGA; the motor rotor position data required for the ARM to complete the motor control can be obtained from the FPGA.

[0003] There are many absolute encoders suitable for motors in the industry, including Tamagawa, Panasonic, Sanyo, and Nikon from abroad, and Tokugawa and Ukai from China. However, different encoder protocols encountered during operation require updating the corresponding reading software, which complicates the application and greatly reduces the convenience of the servo device and the terminal application experience. In addition, the Tamagawa encoder was found in application to send ID commands other than the protocol ID command. Although the encoder can also return a data stream with a correct CRC, the number of frames returned does not correspond to the number of frames required for the ID transmission, resulting in incorrect position data. Therefore, there is an urgent need to provide a technical solution to the above problems. Summary of the Invention

[0004] To solve the above technical problems, the present invention provides an encoder data reading method, system, storage medium and electronic device.

[0005] The technical solution of an encoder data reading method of the present invention is as follows:

[0006] Sending a data reading instruction for obtaining the motor rotor position information of the motor to be controlled to an encoder corresponding to the motor to be controlled;

[0007] When receiving the feedback information sent by the encoder, decoding the feedback information using a decoding method corresponding to the encoder to obtain decoded data;

[0008] Determine whether the first frame data in the decoded data matches the data read instruction, and obtain a first determination result;

[0009] When the first judgment result is yes, the motor rotor position information for controlling the motor to be controlled is obtained from the decoded data.

[0010] The beneficial effects of the encoder data reading method of the present invention are as follows:

[0011] The method of the present invention is compatible with data reading methods of multiple encoders while ensuring the accuracy and reliability of obtaining motor rotor position information, thereby improving the versatility of the servo system and the application efficiency of the terminal.

[0012] Based on the above solution, the encoder data reading method of the present invention can be further improved as follows.

[0013] Furthermore, the data read instruction includes a target ID command, and the method further includes:

[0014] receiving the data read instruction, and determining whether the target ID command in the data read instruction is the same as the original ID command corresponding to the motor to be controlled, to obtain a second determination result;

[0015] When the second judgment result is yes, the data reading instruction is sent to the encoder corresponding to the motor to be controlled.

[0016] Furthermore, the first frame data includes: a feedback ID command, and the determining whether the first frame data in the decoded data matches the data read instruction to obtain a first determination result includes:

[0017] It is determined whether the feedback ID command in the first frame data is the same as the target ID command in the data read instruction to obtain the first determination result.

[0018] Furthermore, the decoded data includes: rotor position information of the motor to be controlled and working status information of the encoder, and the method further includes:

[0019] When the working state information of the encoder is normal, the motor to be controlled is controlled according to the rotor position information of the motor to be controlled.

[0020] Furthermore, it also includes: when the first judgment result is no, issuing an alarm message.

[0021] The technical solution of an encoder data reading system of the present invention is as follows:

[0022] It includes: sending module, processing module, judging module and reading module;

[0023] The sending module is used to send a data reading instruction for obtaining the motor rotor position information of the motor to be controlled to an encoder corresponding to the motor to be controlled;

[0024] The processing module is configured to: upon receiving feedback information sent by the encoder, decode the feedback information using a decoding method corresponding to the encoder to obtain decoded data;

[0025] The judgment module is used to: judge whether the first frame data in the decoded data matches the data reading instruction, and obtain a first judgment result;

[0026] The reading module is configured to obtain motor rotor position information for controlling the motor to be controlled from the decoded data when the first judgment result is yes.

[0027] The beneficial effects of an encoder data reading system of the present invention are as follows:

[0028] The system of the present invention is compatible with data reading methods of multiple encoders while ensuring the accuracy and reliability of obtaining motor rotor position information, thereby improving the versatility of the servo system and the application efficiency of the terminal.

[0029] Based on the above solution, the encoder data reading system of the present invention can also be improved as follows.

[0030] Furthermore, the data reading instruction includes: a target ID command, and the system further includes: a detection module;

[0031] The detection module is used to: receive the data read instruction, and determine whether the target ID command in the data read instruction is the same as the original ID command corresponding to the motor to be controlled, to obtain a second judgment result, and when the second judgment result is yes, call the sending module.

[0032] Furthermore, the first frame data includes: a feedback ID command, and the judgment module is specifically configured to:

[0033] It is determined whether the feedback ID command in the first frame data is the same as the target ID command in the data read instruction to obtain the first determination result.

[0034] A technical solution of a storage medium of the present invention is as follows:

[0035] The storage medium stores instructions, and when a computer reads the instructions, the computer executes the steps of an encoder data reading method of the present invention.

[0036] The technical solution of an electronic device of the present invention is as follows:

[0037] The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the computer is caused to execute the steps of an encoder data reading method according to the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 A schematic flow chart of a method for reading encoder data is shown;

[0039] Figure 2 A diagram showing the working principle of encoder data reading in an encoder data reading method is shown;

[0040] Figure 3 A schematic diagram of a data decoding process in an encoder data reading method is shown;

[0041] Figure 4 A structural diagram of an encoder data reading system is shown. DETAILED DESCRIPTION

[0042] like Figure 1 As shown, a method for reading encoder data includes the following steps:

[0043] S1. Sending a data reading instruction for obtaining motor rotor position information of a motor to be controlled to an encoder corresponding to the motor to be controlled.

[0044] Among them, the motor to be controlled is the motor that needs to be controlled by the ARM processor in the servo system; since the control of the motor requires real-time acquisition of the position data of the motor rotor, this embodiment uses FPGA to send data reading instructions to the encoder corresponding to the motor type of the motor to be controlled.

[0045] It should be noted that due to the different types of motors to be controlled and the ARM processor requiring the motor rotor position information to be real-time, and the FPGA has the characteristics of serial-to-parallel conversion to increase the communication rate, FPGA is used to read the encoder data.

[0046] S2. When feedback information sent by the encoder is received, the feedback information is decoded using a decoding method corresponding to the encoder to obtain decoded data.

[0047] The feedback information includes: the feedback ID command returned by the (undecoded) encoder, the encoder's working status information, the motor rotor position information, the warning status information, and the CRC check data.

[0048] Specifically, the motor rotor position information is the real-time position data of the rotor of the motor to be controlled. It should be noted that the ARM processor must obtain the motor rotor position information when controlling the motor rotor to reach a required speed or target command position. Therefore, it is necessary to continuously obtain the real-time position data of the rotor of the motor to be controlled.

[0049] The encoder's operating status and warning status information are each 8-bit data, transmitted by the encoder to the FPGA, which then transmits it to the ARM processor. The difference between these two data types is that the warning status information is the initial 8-bit data about the encoder's operating status obtained after FPGA decoding, while the operating status information is the optimized data obtained after the warning status information is filtered in the FPGA to prevent false warnings caused by external interference.

[0050] The CRC check data is: the last frame of feedback information. Its main function is to verify the returned data. If there is no abnormality in the data, the XOR result of all data is 0. If there is external interference causing the data to be abnormal, the XOR result of all data is not 0. This data is obtained by feedback from the encoder.

[0051] It should be noted that there are multiple data paths in the FPGA, each corresponding to a decoding method for a motor type. Therefore, the feedback information (feedback signal) is decoded using the decoding method corresponding to the motor type to be controlled.

[0052] S3. Determine whether the first frame data in the decoded data matches the data read instruction to obtain a first determination result.

[0053] The first frame of data includes the feedback ID command, and the data read instruction includes the target ID command. The feedback ID command is the ID command in the feedback information; the target ID command is the ID command in the data read instruction; and the original ID command is the ID command corresponding to the motor type. Different motor types have different original ID commands.

[0054] Specifically, the first frame of data contains only the feedback ID command (i.e., the feedback ID command in this embodiment). The feedback ID command is a 10-bit frame of data in the format of "0010 + feedback ID command + 0." In addition to the feedback ID command, the remaining 5 bits of this frame are fixed-format data. The target ID command format is "0010 + ID command + 0." The target ID command must use this fixed format, otherwise the encoder will not recognize it. Different encoders correspond to different ID commands, and the functions of the ID also vary, as specified in the encoder protocol. For example, an ID command of 0 for Tamagawa requires the encoder to only feedback the motor rotor position information, while for Nikon, it requires the encoder to feedback all information, including the motor rotor position information, the encoder's operating status information, and the warning status information.

[0055] S4. When the first judgment result is yes, obtaining motor rotor position information for controlling the motor to be controlled from the decoded data.

[0056] Specifically, when the matching is successful, it indicates that the feedback information obtained by the FPGA is the data required by the ARM processor, and the motor rotor position information for controlling the motor to be controlled is obtained from the decoded data.

[0057] Preferably, the data read instruction includes: a target ID command.

[0058] It should be noted that the data read instruction includes not only the target ID command but also the version number, motor rotor position information, encoder operating status and warning status information, an enable signal, an initialization completion signal, and the motor type. The enable signal is a switch that is controlled by the FPGA before initialization and by the ARM processor after initialization. The version number is a number that identifies whether the firmware has been updated.

[0059] The method further comprises:

[0060] The data read instruction is received, and it is determined that the target ID command in the data read instruction is the same as the original ID command corresponding to the motor to be controlled, to obtain a second determination result.

[0061] The principle of determining whether the target ID command is the same as the original ID command is to filter out incorrect ID commands, be compatible with various encoder types such as Tamagawa, Panasonic, Sanyo, Nikon, Tokumagawa, and Ukai, and ensure that the ID command sent by the FPGA to the encoder is correct and can be recognized by the encoder.

[0062] It's important to note that the ID command sent to the encoder is the ID command transmitted by the ARM processor to the FPGA, but it's converted in the FPGA into a command the encoder can recognize. The sending module issues the ID command transmitted by the ARM processor to the FPGA, but it's converted in the FPGA into a command the encoder can recognize, thus complying with the encoder protocol.

[0063] When the second judgment result is yes, the data reading instruction is sent to the encoder corresponding to the motor to be controlled.

[0064] Preferably, the first frame data includes: a feedback ID command.

[0065] Then, determining whether the first frame data in the decoded data matches the data read instruction to obtain a first determination result includes:

[0066] It is determined whether the feedback ID command in the first frame data is the same as the target ID command in the data read instruction to obtain the first determination result.

[0067] Specifically, the FPGA determines whether the feedback ID command is identical to the target ID command. If the first determination result is identical, it outputs an initialization completion signal of 1 (the initialization completion signal was 0 before the determination). At this point, the remaining data in the decoded data is sent to the ARM processor (or the ARM processor reads the remaining data in the decoded data). The remaining data includes: rotor position information of the motor to be controlled, encoder operating status information, and alarm information.

[0068] Preferably, the method further comprises:

[0069] When the working state information of the encoder is normal, the motor to be controlled is controlled according to the rotor position information of the motor to be controlled.

[0070] The encoder's operating status information is optimized by filtering warning status information received in the FPGA to prevent false warnings caused by external interference. The encoder's operating status information includes flags for monitoring the encoder's battery status, position data status, operating temperature, and the CRC checksum of returned data. The encoder can only operate normally if the corresponding statuses of these flags are normal.

[0071] It should be noted that when the ARM processor completes data reading, the FPGA returns control of the enable signal to the ARM processor, so that the ARM processor can send the enable signal for the next cycle while reading the data, thereby realizing the real-time data reading function.

[0072] Preferably, the method further includes: issuing an alarm message when the first judgment result is no.

[0073] Specifically, when the first frame data in the decoded data does not match the data reading instruction, the FPGA sends an alarm message to the ARM processor, indicating a data reading error.

[0074] In order to better illustrate the technical solution of this embodiment, Figure 2 Specifically, ARM100 sends a data read instruction including an enable signal, motor type and command ID (target ID command) to the interface module 210 of FPGA200, and the interface module 210 sends the data read instruction to the ID recognition module 223 ( Figure 3); when the ID recognition module 223 successfully identifies, the target ID command is sent to the encoder 300 through the sending module 230, and the encoder 300 sends the feedback information (feedback ID command, rotor position information, encoder status information, alarm information, CRC check code) to the selection receiving module 240 of FPGA200 according to the target ID command; the receiving selection module 240 connects the encoder feedback signal to the corresponding channel according to the motor type of the motor to be controlled and imports it into the analysis module 250 for decoding; the analysis module 250 forwards the decoded first diagnosis data (feedback ID command) to the control module 220 through the sending module 230 for comparison; when the control module 220 successfully compares, it generates an initialization success signal, and the analysis module 250 sends the data required by ARM100 (rotor position information, encoder working status information, etc.) to the ARM100 processor according to the signal; if the comparison fails, the control module generates an alarm message and sends the alarm message to the ARM100 processor through the analysis module.

[0075] It should be noted that if Figure 3 As shown, the analysis module 250 is responsible for decoding the feedback information, organizing the encoder position data, and integrating the encoder warning and alarm information; it contains a counting module 251, and cnt0 generates a flag flag1 for single-bit counting, and cnt1 generates a flag flag2 for single-frame counting; when cnt0 counts to the set threshold n0, it is set to 0 and cnt1 starts to add 1, and when cnt1 counts to the set threshold, cnt0 and cnt1 are all set to 0; when the flag position is 1, the returned data is loaded into the position data, encoder warning and alarm information, and the analysis and decoding are circulated in this way. When the frame number reaches the frame number corresponding to the ID, the serial data to parallel data conversion link is completed, and counting and decoding will start again after the next enable signal arrives. Figure 3 As shown, the control module 220 includes a response module 222 and an alarm module 221; the alarm module 221 performs a comparative analysis of the feedback ID and ID0, and issues an alarm if the ID is the same as ID0; the ID recognition module 223 can filter out erroneous ID commands to ensure that the ID command sent corresponds to the motor type, thereby preventing the encoder 300 from being unable to recognize and not returning data; the response module 222 can control the generation of the initialization start signal, and after the initialization is completed, the enable signal of FPGA200 is effectively switched to the enable signal of ARM100, that is, the enable signal is handed over to ARM100 for control.

[0076] The technical solution of this embodiment is compatible with data reading methods of multiple encoders while ensuring the accuracy and reliability of obtaining motor rotor position information, thereby improving the versatility of the servo system and the application efficiency of the terminal.

[0077] like Figure 4As shown, an encoder data reading system 400 according to an embodiment of the present invention includes: a sending module 410, a processing module 420, a judgment module 430 and a reading module 440;

[0078] The sending module 410 is used to send a data reading instruction for obtaining the motor rotor position information of the motor to be controlled to an encoder corresponding to the motor to be controlled;

[0079] The processing module 420 is configured to: upon receiving the feedback information sent by the encoder, decode the feedback information using a decoding method corresponding to the encoder to obtain decoded data;

[0080] The judgment module 430 is used to: judge whether the first frame data in the decoded data matches the data reading instruction, and obtain a first judgment result;

[0081] The reading module 440 is configured to obtain motor rotor position information for controlling the motor to be controlled from the decoded data when the first judgment result is yes.

[0082] Preferably, the data reading instruction includes: a target ID command, and the system 400 further includes: a detection module;

[0083] The detection module is used to: receive the data read instruction, and determine whether the target ID command in the data read instruction is the same as the original ID command corresponding to the motor to be controlled, to obtain a second judgment result, and when the second judgment result is yes, call the sending module 410.

[0084] Preferably, the first frame data includes a feedback ID command, and the judgment module 430 is specifically configured to:

[0085] It is determined whether the feedback ID command in the first frame data is the same as the target ID command in the data read instruction to obtain the first determination result.

[0086] The technical solution of this embodiment is compatible with data reading methods of multiple encoders while ensuring the accuracy and reliability of obtaining motor rotor position information, thereby improving the versatility of the servo system and the application efficiency of the terminal.

[0087] The above parameters and steps for each module to implement corresponding functions in the encoder data reading system 400 of the present invention can refer to the parameters and steps in the embodiment of the encoder data reading method above, and will not be repeated here.

[0088] A storage medium provided by an embodiment of the present invention includes: instructions stored in the storage medium, and when a computer reads the instructions, the computer executes the steps of an encoder data reading method as described above. For details, please refer to the parameters and steps in the embodiment of the encoder data reading method described above, which will not be repeated here.

[0089] Computer storage media such as USB flash drives, mobile hard drives, etc.

[0090] An embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and runnable on the processor. The embodiment of the present invention is characterized in that when the processor executes the computer program, the computer executes the steps of an encoder data reading method as described above. For details, please refer to the parameters and steps in the embodiment of the encoder data reading method described above, which will not be elaborated here.

[0091] Those skilled in the art will appreciate that the present invention can be implemented as a method, a system, a storage medium, and an electronic device.

[0092] Therefore, the present invention may be embodied in the following forms: entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or in a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the present invention may be embodied in the form of a computer program product embodied in one or more computer-readable media, the computer-readable media containing computer-readable program code. Any combination of one or more computer-readable media may be employed. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may 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 (a non-exhaustive list) of computer-readable storage media include: 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, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may 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. Although embodiments of the present invention have been shown and described above, it should be understood that the above embodiments are exemplary and are not intended to limit the present invention. Those skilled in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for reading encoder data, characterized in that: include: Sending a data reading instruction for obtaining the motor rotor position information of the motor to be controlled to an encoder corresponding to the motor to be controlled; When receiving the feedback information sent by the encoder, decoding the feedback information using a decoding method corresponding to the encoder to obtain decoded data; Determine whether the first frame data in the decoded data matches the data read instruction, and obtain a first determination result; When the first judgment result is yes, obtaining motor rotor position information for controlling the motor to be controlled from the decoded data; The data read instruction includes a target ID command, and the method further includes: receiving the data read instruction, and determining whether the target ID command in the data read instruction is the same as the original ID command corresponding to the motor to be controlled, to obtain a second determination result; When the second judgment result is yes, the data reading instruction is sent to the encoder corresponding to the motor to be controlled; The first frame data includes: a feedback ID command, and the determining whether the first frame data in the decoded data matches the data read instruction to obtain a first determination result includes: It is determined whether the feedback ID command in the first frame data is the same as the target ID command in the data read instruction to obtain the first determination result.

2. The encoder data reading method according to claim 1, characterized in that: The decoded data includes: the rotor position information of the motor to be controlled and the working state information of the encoder, and the method further includes: When the working state information of the encoder is normal, the motor to be controlled is controlled according to the rotor position information of the motor to be controlled.

3. The encoder data reading method according to claim 2, characterized in that: Also includes: When the first judgment result is no, an alarm message is issued.

4. An encoder data reading system, characterized in that: include: Sending module, processing module, judgment module and reading module; The sending module is used to send a data reading instruction for obtaining the motor rotor position information of the motor to be controlled to an encoder corresponding to the motor to be controlled; The processing module is configured to: upon receiving feedback information sent by the encoder, decode the feedback information using a decoding method corresponding to the encoder to obtain decoded data; The judgment module is used to: judge whether the first frame data in the decoded data matches the data reading instruction, and obtain a first judgment result; The reading module is configured to: when the first judgment result is yes, obtain motor rotor position information for controlling the motor to be controlled from the decoded data; The data reading instruction includes: a target ID command, and the system further includes: a detection module; The detection module is used to: receive the data read instruction, and determine whether the target ID command in the data read instruction is the same as the original ID command corresponding to the motor to be controlled, to obtain a second judgment result, and when the second judgment result is yes, to call the sending module; The first frame data includes: a feedback ID command, and the judgment module is specifically used to: It is determined whether the feedback ID command in the first frame data is the same as the target ID command in the data read instruction to obtain the first determination result.

5. A storage medium, characterized in that: The storage medium stores instructions, and when a computer reads the instructions, the computer executes an encoder data reading method according to any one of claims 1 to 3.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the computer is caused to execute the encoder data reading method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Communication method of absolute type encoder

    CN103744351A

  • Encoder reading acquisition method and device, servo system and storage medium

    CN113791734A