0% found this document useful (0 votes)
11 views7 pages

Hamming Code Cleaned

The document discusses alphanumeric codes, particularly focusing on ASCII and Hamming codes. ASCII is a character encoding standard that represents text in computers using a limited set of 128 characters, while Hamming code is an error-detecting and correcting code used in digital systems to ensure data integrity during transmission. The document also explains the principles of parity bits for error detection and correction.

Uploaded by

daudimafwere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Hamming Code Cleaned

The document discusses alphanumeric codes, particularly focusing on ASCII and Hamming codes. ASCII is a character encoding standard that represents text in computers using a limited set of 128 characters, while Hamming code is an error-detecting and correcting code used in digital systems to ensure data integrity during transmission. The document also explains the principles of parity bits for error detection and correction.

Uploaded by

daudimafwere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ALPHANUMERIC CODE

Alphanumeric code is a system that combines letters (A-Z) and digits (0-9)
represent Information. This is type of code is extremely versatile and widely used in
numerous field for data encoding, identification, and encryption purposes .
Alphanumeric character give a greater range of possible combination compared to a
code using only number or only letters , which enhances it’s utility in fields that
require large set of unique identifiers. Generally the digital system are deals with zero
& one in order to make a system to deal with a both numbers & letters we often use
the alphanumeric codding system. There are numerous codding method have been
invented but most commonly alphanumeric code are :-
 ASCII
 EBCDIC
ASCII CODE
The term ASCII stands for(American standard code information interchange) and it
was first published in 1967 & after that it’s being changed & updated. It’s widely
used in computer & other electronic devices for encoding text and data. ASCII
assigns each character (letters, digits ,punctuation, etc ) in a unique number
between 0-128 where simply 95 characters are printable which limited severely it’s
scope due to digital systems technical limitations such as computer at invented time.
ASCII Character Set.
The ASCII character set consist of 128 characters, which are divided into several
categories
1. Control characters (0-31 and 127)
These characters are Non printing characters for controlling hardware device (like
printers) or controlling data flow (like carriage return).
Example:- a) 0:Null character (NULL)
b) 9:Horizontal Tab (TAB)
c) 10:Line feed (LF) move to the next line
2. Printable character (32-126)
These character represent text and are ones you usually see in document. They
include :-
 32: Space ( )
 33: Exclamation mark (!)
 48-57:digits (0-9)
 32-47, 58-64, 91-96, 123-126: Punctuation marks and special symbol ( eg.
,@, $, %, &, *, (, ), etc)
3. Extended ASCII (128-255)
Extended ASCII includes Additional character, which were added to cover other
languages, symbol & graphics. These are used in extended or Non-standard ASCII
system, as the original ASCII standard only defined 128 characters.

How ASCII work


Each ASCII character is represented by a 7-bit binary number, for example :-
 A: 65 in decimal -> 01000001 in binary
 B: 66 in decimal -> 01000010 in binary
 C: 97 in decimal -> 01100001 in binary
ASCII Table example
Decimal Character Binary Hex Description
0 NUL 00000000 00 Null
1 SOH 00000001 01 Start of heading
2 STX 00000010 02 Start of text
3 ETX 00000011 03 End of text
4 EOT 00000100 04 End of
transmission
5 ENQ 00000101 05 Enquiry
Importance of ASCII code
 Standardization: It ensure computer can exchange data and display text
consistently.
 Simplicity: ASCII uses simple numeric codes to represent character, make it
easy for computer to process and understand.
 Compatibility: ASCII is widely supported across many programming
languages, device, and operating systems, making it an essential component
for data exchange.
Limitation of ASCII code
 Limited character set : It has only 128 character which is insufficient for
representing character from non –English languages or Special symbol.
 Language Constraints : ASCII doesn’t fully support international character like
accented character or character from Non-Latin Alphabets (eg.,Arabic, Chinese).

HAMMING CODE
 Is the type of error detecting and error correcting code used in digital
systems like computer memory, communication system
 This was invented by R.W.Hamming in 1950 for detecting and correcting
single- bit errors in data transmission or storage
 Hamming code has two essential elements these are
Data part; is the original data bits that need to be transmitted. These are the
actual bits of information that you want to send.
Parity part; is the additional bits that are added to the data bits to provide
error detection and correction capabilities. These parity bits are calculated
based on the data bits and are used to detect and correct errors that may
occur during transmission.

