A scanning probe microscope comprising: a probe that is mechanically responsive to a driving force, the probe having a tip; a signal generator arranged to provide a drive signal to an actuator arranged to generate the driving force, the drive signal being such as to cause the actuator to move the probe repeatedly towards and away from a sample, wherein the signal generator is arranged to generate probe oscillatory motion, the signal generator is a waveform generator, and the drive signal is such as to provide a cyclical driving force that moves the probe towards and away from the surface; a detection system arranged to output a height signal indicative of a path difference between light reflected from the probe and a height reference beam; image processing apparatus that is arranged to use the height signal to form an image of the sample; and signal processing apparatus arranged to monitor the probe as the probe approaches the sample and to detect a surface position at which the probe interacts with the sample; wherein in response to detection of the surface position the signal processing apparatus is arranged to prompt the signal generator to modify the drive signal, wherein the signal processing apparatus comprises a surface detection unit which is arranged to send a trigger signal to the waveform generator once the surface position is detected, wherein in response to said trigger signal the waveform generator is arranged to modify the drive signal in order to retract the tip of the probe away from the sample, wherein the surface detection unit is arranged to provide an indication of a point in a cycle at which the tip of the probe interacts with the sample surface, and wherein an indication of the surface position is extracted from said point in the cycle. a probe that is mechanically responsive to a driving force, the probe having a tip; a signal generator arranged to provide a drive signal to an actuator arranged to generate the driving force, the drive signal being such as to cause the actuator to move the probe repeatedly towards and away from a sample, wherein the signal generator is arranged to generate probe oscillatory motion, the signal generator is a waveform generator, and the drive signal is such as to provide a cyclical driving force that moves the probe towards and away from the surface; a detection system arranged to output a height signal indicative of a path difference between light reflected from the probe and a height reference beam; image processing apparatus that is arranged to use the height signal to form an image of the sample; and signal processing apparatus arranged to monitor the probe as the probe approaches the sample and to detect a surface position at which the probe interacts with the sample; wherein in response to detection of the surface position the signal processing apparatus is arranged to prompt the signal generator to modify the drive signal, wherein the signal processing apparatus comprises a surface detection unit which is arranged to send a trigger signal to the waveform generator once the surface position is detected, wherein in response to said trigger signal the waveform generator is arranged to modify the drive signal in order to retract the tip of the probe away from the sample, wherein the surface detection unit is arranged to provide an indication of a point in a cycle at which the tip of the probe interacts with the sample surface, and wherein an indication of the surface position is extracted from said point in the cycle.