The interchange between binary Gray code and natural binary code

Source: Internet
Author: User
Tags reflection sort

In order to improve the control accuracy, it is very important to accurately measure the position of the control object in the precise positioning control system. At present, the detection of the location of two methods: the first is the use of position sensors, measured displacement from the transmitter through a/D conversion into digital data sent to the system for further processing. This method has high precision, but it is not practical because of its expensive and difficult to install, and the other is to use photoelectric shaft encoder for precise position control. According to the calibration method and the signal output form, the photoelectric axis angle encoder can be divided into three kinds of increment, absolute and mixed type. The absolute encoder is a direct output of the digital sensor, it is the use of natural binary or circular binary (gray code) mode of photoelectric conversion, the design of the code is generally the use of natural binary code, circular binary code, binary complement and so on. The characteristic is not the counter, at any position of the rotating shaft can read out a fixed and position corresponding to the digital code; strong Anti-interference ability, no cumulative error, after power cut position information will not be lost, but the resolution is determined by the number of binary digits, according to different precision requirements, can choose a different resolution of the number of ascended. There are currently 10-bit, 11-bit, 12-bit, 13-bit, 14-bit, or higher-level.

An absolute encoder using cyclic binary encoding, its output signal is a sort of digital, not the right coincident, each bit is not determined size, can not be directly compared to the size and arithmetic operations, and can not be directly converted to other signals, to go through a code transformation, into a natural binary code, is read by the host computer to achieve the corresponding control. But in the code system transformation has the different processing way, this article emphatically introduces the binary code and the natural Binary Code interchange.

First, gray code (also called circular binary code or reflection binary code) Introduction

Only 0 and 1 can be identified in a digital system, and various data can be converted to binary code for processing. Gray code is a kind of unauthorized code, using absolute coding, the typical gray code is a reflective characteristics and cyclic characteristics of a single step of the complement, its cycle, the single step feature eliminates the random number of significant errors occurred, its reflection , the self complement characteristic makes the negation very convenient. The gray code belongs to the reliability code, is a kind of error minimization coding way, because the natural binary code can be directly converted from the number/mode converter to analog signals, but in some cases, such as from decimal 3 to 4 o'clock binary code to change every bit, so that the digital circuit produces a large spike current pulse. The gray code does not have this disadvantage, it is a sort of digital system in which all adjacent integers have only one number in their numeric representations. When it converts between any two adjacent numbers, only one digit changes. It greatly reduces the confusion of logic from one state to the next. In addition, because the maximum number and the smallest number is also only a number of different, it is usually called gray Reflection code or loop code. The table below is a comparison of several natural binary codes and gray codes:

Decimal number Natural binary Number Gray Code Decimal number Natural binary Number Gray Code
0 0000 0000 8 1000 1100
1 0001 0001 9 1001 1101
2 0010 0011 10 1010 1111
3 0011 0010 11 1011 1110
4 0100 0110 12 1100 1010
5 0101 0111 13 1101 1011
6 0110 0101 14 1110 1001
7 0111 0100 15 1111 1000

Two, binary code and the interchange of natural binary codes

1, the natural binary code conversion into binary gray code

The natural binary codes are converted into binary gray codes, the rule is to retain the highest bit of the natural binary code as the highest bit of the Gray code, while the secondary high Gray code for the binary code of the high and secondary highs are different or, and the rest of the gray code with the order of the second high.

2, binary gray code conversion into natural binary code

Binary code is converted into natural binary code, the rule is to preserve the highest bit of gray code as the highest bit of natural binary code, the secondary high natural binary code for high natural binary code and secondary high gray code is different or, and the rest of the natural binary code with the secondary high natural binary code of the method similar.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.