In a Hamming code, the parity bits are inserted at specific positions among
the data bits, and the resulting code is called a Hamming code . The parity
bits are typically denoted as p1, p2, p3, and so on.
For example, in a (7-bit ) Hamming code, there are 4 data bits (D1, D2, D3,
AND D4) and 3 parity bits (P1, P2, AND P3)
Placement of Parity Bits:

Parity bits are placed at positions that are powers of 2 (e.g., 1, 2, 4, 8, 16,
etc.) within the code word.
The remaining positions are used for the data bits.
Example of 7- bit hamming code with 4 data bit and 3 parity bit will be
placed in a position as

P1 P2 D1 P4 D2 D3 D4

Where; P1,P2,P4 represent position of nth parity bit


D1,D2,D3,D4 represent the position of nth data bit

Number of Parity Bits

The number of parity bits depends on the number of information bits.


Let X = number of information bits
Let P = number of parity bits

The total length of the codeword (x + p) must satisfy:


2^P ≥ X + P + 1

Example 1:
Let x = 4. Find minimum P such that 2^p ≥ 4 + p + 1

Try p = 2: 2² = 4 < 7 → Not satisfied


Try p = 3: 2³ = 8 ≥ 7 → Satisfied

So, total bits = 4 (data) + 3 (parity) = 7 bits

Bit Positions and Parity Bit Placement


Position where the parity bits covers this depends on the point where the bit Pin the
binary is 1
Consider the table bellow
decimal binary
1 001 Bit 1=1 P1
2 010 Bit 2=1 P2
3 011 Bit 1,Bit 2 =1 P1,P2
4 100 Bit 3=1 P4
5 101 Bit 1,Bit3=1 P1,P4
6 110 Bit 2,Bit 3 =1 P2,P4
7 111 Bit 1,Bit 2 ,bit 3 P1,P2,P4
=1

Therefore;
P1 covers bits: 1, 3, 5, 7
P2 covers bits: 2, 3, 6, 7
P4 covers bits: 4, 5, 6, 7

Each parity bit is calculated using even parity (unless otherwise stated).

Solving the value of P1,P2,P4..


Example

Encode the 4-bit binary word: 1011 using a 7-bit Hamming Code with even parity

Step 1: Assign data bits to positions 3, 5, 6, 7:

position 1 2 3 4 5 6 7
bits 1 0 1 1
P1 P2 D1 P4 D2 D3 D4 Step 2: Calculate parity bits
- P1 (positions 1, 3, 5, 7) → bits:
1, 0, 1 → 2 ones → Even → P1 = 0
- P2 (positions 2, 3, 6, 7) → bits: 1, 1, 1 → 3 ones → Odd → P2 = 1
- P4 (positions 4, 5, 6, 7) → bits: 0, 1, 1 → 2 ones → Even → P4 = 0

Final Hamming Code: 0110011


