Modern DSLR cameras use the Phase Detect autofocus method to determine the correct point at which to focus the lens. This method is fast and generally accurate and operates by light travelling through the lens. When you half-press the shutter button on your DSLR while looking through the optical viewfinder, it's Phase Detect autofocus that's used.
The image below shows the AF assembly inside a 5D Mark II camera:
Digital SLR camera autofocus components
The light coming into the camera from the lens hits the main mirror, and most of the light goes upwards, through the pentaprism and out of the viewfinder to your eye. Some of the light, however, goes through a semi-transparent area of the main mirror to hit the secondary mirror (behind the main mirror) and go down to the AF sensor (this is shown by the dotted line in the diagram above).
Digital SLR camera cutaway
Looking at a cutaway view of a generic DSLR camera above, the AF sensor is positioned at the bottom of the mirror box. The thing to note here is that the AF sensor is different to the image sensor which actually takes the photo - the main image sensor is located at the back of the camera (in the image above it's the green/brown rectangle towards the back of the camera).
As mentioned above, the image sensor and the autofocus sensor are different and are in different places. The AF sensor will report back to the AF algorithm running on one of the camera's microprocessors, and the lens will be quickly moved to the point where the AF sensor reports the best focus.
So, the focus at the AF sensor will be as good as possible.
But the photograph is captured at the image sensor. If there is a tiny discrepancy in the distance between the focal point and both sensors, the captured image will be slightly out of focus even though the AF sensor worked perfectly!
Manufacturing tolerances, bad lens mounts, bad lens optics, dirt and many other things can alter the performance of the AF system both temporarily and permanently.
This is where AF Microadjust comes into the picture.
AF Microadjust allows you to slightly shift the focus either forwards or backwards for each and every (phase detect) AF operation.
Canon AF Microadjustment
Nikon AF Fine Tune
On Canon and Nikon cameras, this value is between -20 and +20. The meaning is not specified by the camera manufacturers, although it's generally a fraction of the depth of field of the lens. A setting of -20 shifts by the maximum amount towards the camera, and the +20 shifts by the maximum about away from the camera, and each value in between is somewhere between those two extents. A value of 0 (zero) doesn't shift the focus at all.
With one problem solved, another is created - that of properly calibrating the AF microadjustment value.
There are lots of solutions available - some free, some paid for. They typically involve pointing the camera at some kind of angled target and visually adjusting to the point of correct focus. However, you have to be very careful how you set the tests up, it's easy to get wrong and there's nothing to tell you that you've made a mistake until you try out your camera and the results are bad. The biggest problem, however, is the variability of the camera autofocus system itself - when you focus on the same point 10 times in a row, you won't get 10 identically focused shots! To calibrate, you have to take a number of shots of these targets, and if the focus is slightly different each time, how do you know which value to choose?
FoCal was developed to get around these problems. Using a special target, complex image analysis and statistical methods of removing the effect of camera focus variability, FoCal is able to not only assist in the perfect setup but then go on to calibrate the lens with one click!