In tapping mode, the cantilever is driven to oscillate up and down at its resonant frequency using a piezoelectric actuator. When the oscillating cantilever approaches the sample surface, it intermittently contacts the surface. The amplitude of oscillation changes due to the interaction between the tip and the sample. A feedback loop adjusts the height of the cantilever to maintain a constant oscillation amplitude, thereby generating topographical data of the sample.