Prof. Dr. Thorsten Jungmann (last updated 2026-11-02)
Relates to DET-05 Codes, code converters and standard components
Task
Each code of the lesson is made for its job and its medium. For each of the following jobs, name the code from the lesson that suits it, and give the reason in one sentence. Choose from the binary code, the binary-coded decimal (BCD) code, the excess-3 code, the Gray code, the American Standard Code for Information Interchange (ASCII), Code 39, the Hamming code, the one-hot code and the 7-segment code.
a) Jobs in everyday life:
- You type a letter on your smartphone, and the phone stores it as a code word.
- Your smartphone sends certain packets to wireless headphones, and they have to survive a flipped bit.
- A scanner in a pharmacy reads the pharmaceutical central number on the package of a medicine.
- A keypad with the digits 0 to 9 has one electric line per key.
- A clock shows each digit of the time with single light emitting diodes (LEDs), and you add their weights.
- A laboratory power supply shows the voltage that you set as digits, which you read at a glance.
b) Jobs at the heat pump and in industry:
- The controller of our heat pump transmits the electrical power as a whole number, with which other devices calculate.
- A controller reads the position at a joint of a robot arm.
- A cash register of the 1970s calculates with decimal digits in hardware and needs their nine’s complement.
c) The binary code can also describe positions. Why is it still unsuitable for a rotary encoder? Explain it with the change from sector 3 to sector 4 of a code disc with three tracks.
d) The controller of our heat pump records a message under the number 30 008, which fits into a word of 16 bits in the binary code. Write this number in the BCD code. What does the BCD code cost here, and what does it gain?
Solution
Given
Given explicitly:
- a) and b) nine jobs in everyday life, at the heat pump and in industry, and the nine codes of the lesson
- c) a code disc with three tracks, the change from sector 3 to sector 4
- d) the message number 30 008, a word of 16 bits in the binary code
Known:
- What each code is good for: binary code (DET-05), binary-coded decimal (BCD) code and excess-3 code (DET-05), Gray code (DET-05), American Standard Code for Information Interchange (ASCII) and Code 39 (DET-05), Hamming code (DET-05), one-hot code (DET-05), 7-segment code (DET-05)
Required
a) and b) for each job the code that suits it, with a reason
c) why the binary code is unsuitable for a rotary encoder
d) the number in the BCD code, and what this code costs and gains
a) Jobs in everyday life
- ASCII: It codes letters, digits, punctuation marks and control characters. The phone uses, for example, UTF-8, whose first 128 characters have the same code words as in ASCII (DET-05, 1.5).
- Hamming code: It finds a flipped bit and corrects it. Bluetooth protects the data of certain packets with a shortened Hamming code (DET-05, 2.2).
- Code 39: It is a barcode made for a scanner, and a single misread bar cannot produce another valid character. In Germany, this number stands on the package in Code 39 (DET-05, 1.5).
- One-hot code: Exactly one bit is 1: the electric line of the key that you press (DET-05, 4.1).
- BCD code: Each decimal digit keeps its own four bits with the weights 8, 4, 2 and 1, so you read the time column by column (DET-05, 1.3).
- 7-segment code: It fixes which segments form which digit, so the display shows the shape of the digit (DET-05, 3.3).
b) Jobs at the heat pump and in industry
- Binary code: Its bits have the weights of the powers of two, and it allows an arithmetic like that of the decimal system, so digital systems calculate with it (DET-05, 1.2).
- Gray code: At the border between two positions, only one bit changes, so a misread is off by one position at most (DET-05, 1.4).
- Excess-3 code: If you invert all bits of a code word, you get the code word of the nine’s complement (DET-05, 1.3).
c) Why not the binary code
The code words of the two neighbouring sectors, from the table in the lesson (DET-05, 1.4):
| Sector | Binary code | Gray code |
|---|---|---|
| 3 | 011 | 010 |
| 4 | 100 | 110 |
In the binary code, all three bits change from sector 3 to sector 4. The tracks never change at exactly the same moment, so a reading at the border can catch some bits before and others after the change, for example 111 or 000. These are the code words of the sectors 7 and 0, far away from the real position. In the Gray code, only the first bit changes. A reading at the border gives 010 or 110, so it is off by one sector at most.
d) The message number in the BCD code
In the BCD code, each of the five digits gets its own four bits (DET-05, 1.3): 0011 0000 0000 0000 1000.
The BCD code costs bits: 20 instead of the 16 of the binary word. In return, the conversion is simple: you replace each decimal digit by its four bits, and back, without any calculation.
