3.1. Absolute Coding
Absolute encoders are sensors that directly output digital quantity and can directly provide accurate absolute position information. They use binary code for photoelectric conversion and can read fixed digital code matching any position of the coding ruler without calibration. This kind of encoder has excellent anti-interference ability and avoids cumulative error. Its position information can be retained even without a power supply. However, its measurement accuracy is limited by the choice of binary digits, which can be flexibly adjusted to meet accuracy requirements according to specific needs. In addition, the absolute encoder has a fixed “coding zero point”, which ensures that any other absolute position on the coding ruler is calculated based on this zero point. The absolute position data can be obtained accurately by reading the coding information of the current position [
7,
8].
- (1)
The encoding method of natural binary code
In an absolute coding system, the core function of output code is to accurately determine an absolute position. Taking natural binary code as an example, this coding method, as a weight code, has a one-to-one correspondence with binary numbers. It is characterized by each bit having a clear size value, and these values are arranged from the highest bit to the lowest bit in the order of n power of 2, so they can be directly used for size comparison and arithmetic operation.
Due to the characteristics of natural binary coding, an absolute encoder with this coding method can be easily processed by the external controller so that the actual position reading can be obtained directly without any special conversion operation. For example, if the read natural binary code is 0111, according to the conversion rule from binary to decimal, its position value can be calculated as
As shown in
Table 1, if the natural binary code is used for position reading, it is necessary to select the required number of n bits, that is, n measurement sensing units, according to the required length of the code scale and the required measurement accuracy. The farther the positioning distance, the higher the accuracy, and the more sensing elements are needed, which is not conducive to the miniaturization and integration of the code reader. Moreover, when the binary code of two adjacent readings changes in multiple bits, errors are easily generated if multiple measurement sensing elements identify that the transmission is not synchronous.
- (2)
Gray code method.
Gray code is also known as binary Gray code. Although natural binary code has the ability to directly convert digital signals into analog signals through a digital-to-analog converter, in some specific scenarios, such as when converting from decimal 3 (011) to decimal 4 (100), every bit of the binary number changes [
9]. Therefore, if the encoding method of natural binary code is adopted, when the values of multiple digits simultaneously change, it is impossible to adjust the status of multiple digits synchronously, resulting in the existence of a sequence in the data refresh process. However, in the transitional stage of state change, the obtained readings may produce errors (such as 010 or 111). See
Table 2 for the application of Gray code in a positioning system.
Gray code has unique and significant advantages over other coding methods. Its main advantage lies in that only one digit changes during the conversion between adjacent digits. This remarkable feature effectively reduces the logical confusion that may occur when transitioning from one state to the next and ensures the clarity and accuracy of the transition process.
Gray code has only a one-bit difference between adjacent code groups, which leads to higher reliability in the process of digital position signal conversion. Even if the displacement of the code reader changes slightly, the Gray code only changes by one digit, making it more stable than other coding methods in which two or more digits may simultaneously change in the same situation. This feature significantly reduces the possibility of errors, thus improving the performance and reliability of the whole coding system.
Assuming that the original value starts from 0, the law of Gray code generation is as follows:
Step 1. Change the rightmost bit value.
Step 2. Change the left bit of the first 1 from the right: 011.
Steps 3 and 4. Repeat steps 1 and 2 until all Gray codes have been generated (in other words, step (2n−1) has been taken).
Take the following as an illustrative example: suppose a 3-bit Gray code is generated, and the original value bit is 000.
Step 1. Change the rightmost bit value: 001.
Step 2. Change the left bit of the first 1 from the right: 011.
Step 3. Repeat step 1: 010.
Step 4. Repeat step 2: 110.
This process is performed until all the steps are completed. The three-digit Gray code sequence is as follows: 000, 001, 011, 010, 110, 111, 101, 100.
- (3)
The conversion between binary code and Gray code
According to the comparison in
Table 3, there are significant differences between Gray code and other coding methods. Specifically, whenever the data are refreshed, the digital signal read by the code reader only changes by one bit, and this change has no sequence, thus completely eliminating the possibility of code error and code mixing. This feature significantly reduces the possibility of logical confusion when transitioning from one state to the next. For example, when changing from position 7 (0100) to position 8 (1100), only the most significant bit changes from 0 to 1, and only one bit in the code group changes state [
10].
In addition, Gray code is usually called cyclic binary code or reflective binary code because the difference between the maximum number and the minimum number is only limited to the difference of a one-bit state. The output signal of an absolute encoder with Gray code is a specific number sequence, not a weight code. In this coding, each bit has no fixed size, so it cannot be directly used for size comparison or arithmetic operation. At the same time, Gray code cannot directly convert signals into other types of signals.
In practical application, it is necessary to convert Gray code into natural binary code once and then read it using the upper computer to enable the corresponding control function. In the process of conversion between Gray code and natural binary code, an exclusive OR operation (the same is represented by 0, and a difference is denoted by 1) is used to replace the traditional addition and subtraction operation for binary vertical multiplication and division. This carry-less conversion method is called exclusive OR multiplication and division, and the specific algorithm is not described here.
- (4)
Shift continuous encoding
So-called “continuous code shift” encoding is an encoding form composed of 0 and 1 bits, which are always kept constant. In this encoding rule, any subsequent encoding can be regarded as the result of adding “1” or “0” at the rightmost end after the preceding encoding is shifted one bit to the left. For example, if the current code is 0100110100, the code after removing the leftmost bit is 100110100. Two possible subsequent codes, namely, 1001101000 or 1001101001, can then be obtained by moving the code one bit to the left and filling the bit at the rightmost end. Although there are two options for translation compensation, the subsequent encoding of each encoding is uniquely determined in practical application.
It is worth noting that although there are two options in the process of translation compensation, in practical applications, the subsequent encoding of each encoding is uniquely determined. This is because continuous code shift encoding usually combines other encoding rules or constraints to ensure the uniqueness of the encoding. This uniqueness ensures the accuracy and reliability of encoding, enabling correct identification and parsing of encoded information in digital processing and communication processes.
In shift continuous encoding with n bits, there are n−1 consecutive and identical digits between two adjacent encoding. An overlapping sequence of displaced continuous encoding can be formed if the adjacent codes in a displaced continuous encoding sequence are overlapped according to their identical features. As shown in
Table 4, the sequence is the overlapping sequence of a displaced continuous code with a bit length of 4. In this sequence, each 4-bit adjacent 0/1 digital combination constitutes a unique code. A coding sequence closely related to the digital position can be obtained if the number at any position is taken as the starting point and forms a code together with the three numbers on the right [
11].
3.2. Hybrid Coding
In the field of digital encoding, traditional encoding methods such as binary encoding and Gray code encoding and innovations such as continuous shift encoding have limitations to some extent. Under the condition of limited bits, these coding modes can complete relatively few positioning coding tasks.
A hybrid encoding method is proposed in order to overcome the limitations of these traditional encoding methods. The core idea of this encoding method is to generate a large number of different codewords by using random sequences. Under the condition of finite bits, the combination of random sequence encoding and displacement continuous encoding increases location encoding so as to meet wider application requirements [
10].
Specifically, hybrid encoding combines the advantages of two different encoding modes, absolute and incremental encoding, to achieve higher accuracy and stability, and its working principle is that the position and speed are accurately monitored and fed back through the combined operation of the two encoding modes.
As shown in
Table 5, two coding modes are combined, one for absolute position and the other for relative position.
In practical engineering applications, due to significant vibrations in the working environment, the positioning accuracy of hybrid coding is ±2 mm, and the scale installation track is 300 m. The positioning accuracy of binary coding is ±3 mm.
This encoding method based on a random sequence has many advantages in practical application. First, it can make full use of limited bit resources to generate more location codes, thus improving coding efficiency and flexibility. Secondly, due to the random sequence, the generated codeword has a better anti-jamming capability and can effectively resist the impact of noise and interference on the coding performance. This method also has better security because the generation and conversion process of the random sequence can be designed to be very complex and difficult to predict.
Determining sequences are sequences that can be predetermined and repeatable. A pseudo-random sequence is a sequence that cannot be determined in advance, but its generation process can be repeated; sequences that are neither predetermined nor repeatable are called random sequences.
An m sequence, also known as a maximum periodic feedback shift register sequence, is a pseudo-random binary sequence widely used in various fields [
12]. It can be applied to spread spectrum communication to improve anti-jamming capability and the confidentiality of communication and achieve efficient spectrum utilization and signal separation in CDMA technology in satellite communication. In addition, in terms of digital data processing, an m sequence can be used for encryption and scrambling to ensure data security, synchronization, and bit error rate measurement to improve the accuracy and reliability of data transmission. These applications fully demonstrate the superior performance and wide application prospects of m sequences in the communication field.
An n-level feedback shift register on GF (2) consists of n binary memories and a feedback function f (a
1, a
2, …, a
n), as shown in
Figure 2. There is a total of n registers (a
1, a
2, …, a
n). Each register is a 0/1 binary storage unit, called the stage of feedback shift register. There is a total of 2n possible states. From left to right, there is a feedback f, its input is a
1~a
n, its calculation result is an output of a
n + 1, and the feedback result a
n + 1 is output to an. At the same time, each level of memory ai transmits its contents to the next level a
i−1, and f (a
1, a
2, …, a
n) is calculated as the contents of an at the next time according to the state of memory at that time.
We can precisely encode a specific absolute position by placing a binary marker based on the m-sequence on the encoder scale. When the readers read these binary markers one by one in a given order from the starting point, the coding sequence they form in the memory presents a unique feature. With this unique location code value as the search address, we can quickly find and obtain the detailed location information of each location in the pre-built database so as to effectively enable the function of ranging transmission.
3.3. Coder Bar Grid Description
First, an understanding of the basic composition of the reader is required. Inside the U-shaped reading wharf, a laser transmitter is installed on one side, and a laser receiver is installed on the other side [
13,
14,
15]. The laser transmitter emits a steady beam, which travels through a specific path and is finally received by the corresponding laser receiver. When the receiver successfully receives the beam, it converts this signal into a digital signal to read the data.
When the reader is installed on the ruler track, it begins to efficiently read data. A key element in this process is the light-tight encoder. Different areas on the encoder scale have different effects on the beam. When the beam from the laser transmitter is blocked by one side of the encoder, the laser receiver cannot receive the optical signal, and the digital signal “0” is output.
With the relative displacement of the code reader on the ruler track, the correlative laser sensor continuously passes through the holes on the ruler. The beam can pass normally when the sensor passes through these holes. At this time, the laser receiver receives the optical signal and outputs the digital signal “1”.
We follow certain rules in order to accurately depict the encoder. In encoding, “1” corresponds to the hollow part and “0” to the solid part on the ruler. In this way, the solid and hollow parts on the encoder ruler constitute a unique encoding sequence, as shown in
Table 6. In this example, the code “11100100101011” corresponds to a series of solid and hollow parts on the encoder scale.
It is worth noting that the data reading method of this laser sensor has many advantages. First, it has very high reading accuracy and can meet the needs of most application scenarios. Second, because it uses a laser as the signal transmission medium, it has a strong anti-interference ability and can operate stably in a harsh industrial environment.