Communication method, system, device and storage medium of a magnetic encoder
Patent Information
- Application Number
- CN202311594217.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-24
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2043-11-24
AI Technical Summary
[0004]由于目前的上述通讯芯片通常选用的是半双工模式,即该通讯芯片可以接收和发送,但二者不能同时进行,只能等待发送完成或接收完成后,才能进行接收或发送的切换
[0041]In summary, the solution proposed in this application can improve the accuracy of the position information fed back by the magnetic encoder and reduce errors while ensuring the timeliness of the position information feedback.
Smart Images

Figure CN117614595B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a communication method, system, device, and storage medium for a magnetic encoder. Background Technology
[0002] Magnetic encoders are key devices used in servo products to detect the position information of motor rotors. Their sensitivity, anti-interference and stability directly affect the accuracy and performance of servo control systems. High-precision magnetic encoders have advantages such as shock resistance, dust resistance, oil resistance and simple structure, and have always been the focus of industry research.
[0003] As a position feedback element in servo products, the magnetic encoder can collect analog voltage signals through a magnetoresistive sensor. After passing through its own amplification circuit, the signals are sent to its own main control chip. Then, the internal ADC (Analog to Digital Converter) converts the analog signal into a digital signal. A series of angle analysis algorithms are then used to analyze the position, and the obtained position analysis result, i.e., the analyzed position data, is transmitted to the servo driver through a communication chip.
[0004] Because the aforementioned communication chips typically use half-duplex mode, meaning they can both receive and transmit, but not simultaneously, switching between the two can only occur after either transmission or reception is complete. In practical applications, especially when the rotor is running at high speed, it has been found that the position data fed back by the magnetic encoder has a significant delay, resulting in a large error between the fed-back position data and the actual rotor position.
[0005] In summary, improving the accuracy of the position data fed back by the magnetic encoder and reducing errors is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] The purpose of this invention is to provide a communication method, system, device, and storage medium for a magnetic encoder, so as to improve the accuracy of the position data fed back by the magnetic encoder and reduce errors.
[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0008] In a first aspect, the present invention provides a communication timing control method for a magnetic encoder, comprising:
[0009] Determine the default timing information of the magnetic encoder;
[0010] The delay duration is determined based on the default timing information;
[0011] The trigger time of the magnetic encoder position sampling and parsing in the default timing information is delayed by the delay duration to correct the default timing information of the magnetic encoder, so that the magnetic encoder communicates with the communication device based on the corrected timing information.
[0012] In one implementation, determining the delay duration based on the default timing information includes:
[0013] Based on the default timing information, the interrupt period of the first interrupt is determined; wherein, when the magnetic encoder sends data to the communication device and receives data sent by the communication device, the first interrupt is used for processing.
[0014] Based on the default timing information, the duration between the end time of the magnetic encoder position sampling and parsing and the end time of the interruption period is determined as the first duration.
[0015] Get the preset first reserved duration;
[0016] The difference between the first duration and the first reserved duration is used as the delay duration determined based on the default timing information;
[0017] Wherein, the first reserved time is less than the first time.
[0018] In one implementation, it further includes:
[0019] Increase the interrupt execution time of the first interrupt so that the interrupt exit time of the first interrupt is reduced to a preset first duration threshold.
[0020] The first interrupt includes the interrupt execution time and the interrupt exit time.
[0021] In one implementation, the first reservation duration is a first reservation duration set through the following operation:
[0022] The value of the first duration threshold is used as the value of the first reserved duration.
[0023] In one implementation, the first reservation duration is a first reservation duration set through the following operation:
[0024] The value of the first duration threshold is superimposed with the preset first margin value, and the superimposed value is used as the value of the first reserved duration.
[0025] Wherein, the first margin value does not exceed the value of the first duration threshold.
[0026] In one implementation, it further includes:
[0027] Receive a correction instruction and adjust the value of the delay duration based on the correction instruction.
[0028] In one implementation, it further includes:
[0029] The default timing information and the delay duration determined based on the default timing information are displayed.
[0030] Secondly, the present invention provides a communication timing control system for a magnetic encoder, comprising:
[0031] The default timing information determination module is used to determine the default timing information of the magnetic encoder;
[0032] The delay duration determination module is used to determine the delay duration based on the default timing information;
[0033] The timing information correction module is used to postpone the trigger time of the magnetic encoder position sampling and parsing in the default timing information by the delay duration, so as to correct the default timing information of the magnetic encoder, so that the magnetic encoder can communicate with the communication device based on the corrected timing information.
[0034] Thirdly, the present invention provides a communication timing control device for a magnetic encoder, comprising:
[0035] Memory, used to store computer programs;
[0036] A processor for executing the computer program to implement the steps of the communication timing control method for the magnetic encoder as described above.
[0037] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the communication timing control method for a magnetic encoder as described above.
[0038] This application takes into account that in traditional solutions, communication chips typically use half-duplex mode, meaning reception and transmission cannot occur simultaneously. Furthermore, due to communication protocol requirements, the magnetic encoder must respond quickly and send position data after the servo driver sends a request signal; typically, the time interval between the two cannot exceed 3.2 µs. Based on these limitations, traditional solutions are usually configured to immediately trigger a UART (Universal Asynchronous Receiver / Transmitter) interrupt to send position data after receiving one byte of the request signal. In other words, in traditional solutions, the magnetic encoder triggers a UART interrupt every time the servo driver sends a position request to promptly send the position data, and then performs position sampling and parsing through polling. This results in each transmitted position data being the position data calculated at the start of the previous interrupt, leading to a significant delay. For example, assuming the angular velocity of the motor rotor is ω, the rotor position changes by ω·Δt during the time Δt between the start of position sampling and the transmission of position data. Therefore, at low speeds, especially when stationary, the position error caused by Δt is negligible. However, at high speeds, the position error caused by feedback delay is proportional to the rotational speed; the higher the rotational speed, the greater the error.
[0039] Based on the above analysis, this application considers that, due to the requirements of the communication protocol—namely, the encoder must respond quickly and send out position information after the servo driver sends a request signal—the communication timing between the magnetic encoder and the communication device in the default timing information of the magnetic encoder is inconvenient to adjust, and the position information still needs to be sent out promptly after an interrupt is triggered. Therefore, this application considers that the timing of the magnetic encoder's position sampling and parsing can be adjusted to reduce the aforementioned Δt, thereby reducing the error.
[0040] Specifically, this application first determines the default timing information of the magnetic encoder. Then, based on the default timing information, a delay duration is determined. The trigger time for position sampling and parsing of the magnetic encoder in the default timing information is then postponed by this delay duration, thereby correcting the default timing information of the magnetic encoder. The magnetic encoder can then communicate with the communication device based on the corrected timing information. It is understandable that because the trigger time for position sampling and parsing of the magnetic encoder in the default timing information is postponed, the time between the trigger time of position sampling and parsing and the end of the interrupt is shortened. The time Δt between the trigger time of position sampling and parsing and the transmission of position data is also reduced, making the feedback position data closer to the current actual position.
[0041] In summary, the solution proposed in this application can improve the accuracy of the position information fed back by the magnetic encoder and reduce errors while ensuring the timeliness of the position information feedback. 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 of 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 flowchart illustrating the implementation of a communication timing control method for a magnetic encoder provided in an embodiment of the present invention.
[0044] Figure 2a This is a schematic diagram of the default timing information of a magnetic encoder in a specific context.
[0045] Figure 2b To Figure 2a A diagram illustrating the various stages in the process;
[0046] Figure 3 This is a schematic diagram of the corrected timing information of a magnetic encoder in a specific context.
[0047] Figure 4 This is a schematic diagram of the corrected timing information of a magnetic encoder in another specific scenario;
[0048] Figure 5 This is a schematic diagram of the communication timing control system for a magnetic encoder provided in an embodiment of the present invention;
[0049] Figure 6 This is a schematic diagram of the communication timing control device for a magnetic encoder provided in an embodiment of the present invention. Detailed Implementation
[0050] The core of this invention is to provide a communication timing control method for a magnetic encoder, which can improve the accuracy of the position information fed back by the magnetic encoder and reduce errors while ensuring the timeliness of the position information feedback.
[0051] To enable those skilled in the art to better understand the present invention, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0052] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating an implementation of a communication timing control method for a magnetic encoder according to an embodiment of the present invention. The communication timing control method for the magnetic encoder may include the following steps:
[0053] Step S101: Determine the default timing information of the magnetic encoder.
[0054] Specifically, before correcting the timing information of the magnetic encoder using the scheme of this application, the magnetic encoder is usually already configured with timing information, i.e., the default timing information of the magnetic encoder described herein. For easier understanding, please refer to... Figure 2a This is a schematic diagram illustrating the default timing information of a magnetic encoder in a specific context. In traditional solutions, this is directly based on... Figure 2a This timing sequence is used to control the operation of the magnetic encoder. Figure 2b To Figure 2a A diagram illustrating the various stages in the process.
[0055] The default timing information of the magnetic encoder can be automatically determined by the level status of the relevant pins. In addition, in practical applications, the determined default timing information of the magnetic encoder can be displayed using devices such as oscilloscopes for easy viewing by staff.
[0056] Figure 2a and Figure 2b In the default timing information of the magnetic encoder, there are interrupt timing, communication timing, and position sampling and parsing timing.
[0057] Figure 2a and Figure 2b In the context of magnetic encoders, the interrupt timing specifically includes the interrupt execution time and the interrupt output time. The interrupt execution time is a high level, and... Figure 2a In the specific example, the interrupt execution time is 48µs, and the interrupt exit time is a low level. Figure 2a The interrupt cycle is 14.5us, while the interrupt period is 62.5us. In other words, in... Figure 2a In a specific implementation, within a 62.5µs interrupt cycle, 48µs is the interrupt execution time and 14.5µs is the interrupt exit time. Figure 2a Specifically, it uses UART interrupts, which is also a common solution in practical applications. Furthermore, it can be seen that... Figure 2a In this implementation, during the 48µs interrupt execution time, the communication device's enable pin is in the transmit state for 45µs, and in the receive state for 3µs. The remaining receive state time is during the interrupt exit time. Meanwhile, Figure 2a In the example, the 26µs time for position sampling and position resolution is also included in the 48µs interrupt execution time.
[0058] Figure 2a and Figure 2b In the diagram, the second curve represents the communication timing. Figure 2a In specific scenarios, the magnetic encoder and the communication device use RS-485 communication. Therefore, the communication timing is specifically a RS-485 transmit / receive switching mechanism. In this timing, a high level indicates a transmit state, meaning the magnetic encoder can send data to the communication device, while a low level indicates a receive state, meaning the magnetic encoder can receive data sent by the communication device. In practical applications, the communication device is typically a communication chip.
[0059] Furthermore, it should be noted that due to the characteristics of half-duplex communication, the system must wait for transmission to complete before switching to receive mode; otherwise, communication will fail. Therefore, the transmit / receive switching in RS-485 communication is typically achieved by a magnetic encoder controlling the level of the corresponding pins. For example, in one scenario, at a baud rate of 2.5 Mbps, sending 11 bytes requires at least 44 µs. Figure 2a In this scenario, during the communication timing, the transmit state can be set to occupy for 45us. After this 45us, the magnetic encoder can switch the enable pin of the communication device to the receive state. After 17.5us of the receive state, the magnetic encoder will then switch the enable pin of the communication device to the transmit state, and so on.
[0060] Figure 2a and Figure 2b In the diagram, the third curve represents the timing of position sampling and resolution, or simply the position sampling and resolution timing. A high level indicates the code execution time during the position sampling and resolution process of the magnetic encoder, which can also be called the position sampling and resolution time. Figure 2a The value is 26µs. It can be seen that... Figure 2a In the example, the time difference between the end of position sampling and position parsing and the end of the current UART interrupt is 31.5us. The time difference between the end of position sampling and position parsing and the time when position data is sent when the next UART interrupt is triggered is more than 31.5us. When the rotor is running at high speed, the position error caused by this feedback delay will be large.
[0061] Furthermore, it should be noted that if the magnetic encoder uses ADC interrupts for position sampling and analysis, while UART interrupts are used for receiving and transmitting, the two interrupts will conflict, compromising timing stability and causing significant fluctuations in the rotational speed displayed on the host computer. Therefore, current magnetic encoders use ADC polling for position sampling and analysis.
[0062] Step S102: Determine the delay duration based on the default timing information.
[0063] In this application's solution, the delay duration needs to be determined based on default timing information. The purpose of the delay duration is to change the timing of position sampling and parsing. (See reference...) Figure 3 In terms of effect, it is to Figure 2a The position sampling and parsing timing is shifted to the right, so that the trigger time of position sampling and parsing in the position sampling and parsing timing sequence, i.e. Figure 3 The sampling time of the marked position can be closer to the time when the position data is sent during the next UART interrupt, that is... Figure 3 The location marked in the middle is the time of transmission.
[0064] The specific value of the delay duration can be set and adjusted according to actual needs. There are multiple ways to determine the delay duration, and different methods may yield different delay duration values. In practical applications, the determined delay duration value should be such that the trigger time of position sampling and parsing is relatively close to the time when the position data is transmitted during the next UART interrupt.
[0065] Step S103: Delay the trigger time of the magnetic encoder position sampling and parsing in the default timing information by a certain delay time to correct the default timing information of the magnetic encoder, so that the magnetic encoder can communicate with the communication device based on the corrected timing information.
[0066] Once the delay duration is determined, the trigger time for the magnetic encoder position sampling and parsing in the default timing information can be postponed by that delay duration. The trigger time for position sampling and parsing... Figure 2a and Figure 3 This is simply referred to as the position sampling moment. At this moment, the magnetic encoder samples the position. In the 26us that follows, the sampled data is parsed to obtain the parsed position data. When a position request is received later, the position data can be sent.
[0067] In one specific embodiment of the present invention, step S102 may specifically include:
[0068] Step 1: Determine the interrupt period of the first interrupt based on the default timing information; wherein, the magnetic encoder sends data to the communication device and receives data sent by the communication device, which is processed through the first interrupt;
[0069] Step 2: Based on the default timing information, determine the duration between the end time of the magnetic encoder position sampling and parsing and the end time of the interrupt cycle, and use this duration as the first determined duration;
[0070] Step 3: Obtain the preset first reserved duration;
[0071] Step 4: Use the difference between the first duration and the first reserved duration as the delay duration determined based on the default timing information;
[0072] The first reserved duration is less than the first duration.
[0073] For ease of understanding, Figure 2a and Figure 3 For example, Figure 2a In this embodiment, the interrupt period of the first interrupt can be determined to be 62.5µs based on the default timing information. The first interrupt described here is the interrupt used by the magnetic encoder when sending data to and receiving data from the communication device, which is usually the UART interrupt described above.
[0074] Then, based on the default timing information, the duration between the end time of the magnetic encoder position sampling and parsing within the interrupt cycle and the end time of the interrupt cycle, i.e., the start time of the next interrupt, is determined to be 31.5µs. Figure 2a The first duration determined is 31.5us.
[0075] Next, a preset first reservation duration needs to be obtained. The specific value of the first reservation duration can be set and adjusted according to actual needs, but it must be less than the first duration. It should be noted that the position sampling and position resolution process is part of the interrupt execution time and will not exceed the interrupt execution time. Therefore, it can be understood that the value of the first reservation duration cannot be lower than the interrupt time. For example Figure 3 In this example, since the interrupt time is 14.5us, the first reservation duration must be greater than or equal to 14.5us. Figure 3 Specifically, the first reserved duration is set to 16us, which is greater than the interrupt time of 14.5us.
[0076] After obtaining the preset first reserved duration, the difference between the first duration and the first reserved duration can be calculated, and this difference can be used as the delay duration determined based on the default timing information. Figure 3In the example, the delay duration = 31.5us - 16us = 15.5us, that is, for Figure 2a The timing sequence for position sampling and position resolution needs to be shifted 15.5µs to the right to obtain the desired result. Figure 3 The corrected timing information is shown below. It can be seen that... Figure 3 In this scheme, the original timing of the entire UART interrupt is not changed, and the interrupt execution time is still 48us. However, due to the setting of the delay duration, the position sampling and parsing are essentially postponed. In this case, the triggering time of position sampling and parsing and the time of sending position data will be reduced, making the feedback position data closer to the current actual position.
[0077] In one specific embodiment of the present invention, it may further include:
[0078] Increase the interrupt execution time of the first interrupt so that the interrupt exit time of the first interrupt is reduced to a preset first duration threshold.
[0079] The first interrupt includes the interrupt execution time and the interrupt exit time.
[0080] As described above, the position sampling and position resolution processes are part of the interrupt execution time and will not exceed it. Therefore, the value of the first reservation duration must be greater than or equal to the interrupt exit time. This implementation takes into account that, in order to minimize the first reservation duration, the interrupt exit time can be shortened. That is, in this implementation, the operation used is to increase the interrupt execution time of the first interrupt. Since the interrupt execution time of the first interrupt is increased, for example... Figure 4 In the example, the interrupt execution time is increased to 60us, which reduces the interrupt time of the first interrupt to the preset first duration threshold of 2.5us. This allows for the setting of a smaller first reservation duration.
[0081] In practical applications, considering that the interruption time is usually 2 to 3 microseconds, the first duration threshold can usually be a value of 2 to 3 microseconds.
[0082] It can be seen that, because the interrupt time of the first interrupt is reduced in this implementation method, the delay time can be further increased, and the position sampling and parsing time can be further postponed, so as to be closer to the next position data transmission time, which is conducive to further reducing the error.
[0083] In one specific embodiment of the present invention, the first reservation duration is a first reservation duration set through the following operation:
[0084] The value of the first duration threshold is used as the value of the first reserved duration.
[0085] This implementation takes into account that the first reserved duration should not be less than the interrupt time. Since the interrupt time has been reduced to a very small value in the previous implementation, i.e., reduced to a preset first duration threshold, the value of the first duration threshold can be directly used as the value of the first reserved duration in this implementation, so that the delay duration is as large as possible and the trigger time of position sampling and parsing can be closer to the time of position data transmission during the next UART interrupt.
[0086] Furthermore, in one specific embodiment of the present invention, the first reservation duration is a first reservation duration set through the following operations:
[0087] The value of the first duration threshold is added to the preset first margin value, and the value after addition is used as the value of the first reserved duration.
[0088] Among them, the first margin value does not exceed the value of the first duration threshold.
[0089] This implementation further takes into account that, Figure 4 For example, although theoretically speaking, after Figure 4 After 26µs, the position sampling and position resolution process is complete. Ideally, after... Figure 4 The interrupt execution time ends exactly 26µs after the initial reservation time, allowing for a shorter initial reservation duration. However, in practice, after 26µs, the program may still need to perform some if statement processing, flag processing, etc. If the interval is set to 26µs, which happens to coincide with the interrupt termination time, the corresponding program may not be able to complete all the processing at the exact moment, potentially leading to some errors and abnormal situations.
[0090] In response, this implementation takes into account that a first margin value can be set to act as a buffer, ensuring that the corresponding program can complete within the interruption execution time. Specifically, in this implementation, the value of the first duration threshold described above is superimposed with the preset first margin value, and the superimposed value is used as the value of the first reserved duration.
[0091] For example Figure 4 In the example, the first duration threshold is specifically an interrupt time of 2.5µs, and the first margin value is, for example, 1.5µs. Figure 4In this implementation, the first reserved duration is 4µs. It can be seen that after setting the first margin value in this embodiment, the interrupt execution time does not end after the 26µs of position sampling and resolution, preventing an immediate interruption. There is a 1.5µs buffer before the interrupt occurs, allowing for errors. For example, after the position sampling and resolution process is complete, some if statement processing, flag processing, and other procedures can still be completed using this 1.5µs buffer. Therefore, this implementation method is beneficial for ensuring the reliability of the solution. It is also understandable that setting a small buffer will not significantly affect the delay duration. In practical applications, the first duration threshold is usually 2 to 3µs, while the first margin value is usually not higher than the first duration threshold.
[0092] In one specific embodiment of the present invention, it may further include:
[0093] Receive correction instructions and adjust the delay duration value based on the correction instructions.
[0094] This implementation takes into account that staff may have different usage needs in practical applications. Therefore, this implementation allows staff to actively adjust the delay duration. That is, after detecting the staff's operation, a correction command can be generated and sent to the backend, allowing the backend to adjust the delay duration based on the received correction command. It can be seen that this implementation allows staff to flexibly adjust the delay duration according to actual needs.
[0095] Furthermore, in one specific embodiment of the present invention, it may also include:
[0096] Display the default timing information and the delay duration determined based on the default timing information.
[0097] In this implementation, considering that it is convenient for staff to know the currently determined delay duration and to correct the previous default timing information, the default timing information and the delay duration determined based on the default timing information can be displayed. After display, staff can easily and intuitively determine whether the currently set delay duration is reasonable and whether it needs to be adjusted according to the actual situation. In other words, this implementation further facilitates the work of staff.
[0098] This application takes into account that in traditional solutions, communication chips typically use half-duplex mode, meaning reception and transmission cannot occur simultaneously. Furthermore, due to communication protocol requirements, the magnetic encoder must respond quickly and send position data after the servo driver sends a request signal; typically, the time interval between the two cannot exceed 3.2 µs. Based on these limitations, traditional solutions are usually configured to immediately trigger a UART (Universal Asynchronous Receiver / Transmitter) interrupt to send position data after receiving one byte of the request signal. In other words, in traditional solutions, the magnetic encoder triggers a UART interrupt every time the servo driver sends a position request to promptly send the position data, and then performs position sampling and parsing through polling. This results in each transmitted position data being the position data calculated at the start of the previous interrupt, leading to a significant delay. For example, assuming the angular velocity of the motor rotor is ω, the rotor position changes by ω·Δt during the time Δt between the start of position sampling and the transmission of position data. Therefore, at low speeds, especially when stationary, the position error caused by Δt is negligible. However, at high speeds, the position error caused by feedback delay is proportional to the rotational speed; the higher the rotational speed, the greater the error.
[0099] Based on the above analysis, this application considers that, due to the requirements of the communication protocol—namely, the encoder must respond quickly and send out position information after the servo driver sends a request signal—the communication timing between the magnetic encoder and the communication device in the default timing information of the magnetic encoder is inconvenient to adjust, and the position information still needs to be sent out promptly after an interrupt is triggered. Therefore, this application considers that the timing of the magnetic encoder's position sampling and parsing can be adjusted to reduce the aforementioned Δt, thereby reducing the error.
[0100] Specifically, this application first determines the default timing information of the magnetic encoder. Then, based on the default timing information, a delay duration is determined. The trigger time for position sampling and parsing of the magnetic encoder in the default timing information is then postponed by this delay duration, thereby correcting the default timing information of the magnetic encoder. The magnetic encoder can then communicate with the communication device based on the corrected timing information. It is understandable that because the trigger time for position sampling and parsing of the magnetic encoder in the default timing information is postponed, the time between the trigger time of position sampling and parsing and the end of the interrupt is shortened. The time Δt between the trigger time of position sampling and parsing and the transmission of position data is also reduced, making the feedback position data closer to the current actual position.
[0101] In summary, the solution proposed in this application can improve the accuracy of the position information fed back by the magnetic encoder and reduce errors while ensuring the timeliness of the position information feedback.
[0102] Corresponding to the above method embodiments, this invention also provides a communication timing control system for a magnetic encoder, which can be referred to in conjunction with the above.
[0103] See Figure 5 The diagram shown is a structural schematic of a communication timing control system for a magnetic encoder according to the present invention, comprising:
[0104] The default timing information determination module 501 is used to determine the default timing information of the magnetic encoder;
[0105] The delay duration determination module 502 is used to determine the delay duration based on the default timing information;
[0106] The timing information correction module 503 is used to postpone the trigger time of the magnetic encoder position sampling and parsing in the default timing information by the delay time, so as to correct the default timing information of the magnetic encoder, so that the magnetic encoder can communicate with the communication device based on the corrected timing information.
[0107] In one specific embodiment of the present invention, the delay duration determination module 502 includes:
[0108] An interrupt cycle determination unit is used to determine the interrupt cycle of the first interrupt based on the default timing information; wherein the magnetic encoder processes data sent to and received from the communication device through the first interrupt.
[0109] The first duration determination unit is used to determine, based on the default timing information, the duration between the end time of the position sampling and parsing of the magnetic encoder and the end time of the interruption period within the interruption period, as the determined first duration;
[0110] The first reserved duration acquisition unit is used to acquire a preset first reserved duration.
[0111] The delay duration determination unit is used to take the difference between the first duration and the first reserved duration as the delay duration determined based on the default timing information;
[0112] Wherein, the first reserved time is less than the first time.
[0113] In one specific embodiment of the present invention, an interruption time reduction module is further included, for:
[0114] Increase the interrupt execution time of the first interrupt so that the interrupt exit time of the first interrupt is reduced to a preset first duration threshold.
[0115] The first interrupt includes the interrupt execution time and the interrupt exit time.
[0116] In one specific embodiment of the present invention, the first reserved duration is a first reserved duration set by the first reserved duration acquisition unit through the following operations:
[0117] The value of the first duration threshold is used as the value of the first reserved duration.
[0118] In one specific embodiment of the present invention, the first reserved duration is a first reserved duration set by the first reserved duration acquisition unit through the following operations:
[0119] The value of the first duration threshold is superimposed with the preset first margin value, and the superimposed value is used as the value of the first reserved duration.
[0120] Wherein, the first margin value does not exceed the value of the first duration threshold.
[0121] In one specific embodiment of the present invention, a delay duration correction module is further included, used for:
[0122] Receive a correction instruction and adjust the value of the delay duration based on the correction instruction.
[0123] In one specific embodiment of the present invention, a display module is further included, for:
[0124] The default timing information and the delay duration determined based on the default timing information are displayed.
[0125] Corresponding to the above methods and system embodiments, this invention also provides a communication timing control device for a magnetic encoder and a computer-readable storage medium, which can be found in [reference]. Figure 6 The communication timing control device for the magnetic encoder includes:
[0126] Memory 601 is used to store computer programs;
[0127] Processor 602 is configured to execute the computer program to implement the steps of the communication timing control method for a magnetic encoder as described in any of the above embodiments.
[0128] The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the communication timing control method for the magnetic encoder as described in any of the above embodiments. The computer-readable storage medium referred to herein includes random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the art.
[0129] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0130] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0131] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of the present invention. It should be noted that for those skilled in the art, 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 protection scope of the present invention.
Claims
1. A communication timing control method for a magnetic encoder, characterized in that, include: Determine the default timing information of the magnetic encoder; The delay duration is determined based on the default timing information; The delay duration is such that after postponing the trigger time of position sampling and parsing, the trigger time of position sampling and parsing is close to the time when the position data is sent during the next interruption, and the position sampling and parsing process does not exceed the duration of the interrupt execution time. The trigger time of the magnetic encoder position sampling and parsing in the default timing information is delayed by the delay duration to correct the default timing information of the magnetic encoder, so that the magnetic encoder communicates with the communication device based on the corrected timing information.
2. The communication method of the magnetic encoder according to claim 1, characterized in that, The step of determining the delay duration based on the default timing information includes: Based on the default timing information, the interrupt period of the first interrupt is determined; wherein, when the magnetic encoder sends data to the communication device and receives data sent by the communication device, the first interrupt is used for processing. Based on the default timing information, the duration between the end time of the magnetic encoder position sampling and parsing and the end time of the interruption period is determined as the first duration. Get the preset first reserved duration; The difference between the first duration and the first reserved duration is used as the delay duration determined based on the default timing information; Wherein, the first reserved time is less than the first time.
3. The communication method of the magnetic encoder according to claim 2, characterized in that, Also includes: Increase the interrupt execution time of the first interrupt so that the interrupt exit time of the first interrupt is reduced to a preset first duration threshold. The first interrupt includes the interrupt execution time and the interrupt exit time.
4. The communication method of the magnetic encoder according to claim 3, characterized in that, The first reserved duration is the first reserved duration set through the following operations: The value of the first duration threshold is used as the value of the first reserved duration.
5. The communication method of the magnetic encoder according to claim 4, characterized in that, The first reserved duration is the first reserved duration set through the following operations: The value of the first duration threshold is superimposed with the preset first margin value, and the superimposed value is used as the value of the first reserved duration. Wherein, the first margin value does not exceed the value of the first duration threshold.
6. The communication method of the magnetic encoder according to any one of claims 1 to 5, characterized in that, Also includes: Receive a correction instruction and adjust the value of the delay duration based on the correction instruction.
7. The communication method of the magnetic encoder according to claim 6, characterized in that, Also includes: The default timing information and the delay duration determined based on the default timing information are displayed.
8. A communication timing control system for a magnetic encoder, characterized in that, include: The default timing information determination module is used to determine the default timing information of the magnetic encoder; The delay duration determination module is used to determine the delay duration based on the default timing information; The delay duration is such that after postponing the trigger time of position sampling and parsing, the trigger time of position sampling and parsing is close to the time when the position data is sent during the next interruption, and the position sampling and parsing process does not exceed the duration of the interrupt execution time. The timing information correction module is used to postpone the trigger time of the magnetic encoder position sampling and parsing in the default timing information by the delay duration, so as to correct the default timing information of the magnetic encoder, so that the magnetic encoder can communicate with the communication device based on the corrected timing information.
9. A communication timing control device for a magnetic encoder, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the communication timing control method for a magnetic encoder as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the communication timing control method for a magnetic encoder as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Encoder and encoder control system
CN110941231A
Encoder with current detection function and current detection method
CN111446890A