Pulse output circuit and method of encoder, driver and storage medium

By designing the pulse output circuit of the encoder, the count value is updated and the reference speed is used to update the count value and output signals, the problem that the upper computer only supports pulse communication is solved, and signal conversion and data transmission in different communication methods are realized, ensuring the stability of data Sex and accuracy.

CN119171886APending Publication Date: 2024-12-20SHENZHEN SHUMA ELECTRONICS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411170711.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

During the servo control process, the data of some encoders cannot be transmitted to the upper computer because the upper computer only supports pulsed communication methods, and the encoder has a variety of communication methods, resulting in data transmission obstacles.

Method used

Design a pulse output circuit and method of an encoder. Through the timing module, calculation module, counter and output module, the time difference of the target encoder position update, determine the reference speed, and use this to update the count value to output the A phase signal and B phase The phase signal realizes signal conversion of different communication methods and virtually outputs pulsed encoder, so that the upper computer can transmit data with encoders of different communication methods.

Benefits of technology

It realizes the conversion of encoder output signals of different communication methods into pulsed output signals, solving the problem that the upper computer only supports pulsed communication, ensuring that the data can be transmitted to the upper computer stably and accurately, reducing fluctuations in the counting process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119171886A_ABST
    Figure CN119171886A_ABST
Patent Text Reader

Abstract

The invention relates to a pulse output circuit and method of an encoder, a driver and a storage medium. The circuit comprises a timing module which is used for obtaining a time difference of position updating of a target encoder; the calculation module is used for being connected with a target encoder and the timer respectively, and when the target encoder outputs the position, the reference speed of the target encoder is determined according to the current position of the target encoder, the current count value of the counter and the time difference; the current count value begins to be updated after the reference speed is obtained; the counter is connected with the calculation module and is used for updating a current count value at the reference speed; and the output module is connected with the counter and is used for outputting a target A-phase signal and a target B-phase signal according to the edge value represented by the current count value. By adopting the circuit, encoder output signals in different communication modes can be converted into output signals of a pulse type encoder so as to carry out data transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of servo control, and in particular to a pulse output circuit, method, driver and storage medium of an encoder. Background Art

[0002] During the servo control process, the servo drive needs to communicate with the encoder to obtain the real-time position information of the motor, so as to achieve precise control of the motor. There are two common communication methods for encoders: one is a serial communication method based on protocols such as BISS, EnDat, and UART. In this method, the servo drive needs to initiate communication with the encoder at a certain frequency, so the position information obtained is periodic. The other is a pulse communication method based on protocols such as ABZ, CW / CCW, in which the encoder will actively and continuously output pulse information, so the position information obtained by the drive is continuous. The drive needs to feed back the obtained position information to the host computer. However, some host computers only support pulse communication methods, resulting in the inability to transmit some encoder data to the host computer. Summary of the invention

[0003] Based on this, it is necessary to provide a pulse output circuit, method, driver and storage medium of an encoder to address the above technical problems, which can convert encoder output signals of different communication modes into output signals of a pulse encoder for data transmission.

[0004] A pulse output circuit of an encoder, the circuit comprising:

[0005] Timing module, used to obtain the time difference of target encoder position update;

[0006] a calculation module, which is connected to the target encoder and the timer respectively, and when the target encoder outputs a position, determines a reference speed of the target encoder according to a current position of the target encoder, a current count value of the counter and the time difference; the current count value starts to be updated after obtaining the reference speed;

[0007] A counter, connected to the calculation module, and configured to update a current count value at the reference speed;

[0008] An output module is connected to the counter and is used to output a target A-phase signal and a target B-phase signal according to an edge value represented by the current count value.

[0009] A pulse output method for an encoder, the method comprising:

[0010] Get the time difference of target encoder position update;

[0011] When the target encoder outputs a position, a reference speed of the target encoder is determined according to the current position of the target encoder, the current count value and the time difference; the current count value starts to be updated after obtaining the reference speed;

[0012] updating the current count value at the reference speed;

[0013] According to the edge value represented by the current count value, a target A-phase signal and a target B-phase signal are output.

[0014] A driver is used to be connected to a target encoder and a host computer respectively, and includes a pulse output circuit of the encoder in each embodiment.

[0015] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of an embodiment of a pulse output method of each encoder when executing the computer program.

[0016] A computer-readable storage medium stores a computer program, which implements the steps of the pulse output method embodiment of each encoder when the computer program is executed by a processor.

[0017] The pulse output circuit, method, driver and storage medium of the above-mentioned encoder, since the current count value starts to be updated after the reference speed is obtained, the current count value represents the last position of the target encoder for reference; when the target encoder outputs the position, that is, when the target encoder transmits the position to the outside, the reference speed of the target encoder can be determined according to the current position of the target encoder, the current count value of the counter and the time difference between the position update, and the count value is updated at the reference speed, which can make the entire counting process smooth and reduce fluctuations; by analyzing the pulse edge of the encoder, it can be known that the edge value represents the level of the A-phase signal and the B-phase signal, so the output signal of the encoder of different communication modes can be converted into the output signal of the pulse encoder, which is equivalent to virtualizing an encoder, so that the host computer that only supports the pulse communication mode can transmit data with the encoder of different communication modes through the circuit in this embodiment. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A schematic diagram of a pulse output circuit of an encoder in one embodiment;

