Currently, atomic force microscopy (AFM) is the most preferred scanning probe microscopy method due to its numerous advantages. However, increasing the scanning speed and reducing the interaction forces between the probe's tip and the sample surface are still the two main challenges in AFM. To meet these challenges, we take advantage of the fact that the lateral movements performed during an AFM scan are a repetitive motion and propose a repetitive controller (RC) for the z-axis movements of the piezoscanner. The RC utilizes the profile of the previous scan line while scanning the current line to achieve a better scan performance. The results of the scanning experiments performed with our AFM setup show that the proposed RC significantly outperforms a conventional PI controller that is typically used for the same task. The scan error and the average tapping forces are reduced by 66% and 58%, respectively, when the scanning speed is increased by sevenfold.