A method, device and system for updating program of encoder
Through the communication link between the host computer and the encoder, the new working program is downloaded and verified, which realizes the automatic program update of the encoder, solves the problems of high update difficulty and high cost in the existing technology, and ensures the security and accuracy of the data. sex.
Patent Information
- Application Number
- CN202110192528.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-20
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-02-20
AI Technical Summary
It is difficult and costly to update the program of existing encoders during use. It requires disassembly and professional tools to update, and there is a risk of program leakage.
Download the new working program through the communication link between the host computer and the encoder, verify it and write it into the storage space to realize automatic updating of the encoder program, reduce the difficulty and cost of updating, and ensure the accuracy of the data through the verification frame sex and safety.
Program updates can be achieved without disassembling the encoder, which reduces the difficulty and cost of updates, improves update efficiency, and ensures the correctness and security of data through verification frames to avoid program leaks.
Smart Images

Figure CN112988172B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of encoders, and in particular to an encoder program updating method, device and system. Background Art
[0002] As a measuring device, encoders are often installed as embedded components at the rear end of the shaft of a servo motor, etc., and require an external housing for sealing and shielding. However, encoders installed in servo motors and other equipment, which have been programmed with a complete working program before leaving the factory, will inevitably have various defects during the testing phase or even the use phase. Engineers need to solve the bugs and produce a new version of the program in order to update the original working program. Summary of the invention
[0003] The object of the present invention is to provide a method, device and system for updating the program of an encoder, which can reduce the difficulty and cost of updating the program of the encoder to a certain extent.
[0004] In order to solve the above technical problems, the present invention provides a method for updating a program of an encoder, comprising:
[0005] Receive program update instructions sent by the host computer;
[0006] Erasing the original working program and downloading a new working program through the communication link between the host computer and the encoder;
[0007] The new working program is written into the storage space after the original working program is erased.
[0008] In an optional embodiment of the present application, after downloading the new working program through the communication link connected between the host computer and the encoder, it also includes:
[0009] Identifying the check frames interspersed in each frame of data in the new working program, and verifying the new working program;
[0010] If the new working program passes the verification, the step of writing the new working program into the storage space after erasing the original working program is executed.
[0011] In an optional embodiment of the present application, identifying a check frame interspersed in each frame data of the new working program and checking the new working program includes:
[0012] Identify the identifier of the check frame interspersed between each frame data of the new working program;
[0013] Reading the operation data and the check data of the check frame based on the identifier;
[0014] Performing calculations on the calculation data according to a preset algorithm to obtain calculation result data;
[0015] The calculation result data is compared with the verification data. If the calculation result data is consistent with the verification data, the new working program passes the verification.
[0016] In an optional embodiment of the present application, erasing the original working program includes:
[0017] Switch the current program identifier from the working program identifier to the updating program identifier; and restart the MCU chip of the encoder;
[0018] When the program identifier is identified as an update program identifier after restarting, the original working program is erased;
[0019] Accordingly, after writing the new working program into the storage space after erasing the original working program, the method further includes:
[0020] The current program identifier is switched from the update program identifier to the working program identifier, and the MCU chip of the encoder is restarted.
[0021] In an optional embodiment of the present application, downloading a new working program through a communication link connected between the host computer and the encoder includes:
[0022] The new working program is downloaded via the 485 bus connected between the host computer and the encoder.
[0023] The present application also provides a program update device for an encoder, comprising:
[0024] An instruction receiving module is used to receive program update instructions sent by the host computer;
[0025] A downloading program module, used for erasing the original working program and downloading a new working program through the communication link between the host computer and the encoder;
[0026] The program update module is used to write the new working program into the storage space after erasing the original working program.
[0027] In an optional embodiment of the present application, it also includes a data verification module, which is used to identify the verification frames interspersed in each frame data of the new working program after downloading the new working program through the communication link connecting the host computer and the encoder, and verify the new working program; if the new working program passes the verification, the step of writing the new working program into the storage space after erasing the original working program is executed.
[0028] In an optional embodiment of the present application, the data verification module is used to identify the identifier of the check frame interspersed between each frame data of the new working program; read the operation data and verification data of the check frame based on the identifier; perform operations on the operation data according to a preset algorithm to obtain operation result data; compare the operation result data with the verification data, and if the operation result data is consistent with the verification data, the new working program passes the verification.
[0029] A program update system for an encoder includes an MCU chip built into the encoder and a host computer connected to the MCU chip for communication;
[0030] The MCU chip is used to receive the program update instruction output by the host computer, and execute the steps of implementing the program update method of the encoder as described in any one of the above items.
[0031] In an optional embodiment of the present application, the MCU chip and the host computer are connected via a 485 bus communication.
[0032] The present invention provides a method for updating a program of an encoder, comprising receiving a program update instruction sent by a host computer; erasing an original working program and downloading a new working program through a communication link between the host computer and the encoder; and writing the new working program into a storage space after erasing the original working program.
[0033] In the present application, when the working program in the MCU chip in the encoder is updated, there is no need to disassemble the encoder and then connect the pins of the MCU chip to a special update tool. Instead, a new working program can be directly downloaded through the existing communication link between the host computer and the encoder, thereby updating the working program of the MCU chip in the encoder, reducing the difficulty of updating the encoder program to a certain extent, thereby improving the work efficiency of the encoder program update and reducing the update cost to a certain extent.
[0034] The present application also provides a program updating device and system for an encoder, which has the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0036] Figure 1 A flowchart of a method for updating a program of an encoder provided in an embodiment of the present application;
[0037] Figure 2 This is a structural block diagram of a program updating device for an encoder provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0038] In normal operation of the encoder, in addition to the sensing device reading the rotation position data of the code disk, the decoding program on the MCU chip is also required to decode the coded signal read and output by the sensing device, and then output accurate absolute position information. In the actual encoder, depending on the different measurement objects, the working program executed on its MCU chip is more or less different.
[0039] When the working program on the MCU chip needs to be updated due to a bug or an update to the measured device, the encoder needs to be removed and the encoder casing opened, and a special update tool needs to be connected to the update pin of the MCU chip in the encoder. The working program in the MCU chip is updated with the new working program stored in the update tool.
[0040] The above-mentioned process of updating the working program of the encoder's MCU chip requires certain professional knowledge and can generally be performed by after-sales staff. However, after-sales staff are generally staff who cooperate with the manufacturer, and there is a risk that the new working program will be exported and leaked from the update tool. The encoder can also be returned to the factory for repair and the working program updated directly. However, this will undoubtedly increase the cost and upgrade efficiency of the encoder program update to a certain extent.
[0041] To this end, the present application provides a technical solution that can more simply and efficiently implement the update of the working program in the encoder.
[0042] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0043] like Figure 1 As shown, Figure 1 A flowchart of a program update method for an encoder provided in an embodiment of the present application, the program update method may include:
[0044] S11: Receive the program update instruction sent by the host computer.
[0045] S12: Erase the original working program and download the new working program through the communication link between the host computer and the encoder.
[0046] S13: Writing the new working program into the storage space after erasing the original working program.
[0047] It should be noted that the program update of the encoder mainly refers to the update of the working program on the MCU chip in the encoder. The sensing device in the encoder senses the code channel position signal and outputs the coded signal to the MCU chip. The MCU chip runs the working program to decode the coded signal to obtain the absolute position signal. At present, the MCU chip of the encoder is equipped with special wiring pins, which can be connected to a special update tool, and the program in the encoder is updated through the update tool. Because the encoder is an embedded device, it is obvious that in order to realize the connection between its wiring pins and the update tool, the encoder needs to be disassembled, which makes the encoder software upgrade process cumbersome and requires a lot of manpower and material resources.
[0048] During the normal operation of the encoder, it is also necessary to connect to a host computer. When the encoder monitors and obtains the measured position data, it is necessary to interact with the host computer and upload the measured position data to the host computer. The encoder and the host computer are generally connected by wired communication. For example, the encoder and the host computer can be connected via a 485 bus communication. Obviously, the host computer is generally used to provide the staff with the encoder's measurement data, so the host computer is generally a host that the staff can interact with.
[0049] To this end, in this embodiment, the encoder and the host computer can exchange information, and the host computer sends a new working program for software upgrade to the encoder. After the MCU chip in the encoder downloads and obtains the new working program, the working program can be automatically updated, and the encoder does not need to be disassembled during the whole process; and the new working program in the host computer can be obtained through online transmission by the manufacturer through networking. For example, relevant software can be configured in the host computer. It only needs to start the software and confirm the update. The software can automatically obtain the new working program from the manufacturer's networked terminal device and send the new working program to the encoder. The whole process is simple and can be implemented even by ordinary staff without professional knowledge. The difficulty of software update in the encoder is greatly reduced, and the cost of software update is reduced.
[0050] Furthermore, after the MCU chip in the encoder obtains a new working program, it needs to complete the update of the working program itself. For this reason, generally in the MCU chip of the encoder, two different storage spaces can be divided, which are used to store the working program and the update program respectively. For example, the working program is stored in storage space A, and the update program is stored in storage space B. Then, when there is no need to update the program, the working program stored in storage space A is run, and when the working program in the MCU chip needs to be updated, the update program stored in storage space B needs to be run. For this reason, in an optional embodiment of the present application, after receiving the program update instruction, it can further include:
[0051] Switch the current program ID from the working program ID to the updating program ID; and restart the MCU chip of the encoder;
[0052] When the program identifier is identified as an update program identifier after restart, the original working program is erased;
[0053] After the new working program is written into the storage space after the original working program is erased, the current program identifier is switched from the update program identifier to the working program identifier, and the MCU chip of the encoder is restarted.
[0054] Because there are two different programs stored in the MCU chip, two program identifiers, a working program identifier and an updating program identifier, can be specially set. When the MCU chip is started, the program identifier is first identified. For example, the working program identifier can be set to 1 and the updating program identifier can be set to 0.
[0055] When the encoder is working normally, it is obvious that the current program identifier is also the working program identifier. When the encoder receives the update program instruction from the host computer, the program identifier is triggered to change from the working program identifier to the update program identifier. After the MCU chip is restarted, it is recognized that the program identifier is the update program identifier, and the step of updating the program in the storage space corresponding to the working program is started. After completing the working program update, the program identifier is changed to the working program identifier, and the MCU chip is restarted again. The program identifier in the restarted MCU chip is the working program identifier, and the working program can be executed normally. In this way, the MCU chip can automatically complete its own internally stored working program.
[0056] To sum up, in this application, when the working program of the encoder is updated, there is no need to disassemble the encoder. Instead, the new working program is directly downloaded through the host computer to automatically complete the program update. The whole process is simple to operate and does not require professional staff to disassemble the encoder. This greatly reduces the complexity of program upgrades in the encoder and reduces the update cost of the encoder, which is conducive to the widespread application of the encoder.
[0057] As mentioned above, during the program update process of the encoder, there may be a problem that the working program is exported by non-factory personnel and the program is leaked. Therefore, in an optional embodiment of the present application, after downloading the new working program through the communication link connected between the host computer and the encoder, it also includes:
[0058] Identify the check frames interspersed in each frame of data in the new work program and verify the new work program;
[0059] If the new working program passes the verification, the step of writing the new working program into the storage space after erasing the original working program is executed.
[0060] The data of the new working program is similar to the conventional data, including a start frame, a data frame and an end frame. On this basis, in this embodiment, at least one check frame is further set between the start frame and the end frame, and the check frame can be interspersed between the data of the data frame.
[0061] It should be noted that the reason for inserting at least one check frame in the data frame of the new working program is, on the one hand, to verify the correctness of the new engineering data. By verifying the data in the check frame in the new engineering data, the correctness of the new working program can be ensured to avoid the incorrect version of the relevant data of the downloaded new working program due to unexpected situations.
[0062] On the other hand, only the MCU chip in the encoder produced by this factory can recognize the check frame. The check frame is interspersed in the data frame. Even if the data of the new working program is accidentally leaked, the person or device that obtains the data cannot distinguish which part of the data frame is the check frame. This is equivalent to realizing the anti-leakage function of the new working program to a certain extent.
[0063] Regarding the verification of the check frame, in another optional embodiment of the present application, it may include:
[0064] An identifier for identifying a check frame interspersed between frames of data of a new work program;
[0065] Read the operation data and check data of the check frame based on the identifier;
[0066] Calculate the calculation data according to the preset algorithm to obtain calculation result data;
[0067] The calculation result data is compared with the verification data. If the calculation result data and the verification data are consistent, the new working program is verified.
[0068] It should be noted that the check frame in this embodiment mainly includes three parts: identifier, operation data and check data. When the data of the check frame is interspersed with the data of the data frame, as long as the identifier is read and recognized in the data of the new working program, the subsequent two data must be the operation data and the check data.
[0069] In actual application, a specific identifier may be configured for each encoder's MCU chip so that the check frame can be identified after obtaining the working program, rather than considering the data as part of the data frame.
[0070] After obtaining the calculation data and verification data of the check frame, the calculation data can be calculated according to the preset algorithm, and the calculation result data obtained after the calculation can be compared with the verification data. For example, the content of the check frame contains two data M=123 and N=654. After calculating M=123 through algorithm H, data B=654 is obtained. The algorithm H is preset by the programmer in the update program. If the data calculated by the preset algorithm H in the update program is different from N=654, it is obvious that the correct calculation algorithm corresponding to the calculation data in the obtained new working program is inconsistent with the corresponding algorithm in the update program. Then, the downloaded new working program may have errors, and it may not be the new working program corresponding to the encoder model, so the new working program cannot be directly used for program update.
[0071] As mentioned above, the check frame can be interspersed with multiple data frames, so the identification of each check frame and the corresponding preset algorithm can be different. Therefore, when performing check frame verification, each check frame verification needs to pass, which means that the new working program has passed the verification data correctly before subsequent updates can be performed.
[0072] In summary, in this embodiment, by inserting check frames in the new working program, the correctness of the data of the new working program can be checked, and the confidentiality of the new working program can be achieved to a certain extent, thereby avoiding data leakage and improving the security of the new working program.
[0073] In an optional embodiment of the present application, before the encoder leaves the factory, two different applications are burned into the A position and the B position on the MCU chip on the production line, and the flag is set to the default state; the encoder can judge whether the A position program or the B position program needs to be run through the stored flag. Assuming that the flag is in the default state, the A position program is run. If the flag is in the non-default state, the B position program is run; the program stored in the A position is a normal function application, and the program stored in the B position is to update and erase the A position program. Before each operation of the encoder, it will first judge the state of the flag and then jump to the corresponding area to run the program. Therefore, when the encoder leaves the factory, the flag is in the default state, and the A position program will run.
[0074] When a bug occurs in the encoder program and needs to be updated, the host computer only needs to send a program update command (cmd_updata).
[0075] After the encoder recognizes the command, it sets the flag to a non-default state. At this time, the MCU chip is restarted because it will first determine that the flag is in a non-default state. Then the program stored in position B is executed; the function of the program stored in position B is to erase the original program in position A, and write the received program data into position A through a certain communication protocol. After completion, the flag is restored to the default state. The "certain communication protocol" mainly refers to:
[0076] The protocol defined by the programmer mainly includes the start frame, check frame, data frame and end frame.
[0077] The function of the start frame is to inform the program at position B that the next data to be sent belongs to the program that needs to be updated. The program code in B enters the state of receiving program data.
[0078] The function of the data frame is to inform the program at position B that the frame data belongs to the program data and should be written to the corresponding program storage location.
[0079] The function of the end frame is to notify the program at position B that the program data transmission is completed. After the Flag is restored to the default state, the program pointer jumps to the program at position A for execution.
[0080] The function of the check frame is to be interlaced after the start frame and before the end frame through the implemented design. The specific implementation method is: when the B position program receives the frame header of the check frame and determines that the frame is a check frame, it performs the corresponding algorithm check and returns the result of the check, whether it succeeds or fails. If it succeeds, it continues to update, and if it fails, it stops updating.
[0081] The check frame can be mixed multiple times after the start frame and before the end frame, so that multiple check algorithms can be designed to prevent crackers from cracking the program. The protocol for updating data is customized by the designer, which is different from some upgrade protocols disclosed on the Internet (such as xmodem). The disclosed protocols are easy to be cracked and exploited. After the designer customizes it and adds some check frames, it greatly increases the difficulty of cracking, thereby ensuring the security of program data.
[0082] The following is an introduction to a program updating device for an encoder provided by an embodiment of the present invention. The program updating device for an encoder described below and the program updating method for an encoder described above can be referred to each other.
[0083] Figure 2 The structural block diagram of the program updating device of the encoder provided by the embodiment of the present invention is shown in FIG. Figure 2 The program updating device of the encoder may include:
[0084] The instruction receiving module 100 is used to receive the program update instruction sent by the host computer;
[0085] A downloading program module 200 is used to erase the original working program and download a new working program through the communication link between the host computer and the encoder;
[0086] The program update module 300 is used to write the new working program into the storage space after erasing the original working program.
[0087] In an optional embodiment of the present application, it also includes a data verification module, which is used to identify the verification frames interspersed in each frame data of the new working program after downloading the new working program through the communication link connecting the host computer and the encoder, and verify the new working program; if the new working program passes the verification, the step of writing the new working program into the storage space after erasing the original working program is executed.
[0088] In an optional embodiment of the present application, the data verification module is used to identify the identifier of the check frame interspersed between each frame data of the new working program; read the operation data and verification data of the check frame based on the identifier; perform operations on the operation data according to a preset algorithm to obtain operation result data; compare the operation result data with the verification data, and if the operation result data is consistent with the verification data, the new working program passes the verification.
[0089] In an optional embodiment of the present application, the update program module 300 is used to switch the current program identifier from the working program identifier to the update program identifier; and restart the MCU chip of the encoder; when the program identifier is identified as the update program identifier after restart, the original working program is erased;
[0090] It also includes an identification switching module, which is used to write the new working program into the storage space after erasing the original working program, switch the current program identification from the update program identification to the working program identification, and restart the MCU chip of the encoder.
[0091] In an optional embodiment of the present application, the download program module 200 is used to download the new working program via a 485 bus connected between the host computer and the encoder.
[0092] The program updating device of the encoder of this embodiment is used to implement the aforementioned program updating method of the encoder. Therefore, the specific implementation of the program updating device of the encoder can be found in the embodiment of the program updating method of the encoder in the above text, which will not be repeated here.
[0093] The present application further provides a program update system for an encoder, which may include an MCU chip built into the encoder, and a host computer communicatively connected to the MCU chip;
[0094] The MCU chip is used to receive a program update instruction output by a host computer and execute the steps of implementing any of the above encoder program update methods.
[0095] The steps of the program updating method may include:
[0096] Receive program update instructions sent by the host computer;
[0097] Erasing the original working program and downloading a new working program through the communication link between the host computer and the encoder;
[0098] The new working program is written into the storage space after the original working program is erased.
[0099] Optionally, the MCU chip and the host computer can be connected via a 485 bus communication.
[0100] To sum up, the program update system of the encoder provided in this embodiment does not need to dismantle the encoder when updating the working program on the MCU chip in the encoder. The host computer can directly transmit the working program related data required for the update to the MCU chip, thereby realizing the automatic update of the MCU chip. The operation is simple and can be implemented by staff without too much professional knowledge, which greatly reduces the difficulty and cost of updating the encoder program.
[0101] 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 that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment that includes a series of elements are inherent to the elements. In the absence of more restrictions, the elements limited by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or equipment that includes the elements. In addition, the above-mentioned technical solution provided in the embodiment of the present application is consistent with the corresponding technical solution in the prior art in principle, and the part is not described in detail, so as not to repeat too much.
[0102] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core ideas of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A method for updating a program of an encoder, characterized in that: include: Receive program update instructions sent by the host computer; Erasing the original working program and downloading a new working program through the communication link between the host computer and the encoder; Writing the new working program into the storage space after erasing the original working program; After downloading the new working program through the communication link between the host computer and the encoder, the method further includes: Identifying the check frames interspersed in each frame of data in the new working program, and verifying the new working program; If the new working program passes the verification, the step of writing the new working program into the storage space after erasing the original working program is executed; Identifying the check frames interspersed in each frame of data in the new working program and checking the new working program, including: Identify the identifier of the check frame interspersed between each frame data of the new working program; Reading the operation data and the check data of the check frame based on the identifier; Performing calculations on the calculation data according to a preset algorithm to obtain calculation result data; Comparing the calculation result data with the verification data, if the calculation result data and the verification data are consistent, the new working program passes the verification; Erase the original working procedures, including: Switch the current program identifier from the working program identifier to the updating program identifier; and restart the MCU chip of the encoder; When the program identifier is identified as an update program identifier after restarting, the original working program is erased; Accordingly, after writing the new working program into the storage space after erasing the original working program, the method further includes: The current program identifier is switched from the update program identifier to the working program identifier, and the MCU chip of the encoder is restarted.
2. The method for updating a program of an encoder according to claim 1, wherein: Downloading a new working program through a communication link between the host computer and the encoder includes: The new working program is downloaded via the 485 bus connected between the host computer and the encoder.
3. A program updating device for an encoder, characterized in that: include: An instruction receiving module is used to receive program update instructions sent by the host computer; A downloading program module, used for erasing the original working program and downloading a new working program through the communication link between the host computer and the encoder; An update program module, used for writing the new working program into the storage space after erasing the original working program; It also includes a data verification module, which is used to identify the verification frames interspersed in each frame data of the new working program after downloading the new working program through the communication link connected between the host computer and the encoder, and verify the new working program; if the new working program passes the verification, the step of writing the new working program into the storage space after erasing the original working program is executed; The data verification module is used to identify the identifier of the verification frame interspersed between each frame data of the new working program; read the operation data and verification data of the verification frame based on the identifier; and calculate the operation data according to a preset algorithm to obtain the operation result data; Comparing the calculation result data with the verification data, if the calculation result data and the verification data are consistent, the new working program passes the verification; The update program module is used to switch the current program identifier from the working program identifier to the update program identifier; and restart the MCU chip of the encoder; when the program identifier is identified as the update program identifier after restart, the original working program is erased; It also includes an identification switching module, which is used to write the new working program into the storage space after erasing the original working program, switch the current program identification from the update program identification to the working program identification, and restart the MCU chip of the encoder.
4. A program update system for an encoder, characterized in that: It includes an MCU chip built into the encoder, and a host computer that is communicatively connected to the MCU chip; The MCU chip is used to receive the program update instruction output by the host computer, and execute the steps of implementing the program update method of the encoder as described in any one of claims 1 to 2.
5. The program update system of an encoder according to claim 4, characterized in that The MCU chip and the host computer are connected via a 485 bus communication.
Citation Information
Patent Citations
Method and device for updating application program
CN103744712A
Method, device and system for firmware upgrading of control equipment of unmanned ship
CN109491688A