[0019] Figure 2 A schematic diagram of the signal output format of phase A leading and phase B leading in one embodiment;

[0020] Figure 3 is a schematic diagram of the bit width of a counter in one embodiment;

[0021] Figure 4is a circuit diagram of a pulse output circuit of an encoder in one embodiment;

[0022] Figure 5 It is a flow chart of a pulse output method of an encoder;

[0023] Figure 6 Schematic diagram of a location tracking process in one embodiment. DETAILED DESCRIPTION

[0024] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0026] It should be noted that all directional indications in the embodiments of the present application (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.

[0027] In addition, in this application, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0028] It can be understood that the “connection” in the following embodiments should be understood as “electrical connection”, “communication connection”, etc. if the connected circuits, modules, units, etc. have electrical signals or data transmission between each other.

[0029] In one embodiment, Figure 1As shown, it is a schematic diagram of the pulse output circuit of the encoder in one embodiment. The calculation module 120 is used to connect with the target encoder 210, the timing module 110 is connected with the calculation module 120, the calculation module 120 is connected with the counter 130, and the counter 130 is connected with the output module 140. The timing module 110 is used for the time difference of the target encoder position update; the calculation module 120 is used to determine the reference speed of the target encoder 210 according to the current position of the target encoder 210, the current count value of the counter 130 and the time difference when the target encoder 210 outputs the position; the current count value starts to be updated after obtaining the reference speed; the counter 130 is used to update the current count value at the reference speed; the output module 140 is used to output the target A phase signal and the target B phase signal according to the edge value represented by the current count value.

[0030] The target encoder position update time difference may be the time difference between the last position update time of the target encoder 210 and the current position update time, provided by the target encoder 210 interface; or may be self-generated by the timing module 110 according to a preset period.

[0031] The communication mode of the target encoder 210 is not limited, and can be a serial communication mode, a pulse communication mode, or other modes, as long as it can output a position. The current position of the target encoder 210 can be a position directly output by the target encoder 210, or can be obtained by dividing the position output by the target encoder 210.

[0032] Specifically, the current count value of the counter 130 is used to represent the position of the target encoder 210. The counter 130 can set the count value of the counter 130 to match the current position of the target encoder 210 when the target encoder 210 outputs the position for the first time. For example, if the current position output by the target encoder 210 for the first time is P0, then the initial count value of the counter 130 is also P0. The current count value starts to be updated after obtaining the reference speed. Then, when the target encoder 210 outputs the position for the second time, the counter 130 has not yet obtained the reference speed, so the current count value is still the initial count value P0. Then, after obtaining the reference speed v1 between the position output for the first time and the position output for the second time, the counter 130 starts counting from the initial count value P0 at the reference speed v1 and updates the current count value; in an ideal case, until the target encoder 210 outputs the position for the third time, the current count value is the corresponding value when the target encoder 210 outputs the position for the second time. Therefore, the position represented by the current count value is the previous position of the target encoder 210 for reference.

[0033] It can be understood that in the subsequent position processing process, the calculation module 120 is used to determine the reference speed of the target encoder 210 according to the current position of the target encoder 210, the current count value of the counter 130 and the time difference when the output position of the target encoder 210 is detected. The position represented by the current count value of the counter 130 is the last position of the target encoder 210 for reference. Combined with the current position of the target encoder 210 and the time difference between the two positions, the reference speed can be obtained. The reference speed represents the rotation speed of the target encoder 210 from the last position to the current position. It can be understood that when the motor speed is slow, the reference speed is small, as small as one thousandth of a pulse, etc.; when the motor speed is fast, the reference speed is large, as large as the pulse level.

[0034] The counter 130 is used to start updating the current count value at the reference speed after obtaining the reference speed. The counter 130 starts counting after obtaining the reference speed. Then, when the target encoder 210 outputs the latest position, the calculation module 120 determines the reference speed represented by the previous position and the current position, and the counter 130 updates the current count value at the reference speed, which is equivalent to the counter 130 tracking the current position at the reference speed from the count value represented by the previous position of the target encoder 210. In addition, using the current count value of the counter 130 for speed calculation instead of directly using the previous position of the target encoder 210 can keep the remaining position difference of the previous tracking until the current tracking process, thereby avoiding the cumulative error caused by not catching up or overspeeding, and ensuring data stability and accuracy.

[0035] The current count value includes a count value representing a pulse and an edge value, and the edge value is the count value representing the edge. Taking the count value 1 representing a pulse as an example, the decimal part can be observed to determine the AB phase level. In the encoder, the phase difference of the AB phase signal is always 90°. When generating the AB two-phase signal, the pulse ahead of the A phase is used for explanation. When the decimal part is between 0 and 0.25, it belongs to the 0 area, so the A phase outputs a low level and the B phase outputs a low level. When the decimal part is between 0.25 and 0.5, it belongs to the 1 area, so the A phase outputs a high level and the B phase outputs a low level. When the decimal part is between 0.5 and 0.75, it belongs to the 2 area, so the A phase outputs a high level and the B phase outputs a high level. When the decimal part is between 0.75 and 1, it belongs to the 3 area, so the A phase outputs a low level and the B phase outputs a high level. Therefore, the output module 140 is used to simultaneously determine the A phase level and the B phase level according to the edge value represented by the current count value, and then generate the target A phase signal and the target B phase signal. The output module 140 is also used to transmit the target A-phase signal and the target B-phase signal to a host computer.

