A coding and decoding method and system for an ultra-long absolute grating ruler based on fusion coding
The encoding and decoding of ultra-long absolute grating rulers generated by the fusion encoding method solves the problems of complex structure, high cost and difficult decoding in the existing technology, and realizes efficient and low-complexity absolute position measurement, which is suitable for large-stroke and high-precision grating ruler applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XI AN JIAOTONG UNIV
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-05
AI Technical Summary
Existing absolute grating ruler encoding technology suffers from problems such as complex structure, high cost, difficult signal processing, and high decoding complexity when achieving ultra-long stroke and high-precision positioning, making it difficult to meet the requirements of long stroke and high real-time decoding.
By adopting a fusion encoding method, two M sequences are alternately generated into a fusion encoding sequence. Decoding with O(1) time complexity is achieved by simplifying the lookup table and using a fixed formula, which reduces the decoding complexity and storage requirements and simplifies the grating ruler structure.
It breaks through the periodicity limitation of a single pseudo-random sequence without increasing the number of code channels, reduces decoding complexity and time, improves system reliability and environmental adaptability, and is suitable for low-cost, low-power embedded systems.
Smart Images

Figure CN122149315A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of photoelectric coding technology, and in particular to a coding and decoding method and system for an ultra-long absolute grating ruler based on fusion coding. Background Technology
[0002] In fields such as precision manufacturing, ultra-precision measurement, large scientific facilities, and high-end equipment manufacturing, long-stroke, high-precision absolute position measurement is one of the core technological requirements. Absolute linear encoders, as key sensors for achieving this requirement, rely heavily on their encoding methods, which directly determine the system's measurement range, accuracy, reliability, and real-time performance. As equipment develops towards ultra-long strokes and ultra-high precision, existing absolute position encoding technologies face significant contradictions and challenges in meeting the dual demands of "ultra-long" and "high-real-time decoding."
[0003] Among the existing schemes for encoding the aforementioned grating rulers, binary codes and their derivative codes (such as natural binary codes and Gray codes) are intuitive in principle and simple to decode, but their encoding capacity is directly determined by the number of parallel code channels. To achieve absolute positioning over ultra-long distances (tens of meters or even longer), the number of code channels required will increase dramatically, resulting in an exceptionally complex physical structure of the grating ruler, high manufacturing costs, and, because the reading head needs to sense a large number of code channels simultaneously, signal processing becomes difficult, and system reliability is reduced.
[0004] Meanwhile, while single pseudo-random sequence coding possesses excellent autocorrelation and periodicity properties, and can express a large number of unique positions with a single or few code channels, thus alleviating the structural complexity caused by multiple code channels to some extent, for ultra-long grating rulers, the required lookup table capacity increases exponentially, placing extremely high demands on the storage resources of decoding processors (such as microcontrollers and FPGAs), making decoding difficult.
[0005] To overcome the periodicity limitation of a single sequence, existing technologies have proposed a variety of composite encoding schemes, such as combining sequences with different periods, as exemplified by the patent application entitled "An Absolute Linear Grating Ruler and Its Encoding Method" (publication number CN104713479A). However, most of these methods transform the decoding process into a complex pattern matching or large-capacity global table lookup problem. Existing decoding methods struggle to achieve continuous displacement analysis of adjacent positions and cannot ensure accurate real-time position acquisition at startup. Summary of the Invention
[0006] In order to overcome the shortcomings of the prior art, the present invention aims to provide an encoding and decoding method and system for an ultra-long absolute grating ruler based on fusion coding. Through the encoding fusion mechanism and the corresponding decoding method, an ultra-long measurement range is achieved within a single encoding sequence, breaking through the period length limitation of a single pseudo-random sequence. At the same time, the decoding complexity and time of the absolute position are greatly reduced, and the decoding operation is simplified to a very small number of table lookups and one fixed formula calculation, achieving a near-constant O(1) time complexity decoding, which meets the requirements of high-speed real-time measurement.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: An encoding and decoding method for an ultra-long absolute grating ruler based on fusion coding includes the following steps: 1) Generation of fused coded sequences; 1.1) Generate an n-bit M-sequence as the base sequence 1. The length of the M-sequence is... Its index range is 1 ~ ; 1.2) Based on an n-bit M-sequence, in the corresponding linear feedback shift register structure, the maximum M-sequence is obtained as the base sequence 2 by adding all-zero states and adjusting the feedback logic. The length of the maximum M-sequence is... Its index range is 0 ~ ; 1.3) Construct a lookup table, which is indexed by the binary values of all possible consecutive n-bit windows in the maximum M-sequence, and stores the starting position number of the window in the maximum M-sequence; 1.4) The code elements are extracted cyclically from the maximum M sequence and the M sequence in an alternating manner to generate the fused coding sequence. Starting from the 0th bit of the maximum M sequence, the i-th bit of the M sequence and the i-th bit of the maximum M sequence are extracted alternately, where i is an integer and i≥1. If the bit index of any base sequence exceeds its length, the cyclic reading starts from the beginning. 1.5) The fused coding sequence is sequentially etched onto the absolute coding track of the grating ruler in the form of physical features; 2) Location decoding: 2.1) From the signal obtained from the grating ruler reading head, extract a continuous symbol of length 2n bits as the current decoding window; 2.2) Separate the 2n bits of the decoding window according to their bit order to obtain an n-bit odd sequence consisting of odd bits. and an n-digit even number sequence consisting of even digits ; 2.3) Query the lookup table to obtain the odd number sequences respectively. and even sequence Corresponding odd position index and even position index ; 2.4) Indexing by odd position and even position index The absolute position K of the decoding window in the fused encoding sequence is determined by a preset calculation formula.
[0008] The alternating extraction process described in step 1.4) continues until the M sequence is completed. After several complete iterations, the total length of the resulting fused encoded sequence is .
[0009] In step 2.4), based on the odd position index... and the even-numbered position index Determine the absolute position K as follows: First, based on the location index value and Calculate the position period P: like , ; like , ; Then, the final absolute position K is calculated based on the position period P obtained from the calculation: make , like ; like , .
[0010] A coding and decoding system for an ultra-long absolute grating ruler based on fusion coding includes a sequence generation module, a coding table construction module, a fusion coding generation module, a signal acquisition and processing module, a window extraction module, a parity separation module, and a position calculation module for position decoding. Sequence generation module: used to execute steps 1.1) and 1.2) of the encoding / decoding method to generate the M-sequence and the maximum M-sequence; Encoding table construction module: used to execute step 1.3 of the encoding / decoding method and construct the lookup table; Fusion encoding generation module: used to execute step 1.4 of the encoding / decoding method to generate a fusion encoded sequence; Signal acquisition and processing module: used to acquire signals from the reading head and perform binarization processing; Window extraction module: used to execute step 2.1 of the encoding / decoding method to capture the decoding window; Parity separation module: used to execute step 2.2 of the encoding / decoding method to obtain the n-bit odd number sequence. and the n-bit even number sequence ; The location calculation module stores the lookup table and is used to execute steps 2.3) and 2.4) of the encoding and decoding method to query the location number and calculate the absolute location K.
[0011] The location calculation module is implemented by a field-programmable gate array (FPGA), application-specific integrated circuit (ASIC), or microprocessor.
[0012] An ultra-long absolute grating ruler, wherein the encoded sequence engraved on the absolute encoding track is generated according to the encoding and decoding method.
[0013] An absolute position measuring device, employing the aforementioned encoding / decoding system or the aforementioned ultra-long absolute grating ruler.
[0014] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the encoding / decoding method.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention generates a 2n-bit fused encoding sequence by fusing two n-based sequences, providing a huge non-repeating encoding length, exponentially reducing the decoding workload of the lookup table, and eliminating the need for periodic judgment or global search. The decoding formula enables instantaneous positioning at any location through two table lookups and one calculation, without the need for periodic judgment or global search; the method has a time complexity of O(1), with extremely low requirements for processor computing power and storage space; at the same time, it can achieve ultra-long displacement measurement without increasing the absolute code channel, simplifying the mechanical structure of the grating ruler, the design of the reading head, and the optical system, improving the overall reliability and environmental adaptability, maintaining the physical simplicity and high reliability of the system, and avoiding the structural complexity, high cost, and signal interference problems caused by increasing the number of parallel code channels.
[0016] The fusion coding proposed in this invention meets the urgent need for absolute coding of ultra-long grating rulers in fields such as large scientific facilities and high-end equipment manufacturing. It is particularly suitable for low-cost, low-power embedded systems and has good application prospects and promotion value. Attached Figure Description
[0017] Figure 1 This is an example diagram of 8-bit fusion encoding generation in an embodiment of the present invention.
[0018] Figure 2 This is a flowchart of the location decoding process according to an embodiment of the present invention.
[0019] Figure 3 This is an example diagram of an 8-bit fusion encoding representation of an embodiment of the present invention.
[0020] Figure 4This is a graph showing the performance analysis of fusion coding in an embodiment of the present invention.
[0021] Figure 5 This is a schematic diagram of the fusion coding system architecture according to an embodiment of the present invention. Detailed Implementation
[0022] To make the objectives and technical solutions of this invention clearer and easier to understand, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. The specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention.
[0023] An encoding and decoding method for an ultra-long absolute grating ruler based on fusion coding includes the following steps: 1) Generation of fused coded sequences; 1.1) Generate an n-bit M-sequence as the base sequence 1. The length of the M-sequence is... Its index range is 1 ~ ; 1.2) Based on an n-bit M-sequence, in the corresponding linear feedback shift register structure, the maximum M-sequence is obtained as the base sequence 2 by adding all-zero states and adjusting the feedback logic. The length of the maximum M-sequence is... Its index range is 0 ~ ; 1.3) Construct a lookup table, which is indexed by the binary values of all possible consecutive n-bit windows in the maximum M-sequence, and stores the starting position number of the window in the maximum M-sequence; 1.4) Symbols are extracted alternately from the maximum M-sequence and the M-sequence to generate a fused coding sequence. Starting from the 0th bit of the maximum M-sequence, the i-th bit of the M-sequence and the i-th bit of the maximum M-sequence are extracted alternately, where i is an integer, i≥1. If the index of any base sequence exceeds its length, the cycle starts from the beginning. The alternating extraction process continues until the M-sequence is complete. After several complete iterations, the total length of the resulting fused encoded sequence is ; 1.5) The fused coding sequence is sequentially etched onto the absolute coding track of the grating ruler in the form of physical features; Reference Figure 1 In this embodiment, a 4-bit shift register is selected, and primitive polynomials are used. Generate a period of The M-sequence has a complete period of: 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1; in this embodiment, an all-zero state feedback is added to a 4-bit shift register to generate a period of The maximum M-sequence is used; a complete period of this sequence is: 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1; the base sequence 1 uses the M-sequence, and the base sequence 2 uses the maximum M-sequence. Code elements are continuously extracted from the maximum M-sequence and the M-sequence in an alternating manner until the M-sequence is completely cycled 8 times, which generates an 8-bit fused code. The final total length of the generated fused code sequence is 240 bits. 2) Location decoding: 2.1) From the signal obtained from the grating ruler reading head, extract a continuous symbol of length 2n bits as the current decoding window; 2.2) Separate the 2n bits of the decoding window according to their bit order to obtain an n-bit odd sequence consisting of odd bits. and an n-digit even number sequence consisting of even digits ; 2.3) Query the lookup table to obtain the odd number sequences respectively. and even sequence Corresponding odd position index and even position index ; 2.4) Indexing by odd position and even position index The absolute position K of the decoding window in the fused coding sequence is determined by a preset calculation formula; In step 2.4), based on the odd position index... and the even-numbered position index Determine the absolute position K as follows: First, based on the location index value and Calculate the position period P: like , ; like , ; Then, the final absolute position K is calculated based on the position period P obtained from the calculation: make , like ; like , .
[0024] In this embodiment, position 1 represents the first sequence read by the reading head, and position 2 represents the second sequence read by the reading head as it moves to the right. These reading head encoded sequences satisfy the shift characteristics, thus enabling continuous displacement analysis; (Refer to...) Figure 2When the reading head moves relative to the grating ruler, its photodetector continuously reads the encoded signal. During decoding, the signal is sampled and binarized at a fixed frequency (e.g., 10MHz). From the binarized signal stream, a continuous 8-bit (i.e., 2n bits, n=4) signal segment is extracted as the current decoding window. After obtaining the fused encoded sequence read by the reading head, parity separation is performed, and the odd-numbered bits (bits 1, 3, 5, and 7) in the 8-bit window are extracted to form a 4-bit odd-numbered sequence. Extract the even-numbered bits (2nd, 4th, 6th, and 8th bits) from the 8-bit window to form another 4-bit even-number sequence. First, pre-store a position code lookup table, which stores the unique starting position index (0 to 15) of all 4-bit code sequences; then... and These are used as keys to quickly obtain the two position index values by searching the positional encoding lookup table. and ;according to and Based on the size relationship, select the corresponding formula to calculate the absolute starting position K (counting from 0) of the current 8-bit fused coding sequence in the entire fused coding sequence. First, calculate the position period P. like , ; like , ; Calculate the fusion coding position K based on the P value: like ; like , ; The calculated K value is the absolute window position. Multiplying it by the physical width of a single symbol gives the absolute physical position of the read head.
[0025] Reference Figure 3 , Figure 3 The key data of the first 6 and last 3 consecutive 8-bit decoding windows and their decoding process in the 8-bit fused encoding sequence are shown, and the correctness and effectiveness of the decoding formula of the present invention are verified. The formula, combined with the table lookup operation, realizes instantaneous decoding with O(1) time complexity, completely avoiding the large-capacity lookup or complex matching process in the traditional method.
[0026] Reference Figure 4In this embodiment, the parameter N is set to a value ranging from 1 to 10, corresponding to a coding bit length n = 2N, that is, a coding bit length ranging from 2 bits to 20 bits. The comparison scheme uses the traditional M-sequence encoding method. When the coding bit length n = 20, the decoding amount of the traditional M-sequence reaches 2.5MB, while the fusion encoding only requires 1.25KB, reducing the decoding amount by approximately 2048 times. The fusion encoding method proposed in this invention achieves an optimal balance between encoding capacity and decoding complexity through encoding structure and optimized decoding. Simulation data shows that this method reduces decoding complexity to the logarithmic level while maintaining exponential growth in encoding capacity, making it particularly suitable for low-cost, small-memory embedded systems, demonstrating significant technological advancement and practical value.
[0027] Reference Figure 5 In this embodiment, an encoding and decoding system for an ultra-long absolute grating ruler based on fusion coding is used. The absolute coding track of the transmissive grating ruler 2 is engraved with the encoding sequence described in this embodiment. The parallel light source 1 illuminates the transmissive grating ruler 2, and the linear image sensor 3 located on the other side of the transmissive grating ruler 2 receives the light signal transmitted through the transmissive grating ruler 2 and converts it into a corresponding photoelectric signal. The signal is then sent to the solution unit 4. The position calculation module integrated in the solution unit 4 adopts a field-programmable gate array (FPGA). The FPGA serves as the core processing unit and stores a lookup table (LUT) in the IP core ROM. It integrates a real-time decoding method, which can efficiently complete signal window truncation, parity bit separation, table lookup, and position calculation formula calculation, thereby ensuring that the entire decoding process is completed within a microsecond delay.
Claims
1. A method for encoding and decoding an ultra-long absolute grating ruler based on fusion coding, characterized in that, Includes the following steps: 1) Generation of fused coded sequences; 1.1) Generate an n-bit M-sequence as the base sequence 1. The length of the M-sequence is... Its index range is 1~ ; 1.2) Based on an n-bit M-sequence, in the corresponding linear feedback shift register structure, the maximum M-sequence is obtained as the base sequence 2 by adding all-zero states and adjusting the feedback logic. The length of the maximum M-sequence is... Its index range is 0~ ; 1.3) Construct a lookup table, which is indexed by the binary values of all possible consecutive n-bit windows in the maximum M-sequence, and stores the starting position number of the window in the maximum M-sequence; 1.4) The code elements are extracted cyclically from the maximum M sequence and the M sequence in an alternating manner to generate the fused coding sequence. Starting from the 0th bit of the maximum M sequence, the i-th bit of the M sequence and the i-th bit of the maximum M sequence are extracted alternately, where i is an integer and i≥1. If the bit index of any base sequence exceeds its length, the cyclic reading starts from the beginning. 1.5) The fused coding sequence is sequentially etched onto the absolute coding track of the grating ruler in the form of physical features; 2) Location decoding: 2.1) From the signal obtained from the grating ruler reading head, extract a continuous symbol of length 2n bits as the current decoding window; 2.2) Separate the 2n bits of the decoding window according to their bit order to obtain an n-bit odd sequence consisting of odd bits. and an n-digit even number sequence consisting of even digits ; 2.3) Query the lookup table to obtain the odd number sequences respectively. and even sequence Corresponding odd position index and even position index ; 2.4) Indexing by odd position and even position index The absolute position K of the decoding window in the fused encoding sequence is determined by a preset calculation formula.
2. The encoding / decoding method according to claim 1, characterized in that, Step 1.4) The alternating extraction process continues until the M sequence is complete. After several complete iterations, the total length of the resulting fused encoded sequence is .
3. The encoding / decoding method according to claim 1, characterized in that, In step 2.4), based on the odd position index... and the even-numbered position index Determine the absolute position K as follows: First, based on the location index value and Calculate the position period P: like , ; like , ; Then, the final absolute position K is calculated based on the position period P obtained from the calculation: make , like ; like , .
4. A coding and decoding system for an ultra-long absolute grating ruler based on fusion coding, characterized in that, It includes a sequence generation module, an encoding table construction module, a fusion encoding generation module, a signal acquisition and processing module, a window extraction module, a parity separation module, and a position calculation module for position decoding; Sequence generation module: used to perform steps 1.1) and 1.2) of claim 1 to generate the M-sequence and the maximum M-sequence; Encoding table construction module: used to execute step 1.3 of claim 1 to construct the lookup table; Fusion coding generation module: used to execute 1.4 of claim 1 to generate a fusion coding sequence; Signal acquisition and processing module: used to acquire signals from the reading head and perform binarization processing; Window extraction module: used to execute step 2.1 of claim 1, to capture the decoding window; Parity separation module: used to execute step 2.2 of claim 1 to obtain the n-bit odd number sequence. and the n-bit even number sequence ; Location calculation module: It stores the lookup table and is used to execute steps 2.3) and 2.4) of claim 1 to query the location number and calculate the absolute location K.
5. The encoding / decoding system according to claim 4, characterized in that, The location calculation module is implemented by a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), or a microprocessor.
6. An ultra-long absolute grating ruler, characterized in that, The encoded sequence engraved on its absolute encoded code track is generated by the encoding and decoding method according to claim 1 or 2.
7. An absolute position measuring device, characterized in that, The encoding / decoding system described in claim 4 or the ultra-long absolute grating ruler described in claim 6 is employed.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the encoding / decoding method as described in claim 1 or 3.
Citation Information
Patent Citations
Absolute type linear grating ruler and encoding method thereof
CN104713479A