## 2 Materials and Methods
### Software  
LabVIEW, short for Laboratory Virtual Instrument Engineering Workbench, is a graphical programming environment developed by National Instruments. It is widely used for diverse applications in industry and academia. For the developed AFM system, the entire software is programmed in LabVIEW. This includes the graphical user interface (GUI), subroutines for calculation of piezo voltages, plotting of scanned images, and control of the feedback loop. A flowchart in Figure 6 illustrates the scanning process of the AFM. The system is first initialized by configuring new channels for input and output. In the software, analog input, AI0 is configured to accept the deflection signal from the signal conditioning module. The three analog outputs, namely AO0, AO1, and the positive variable power supply are set to control the piezo's motion in the \(X\)  
Figure 5: Block diagram of AFM and control system. \(Y\), and \(Z\) directions, respectively. The simplest way to configure channels in LabVIEW is to invoke NI-DAQmx, a programming interface to communicate with data acquisitiondevices. Next, the sequence of scanning voltages for \(X\) (fast axis) and \(Y\) (slow axis) directions are calculated. These scanning voltages are calculated based on parameters specified by the user. The parameters include size of scanned image, scan points (number of data points along fast axis), scan lines (number of data points along slow axis), and scanning coefficient (voltage value required per unit distance). Figure 7 shows a simplified schematic of the scanning sequence in the LabVIEW block diagram. By using nested \"For Loops\", the scanning sequence can be implemented efficiently. The inner loop handles positions in the fast axis and the outer loop controls the voltage steps along the slow axis. The \"Scan lines\" and \"Scan points\" that are connected to the \"\(N\)\" terminal of their respective loops determine the number of iterations for each loop to execute. At the same time, these two parameters control the number of pixels to represent an AFM image. A \"Replace Array Subset\" function is responsible to update the values of the pixels in real-time during the scanning process. Generally, the value of each pixel in an AFM image corresponds to a measured height value which is associated witha pair of surface coordinates, \((x,y)\). Each height value is directly proportional to the instantaneous output voltage that is fed into the \(Z\)-piezo. As mentioned previously, the output voltage is used to control the height of the sample stage in order to maintain a constant force between the AFM tip and the sample. When each scan line has beencarried out (all iterations of the inner loop are completed), the 2D plot is updated once. In LabVIEW, the \"Intensity Graph\" is used to present 3D data on a 2D plot by using color to display the values of the third dimension. The entire scanning process comes to an end when all the lines are completely scanned. As a result, an AFM image is created. In order to perform imaging in constant-force mode, a feedback controller is required in the AFM system. In our AFM setup, the control of the feedback loop is implemented in the LabVIEW environment without any extra hardware. This approach is flexible and allows us to configure the system settings easily and quickly. Figure 8 illustrates a schematic of the feedback controller in the LabVIEW block diagram. The main unit used in this subroutine is the PID (proportional, integral, derivative) controller. Here, the process variable is the deflection signal from the signal conditioning module. This signal isthen compared to a set-point value (set by the user) internally. The output of the PID controller is then used to drive the \(Z\)-piezo through the positive variable power supply channel in our setup. By choosing appropriate values for the P, I, and D terms, the tip of the cantilever \"tracks\" the surface during scanning and the deflection of the cantilever can be held constant. This program loop runs in parallel with the scanning process.