[0036] Optionally, when the current count value of the counter 130 reaches the zero position of the target encoder 210, a Z phase signal is output. The integer part of the current count value (indicating the number of pulses) can be observed. Assuming that the zero position of the actual encoder is Pz, a high level is output whenever the integer part of the count value is equal to the zero position, which is equivalent to a virtual encoder outputting a Z level in real time according to the current position.

[0037] In this embodiment, since the current count value starts to be updated after the reference speed is obtained, the current count value represents the last position of the target encoder for reference; when the target encoder outputs the position, that is, when the target encoder transmits the position to the outside, the reference speed of the target encoder can be determined according to the current position of the target encoder, the current count value of the counter and the time difference between the position update, and the count value is updated at the reference speed, which can make the entire counting process smooth and reduce fluctuations; by analyzing the pulse edge of the encoder, it can be known that the edge value represents the level of the A-phase signal and the B-phase signal. The pulse output circuit of the encoder in this embodiment can convert the encoder output signal of different communication modes into the output signal of a pulse encoder, which is equivalent to virtualizing an encoder, so that the host computer that only supports the pulse communication mode can transmit data with encoders of different communication modes through the circuit in this embodiment.

[0038] In one embodiment, the calculation module 120 is used to connect to the target encoder 210, perform resolution conversion on the position output by the target encoder 210 according to the resolution conversion coefficient, and obtain the current position of the target encoder 210; and

[0039] According to the current position of the target encoder 210, the current count value of the counter 130, and the time difference, the reference speed of the target encoder 210 is determined.

[0040] Among them, the current position of the target encoder 210 can be the position after frequency division. The resolution conversion coefficient can be input according to demand, and can be used to reduce the resolution of the encoder to adapt to the receiving parameters of the host computer. It is understandable that the resolution of the encoder can also be increased to improve the accuracy of the obtained position.

[0041] The resolution of the encoder indicates the number of positions output by the encoder shaft when it rotates one circle, also known as the number of lines. The higher the resolution, the smaller the minimum angular displacement and the higher the accuracy of the encoder; the lower the resolution, the larger the minimum angular displacement and the lower the accuracy of the encoder.

[0042] Specifically, assuming that the number of AB pulses required to be output by the target encoder 210 when the motor rotates one circle is M, and the resolution of the position data fed back by the target encoder 210 is N, the resolution conversion coefficient can be defined as K=M / N. Whenever the position is updated, it only needs to be multiplied by K to get the corresponding divided position value.

[0043] The position output by the target encoder 210 is converted in resolution according to the resolution conversion coefficient to obtain the current position of the target encoder 210. For example, if the resolution conversion coefficient is K, then the position output by the target encoder 210 is P1, and the current position of the target encoder 210 is K*P1. Subsequently, the reference speed of the target encoder 210 is determined according to the current position of the target encoder 210, the current count value of the counter 130, and the time difference.

[0044] In this embodiment, the resolution supported by the host computer may not match the resolution of the target encoder. Therefore, by setting a resolution conversion coefficient for resolution conversion, the target encoder can be adapted to the host computer and the data of the target encoder can be transmitted to the host computer.

[0045] In one embodiment, the resolution conversion factor may be less than 1, so as to reduce the resolution of the position output by the target encoder.

[0046] In this embodiment, since the resolution supported by the host computer that only supports pulse encoders is relatively low, and the resolution of the encoder using the serial protocol is much larger than the resolution of the pulse encoder, it is necessary to reduce the resolution of the position of the target encoder to reduce the transmission speed of the position data so that the host computer can support the access of the target encoder.

[0047] In one embodiment, the output module 140 is further configured to output a Z-phase signal matching the pulse width mode of the target encoder 210 when the current count value of the counter 130 reaches the zero position of the target encoder 210 .

[0048] The pulse width mode is used to indicate the pulse width of the zero position of the Z phase signal. For example, the pulse width mode includes 1 / 4 pulse width mode, 1 / 2 pulse width mode, 3 / 4 pulse width mode and 1 times pulse width mode. The pulse width refers to the pulse width of a pulse.

[0049] Specifically, when the target encoder 210 outputs the zero position, the current position of the target encoder 210 is obtained. When the current count value reaches the current position, the counter 130 is used to output a zero trigger signal; after the output module 140 receives the zero trigger signal, it outputs a Z-phase signal that matches the pulse width mode of the target encoder 210. Taking the zero point position as a high level as an example, when generating the Z signal, the integer part of the count value can be observed. Assuming that the zero point position of the target encoder 210 is Pz, it is only necessary to multiply it by the resolution conversion coefficient K to obtain the current zero point position, and output a high level whenever the integer part of the count value is equal to the current zero point position, which is equivalent to a virtual encoder outputting a Z-phase signal in real time according to the zero point position of the target encoder.

[0050] In this embodiment, when the current count value of the counter reaches the zero position of the target encoder, a Z-phase signal matching the pulse width mode of the target encoder is output, and an encoder of any communication mode can be converted into a zero-position pulse signal and output to the host computer.

