I’ve been thinking for quite some time about error correction. About using the structure of the MFM to our advantage. I’ve come up with something although I haven’t implemented the idea yet.
As you know from my many references to it, http://techtravels.org/?p=62 , this post shows the 32 possible byte combinations from legal raw MFM.
I’ve run some numbers today. First, there are illegal values, and then you have illegal PAIRS of MFM bytes. For instance, while 0xAA is valid by itself, and 0x11 is valid by itself, 0xAA11 is illegal, because the combination of those would produce 4 consecutive zeros, and as we know, this is illegal. Just like 0x55 is legal and 0x88 is legal, but 0x5588 is illegal because that would produce back-to-back 1’s, also illegal.
So as far as PAIRS go, roughly 1/3 of the total possible pairs (32*32=1024), are illegal. That works out to be 341 pairs or so. I was always interested in the percentage of bad pairs so we could use that info to detect bad bits/bytes.
So here’s my logic:
We need to know the data is bad, and that we fixed the data once we’ve attempted some error correction stuff. The checksum works fine here. The checksum uses XOR, and while its not perfect, it provides us with a decent check.
Next, we need to know which bytes are bad so we know which ones to fix. This is also easy. Because we know which raw values are ok, we can simply check the bytes against a table (when the checksum fails), and then we know roughly which ones are bad. The byte before or after might be screwy, but we have the general location.
So now that we know which bytes need fixed, we need to figure out what the correct values for the bytes would be. Enter hamming distance. If you don’t know what that is, look here. Long and short of it is that it provides a measurement of how many bits need flipped/changed to go from one byte to another. In our case, it tells us that if we have a single-bit error (and this we have to guess on), and we give it the bad byte, it will tell us which LEGAL mfm bytes the byte could have been. I wrote a small c program today that calculates the hamming distance between BAD BYTES, and legal mfm bytes. Note this produced ~7200 lines of results.
So then what, we now have a small subset of guesses to make at the byte value. Now, if there is just one bad byte, then its easy enough to swap in some choices, and then re-checksum the track to see if that fixes it. If there are multiple values, this becomes much harder for me to wrap my head around programmatically wise. I think the problem wreaks of recursion, which I’ve never been very good at. I need to test all the possible (or probable) values in each of the appropriate locations. This is not simple iteration, as far as I know.
So here’s some examples: (these are in decimal,not my normal hex)
Let’s say our bad byte is DEC 83. Once again, this is illegal because of the “3” ended in binary 11.
So, the output from my program tells me that a single-bit error could have cause an 81 to look like an 83, that means bit 2 in that byte got mangled from a 0 to a 1.
But it could been an 82 as well. So bit 1 might have been set, when it should have been cleared.
But that’s it. Assuming that we just had a single-bit error, then those are the only two possibilities. I think single-bit errors are the most common, but I’ll need to work on this.
OK, so now let’s look at 2-bit errors in the same byte. If bad byte is still 83, then 17, 18, and 85 are possible choices.
What I’m really doing is intelligently narrowing the search space to valid possible choices. And then, I could apply the PAIR logic from above, and potentially eliminate more of the choices.
I think it might make sense to check upwards of 3-bad bits of error…… After that it seems like maybe brute force might just be better/simpler…..
While this stuff is nice, if we have a byte get mangled in such a way that it produces another legal different raw mfm byte, then it might be impossible to check. I can still apply my pair-logic to it which might help identify which byte is the problem byte.
Definitely different and excited stuff. I’ve never seen this idea used before, at least not in the amiga floppy world.