A method of operating an atomic force microscope, comprising a probe, the probe being moved forth and back during respective trace and retrace times of a scan line, the method comprising: a) during trace time, oscillating the probe, b) generating a z feedback signal to keep an amplitude of oscillation of the probe constant at a setpoint value, the z feedback signal being generated by a first feedback loop, c) during retrace time, placing the probe in a drift compensation state by changing the setpoint value to a different value so that the z feedback signal being generated by the first feedback loop causes the probe to move away from the sample and oscillate free, d) detecting an amplitude of free oscillation of the probe and adjusting with a second feedback loop its excitation signal to maintain the amplitude of free oscillation of the probe close to a set value.
展开▼