Prof. Dr. Thorsten Jungmann (last updated 2026-11-02)

Relates to DET-05 Codes, code converters and standard components

Task

The rotary encoder at a joint of a robot arm delivers the position of the joint in the Gray code, while the controller calculates in the binary code. The code disc has 16 sectors and four tracks. A code converter turns the Gray code word with the bits , , and into the binary code word with the bits , , and , with the weight 8. This is the code table:

Sector
000000000
100010001
200110010
300100011
401100100
501110101
601010110
701000111
811001000
911011001
1011111010
1111101011
1210101100
1310111101
1410011110
1510001111

a) Minimize with a Karnaugh map.

b) Minimize with a Karnaugh map.

c) Minimize with a Karnaugh map.

d) Draw the Karnaugh map of . You do not need to write down its expression. What happens to the loops from a) to d)?

e) Express the four outputs with XOR gates with two inputs, as a chain from the highest bit down. How many XOR gates does the code converter need?

f) Check your chain for sector 11.

A colleague has built this code converter with a fault and reports: and agree with the code table in all 16 rows, but and do not:

Row from the code table in the simulator from the code table in the simulator
000000000
100010011
200101111
300111100
401001010
501011001
601100101
701110110
810001111
910011100
1010100000
1110110011
1211000101
1311010110
1411101010
1511111001

Simulation of the faulty code converter from Gray to binary, with four logic inputs and three XOR gates, in which all inputs and all outputs are low
Simulation of the faulty code converter from Gray to binary, with four logic inputs and three XOR gates, in which all inputs and all outputs are low

Open in the simulator

g) In which rows do and deviate, and why do both outputs deviate in the same rows? Which input of which gate is connected wrongly? Confirm it in the simulation.

◀️ Back to the task


Solution

Given

Given explicitly:

  • the code table of the Gray code with four bits for the 16 sectors, the inputs , , and , the outputs , , and
  • XOR gates with two inputs
  • g) the outputs that a colleague measured, and the simulation

Known:

  • Gray code (DET-05)
  • Code converter from Gray to binary as a chain of XOR gates (DET-05)
  • Karnaugh map with loops of ones and the chequerboard of the XOR operation (DET-03, DET-03)
  • Finding a built-in fault with the row-by-row comparison (DET-05)

Required

a) to c) the minimal disjunctive normal form (DNF) of , and
d) the map of , and what happens to the loops
e) the chain of XOR gates and their number
f) the check for sector 11
g) the deviating rows, what they have in common and the wrong connection

a) Output

Steps 1 and 2 of the synthesis (DET-03, 1.1) are done with the code table. For steps 3 and 4, read the input code word of each sector with a 1 in the output. The cells of the map are numbered with the Gray code word as a binary number, with the weight 8. The output is 1 for the sectors 8, 9, 10, 11, 12, 13, 14 and 15, whose code words all have :

Karnaugh map of the output Y3 with ones in the cells of the rows 8, 9, 10, 11, 12, 13, 14, 15 and one loop
Karnaugh map of the output Y3 with ones in the cells of the rows 8, 9, 10, 11, 12, 13, 14, 15 and one loop

The eight ones form one loop, half of the map: a single input remains.

b) Output

The output is 1 for the sectors 4, 5, 6, 7, 12, 13, 14 and 15. As binary numbers, their code words are:

Karnaugh map of the output Y2 with ones in the cells of the rows 4, 5, 6, 7, 8, 9, 10, 11 and 2 loops
Karnaugh map of the output Y2 with ones in the cells of the rows 4, 5, 6, 7, 8, 9, 10, 11 and 2 loops

Two loops of four remain. This form is the XOR operation of and (DET-02, 4.3).

c) Output

The output is 1 for the sectors 2, 3, 6, 7, 10, 11, 14 and 15. As binary numbers, their code words are:

Karnaugh map of the output Y1 with ones in the cells of the rows 2, 3, 4, 5, 8, 9, 14, 15 and 4 loops
Karnaugh map of the output Y1 with ones in the cells of the rows 2, 3, 4, 5, 8, 9, 14, 15 and 4 loops

Only four loops of two remain, and no loop can be larger. The input has dropped out, and the ones form a chequerboard in , and (DET-03, 4.5).

d) Output

The output is 1 for the odd sectors, 1, 3, 5, 7, 9, 11, 13 and 15. As binary numbers, their code words are:

Karnaugh map of the output Y0 with ones in the cells of the rows 1, 2, 4, 7, 8, 11, 13, 14 and 8 loops
Karnaugh map of the output Y0 with ones in the cells of the rows 1, 2, 4, 7, 8, 11, 13, 14 and 8 loops

Each 1 stands alone, because every neighbour of a cell with a 1 contains a 0: the map is a complete chequerboard, and the minimal DNF has eight terms with four literals each. No loop can minimize it; the XOR operation can (DET-03, 4.5).

From a) to d), every further input halves the size of the loops and doubles their number: 1, 2, 4 and 8 loops.

e) The chain of XOR gates

The results of a) to d) show the pattern: each output is the XOR of one more input. Each bit of the binary code word is the XOR of the Gray bit at its position and the binary bit above it (DET-05, 4.2):

Because each output needs the one above it, the XOR gates stand one behind the other, from the highest bit down. The code converter needs three XOR gates with two inputs. A two-level circuit would need eight AND gates with four inputs each and an OR gate with eight inputs for alone.

f) Check for sector 11

Sector 11 has the Gray code word 1110. For , , and :

The binary code word is 1011. Check with the weights:

✓

The simulation shows the chain; step 6 of the synthesis compares it with the code table (DET-03, 5.3). Switch the four inputs through the 16 code words, and compare the outputs with each row of the code table.

Simulation of the code converter from Gray to binary as a chain of three XOR gates: the inputs 1110 give the outputs 1011, the number eleven
Simulation of the code converter from Gray to binary as a chain of three XOR gates: the inputs 1110 give the outputs 1011, the number eleven

Open in the simulator

g) The fault

Step 6 compares each output with the code table, row by row (DET-05, 4.4). and deviate in the same rows, 4, 5, 6, 7, 12, 13, 14 and 15. These are exactly the rows with . is correct, so look at the next gate in the chain: the XOR gate of should receive and . Because , the signals and differ exactly where . So this gate does not receive but :

is formed from this wrong signal, and an XOR gate passes a wrong input on as a wrong output, so both outputs deviate in the same rows. The first of them in the chain points to the fault: look at the gate of , not at the gate of .

The simulation confirms it: the upper input of the second XOR gate comes from . To correct the fault, connect this input to .