I am faced with a tricky challenge: To extract binary data from an iPhone magnetic strip card reader. This is what the magnetisation on the card looks like:
Here is the .WAV the iPhone receives when you swipe a card (don't get your hopes up too much, it is a bonus loyalty card ;)). That's three swipes by the way, at different speeds. This is the raw SInt16 dump for the swipe I am using.
Someone seems to have done it here but the actual data I capture isn't particularly easy to process.
The reading starts (and finishes) with an indeterminate number of 'zeros ' -- note that the wave only repeats after 2 ZEROS have been collected, this represents N-S followed by S-N:
(note that each of the three lines represents me swiping a different card; the bottom card in this image is 15 years old, so the magnetic field is clearly severely degraded in some places, not visible in this shot)
This will allow an algorithm to ascertain a clock tick.
The magnetic field reverses on each clock tick. Also for a binary 1, the magnetic field reverses exactly in the middle of a tick:
The sequence always starts with a 1101+0(parity bit) start sentinel. You can pick this out in all three readings in the above graph. It is indicated more clearly in the cosmodro article I linked at the top of the question.
Here is an example of magnetic degradation (taken further along on the bottom card reading):
I am trying to figure out a sensible way to convert this waveform into its corresponding binary sequence.
I have found one PDF that goes into some detail, but I can't figure out the algorithm they are using.
This PDF contains one interesting image:
If I could extract the red and blue lines as per this diagram, I could use either one of them to extract the data, but I can't figure out the logic behind the construction.
So this is my question: How do I extract the binary sequence?
PS. Note that the swipe speed is not going to be constant. So once the clock has been determined, in needs to be constantly adjusted from one tick to the next.
PPS. Would autocorrelation catch pairs of ticks? (seeing as ticks will alternate N-S S-N ... )
EDIT (June '12): I needed a lot of help on this one, but finally I have completed a solid reader ( http://www.magstripedecoder.com/ ). Thanks for everyone who helped! I recommend #musicdsp on IRC's efnet channel for anyone dedicated enough to take the challenge of getting to grips with the maths -- it's really really hard!