Code Converter Circuits
BCD to Gray, Gray to BCD, BCD to Excess-3 circuits.
Microcontroller peripherals like the 8051 BCD output port and seven-segment display drivers depend on code converter circuits to translate between number representations. The 7447 BCD-to-seven-segment IC and the 74184 BCD-to-binary converter are two workhorses found in instrumentation front ends.
Core Concept
A code converter circuit translates digital words from one encoding scheme to another without changing the quantity they represent. The three most examined types are BCD-to-Excess-3, Binary-to-Gray, and Gray-to-Binary.
BCD-to-Excess-3 is implemented by adding 0011 (decimal 3) to each BCD digit using a 74LS83 4-bit binary adder. The 74LS83 has a propagation delay of 16 ns at 5 V. Excess-3 is a self-complementing code, meaning the 9s complement of a digit is obtained by inverting all bits.
Gray-to-Binary and Binary-to-Gray both use chains of XOR gates. The 74HC86 quad 2-input XOR IC is the standard choice. It operates from 2 V to 6 V, has a propagation delay of 7 ns at 5 V, and dissipates under 0.1 mW at static CMOS levels. Gray code is used in shaft encoders because only one bit changes between adjacent positions, eliminating glitching.
Boolean Expression
Binary-to-Gray conversion: G₃ = B₃, G₂ = B₃ ⊕ B₂, G₁ = B₂ ⊕ B₁, G₀ = B₁ ⊕ B₀. Each Gray bit is the XOR of the corresponding binary bit and the next higher binary bit. The MSB is unchanged.
Gray-to-Binary conversion: B₃ = G₃, B₂ = B₃ ⊕ G₂, B₁ = B₂ ⊕ G₁, B₀ = B₁ ⊕ G₀. Each binary bit is the XOR of the previously computed binary bit above and the current Gray bit. This chain is sequential from MSB to LSB.
Given:
Binary number B3 B2 B1 B0 = 1 0 1 1
Convert to Gray code.
Formula / Rule:
G3 = B3
G2 = B3 XOR B2
G1 = B2 XOR B1
G0 = B1 XOR B0
Step by step:
G3 = 1
G2 = 1 XOR 0 = 1
G1 = 0 XOR 1 = 1
G0 = 1 XOR 1 = 0
Final Answer:
Gray code = 1 1 1 0
Verification (Gray back to Binary):
B3 = G3 = 1
B2 = B3 XOR G2 = 1 XOR 1 = 0
B1 = B2 XOR G1 = 0 XOR 1 = 1
B0 = B1 XOR G0 = 1 XOR 0 = 1
Binary = 1 0 1 1 Correct.Exam Tip: In Gray-to-Binary conversion, the chain runs from MSB to LSB and each step uses the previously computed binary bit, not the Gray bit. A very common mistake is using G bits on both sides. For BCD-to-XS3, the carry out of the adder must be ignored — only the 4-bit sum matters. Anna University often asks you to design a 2-bit or 3-bit Gray converter using a K-map and XOR gates; memorise that the XOR gate is the only gate needed for both directions.
Key Properties
- BCD-to-XS3: uses 74LS83 adder, propagation delay 16 ns, supply 5 V
- Gray/Binary converters: use 74HC86 XOR, delay 7 ns, supply 2–6 V (CMOS)
- 74HC86 power dissipation: less than 0.1 mW static, 80 µA max quiescent current
- Fan-out: 74HC86 drives 50 CMOS or 10 TTL loads
- Gray code: only 1 bit changes between consecutive values — eliminates encoder glitches
- Excess-3 is self-complementing: inverting all bits gives the 9s complement
- BCD-to-binary conversion for multi-digit BCD uses 74184 (dedicated IC, obsolete in new designs but exam-relevant)
Quick Revision
- Binary-to-Gray: MSB unchanged, each lower bit = XOR of adjacent binary bits
- Gray-to-Binary: MSB unchanged, each lower bit = XOR of previous binary and current Gray
- BCD-to-XS3: add 0011 (binary 3) using a 4-bit adder
- XS3-to-BCD: subtract 0011 (or add 1101) from XS3 digit
- Gray code used in rotary encoders to prevent multiple simultaneous bit changes
- 74HC86 quad XOR is the standard IC for Gray converters, 7 ns delay at 5 V
- 74LS83 4-bit adder handles BCD-to-XS3, 16 ns delay
- Exam trap: in Gray-to-Binary, students incorrectly XOR two Gray bits instead of the computed binary bit with the next Gray bit
Code Converter Quiz
Challenge yourself on BCD, Gray, and Excess-3 code conversion circuits.
Q1.What is the Excess-3 code equivalent of BCD digit 6?
Related Articles
BCD Code
Binary coded decimal, valid and invalid BCD, BCD addition.
12 min read
BCD Adder
4-bit BCD addition, correction logic for invalid BCD.
4 min read
Gray Code
Reflected binary code, binary to Gray conversion.
4 min read
Excess-3 Code
Self complementing code, BCD to Excess-3 conversion.
4 min read
BCD to 7-Segment Decoder
IC 7447, display driver, segment mapping.
5 min read