I have an odd communication channel, and I need to detect errors and also exclude certain sequences in the channel.
Each message has a length of 12 bits, divided into 3 pieces (4 bits each). I need to extract at least 450 different codes from this, so that I can have a distance from interference of up to 3.
However, I cannot have two nails in the sequence the same, so the following sequences are not valid:
0xf 0xf 0xf - Three of the same nibbles in sequence 0x8 0x8 0x0 - Two of the same nibbles in sequence 0xf 0x3 0x3 - Two of the same nibbles in sequence
In addition, messages can follow each other without interruptions, so the beginning of one sequence cannot have the same first piece as the end of the last sequence:
0x327 0x743 - Even though they are not in the same message, two sequential nibbles are the same in the message stream
But the following sequences are in order:
0x1 0x2 0x1 - Two nibbles same, but separated by another nibble 0x0 0x1 0x2 - All nibbles different 0xf 0x8 0x3 - All nibbles different
And the following series of messages is in order:
0x121 0x012 0xf83 - No two adjacent nibbles are the same is the stream of messages
My first thought is to use 9 bits for my message, broken into three 3-bit parts as the top bits of each nibble:
mmmc mmmc mmmc - Each character is a bit, m bits are message, c bits are checksum/parity/etc
Then create an input table 512 that gives me three bits to fill c so that it creates distance for hamming, eliminating unpleasant sequences.
However, this will work on a low-performance embedded processor, and if I can use arithmetic to generate c bits on the fly, it will save memory (instead of more processor time), which is more valuable in this case.
Is there some math I can do to solve this problem without a table?
Alternatively, is there another math packaging method that meets the requirements?