I am busy with a prototype of a DIY Linear Magnetic Encoder - Ingredients:
1- Fridge magnet - Yes, or those sheets that stick on the side of a car with marketing material.
2- Arduino (or Teensy) AVR micro-controller running at 16MHz.
3- 2x Linear Hall sensors.
4- Breadboard and some LED's
Principle:
The 2 hall sensors slide past the magnets strips on the back of fridge magnet. Those magnets are arranged (by chance?) North-South-North-South, spaced 4mm between North's.
If the sensors are placed 1mm (1/4 of 4mm, or multiples thereof) apart, then the analog output is 2 very nice waves (90 degrees out of phase), just as noted by RomanLini.
Using atan2(wave1, wave2), you get an angle between -PI and PI, which is a % of travel from 0.0mm to 4.0mm. So you need to keep track of movement and where 4.0mm wraps back to 0.00mm
Results so far: 0.014 mm accuracy!!
Challenges:
How accurate are the fridge magnets over a long length?
Speed, commercial readers reach 1m/sec. I am at 1cm/sec !!
Results were obtained with sensors touching the magnets, on 2mm gap there is virtually no result.