A computer-readable storage medium storing instructions that, when executed by a processor of an atomic force microscope including a tip mounted on a cantilever, an XY scanner, and a Z scanner, cause the atomic force microscope to perform operations comprising:
- in a normal measuring state in which the tip is vibrating at a specific frequency, acquiring a surface characteristic of an object while relatively moving the object with respect to the tip in a first direction by the XY scanner;
- determining an abnormal state when an amplitude of the vibrating tip is out of a specific range;
- and
- in response to determining the abnormal state, separating the tip from the surface of the object by contracting the Z scanner,
- wherein, during the contracting of the Z scanner, a contraction speed of the Z scanner is maintained equal to or greater than a predetermined lower limit.