# Data Coding Theory/Transmission Codes

## Basic CodingEdit

It turns out that we can actually improve the performance of our system simply by changing the bits in our system. We can change the order of bits, or we can change the number of bits that we send, to help decrease error rates. This chapter will talk about transmission codes that can help increase system performance.

## Gray CodesEdit

Let us look at a basic QASK system:

- "00" = +5V
- "01" = +1.66V
- "10" = -1.66V
- "11" = -5V

We will call these "symbol 1" (for 00), "symbol 2" (for 01), "symbol 3" (for 10) and "symbol 4" (for 11).

Now, let us make a basic assumption that the only errors we get will be errors between adjacent symbols. For instance, Symbol 1 can be mistaken for symbol 2, but symbol 1 can never be mistaken for symbol 3. In reality, there is always a very small chance that this could happen, but we will simply ignore it for our purposes.

Now, we have 6 error conditions:

- Symbol 1 looks like Symbol 2
- Symbol 2 looks like Symbol 1
- Symbol 2 looks like Symbol 3
- Symbol 3 looks like Symbol 2
- Symbol 3 looks like Symbol 4
- Symbol 4 looks like Symbol 3

We can also see that in error conditions 1, 2, 5, and 6, a symbol error only produces 1 bit error. The other bit is actually not transmitted in error. The only time where we see 2 bits transmitted in error is when there is a mixup between symbols 2 and 3. We can calculate our probability of bit error as such:

P_{one bit error} is the probability that 1 bit from the symbol will be in error. P_{two bits error} is the probability that both symbols will be received in error.

To alleviate this problem, we can reorder our symbols, and map them the following way:

- "00" = +5V
- "01" = +1.66V
- "11" = -1.66V
- "10" = -5V

Now, when any symbol is received in error, there is only one bit error. This small trick is called "Gray Coding", and is a useful (but simple) method to improve system performance in terms of net bit errors.

### Using Gray CodesEdit

Gray codes are a simple example of how using an encoding/decoding mechanism in a communications system can have an effect on the error rate of the system. In future chapters we will discuss error correction codes (ECC) that can be used to find and fix single-bit errors in a signal. If we use Gray codes to ensure that the majority of errors are single-bit errors, we can then use more advanced ECC codes to resolve these errors.

Gray codes are typically not used on their own, but are combined with more robust coding methods, like described above.