OR
- P1( positions: 1, 3, 5, 7) → P1 ⊕ 1 ⊕ 0 ⊕ 1 = 0 → P1 = 0
- P2 (position 2, 3, 6, 7) → P2 ⊕ 1 ⊕ 1 ⊕ 1 = 1 → P2 = 1
- P4 (position 4, 5, 6, 7 → P4 ⊕ 0 ⊕ 1 ⊕ 1 = 0 → P4 = 0
Final Hamming Code: 0110011

Error Detection and Correction


The binary information is transferred from one location to another location through
some communication medium. The external noise can change bits from 1 to 0 or 0 to
1. This change in values changes the meaning of the actual message and is called an
error.
For efficient data transfer, there should be error detection and correction codes.

Error detection code


is a binary code that detects digital errors during transmission.
To detect errors in the received message, we add some extra bits to the actual data.
Without the addition of redundant bits, it is not possible to detect errors in the
received message.
Error correcting code
is a method of encoding data in such a way that it allows the detection and
correction of errors that may occur during data transmission or storage. It works by
adding redundant bits to the original data to create a codeword, which can be
analyzed later to identify and fix any errors.

A parity bit

A parity bit is an extra bit that is added to the message bits or data-word bits on the
sender side.
Data-word bits along with parity bits is called a codeword.
The parity bit is added to the message bits on the sender side, to help in error
detection at the receiver side.
Parity Bit Method of detecting error
A parity bit is an extra bit included in the binary message to make a total number of
1’s either odd or even.
There are two parity systems
 Even parity checks
 odd parity checks.

Even Check (Even Parity):

To add an even check, you count the number of 1s in the message. If the count is
odd, you add a 1 to the end of the message. If the count is even, you add a 0. This
way, the total number of 1s in the message (including the added bit) is always even.

For example the message is: 1010

count the 1s: 2 (even)

So, add a 0: 10100

Odd Check (Odd Parity):

to iemploy this,. You count the number of 1s in the message. If the count is even, you
add a 1 to the end of the message. If the count is odd, you add a 0. This way, the total
number of 1s in the message (including the added bit) is always odd.

Using the same example: 1010

count the 1s: 2 (even)


So, add a 1: 10101

When the message is received, the receiver checks the parity bit (the added bit) to
make sure it matches the expected pattern (even or odd). If it doesn't match, it
means an error occurred during transmission, and the receiver can request the
message to be resent.

Or other way
Given hamming code 0010011 is received.

Step 1: Recalculate parity bits using the received code.

Check:
- P1 (positions 1, 3, 5, 7) → bits: 0, 1, 0, 1 → 2 ones → Even → Correct
- P2 (positions 2, 3, 6, 7) → bits: 0, 1, 1, 1 → 3 ones → Odd → Error
- P4 (positions 4, 5, 6, 7) → bits: 0, 0, 1, 1 → 2 ones → Even → Correct

Error is only in P2. Since only P2 is wrong, the error is in position 2.


Received code: 001101001

Check parity bits:

- P1 group: bits 1, 3, 5, 7, 9 → bits: 0, 1, 1, 1, 1 → 4 ones → Even → Should be odd →


Error in P1
- P2 group: bits 2, 3, 6, 7 → bits: 0, 1, 0, 1 → 2 ones → Even → Should be odd → Error
in P2
- P4 group: bits 4, 5, 6, 7 → bits: 1, 1, 0, 1 → 3 ones → Odd → Correct
- P8 group: bits 8, 9 → bits: 0, 1 → Odd → Correct

Error in P1 and P2 only, hence the error is in position 3 (P1 + P2 = 1 + 2 = 3)

Corrected Code: Flip bit at position 2 → 0110011

Example 3: 9-bit Hamming Code with Odd Parity

Let’s take 5 information bits: D1, D2, D3, D4, D5


Determine parity bits: p = 4
Total bits: 5 + 4 = 9 bits

Bit positions:
1(P1), 2(P2), 3(D1), 4(P4), 5(D2), 6(D3), 7(P8), 8(D4), 9(D5)

Example Data: 11001

Place data into D1 to D5:


Bit Positions: 1 2 3 4 5 6 7 8 9
Bits: __1_10_01

Now calculate odd parity for each parity bit:

- P1 (positions 1, 3, 5, 7, 9) → bits: 1, 1, 1 → 3 ones → Odd → P1 = 0


- P2 (positions 2, 3, 6, 7) → bits: 1, 0, 1 → 2 ones → Even → P2 = 1
- P4 (positions 4, 5, 6, 7) → bits: 1, 0, 1 → 2 ones → Even → P4 = 1
- P8 (positions 8, 9) → bits: 0, 1 → 1 one → Odd → P8 = 0

Final 9-bit Hamming Code: 011101001

Error Correction in 9-bit Code (Odd Parity)

Assume transmitted code: 011101001


Received code: 001101001

Check parity bits:

- P1 group: bits 1, 3, 5, 7, 9 → bits: 0, 1, 1, 1, 1 → 4 ones → Even → Should be odd →


Error in P1
- P2 group: bits 2, 3, 6, 7 → bits: 0, 1, 0, 1 → 2 ones → Even → Should be odd → Error
in P2
- P4 group: bits 4, 5, 6, 7 → bits: 1, 1, 0, 1 → 3 ones → Odd → Correct
- P8 group: bits 8, 9 → bits: 0, 1 → Odd → Correct

Error in P1 and P2 only, hence the error is in position 3 (P1 + P2 = 1 + 2 = 3)

Error Correction in 9-bit Code (Odd Parity)

Assume transmitted code: 011101001


Received code: 001101001

Check parity bits:

- P1 group: bits 1, 3, 5, 7, 9 → bits: 0, 1, 1, 1, 1 → 4 ones → Even → Should be odd →


Error in P1
- P2 group: bits 2, 3, 6, 7 → bits: 0, 1, 0, 1 → 2 ones → Even → Should be odd → Error
in P2
- P4 group: bits 4, 5, 6, 7 → bits: 1, 1, 0, 1 → 3 ones → Odd → Correct
- P8 group: bits 8, 9 → bits: 0, 1 → Odd → Correct

Error in P1 and P2 only, hence the error is in position 3 (P1 + P2 = 1 + 2 = 3)

Corrected bit at position 3 → Final code: 011101001

You might also like