Late joiner!
I would recommend capacitance, assuming (1) there is an opportunity to calibrate and (2) the environment is fairly free of non-repeatable (i.e., cannot be captured during calibration) outside influences. Block A has active electronics on it. Block B has a metal (foil works) plate on the side facing Block A. Block A includes one plate of a capacitor, a driven shield for that plate, and a ground "plate" (consisting of a ring of foil around the perimeter of the side facing Block B).
The field from the driven center plate to the grounded perimeter is forced to extend fairly far out into space. The disturbance by the foil on Block B alters the capacitance between the center plate and ground. Measure the capacitance (there are various ways) vs. distance to establish a calibration curve and you are done. This is fairly immune to temperature, very susceptible to dielectric constant change of the intervening material, and very cheap to build (under $30 in electronics - voice of experience!). One part in 400 is not too difficult to do with a 2nd order curve fit (8-bit microcontroller is sufficient, but a math library helps!), but accuracy also depends on movement being restricted to X direction.
I know this is old but just ran across some Light to frequency converters. With a resolution of 16 bits and a wide range of sensitivities, Looks as if this might be the low cost answer. Please check taosinc.com for more info.The available devices include both analog and digital.Some with programmable gain. for a wide range of light sensitivity. Couple this with a reflectivity of block A or source on block A with sensor on block B, the range can can be varied. Also using an adjustable light source, the distance can be varied over a wide range. The cost of the sensors are only a couple bucks. I am going to build a motion sensor using one of the analog as well as one of the digital sensors. I have a need to measure the absolute speed of motion of an object independent of direction. Sorry for the long response time.
Bill
Brilliant ideas. All worth trying.
Timatthelab, would block B's foil still be affected to a detectable margin at far distances. Say, at 20cm?
Saturation, I can not wait to try the light range finder option.
Billpenner, I am going to look into your option.
Cabe
The range for capacitance measurements depends primarily on the geometry, of which the distance is a big part. I have found that the usable range is about 1 to 3 times the diameter of the electrode "plate" used. In this case, one plate is the center sensor, while the other is the ground ring, complicated by the "reflection" off of the Block B target. With sufficient width of the ground ring, one could expect decent results to about 2 to 3 times the sensor diameter. If you get much farther than that, the amount of gain required is so great that the noise become problematic (although you can recover from it to a point if you can average over a long enough time).
Also, note that Block B does not necessarily need a foil, if it's dielectric constant is sufficiently high. E.g., the raw material used in soylent green is full of water, so you can use this technique as a decent "person detector".
What about String-pots?
With a little bit of calibration/interpolation, you can probably achieve the accuracy you're after
Or LVDTs?
http://www.lvdt.co.uk/pdf/AML-E.pdf
Or finally magnetic encoders;
http://www.renishaw.com/en/magnetic-linear-encoders-and-magnetic-ring-encoders--9802
Any of those are simpler/easier to implement that optical or US solutions, and should give you the kind of accuracy you're after.
String pots aren't a bad idea, except when you have to worry about humidity changes and string stretch. Good for being able to replace them though, and wouldn't be too hard to implement a centering capability with end cap limit switches. The LVDT's are quite a bit more accurate, IMHO, used them for flight control position sensing on Helicopters. Currently work with encoders and wheels that measure speed/distance for conveyor belts. They work well if you can find the right combination to get the 7.5 degree measurements to equal a specific linear measurement.
Regular calibration (yearly) should take care of any stretch in the steel wire used for the pots strings.. not sure how humidity would affect that. (temperature is likely to much bigger effect).
As for the encoders, take a look at the link.. I meant linear magnetic encoders, they use magnetic strips with alternating poles with a moving reader head. the accuracy can be down to a micron if required, 20microns is quite common (0.02mm). Bit more difficult to use but worth it if accuracy and reliability is what you need