This section applies specifically to imaging in . For other imaging modes, the process is similar, except that "deflection" should be replaced by the appropriate feedback variable.
When using the AFM to image a sample, the tip is brought into contact with the sample, and the sample is raster scanned along an x–y grid (fig 4). Most commonly, an electronic feedback loop is employed to keep the probe-sample force constant during scanning. This feedback loop has the cantilever deflection as input, and its output controls the distance along the z axis between the probe support (2 in fig. 3) and the sample support (8 in fig 3). As long as the tip remains in contact with the sample, and the sample is scanned in the x–y plane, height variations in the sample will change the deflection of the cantilever. The feedback then adjusts the height of the probe support so that the deflection is restored to a user-defined value (the setpoint). A properly adjusted feedback loop adjusts the support-sample separation continuously during the scanning motion, such that the deflection remains approximately constant. In this situation, the feedback output equals the sample surface topography to within a small error.
Historically, a different operation method has been used, in which the sample-probe support distance is kept constant and not controlled by a feedback (servo mechanism). In this mode, usually referred to as "constant-height mode," the deflection of the cantilever is recorded as a function of the sample x–y position. As long as the tip is in contact with the sample, the deflection then corresponds to surface topography. This method is now less commonly used because the forces between tip and sample are not controlled, which can lead to forces high enough to damage the tip or the sample. It is, however, common practice to record the deflection even when scanning in "constant force mode," with feedback. This reveals the small tracking error of the feedback, and can sometimes reveal features that the feedback was not able to adjust for.
The AFM signals, such as sample height or cantilever deflection, are recorded on a computer during the x–y scan. They are plotted in a pseudocolor image, in which each pixel represents an x–y position on the sample, and the color represents the recorded signal.