Jump to content

Hamming decode by hand

- - - - -

  • Please log in to reply
No replies to this topic

#1
stn0091

stn0091

    Newbie

  • Members
  • Pip
  • 1 posts
Nevermind, I figured it out.


Input: 1903 (11-bit binary 11101101111)


1   2   3   4   5   6   7   8   9   10   11

P   P   D   P   D   D   D   P   D    D    D

1   1   1   0   1   1   0   1   1    1    1


Parity check:

{

   Parity bit 8: Bits 8, 9, 10 and 11 are "1" and add up to four, which is even so parity bit 8 is "0"

   Parity bit 4: Bits 4, 5, 6 and 7 have two 1's, adding up to two which is even so parity bit 4 is "0"

   Parity bit 2: Bits 2, 3, 6, 7, 10 and 11 add up to five, which is odd so parity bit 2 is "1"

   Parity bit 1: Bits 1, 3, 5, 7, 9 and 11 add up to five which is odd so parity bit 1 is "1"

}


This gives me the the binary number 0011 which is 3 in decimal form, telling me that bit 3 is bad.


The corrected packet is:


1   2   3   4   5   6   7   8   9   10   11

P   P   D   P   D   D   D   P   D    D    D

1   1   [b]0[/b]   0   1   1   0   1   1    1    1


Reading the data bits gives me the corrected 7-bit binary number 0110111, 55 in decimal form.

My mistake was ignoring the bits marked for parity in the sequence when I did the check. For example, when checking parity bit 1, I only looked at bits 3, 5, 7, 9 and 11 of the sequence and ignored bit 1. I didn't realize the parity bits look at themselves also when checking for errors.

Now I can finally start writing the actual code for this. :D






~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Anyone out there familiar with Hamming encoding/decoding? I need some help with the decoding part.

Bits 1, 2, 4 and 8 are the parity bits and the total number of bits after encoding is 11; the input number will have 6 bits.

Even parity is used.


1   2   3   4   5   6   7   8   9   10   11

P   P   D   P   D   D   D   P   D    D    D


P means that bit is for used for parity and D means that bit is used for data

Parity bit 1 is for bits 3, 5, 7, 9, 11

Parity bit 2 is for bits 3, 6, 7, 10, 11

Parity bit 4 is for bits 5, 6, 7

Parity bit 8 is for bits 8, 9, 10, 11


If the input is the decimal number 65, then its binary form 1000001 will be put into data

bits 3, 5, 6, 7, 9, 10, 11.


1   2   3   4   5   6   7   8   9   10   11

P   P   D   P   D   D   D   P   D    D    D

        1       0   0   0       0    0    1


After counting the 1's and setting the parity bits, I'll end up with an encoded

11-bit binary value of 00100001001.


Why 11-bits? Because my teacher made the assignment that way.

So, encoding isn't much of a problem for me. I can't seem to decode properly at all though.

Say I'm given the decimal value 1903 (11-bit binary 11101101111). I'm suppose to check the parity bits to make sure that the data is correct. In this case, I should find that bit 3 is bad, correct it and end up with the decoded decimal value 55 (11-bit binary 00000110111).

I can't seem to get it right though. Can someone explain to me how to properly decode?

Edited by stn0091, 13 October 2010 - 02:22 PM.
resolved





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users