Signal processing method of incremental encoder and incremental encoder
By processing the signals of the incremental encoder through FPGA, the cost and control stability problems caused by multiple encoders are solved, and multiple encoders with arbitrary output resolutions are realized, providing accurate information and high performance, and suppressing non-common mode interference. .
Patent Information
- Application Number
- CN202410831377.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-26
AI Technical Summary
When existing incremental encoders need to output different resolutions in different motion systems, multiple encoders are usually required, resulting in increased costs, poor synchronization, unstable control, and limited installation.
Field programmable logic array FPGA is used for signal processing. Through filtering, DDR sampling, fitting and prediction steps, it can process multiple high-frequency input signals, calculate the main frequency step size and predict the output signal position, and can output any desired resolution, reducing the number of encoders and improving control stability.
It implements multiple encoders with arbitrary output resolution, provides accurate incremental information, has high response performance and rate performance, suppresses non-common mode interference, reduces costs, and has unlimited installation.
Smart Images

Figure CN118424343B
Abstract
Description
Technical Field
[0001] A method for processing signals of an incremental encoder and an incremental encoder. Background Art
[0002] Incremental encoders are widely used in automated production lines, robotics, and servo motor control. In automated production lines, incremental encoders are used to measure and control machine position. In robotics, incremental encoders provide accurate motion feedback, enabling robots to precisely control their motion. In servo motor control, incremental encoders provide precise position feedback, enabling servo motors to achieve high-precision motion control.
[0003] Within the same motion system, different position acquisition systems may require outputs of varying resolutions. For example, systems requiring high resolution and systems unable to sample high-frequency pulses require multiple encoders when multi-point output is required, significantly increasing costs. Furthermore, multiple encoders suffer from poor synchronization, unstable control, and installation limitations. Alternatively, encoder line counts may require on-site configuration. While some approaches exist, these solutions often suffer from significant duty cycle jitter, unstable rate fluctuations, poor rigidity, and the ability to only divide but not multiply frequencies. Summary of the Invention
[0004] Embodiments of the present application provide a method for signal processing of an incremental encoder and an incremental encoder.
[0005] In a first aspect, an embodiment of the present application provides a method for signal processing of an incremental encoder, the method being implemented by a field programmable logic array (FPGA), the method comprising:
[0006] A filtering step, based on a sampling time and a preset time parameter, samples the received multiple high-frequency input signals, and filters the sampled signals to obtain an A-phase signal, a B-phase signal, and a Z-phase signal;
[0007] a DDR sampling step of performing double rate DDR sampling on the A-phase signal and the B-phase signal, respectively, and calculating a plurality of first speeds between each A-state change of the A-phase signal and each B-state change of the B-phase signal;
[0008] a fitting step of performing dynamic fitting based on the plurality of first speeds and calculating a main frequency step length in combination with a preset output resolution of the incremental encoder;
[0009] The prediction step predicts the positions of the A-phase output signal, the B-phase output signal, and the Z-phase output signal based on the main frequency step, the A-phase signal, the B-phase signal, and the Z-phase signal.
[0010] In a second aspect, an embodiment of the present invention provides an incremental encoder, including a field programmable logic array (FPGA), wherein the FPGA includes:
[0011] The filtering unit samples the received multiple high-frequency input signals based on the sampling time and the preset time parameters, and filters the sampled signals to obtain an A-phase signal, a B-phase signal, and a Z-phase signal;
[0012] a DDR sampling unit, performing double rate DDR sampling on the A-phase signal and the B-phase signal, respectively, and calculating a plurality of first speeds between each A-state change of the A-phase signal and each B-state change of the B-phase signal;
[0013] a fitting unit, performing dynamic fitting based on the plurality of first speeds and calculating a main frequency step length in combination with a preset output resolution of the incremental encoder;
[0014] The prediction unit predicts positions of the A-phase output signal, the B-phase output signal, and the Z-phase output signal based on the main frequency step, the A-phase signal, the B-phase signal, and the Z-phase signal.
[0015] The encoder in the present invention can conveniently output any desired output resolution without using multiple encoders, thereby reducing costs, providing stable control, and unlimited installation.
[0016] The present invention can simultaneously feed back accurate incremental information to multiple encoders with arbitrary output resolutions, has high response performance and rate performance, and can suppress non-common mode interference. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 According to an embodiment of the present application, a schematic structural diagram of an incremental encoder is shown;
[0018] Figure 2 According to an embodiment of the present application, a flow chart of a method for signal processing of an incremental encoder is shown;
[0019] Figure 3 According to an embodiment of the present application, a schematic diagram of an A-phase signal, a B-phase signal, and a Z-phase signal is shown;
[0020] Figure 4 According to an embodiment of the present application, a schematic diagram of calculating a first speed is shown. DETAILED DESCRIPTION
[0021] Illustrative embodiments of the present application include, but are not limited to, a method of signal processing for an incremental encoder and an incremental encoder.
[0022] An incremental encoder converts the displacement information of a moving device into a continuous pulse signal, with the number of pulses representing the magnitude of the displacement. An incremental encoder only outputs a signal when the device is moving. The encoder typically divides these signals into two output groups: Channel A and Channel B, with a 90° phase difference between the two groups. By simultaneously acquiring these two signals, the direction and angle of rotation can be determined. In addition to Channels A and B, incremental encoders also have an additional Channel Z output signal, which represents the encoder's specific mechanical zero reference position. Incremental encoders only output the device's position change and direction of motion; they do not output the device's absolute position. The three-phase output of A, B, and Z helps improve the encoder's resolution and accuracy, enabling it to more accurately reflect the state of motion.
[0023] In this invention, an FPGA (field programmable gate array) is used to filter the differential signals of the three input channels A, B, and Z, respectively, according to a minimum level duration parameter, to obtain single-ended signals A, B, and Z. DDR (double data rate) sampling is performed on each of the single-ended signals A and B to obtain high-resolution speed and the encoder's direction of motion, thereby obtaining speed X1.
[0024] The filtered velocity X1 is subjected to a series of algorithmic compensations and unit conversions. Combined with the desired output resolution, the frequency step length is calculated. The frequency step length and output resolution are then used to predict the state change point for output A or B, and the A and B levels are output. Based on the high-level state of the Z signal, the reference mechanical zero position is predicted and the Z signal is output. This process is repeated using different output resolutions, outputting A, B, and Z signals for each output resolution. The compensated position is then used to generate single-ended A, B, and Z outputs. Finally, differential A, B, and Z signals are output through a differential circuit.
[0025] The embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
[0026] Figure 1 FIG2 shows a schematic structural diagram of an incremental encoder 100 according to an embodiment of the present application. The incremental encoder 100 includes a receiving circuit 101 , a field programmable logic array (FPGA) 102 , and a differential circuit 103 .
[0027] Receiver circuit 101 is configured to receive multiple input pulses of arbitrary high-frequency resolution as multiple high-frequency input signals. Receiver circuit 101 is provided with an A+ signal terminal, an A- signal terminal, a B+ signal terminal, a B- signal terminal, a Z+ signal terminal, and a Z- signal terminal. Thus, it can generate six high-frequency input signals: an A+ input signal, an A- input signal, a B+ input signal, a B- input signal, a Z+ input signal, and a Z- input signal.
[0028] FPGA 102 receives six high-frequency input signals from receiving circuit 101 and processes these signals. FPGA 102 includes a filtering unit 1021 , a DDR sampling unit 1022 , a fitting unit 1023 , and a prediction unit 1024 .
[0029] Figure 2 A signal processing method for an incremental encoder according to an embodiment of the present invention is shown, and the method is implemented by FPGA 102 .
[0030] In the filtering step S21 , the filtering unit 1021 samples the received multiple high-frequency input signals based on the sampling time and the preset time parameter, and filters the sampled signals to obtain an A-phase signal, a B-phase signal, and a Z-phase signal.
[0031] The multiple high-frequency input signals include three pairs of differential input signals, each pair of differential input signals includes a positive input signal and a negative input signal, and the positive input signal and the negative input signal are synthesized to obtain a synthesized signal of the pair of differential input signals.
[0032] For example, the first pair of A-phase differential input signals includes an A+ input signal (i.e., a positive input signal) and an A- input signal (i.e., a negative input signal), and the A+ input signal and the A- input signal are combined to generate a combined signal A. The second pair of B-phase differential input signals includes a B+ input signal (i.e., a positive input signal) and a B- input signal (i.e., a negative input signal), and the B+ input signal and the B- input signal are combined to generate a combined signal B. The third pair of Z-phase differential input signals includes a Z+ input signal (i.e., a positive input signal) and a Z- input signal (i.e., a negative input signal), and the Z+ input signal and the Z- input signal are combined to generate a combined signal Z.
[0033] In this step, each positive input signal and each negative input signal are sampled in the following manner.
[0034] Specifically, for example, for the A+ input signal, when sampling is performed at the same level and the sampling time is greater than the preset time parameter, the A+ input signal is recorded (sampled), otherwise the state of the composite signal A remains unchanged.
[0035] For example, for the A-input signal, when sampling is performed at the same level and the sampling time is greater than the preset time parameter, the A-input signal is recorded (sampled), otherwise the state of the composite signal A remains unchanged.
[0036] Here, the state of the composite signal refers to the level of the composite signal, ie, a high level or a low level.
[0037] Similarly, other positive input signals and negative input signals are sampled in the above manner.
[0038] Here, the preset time parameter is determined based on the internal main frequency of FPGA 102, the input resolution of the high-frequency input signal, and the maximum rotation speed of the code disk in incremental encoder 100. The preset time parameter is, for example, a minimum level duration parameter KT_Min, which is specifically calculated using the following formula 1.
[0039] Formula 1:
[0040] During device operation, the theoretical minimum duration of the original input signal is the ratio of the duration of the resolution at maximum speed to the internal clock frequency of the FPGA. However, during encoder operation, the encoder may exceed the speed or experience jitter, causing the original input signal duration to be less than the theoretical minimum duration. Therefore, a duration margin of less than 1 is defined as a coefficient based on these conditions.
[0041] Next, the sampled input signal is filtered as follows.
[0042] During the sampling process, when the recorded positive input signal and the negative input signal are opposite, sampled at the same level and the sampling time is greater than the preset time parameter, if the recorded positive input signal is consistent with the state of the composite signal, the state of the composite signal remains unchanged; otherwise, the state of the composite signal is changed to the positive input signal.
[0043] For example, when the recorded (sampled) A+ input signal and the A- input signal are opposite, sampled at the same level and the sampling time is greater than KT_Min, if the recorded A+ input signal is consistent with the state of the composite signal A, for example, both are high levels, then the state of the composite signal A remains unchanged (i.e., remains at a high level); otherwise, the state of the composite signal A is changed to the A+ input signal.
[0044] Similarly, the sampled B+ input signal and B- input signal, and the sampled Z+ input signal and Z- input signal are filtered in the above manner to obtain respective composite signals B and Z.
[0045] After the above sampling and filtering, the final synthesized signals A, B, and Z are used as the A-phase signal, B-phase signal, and Z-phase signal, as shown in Figure 3 In the present invention, the burrs of non-common mode interference can be suppressed to the greatest extent through the filtering step.
[0046] In DDR sampling step S22, DDR sampling unit 1022 performs double data rate (DDR) sampling on the A-phase signal and the B-phase signal, respectively, and calculates multiple first velocities between each A-state change of the A-phase signal and each B-state change of the B-phase signal. This method utilizes high-frequency DDR technology to conveniently sample the A-phase and B-phase quadrature signals, thereby obtaining high-resolution velocity information.
[0047] Specifically, a clock phase-locked loop (PLL) within FPGA 102 generates a high-frequency clock and a main-frequency clock. The high-frequency clock and the main-frequency clock are multiples of each other and are periodically aligned at the multiple. The frequency of the high-frequency clock is higher than that of the main-frequency clock. For example, the high-frequency clock is 320 megahertz (MHz) and the main-frequency clock is 40 MHz.
[0048] The A-phase signal and the B-phase signal are respectively subdivided and sampled with a high-frequency clock, and then the A-phase signal and the B-phase signal are respectively sampled at the main frequency clock. Based on the subdivided sampling and the main frequency sampling, multiple first speeds between each A-state change of the A-phase signal and each B-state change of the B-phase signal are calculated.
[0049] Specifically, for a consecutive A state change and a B state change, the first speed is calculated based on the number of main frequencies between the A state change and the B state change, the number of starting subdivision samples of the start state change, and the number of ending subdivision samples of the end state change.
[0050] In this embodiment, the state change refers to a change in the signal level between high and low levels, that is, the state change occurs when the signal level has a rising edge or a falling edge.
[0051] Here, one of the state changes A and B is the starting state change, and the other state change is the ending state change. Figure 4 As shown, first, a rising edge appears at A, and the state change of A is the starting state change; secondly, a rising edge appears at B, and the state change of B is the ending state change.
[0052] Specifically, the first speed X1 is calculated by the following formula 2.
[0053] Formula 2:
[0054] exist Figure 4 In the example shown, the number of main frequencies between the rising edge of A and the rising edge of B is 5, the number of starting subdivision samples is 8, and the number of ending subdivision samples is 1.
[0055] In the above manner, a plurality of first speeds X1 can be calculated between each successive change in state A and state B. It is understandable that the latest (most recent) X1 can be calculated as time changes.
[0056] It can be understood that, since there is a 90° phase difference between the A-phase signal and the B-phase signal, the rotation direction of the encoder can also be determined while calculating the first speed X1.
[0057] In the fitting step S23 , the fitting unit 1023 performs dynamic fitting based on the multiple first speeds X1 and calculates the main frequency step length in combination with the preset output resolution R1 of the incremental encoder 100 .
[0058] Specifically, the currently calculated 2 n-1 The consecutive first speeds X1 are added together to obtain n speeds, and a corresponding weight value is assigned to each speed, where n is an integer greater than or equal to 1.
[0059] For example, n is 1, 2, 3, 4, 5, 6, 7, or 8. For example, when n=1, the currently calculated (i.e., most recent) first velocity X1 is added together to obtain the first velocity X1; when n=2, the currently calculated two first velocities X1 are added together to obtain the second velocity X2; when n=3, the currently calculated four first velocities X1 are added together to obtain the third velocity X4; when n=4, the currently calculated eight first velocities X1 are added together to obtain the fourth velocity X8; when n=5, the currently calculated 16 first velocities X1 are added together to obtain the fifth velocity X16; when n=6, the currently calculated 32 first velocities X1 are added together to obtain the sixth velocity X32; when n=7, the currently calculated 64 first velocities X1 are added together to obtain the sixth velocity X64; and when n=8, the currently calculated 128 first velocities X1 are added together to obtain the eighth velocity X128.
[0060] Based on the n speeds and their respective weight values, the estimated speed of the incremental encoder 100 at different times t is calculated, and based on the currently calculated first speed X1 and the weighted sum of the n weight values, the sampling speed is calculated.
[0061] Specifically, the estimated speed is calculated based on the following Formula 3, and the sampling speed is calculated based on the following Formula 4.
[0062] Formula 3:
[0063]
[0064] Formula 4:
[0065] The weight sum refers to the sum of the weights of the eight speeds, that is, the sum of weight (1), weight (2), weight (3), weight (4), weight (5), weight (6), weight (7), and weight (8).
[0066] Based on the difference between the estimated speed and the sampled speed, each of the eight weights is adjusted. Specifically, when the difference is smaller, n weights are adjusted so that the larger n is, the larger the weight, and the smaller n is, the smaller the weight. When the difference is larger, n weights are adjusted so that the larger n is, the smaller the weight, and the smaller n is, the larger the weight.
[0067] Then, the main frequency step size is calculated based on the preset output resolution R1, the weight sum of the adjusted 8 weight values, the current estimated speed, and the step size error.
[0068] It can be understood that the current estimated speed is calculated based on the adjusted 8 weight values.
[0069] The main frequency step size can be calculated based on the following formula 5.
[0070] Formula 5:
[0071] The initial value of the step error is 0. Here, the step error is adjusted based on the A-phase signal, the B-phase signal, the input resolution of the high-frequency input signal, and the preset output resolution R1. The details will be described below. It is understood that the initial value of the step error is 0.
[0072] In the prediction step S24 , the prediction unit 1024 predicts the positions of the A-phase output signal, the B-phase output signal, and the Z-phase output signal based on the main frequency step size, the A-phase signal, the B-phase signal, and the Z-phase signal.
[0073] First, the actual position is calculated based on the state changes of the A-phase signal and the B-phase signal, the preset output resolution R1, and the input resolution of the high-frequency input signal.
[0074] The actual position is represented by the actual input accumulation M1 and the actual output accumulation M2. The actual input accumulation M1 and the actual output accumulation M2 are calculated as follows.
[0075] When the A-phase signal and the B-phase signal have rising edges or falling edges, the actual input accumulation M1 is accumulated and added or subtracted using the preset output resolution R1 based on the rising edges or falling edges of the A-phase signal and the B-phase signal and the relative level status.
[0076] Specifically, according to the well-known encoder quadruple frequency phase detection, when the A-phase signal has a rising edge, if the other signal is at a high level, it is an addition operation (ie, M1+R1), otherwise it is a subtraction operation (ie, M1-R1).
[0077] When the A-phase signal has a falling edge, if the other signal is at a high level, it is an addition operation (ie, M1-R1), otherwise it is a subtraction operation (ie, M1+R1).
[0078] When the B-phase signal has a rising edge, if the other signal is at a high level, it is an addition operation (ie, M1-R1), otherwise it is a subtraction operation (ie, M1+R1).
[0079] When the B-phase signal has a falling edge, if the other signal is at a high level, it is an addition operation (ie, M1+R1), otherwise it is a subtraction operation (ie, M1-R1).
[0080] It is understandable that the initial value of the actual input accumulation M1 is 0.
[0081] If the actual input accumulation M1 is greater than or equal to the input resolution, the actual input accumulation M1 is modulo the input resolution, that is, the actual input accumulation M1 / input resolution, and then the remainder is taken. At this time, the actual output accumulation M2 is added to the quotient, and the actual input accumulation M1 is equal to the remainder.
[0082] It is understandable that the initial value of the actual output accumulation M2 is 0.
[0083] If the actual input accumulation M1 is less than 0, the actual input accumulation M1 is modulo the input resolution. At this time, the actual output accumulation M2 is added to the quotient, and the actual input accumulation M1 is equal to the remainder plus the input resolution.
[0084] If the actual output accumulation M2 is greater than or equal to 4 times the preset output resolution R1, the remainder of 4 times the preset output resolution R1 is calculated for the actual output accumulation M2, and the actual output accumulation M2 is equal to the remainder.
[0085] If the actual output accumulation M2 is less than 0, the actual output accumulation is modulo 4 times the preset output resolution R1, and the actual output accumulation M2 is equal to the remainder plus 4 times the preset output resolution R1.
[0086] It is understandable that according to Figure 3 The A-phase signal and the B-phase signal shown in the figure can continuously update the actual input accumulation M1 and the actual output accumulation M2 over time.
[0087] Next, the predicted position is calculated based on the state changes of the A-phase signal and the B-phase signal, the input resolution, and the main frequency step size.
[0088] The predicted position is represented by the predicted input accumulation N1 and the predicted output accumulation N2. The specific calculation of the predicted input accumulation N1 and the predicted output accumulation N2 is as follows.
[0089] Based on the rising edge of the main frequency clock, the predicted input accumulation N1 is accumulated using the main frequency step size to perform cumulative addition or subtraction operations.
[0090] Specifically, first, it is determined whether to perform an addition or subtraction operation based on the respective state changes of the A-phase signal and the B-phase signal, and then an addition or subtraction operation is performed every time a rising edge of the main frequency clock appears.
[0091] For example, when a rising edge occurs in the A-phase signal and the B-phase signal is at a high level, an addition operation is performed. Then, each time a rising edge of the main frequency clock occurs, the predicted input accumulation N1 is increased by the main frequency step size.
[0092] For example, when a falling edge occurs in the A-phase signal and the B-phase signal is at a high level, a subtraction operation is performed. Then, each time a rising edge of the main frequency clock occurs, the predicted input accumulation N1 is reduced by one main frequency step.
[0093] If the predicted input accumulation N1 is greater than or equal to the input resolution, the input resolution is subtracted and the predicted output accumulation N2 is increased by 1.
[0094] If the predicted input accumulation N1 is less than 0, the input resolution is added and the predicted output accumulation N2 is reduced by 1.
[0095] If the predicted input accumulation N1 is greater than or equal to 4 times the output resolution, the predicted output accumulation N2 is used to take the remainder of 4 times the output resolution so that the predicted output accumulation N2 is equal to the remainder.
[0096] If the predicted output accumulation N2 is less than 0, the predicted output accumulation N2 is used to take the remainder of 4 times the output resolution, so that the predicted output accumulation N2 is equal to the remainder plus the preset output resolution R1.
[0097] It is understandable that according to Figure 3 The A-phase signal and the B-phase signal shown in the figure can continuously update the predicted input accumulation N1 and the predicted output accumulation N2 over time.
[0098] When the actual input accumulation M1 is updated or the actual output accumulation M2 is updated, the predicted input error Q1 is calculated based on the actual input accumulation M1 and the predicted input accumulation N1 at this time, and the predicted output error Q2 is calculated based on the actual output accumulation M2 and the predicted output accumulation N2 at this time. The specific calculation is as follows:
[0099] Q1= M1- N1
[0100] Q2= M2- N2
[0101] Next, based on the difference between the actual position and the predicted position, the step size error is calculated and used to inversely compensate for the main frequency step size. Specifically, step size error = (predicted output error Q2 * input resolution) / 4 + predicted input error Q1) * K_s, where K_s is a coefficient between 1 and 0. The larger the step size error, the closer K_s is to 1, and vice versa.
[0102] Based on the above formula 5, it can be seen that the main frequency step size also depends on the step size error. Therefore, the step size error can be used to invert the main frequency step size.
[0103] Next, based on the predicted position, the A-phase output signal and the B-phase output signal are predicted.
[0104] Specifically, the lower two bits of the binary number of the predicted output accumulation N2 are used to predict the state identification of the A-phase output signal and the B-phase output signal. The specific mapping relationship is as follows: Figure 3 shown.
[0105] For example, if the predicted output cumulative N2 is 4 and the lower two digits of the binary number are 00, then according to Figure 3 The mapping relationship can determine that the AB state is 10, which means that the A-phase output signal A_1 is "1" (high level) and the B-phase output signal B_1 is "0" (low level).
[0106] Then, the predicted position when the high level in the Z-phase signal arrives is used as the position of the Z-phase output signal.
[0107] Specifically, if Figure 3 As shown in the figure, when the Z-phase signal reaches a high level, the current predicted output accumulation N2 (i.e., the current compensation position) is recorded. N2 = 4 is used as the position of the Z-phase output signal Z_1 (i.e., the Z-phase signal output position). In other words, when N2 = 4, the output Z_1 is high.
[0108] It can be understood that, according to the preset output resolution R1, corresponding A_1, B_1, and Z_1 can be output.
[0109] It is understandable that by setting different preset output resolutions, different positions of the A-phase output signal, the B-phase output signal, and the Z-phase output signal can be predicted (output).
[0110] like Figure 1 As shown, the FPGA 102 further includes a fitting unit 1023' and a prediction unit 1024', and a preset output resolution R2 is set for them. The FPGA 102 further includes a fitting unit 1023", and a prediction unit 1024", and a preset output resolution R3 is set for them. It can be understood that according to Figure 2According to the method shown, the prediction unit 1024 ′ can predict (output) A_2 , B_2 , and Z_2 , and the prediction unit 1024 ″ can predict (output) A_3 , B_3 , and Z_3 .
[0111] It is understandable that the fitting unit and the prediction unit may be set accordingly according to the number of preset output resolutions.
[0112] It is understandable that A_1, B_1, Z_1, A_2, B_2, Z_2, A_3, B_3, Z_3 can be output simultaneously.
[0113] A_1, B_1, Z_1, A_2, B_2, Z_2, A_3, B_3, and Z_3 are input to the differential circuit 103 to form differential signals for input to the outside of the encoder 100.
[0114] The encoder in the present invention can easily output any desired output resolution without using multiple encoders, thereby reducing costs, ensuring stable control, and being unrestricted in installation.
[0115] The present invention can simultaneously feed back accurate incremental information to multiple encoders with arbitrary output resolutions, has high response performance and rate performance, and can suppress non-common mode interference.
[0116] In the accompanying drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or order may not be required. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of a structural or method feature in a particular figure does not imply that such feature is required in all embodiments, and in some embodiments, such features may not be included or may be combined with other features.
[0117] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems raised by this application. In addition, in order to highlight the innovative part of this application, the above-mentioned device embodiments of this application do not introduce units / modules that are not closely related to solving the technical problems raised by this application. This does not mean that other units / modules do not exist in the above-mentioned device embodiments.
[0118] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "including a" does not exclude the presence of other identical elements in the process, method, article or device that includes the element.
[0119] Although the present application has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the application.
Claims
1. A method for signal processing of an incremental encoder, characterized in that: The method is implemented by a field programmable logic array (FPGA), and the method comprises: A filtering step, based on a sampling time and a preset time parameter, samples the received multiple high-frequency input signals, and filters the sampled signals to obtain an A-phase signal, a B-phase signal, and a Z-phase signal; a DDR sampling step of performing double rate DDR sampling on the A-phase signal and the B-phase signal respectively, and calculating a plurality of first speeds between each A-state change of the A-phase signal and each B-state change of the B-phase signal; A fitting step, performing dynamic fitting based on the plurality of first speeds and calculating the main frequency step length in combination with a preset output resolution of the incremental encoder; A prediction step, based on the main frequency step length, the A phase signal, the B phase signal, and the Z phase signal, predicting the positions of the A phase output signal, the B phase output signal, and the Z phase output signal, The preset time parameter is determined based on the internal main frequency of the FPGA, the input resolution of the high-frequency input signal, and the maximum rotation speed of the code disk in the incremental encoder. Wherein, the multiple high-frequency input signals include three pairs of differential input signals, each pair of differential input signals includes a positive input signal and a negative input signal, and the positive input signal and the negative input signal are synthesized to obtain a synthetic signal of the differential input signal, each pair wherein, for each pair of differential input signals, the filtering step further includes: For the positive input signal, when sampling is performed at the same level and the sampling time is greater than the preset time parameter, the positive input signal is recorded, otherwise the synthesized signal remains unchanged; and for the negative input signal, when sampling is performed at the same level and the sampling time is greater than the preset time parameter, the negative input signal is recorded, otherwise the synthesized signal remains unchanged; When the recorded positive input signal and the negative input signal are opposite, sampled at the same level and the sampling time is greater than the preset time parameter, if the recorded positive input signal is consistent with the state of the synthetic signal, the synthetic signal remains unchanged, otherwise, the synthetic signal is changed to the positive input signal, The DDR sampling step comprises: Using a clock phase-locked loop inside the FPGA to generate a high-frequency clock and a main-frequency clock, the high-frequency clock and the main-frequency clock are in a multiple relationship and are periodically aligned at the multiple, wherein the frequency of the high-frequency clock is higher than the frequency of the main-frequency clock; The A-phase signal and the B-phase signal are respectively subdivided and sampled with the high-frequency clock, and then the A-phase signal and the B-phase signal are respectively sampled with the main frequency clock, and a plurality of first speeds between each A-state change of the A-phase signal and each B-state change of the B-phase signal are calculated based on the subdivided sampling and the main frequency sampling, For a continuous A state change and a B state change, the first speed is calculated based on the number of main frequencies between the A state change and the B state change, the number of starting subdivision samples of the start state change, and the number of ending subdivision samples of the end state change. Among them, one state change among the one A state change and the one B state change is the starting state change, and the other state change is the ending state change, The fitting step comprises: The currently calculated 2 n-1 The consecutive first speeds are added up respectively to obtain n speeds, and a corresponding weight value is assigned to each speed, where n is an integer greater than or equal to 1; Based on the n speeds and their respective weight values, the estimated speed of the incremental encoder at different times is calculated, and based on the currently calculated first speed and the weighted sum of the n weight values, the sampling speed is calculated; Based on the difference between the estimated speed and the sampled speed, adjusting n weight values respectively; The main frequency step length is calculated based on the preset output resolution, the adjusted weight sum of the n weight values, the current estimated speed, and the step length error; The step error is adjusted based on the A-phase signal, the B-phase signal, the input resolution of the high-frequency input signal, and the preset output resolution. The prediction step includes: Calculating an actual position based on respective state changes of the A-phase signal and the B-phase signal, the preset output resolution, and the input resolution of the high-frequency input signal; Calculate a predicted position based on the state changes of the A-phase signal and the B-phase signal, the input resolution, and the main frequency step size; Based on the difference between the actual position and the predicted position, the step error is obtained, which is used to inversely compensate the dominant frequency step; Based on the predicted position, predict the A-phase output signal and the B-phase output signal; The predicted position when the high level in the Z-phase signal arrives is used as the position of the Z-phase output signal.
2. The method according to claim 1, characterized in that The three pairs of differential input signals include a pair of A-phase differential input signals, a pair of B-phase differential input signals, and a pair of Z-phase differential input signals. After the filtering step, the final composite signal of a pair of A-phase differential input signals is used as the A-phase signal, the final composite signal of a pair of B-phase differential input signals is used as the B-phase signal, and the final composite signal of a pair of Z-phase differential input signals is used as the Z-phase signal.
3. The method according to claim 1, characterized in that Adjusting n weight values respectively based on the difference between the estimated speed and the sampled speed comprises: When the difference is smaller, n weight values are adjusted so that the larger the n, the larger the weight value, and the smaller the n, the smaller the weight value. When the difference is larger, the n weight values are adjusted so that the larger the n, the smaller the weight value, and the smaller the n, the larger the weight value.
4. The method according to any one of claims 1 to 3, characterized in that By setting different preset output resolutions, different A-phase output signals, B-phase output signals, and Z-phase output signals can be predicted.
5. An incremental encoder, characterized in that: The method comprises a field programmable logic array (FPGA), wherein the FPGA implements the signal processing method of the incremental encoder according to any one of claims 1 to 4.
