A method of operating a scanning probe microscope wherein a control loop is provided which is configured for controlling one or more feedback parameters of the scanning probe microscope, wherein the scanning probe microscope comprises a sensor device including a cantilever having a probe tip, wherein the scanning probe microscope includes at least one stage actuator for actuating at least one of an object stage or sensor stage in order to vary a relative distance between the sensor device and a sample, and wherein a controller is provided with one or more control parameters configured to control the at least one stage actuator for keeping the sample at a desired distance with respect to the cantilever, the method including: performing one or more system identification measurements during operation of the control loop, wherein during the one or more system identification measurements an excitation signal with a plurality of frequency components is introduced in the control loop and a resulting response signal indicative of a cantilever displacement or a stage-sample distance between the sensor device and the sample is measured, wherein a model response function is identified using said excitation signal and said resulting response signal; adapting one or more settings and/or input signals in the control loop based on the identified model response function, wherein characterization of the sample by means of the scanning probe microscope is performed using the adapted one or more settings and/or input signals; and wherein the method further includes providing a periodic actuation signal to the sensor device using a probe actuator for inducing periodic movement between the probe tip and the sample during scanning of a surface of the sample with the probe tip, characterized in that during a second system identification measurement a second excitation signal with a plurality of frequency components is added downstream of the probe actuator at an actuator output signal of the probe actuator, and wherein a second model response function is identified using the added second excitation signal and a measured second response signal indicative of a displacement of the probe tip of the sensor device, wherein the identified second model response function is used for adapting the actuation signal provided to the sensor device for characterization of the sample. performing one or more system identification measurements during operation of the control loop, wherein during the one or more system identification measurements an excitation signal with a plurality of frequency components is introduced in the control loop and a resulting response signal indicative of a cantilever displacement or a stage-sample distance between the sensor device and the sample is measured, wherein a model response function is identified using said excitation signal and said resulting response signal; adapting one or more settings and/or input signals in the control loop based on the identified model response function, wherein characterization of the sample by means of the scanning probe microscope is performed using the adapted one or more settings and/or input signals; and wherein the method further includes providing a periodic actuation signal to the sensor device using a probe actuator for inducing periodic movement between the probe tip and the sample during scanning of a surface of the sample with the probe tip, characterized in that during a second system identification measurement a second excitation signal with a plurality of frequency components is added downstream of the probe actuator at an actuator output signal of the probe actuator, and wherein a second model response function is identified using the added second excitation signal and a measured second response signal indicative of a displacement of the probe tip of the sensor device, wherein the identified second model response function is used for adapting the actuation signal provided to the sensor device for characterization of the sample.