[0051] In one embodiment, the edge value is a two-bit binary value; the output module 140 is used to perform a logical operation based on the two-bit binary value to obtain a target A-phase level and a target B-phase level; generate a target A-phase signal according to the A-phase level and generate a target B-phase signal according to the B-phase level.

[0052] Specifically, the edge value is a two-bit binary number, and the edge value is 00, 01, 10, and 11, which correspond to the four edge conditions of the A-phase signal and the B-phase signal. Figure 2 As shown, it is a schematic diagram of the signal output format of phase A leading and phase B leading in one embodiment. Figure 2 All of them are pulse signals. In one cycle, it can be divided into 4 areas, namely area 0, area 1, area 2 and area 3, corresponding to edge values ​​00, 01, 10 and 11, bit1 and bit0 respectively. Define area 0 when both phase A signal and phase B signal are low. It can be understood that other situations can also be defined as area 0. Taking phase A leading as an example, when phase A level is high and phase B level is low, it is area 1; when phase A level is high and phase B level is high, it is area 2; when phase A level is low and phase B level is high, it is area 3. High level is regarded as 1 and low level is regarded as 0. Then the relationship between edge value, phase A level and phase B level can be obtained after performing logical operation on two binary values. The same is true for the phase B leading mode, which will not be repeated here.

[0053] Optionally, when the target encoder 210 is in the A-phase advance mode, the two-bit binary value is XORed to obtain the A-phase level, and the first bit (bit1) of the edge value is used as the B-phase level, thereby generating a target A-phase signal and a target B-phase signal.

[0054] When the target encoder 210 is in the B-phase advance mode, the two binary values ​​are XORed to obtain the B-phase level, and the first bit (bit1) of the edge value is used as the A-phase level, thereby generating the target A-phase signal and the target B-phase signal.

[0055] Optionally, when the target encoder 210 is in the A-phase lead mode, the two-bit binary value is XORed to obtain the A-phase level, and the first bit (bit1) of the edge value is inverted as the B-phase level, thereby generating a target A-phase signal and a target B-phase signal.

[0056] When the target encoder 210 is in the B-phase advance mode, the two-bit binary value is XORed to obtain the B-phase level, and the first bit (bit1) of the edge value is inverted as the A-phase level, thereby generating the target A-phase signal and the target B-phase signal.

[0057] In this embodiment, logical operations are performed based on two-bit binary values ​​to obtain the target A phase level and the target B phase level, and generate the target A phase signal and the target B phase signal. The encoder outputs of different communication modes can be converted into pulse outputs through simple counting, and the implementation method is simple.

[0058] In one embodiment, the counter 130 includes an accumulator and a pulse counter 130 connected to each other, and the pulse counter 130 is connected to the output module 140;

[0059] The accumulator is used for accumulating counts at a reference speed, and when the count reaches an edge characterization value, the pulse counter 130 is used for updating the edge value.

[0060] The edge characterization value refers to the value corresponding to the edge. For example, the edge characterization value is 0.25, which is the bit 0 of the edge value (2 -2 =0.25). Every time the count value of the accumulator increases by 0.25, the edge value of the trigger pulse counter 130 increases by one; every time the count value of the accumulator decreases by 0.25, the edge value of the trigger pulse counter 130 decreases by one. The principle is that the accumulator counts from 0 to 0.235678, to 0.245698 at the reference speed until the pulse counter increases by one at 0.25. Or, taking binary as an example, Figure 3 FIG. 1 is a schematic diagram of the bit width of the counter 130 in one embodiment. In pulse units, the pulse value part can be considered as the integer part, and the edge value and the accumulator count value part are both decimal parts. The accumulator part represents the counting accuracy, such as Figure 3 Medium precision up to 2 -7 A pulse. Figure 3 When the accumulator reaches the edge representation value 111111, the edge value needs to be updated to 01, that is, the edge value changes from 00 to 01, and the signal also changes from A phase low level and B phase low level to A phase high level and B phase low level.

[0061] The counter 130 includes an accumulator and a pulse counter 130 connected to each other; the accumulator is used to connect to the target encoder 210, and the pulse counter 130 is connected to the output module 140. The pulse counter 130 is used to count pulses and edges. It can be understood that the integer part of the pulse counter 130 is used to count pulses, and the decimal part is used to count edges. For example, taking binary as an example, the current count value is expressed as 11.11, which means that the current count reaches the third edge of the third pulse.

[0062] Since the speed of the encoder can be calculated by counting the number of pulses in a fixed time interval, then the clock frequency of the circuit in the embodiment of the present application is 1 MHz, that is, the clock period is 10 -6 Seconds, s (seconds) = 10 6 T, where T is a fixed time interval, and the target encoder 210 rotates once for 1000p (pulses). If the speed of the target encoder 210 is very low, such as 1r (turn) per second, then v = 1r / s = 1000p / s = 1000 / 10 6 =10 -3 (Unit: P / T). At this time, the speed is very small, and the pulse counter 130 alone cannot accurately count. In this case, the accumulator can store the decimal places represented by the speed, such as 10. -3 To ensure accuracy.

[0063] In this embodiment, by dividing the counter into an accumulator and a pulse counter, the accumulator can be configured in bit width according to requirements, and can be easily replaced in hardware to meet different accuracy requirements.

