I need to transmit data over the line with some noise. Each transmission packet is only one byte (8 bits). I need that the receiver will be able to catch errors (and optionally correct some of them - but it is not essential as I can repeat the transmission in case of error).
Now I know two options:
So may be there is any intermediate coding algorithm more reliable than parity control but easy than Hamming code?
Ok here is something you can do:
take any 2 bits (or bytes, just understand that most languages support byte operators much more than bit operators), xor them together... this is your verification code...
so you have:
xor (^) table
_________________________
| 0 | 1
0 | 0 | 1
1 | 1 | 0
so some sort of code:
byteA = 0x3d;
byteB = 0x47;
verificationCode = byteA ^ byteB;
then you send these 3 bytes across the wire, and you can use them to detect a transmission failure...
This is not a hamming code, it is a simple detection method ...
hamming codes work on nibbles, half bytes:
imagine a bit type:
bit a = 1;
bit b = 0;
bit c = 1;
bit d = 1;
bit p1 = (a + b + d) % 2;
bit p2 = (a + c + d) % 2;
bit p3 = (b + c + d) % 2;
then you mash the bits and pbits together and put them over the wire:
[p1,p2,a,p3,b,c,d, p4 if it exists]
so if you calculate the parity codes on the other side:
if one bit is flipped, then you can recover:
(assume all parity bits not specified are correct)
if it isn't one of these state... then there are 2 or more bits wrong, and you must re-transmit...
you can also add some verification by using a 4th parity bit, which also conveniently fits into an 8 bit byte...