
To track a rotating shaft in robot, machinery, or CNC machine, we have to use shaft optical encoder. There are two type of shaft optical encoder, Incremental Encoder and Absolute Encoder.
Absolute encoder has a binary coded disk - same as the one shown in fig.1 - on a rotating shaft, white sections of the disk in fig.1 are transparent while the grey sections are opaque. An infrared emitter is mounted on one side of each track, and an infrared receiver ("phototransistor") is mounted on the other side of each track.
Outputs from the four infrared receivers will produce on of the gray code shown below, the disk will rotate when the shaft rotates, as a result; the output grey code will vary. Each code represents an absolute angular position of the shaft in its rotation.
Disk in fig.1 is divided into 16 parts, as a result; the position of the shaft can be determined to the nearest 22.5o ("360/16"). If the system requires more accuracy, designer can use 8 bit disk which will make the result to the nearest 1.4o ("360/256")
What is Gray Code?
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 | Gray Code 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 1000 |
Gray code is another binary code, just like BCD code ("Binary Coded Decimal"), its play a big role in automation, since it is used for encoding rotating shafts position. This code is similar to binary code, it has the same possible combinations but it is arranged in a different order as shown in the table at the right.
You can generate the equivalent gray code for any decimal number by constructing a table similar to the one we have at the right. The LSB column starts with one 0 then a set two 1's and two 0's as you go down. The second LSB column starts with two 0's then a set of four 1's and four 0's as you go down, and so on for the rest digits.
The purpose of using Gray Code.
The main reason to use gray code instead of regular binary code is to reduce the size of the largest possible error in reading the shaft position to the value of the LSB. If the disk used straight binary code, the largest possible error would be the value of the MSB.
To understand this, look at the table and suppose that the disk has moved from the position 7 to the position 8 and the encoder fails to read the MSB changed bit. If the disk used straight binary code, the output code would be 0000 which is equal to the position number 0 that is far 8 steps from the real location! Otherwise, when the same error occurs and the disk used the Gray Code the output code would be 0100, which is equal to the position number 7 that is only one step far from the real position.
In general, when the gray code is used for disk encoding, and the detectors fails to detect the new bit value during the transition, the resulting code will be always the code for the previous position. As a result, the maximum error will be always the value of the LSB!
Optical Motor Shaft Absolute Encoder Using Gray Code By adminstrator Rev1.0 Copyright© 2007. |
You are here: Home > Tutorials > Optical Motor Shaft Absolute Encoder Using Gray Code |