[0064] In one embodiment, the circuit further includes a comparator, one end of which is connected to the calculation module 120, and the other end of which is connected to the counter 130; the comparator is used to compare the current count value with the current position, and when the current count value does not reach the current position, the counter 130 is triggered to continue counting at a reference speed; and when the current counter 130 reaches the current position, the counter 130 is triggered to stop counting.

[0065] Specifically, the comparator is used to compare the current count value with the current position. When the current count value does not reach the current position, that is, the counter 130 has not tracked the current position, the counter 130 continues to track the current position and continues to count at the reference speed. When the current count value reaches the current position, it means that all pulses represented by the target encoder 210 have been issued, and the counter 130 is triggered to stop counting.

[0066] In this embodiment, the counter tracks the current count value, compares the current count value with the current position through the comparator, and triggers the counter to continue counting or stop counting. That is, when the target encoder is working, it will continue to output the target A phase signal and the target B phase signal, and when the target encoder stops working, it does not need to output the signal and can switch the circuit along with the target encoder.

[0067] In one embodiment, Figure 4 As shown, it is a flow chart of a pulse output method of an encoder, which can be applied to a processor, and the processor can be a central processing unit (CPU), a field programmable gate array (FPGA), etc., including:

[0068] Step 402, obtaining the time difference of the target encoder position update.

[0069] Step 404, when the target encoder outputs a position, the reference speed of the target encoder is determined according to the current position of the target encoder, the current count value and the time difference; the current count value starts to be updated after obtaining the reference speed.

[0070] Step 406, updating the current count value with the reference speed.

[0071] Step 408: output a target A-phase signal and a target B-phase signal according to the edge value represented by the current count value.

[0072] In this embodiment, since the current count value starts to be updated after the reference speed is obtained, the current count value represents the last position of the target encoder for reference; when the target encoder outputs the position, that is, when the target encoder transmits the position to the outside, the reference speed of the target encoder can be determined according to the current position of the target encoder, the current count value and the time difference between the position update, and the count value is updated at the reference speed, which can make the entire counting process smooth and reduce fluctuations; by analyzing the edge of the encoder, it can be known that the edge value represents the level of the A-phase signal and the B-phase signal. The pulse output circuit of the encoder in this embodiment can convert all encoders into the output signal of the pulse encoder, so that the host computer that only supports the pulse communication method can transmit data with various encoders through the circuit in this embodiment.

[0073] In one embodiment, a target A phase signal and a target B phase signal are output according to an edge value represented by a current count value, including: determining a target A phase level and a target B phase level according to the edge value represented by the current count value; generating a target A phase signal according to the target A phase level, and generating a target B phase signal according to the target B phase level.

[0074] Specifically, the memory pre-stores a mapping relationship between the edge value and the corresponding A-phase level and B-phase level. Therefore, the processor can determine the target A-phase level and the target B-phase level from the mapping relationship according to the edge value represented by the current count value.

[0075] In this embodiment, based on the edge value represented by the current count value, the target A phase level and the target B phase level are obtained, and the target A phase signal and the target B phase signal are generated. The encoder outputs of different communication modes can be converted into pulse outputs through simple counting, and the implementation method is simple.

[0076] In one embodiment, determining a reference speed of the target encoder according to a current position of the target encoder, a current count value of the counter, and a time difference includes:

[0077] Performing resolution conversion on the position output by the target encoder according to the resolution conversion coefficient to obtain the current position of the target encoder;

[0078] The reference speed of the target encoder is determined according to the current position of the target encoder, the current count value of the counter and the time difference.

[0079] In this embodiment, the resolution supported by the host computer may not match the resolution of the target encoder. Therefore, by setting a resolution conversion coefficient for resolution conversion, the target encoder can be adapted to the host computer and the data of the target encoder can be transmitted to the host computer.

[0080] In one embodiment, the method further includes: when the current count value of the counter reaches the zero position of the target encoder, outputting a target Z-phase signal matching the pulse width pattern of the target encoder.

[0081] In this embodiment, when the current count value reaches the zero position of the target encoder, a target Z-phase signal matching the pulse width mode of the target encoder is output, and an encoder of any communication mode can be converted into a zero-position pulse signal and output to the host computer.

[0082] In one embodiment, updating the current count value at a reference speed includes: comparing the current count value with the current position, and updating the current count value at the reference speed when the current count value does not reach the current position; and stopping counting when the current counter reaches the current position.

[0083] In this embodiment, when the current count value does not reach the current position, it means that the current position of the target encoder has not been tracked and needs to be tracked further; when the current count value reaches the current position, it means that the current position of the target encoder has been tracked, the signals have been sent, and it can be turned on and off with the target encoder.

[0084] For the specific limitations on the pulse output method of the encoder, please refer to the limitations on the pulse output circuit of the encoder mentioned above, which will not be repeated here.

[0085] In one embodiment, a pulse output circuit of an encoder includes:

[0086] Step (a1), obtaining the time difference of the target encoder position update.

[0087] Step (a2), when the target encoder outputs a position, the resolution of the position output by the target encoder is converted according to the resolution conversion coefficient to obtain the current position of the target encoder.

