Numerical simulations of the frequency modulation atomic force microscope, including the whole dynamical regulation by the electronics, show that the cantilever dynamics is conditionally stable and that there is a direct link between the frequency shift and the conservative tip-sample interaction. However, a soft coupling between the electronics and the nonlinearity of the interaction may significantly affect the damping. A resonance between the scan speed and the response time of the system can provide a simple explanation for the spatial shift and contrast inversion between topographical and damping images, and for the extreme sensitivity of the damping to a tip change.