[0088] Step (a3), determining the reference speed of the target encoder according to the current position of the target encoder, the current count value of the counter and the time difference; the current count value starts to be updated after obtaining the reference speed.

[0089] Step (a4), comparing the current count value with the current position, and when the current count value does not reach the current position, updating the current count value at the reference speed.

[0090] Step (a5), determining the A-phase level and the B-phase level according to the edge value represented by the current count value.

[0091] Step (a6), generating a target A-phase signal according to the A-phase level, and generating a target B-phase signal according to the B-phase level.

[0092] Step (a7), when the current count value of the counter reaches the zero position of the target encoder, a target Z-phase signal matching the pulse width pattern of the target encoder is output.

[0093] Step (a8), when the current counter reaches the current position, stop counting.

[0094] It should be understood that although the above Figure 4 The steps in the flowchart are shown in sequence as indicated by arrows, and the steps in steps (a1) to (a8) are shown in sequence as indicated by numbers, but these steps are not necessarily performed in the order indicated by arrows or numbers. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be performed in other orders. Moreover, Figure 4 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0095] In one embodiment, Figure 5 FIG. 1 is a circuit diagram of a pulse output circuit of an encoder in one embodiment. Figure 5 The target encoder, calculation module, accumulator, pulse counter, and output module are connected in sequence. The timing module is connected to the speed calculation unit. One end of the comparator is connected to the frequency division unit, the other end is connected to the pulse counter, and the enable end is connected to the accumulator. The target count value in the calculation module indicates the current position of the target encoder.

[0096] 1. Timing module

[0097] The timing module works under the system clock, adding one per clock cycle until it is cleared when a feedback position update event occurs, thereby recording the time difference between two position updates. The feedback position update event can be provided by the position source (i.e., the corresponding encoder interface) or generated by the timing module according to a preset count cycle.

[0098] 2. Computing module

[0099] The calculation module includes two calculation steps. The first step is resolution conversion, which is to multiply the position data output by the target encoder by the preset resolution conversion coefficient to convert it into the target value of the pulse counter to represent the current position of the target encoder. The second step is speed calculation, which is to first subtract the current count value of the pulse counter from the target count value to obtain the remaining number of pulses, and then divide it by the time difference of the timing module to obtain the reference speed value, that is, to obtain the incremental value and direction of the virtual encoder position within the unit system clock cycle.

[0100] Here, an increment threshold (not exceeding 0.25) can be preset. If the calculated increment value is greater than the threshold, the output increment value is directly replaced by the threshold, thereby limiting the pulse output frequency.

[0101] 3. Comparator

[0102] The comparator is responsible for comparing the current count value of the pulse counter with the target count value. If the two are not equal, it means that the current number of remaining pulse edges is not 0. At this time, the accumulator will be enabled to start working so that the pulse counter continues to track the target value; if the two are equal, it means that all pulses have been sent, so the accumulator can be turned off.

[0103] 4. Accumulator

[0104] The accumulator accumulates and sums upward or downward according to the incremental value and direction (reference speed) provided by the calculation module, and triggers the counting process of the pulse counter. Every time the accumulator increases by 0.25, the pulse counter is triggered to increase by one; every time the accumulator decreases by 0.25, the pulse counter is triggered to decrease by one.

[0105] 5. Pulse counter

[0106] The pulse counter is used to record the number of pulses currently issued. It only retains 2 decimal places (binary). These two decimal places are used to record the area number of the pulse cycle to which the current position of the target encoder belongs.

[0107] Here, a maximum count value needs to be preset. When the pulse counter underflows, it returns to the maximum value, and when the pulse counter overflows, it is reset to 0.

[0108] 6. Output Module

[0109] The output module is responsible for generating A, B, and Z three-phase pulse signals according to the count value of the pulse counter. The AB phase output includes two modes: A phase leading and B phase leading. The Z signal output includes four modes: 1 / 4 line width, 1 / 2 line width, 3 / 4 line width, and 1 times line width:

[0110] (1) AB phase signal output

[0111] If it is A phase leading mode, let A phase level equal to the logic XOR level of bit0 and bit1 of the pulse counter, and B phase level equal to bit1 of the pulse counter.

[0112] If it is the B phase leading mode, let the B phase level equal to the logic XOR level of bit0 and bit1 of the pulse counter, and the A phase level equal to bit1 of the pulse counter.

[0113] (2) Z phase signal output

[0114] If the Z signal is in 1 / 4 line width mode, the Z phase outputs a high level when the integer part of the pulse counter is equal to the zero position and the decimal place is equal to 0, otherwise it outputs a low level.

[0115] If the Z signal is in 1 / 2 line width mode, the Z phase outputs a high level when the integer part of the pulse counter is equal to the zero position and the decimal place is less than or equal to 1, otherwise it outputs a low level.

[0116] If the Z signal is in 3 / 4 line width mode, the Z phase outputs a high level when the integer part of the pulse counter is equal to the zero position and the decimal place is less than or equal to 2, otherwise it outputs a low level.

[0117] If the Z signal is in 1x line width mode, the Z phase outputs a high level when the integer part of the pulse counter is equal to the zero position, otherwise it outputs a low level.

[0118] The following is the implementation process of the encoder's pulse output method:

[0119] 1. If the number of AB pulses that the driver needs to output when the motor rotates one circle is M, a pulse encoder with a resolution of M can be virtualized, and a counter can be set to indicate the current position of the virtual encoder, with a counting range of 0 to M-1. Every time the counter changes by 1, the AB port of the corresponding virtual encoder outputs a pulse, and when the count value crosses the zero position, the Z port outputs a pulse.

[0120] 2. Feedback location update method

[0121] (1) The target encoder is a serial communication feedback encoder

[0122] The serial encoder interface module provides position data and triggers a position update event at the end of communication. This ensures that the feedback data is always the latest value, but the data update cycle is uncertain and has certain fluctuations.

[0123] (2) The target encoder is a pulse feedback encoder

[0124] The pulse encoder interface module provides position data, and the timing module generates position update events according to a preset period, so that the position update rate can be determined as needed.

[0125] 3. Resolution conversion

[0126] Assuming that the position data resolution of the actual encoder (i.e., the target encoder) feedback is N, the resolution conversion coefficient K=M / N can be defined. Whenever the feedback position is updated, it only needs to be multiplied by K to obtain the current position P of the actual encoder represented in the virtual pulse encoder.

[0127] 4. Virtual encoder tracking process

[0128] (1) Feedback position first update

[0129] Assuming that the feedback position is P0, the virtual position value K*P0 is obtained after resolution conversion. At this time, the current count value C0 of the counter is directly updated to K*P0 so that the virtual encoder position is the same as the feedback encoder position.

[0130] (2) Feedback position second update

[0131] Assuming that the feedback position is P1, the current position value K*P1 is obtained after resolution conversion, and the time difference T1 between this time and the first update is recorded.

[0132] Subtract the current count value C0 of the counter from the feedback position K*P1 and divide it by the time difference T1 to calculate the rotation speed (reference speed) of the virtual pulse encoder V1=(K*P1-C0) / T1=K(P1-P0) / T1.

[0133] Next, the counter will start changing from C0 at speed V1 until the current count value also equals K*P1. This counting process is equivalent to the virtual encoder tracking the latest position K*P1 of the actual encoder from the current position C0.

[0134] (3) Feedback position xth update (x>2)

[0135] Assume that the feedback position is P x , after resolution conversion, the virtual position value K*P is obtained x , record the time difference T between this time and the last update x .

[0136] Use feedback position K*P x Subtract the current value C of the counter x-1 Divide by the time difference T x , thereby calculating the speed V of the virtual pulse encoder x =(K*P x -C x-1 ) / Tx.

[0137] Next, the counter will be incremented from C x-1 Position according to speed V x Start changing until the count value also equals K*P x This counting process is equivalent to the virtual encoder from the current position C x-1 Track the latest position K*P of the actual encoder x .

[0138] Considering the fluctuation of each feedback position update time or the pulse output speed limit, the counter’s last tracking process may not be completed when the position is updated. x-1 May not reach K*P yet x-1 Therefore, when calculating the speed, the number to be subtracted is the current count value C of the counter. x-1 Rather than the feedback position value K*P of the last target encoder x-1 , so that the remaining position difference from the last tracking is retained in this tracking process, thus avoiding cumulative errors.

[0139] 5. Illustration of the virtual encoder position tracking process

[0140] like Figure 6 As shown in FIG. 1 , a schematic diagram of the position tracking process in an embodiment is shown. Assuming that the resolution conversion coefficient K is 0.1, the initial value of the feedback position (the position output by the target encoder) is 100, and then changes backward uniformly at a rate of 50 per time unit. The actual feedback position is the position output by the target encoder, and the virtual feedback position is the current position of the target encoder. It can be understood that Figure 6 The speed indicated in is very large. When the speed is low, Figure 6 The values ​​in are reduced by several orders of magnitude.

[0141] (1) The first feedback position P0 is updated to 100, the calculated virtual position value is 10, and the counter is directly updated to 10.

[0142] (2) The second feedback position P1 is updated to 400, and the calculated virtual position value is 40. The recorded time difference T1 is 6, so the speed V1 is 5 = (40-10) / 5, and the counter increases by 5 per time unit starting from 10; that is, when the actual encoder feeds back the position for the second time, the current count value of the counter is still 10, and the speed V1 is calculated and then counted from 10.

[0143] (3) The third feedback position P2 is updated to 650, the calculated virtual position value is 65, and the recorded time difference T2 is 5. At this time, the counter has only increased to 35, which is 5 less than the tracking target. Therefore, the speed V2 is 6 = (65-35) / 5. The counter increases by 6 per time unit starting from 35, which is equivalent to the virtual encoder accelerating to catch up with the actual position.

[0144] (4) The fourth feedback position P3 is updated to 900, the calculated virtual position value is 90, and the recorded time difference T3 is 6. At this time, the counter has increased to 65, reaching the target value. Therefore, the speed V3 is 5 = (90-65) / 5, and the counter increases by 5 every time unit starting from 65.

[0145] (5) If the fifth feedback position is not updated, the current count value has reached the current position 90 of the target encoder, and counting stops. If the fifth feedback position is updated, the current count value has not reached the fifth updated position of the target encoder, and the time difference T4 of the target encoder position update is continued to be obtained, and subsequent counting and signal output are continued.

[0146] 7.ABZ three-phase signal generation

[0147] Since both phases AB have a rising edge and a falling edge in one pulse cycle, one pulse cycle can be divided into four regions according to the level of the two-phase AB signal, so that there is only one edge when switching between two adjacent regions. Figure 2 As shown in the figure, the area when both AB are at low level at the same time is fixed as 0. The decimal part refers to the edge value part. The decimal part 0 corresponds to the binary edge value 00, the decimal part 0.25 corresponds to the binary edge value 01, the decimal part 0.5 corresponds to the binary edge value 10, and the decimal part 0.75 corresponds to the binary edge value 11.

[0148] (1) When generating AB two-phase signals, the count value of 1 represents a pulse width. Therefore, the decimal part of the count value can be observed to determine the AB phase level. Take the A phase leading as an example to illustrate:

[0149] When the decimal part is between 0 and 0.25, it belongs to the 0 area, so phase A outputs a low level and phase B outputs a low level.

[0150] When the decimal part is between 0.25 and 0.5, it belongs to area 1, so phase A outputs a high level and phase B outputs a low level.

[0151] When the decimal part is between 0.5 and 0.75, it belongs to area 2, so phase A outputs a high level and phase B outputs a high level.

[0152] When the decimal part is between 0.75 and 1, it belongs to area 3, so phase A outputs a low level and phase B outputs a high level.

[0153] From this, we can see that we only need to compare the decimal value of the counter in real time and select the level output corresponding to AB, which is equivalent to a virtual encoder outputting the AB level in real time according to the current position.

[0154] (2) When generating the Z signal, the integer part of the count value can be observed. Assuming that the zero position of the actual encoder is Pz, it is only necessary to multiply it by the resolution conversion coefficient K to obtain the current zero position of the actual encoder. Whenever the integer part of the count value is equal to the current zero position of the actual encoder, a high level is output, which is equivalent to a virtual encoder outputting the level of the Z phase signal in real time according to the current position.

[0155] In one embodiment, a driver is provided, which is used to be connected to a target encoder and a host computer respectively, and includes a pulse output circuit of the encoder in any of the above embodiments.

[0156] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned method embodiments when executing the computer program.

[0157] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method embodiments are implemented.

[0158] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.

[0159] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes in the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0160] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A pulse output circuit of an encoder, It is characterized in that The circuit comprises: Timing module, used to obtain the time difference of target encoder position update; A calculation module, connected to the target encoder and the timing module respectively, and when the target encoder outputs a position, determining a reference speed of the target encoder according to the current position of the target encoder, the current count value of the counter and the time difference; the current count value starts to be updated after obtaining the reference speed; The counter is connected to the calculation module and is used to update the current count value at the reference speed; An output module is connected to the counter and is used to output a target A-phase signal and a target B-phase signal according to an edge value represented by the current count value.

2. The circuit according to claim 1, It is characterized in that The calculation module is used to perform resolution conversion on the position output by the target encoder according to the resolution conversion coefficient to obtain the current position of the target encoder; as well as A reference speed of the target encoder is determined according to the current position of the target encoder, the current count value of the counter and the time difference.

3. The circuit according to claim 1, It is characterized in that The output module is also used to output a Z-phase signal matching the pulse width mode of the target encoder when the current count value of the counter reaches the zero position of the target encoder.

4. The circuit according to claim 1, It is characterized in that The edge value is a two-bit binary value; The output module is used to perform a logic operation based on the two-bit binary value to obtain a target A-phase level and a target B-phase level; The target A-phase signal is generated according to the target A-phase level and the target B-phase signal is generated according to the target B-phase level.

5. The circuit according to claim 1, It is characterized in that The counter comprises an accumulator and a pulse counter connected to each other, the accumulator is used to be connected to the target encoder, and the pulse counter is connected to the output module; The accumulator is used for accumulating counts at the reference speed, and when the count reaches an edge characterization value, the pulse counter is used for updating the edge value.

6. The circuit according to claim 1, It is characterized in that The circuit further comprises a comparator, one end of the comparator is connected to the calculation module, and the other end of the comparator is connected to the counter; The comparator is used to compare the current count value with the current position, and when the current count value does not reach the current position, trigger the counter to continue counting at the reference speed; as well as When the current counter reaches the current position, the counter is triggered to stop counting.

7. A pulse output method of an encoder, It is characterized in that The method comprises: Get the time difference of target encoder position update; When the target encoder outputs a position, a reference speed of the target encoder is determined according to the current position of the target encoder, the current count value and the time difference; the current count value starts to be updated after obtaining the reference speed; updating the current count value at the reference speed; According to the edge value represented by the current count value, a target A-phase signal and a target B-phase signal are output.

8. The method according to claim 7, It is characterized in that Outputting a target A-phase signal and a target B-phase signal according to the edge value represented by the current count value includes: Determining a target A-phase level and a target B-phase level according to an edge value represented by the current count value; A target A-phase signal is generated according to the target A-phase level, and a target B-phase signal is generated according to the target B-phase level.

9. A driver, It is characterized in that Used to be connected to a target encoder and a host computer respectively, comprising the circuit described in any one of claims 1 to 6.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to claim 7 or 8 are implemented.

11. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to claim 7 or 8 are implemented.