Using LabVIEW to Build a High-Performance Controller for an Atomic Force Microscope

"We have been using NI products for many years with excellent results. Domain experts can manage development instead of retaining software developers, which is a big advantage for a small team."

- Dr. Ashwin Lal, Shilps Sciences Private Limited

The Challenge:

We aimed to develop an affordable, high-performance controller for an atomic force microscope (AFM) that included all standard features and was readily scalable. We also wanted the ability to integrate the AFM with external instruments.

The Solution:

We used the LabVIEW Real-Time Module and the LabVIEW FPGA Module with a Single-Board RIO controller to develop an AFM with full functionality comprising various advanced imaging modes that require complex real-time control loops.

About Shilps Sciences 

Shilps Sciences is a young company located in Bangalore, the innovation capital of India. We leverage advances in nano and microtechnology to build cutting-edge products for use in life sciences and nanotechnology research. A key subject underlying our product development is measuring heterogeneity in biological cells.


We have developed an affordable atomic force microscope (AFM) suitable for imaging and analysis of cells. Low-cost AFMs in the market typically do not have features for cell analysis such as an optical microscope, large positioning capability, or liquid chamber option. However, there is demand for AFM-based analysis of biological specimens. Some examples include cell stiffness measurements for metastatic potential in cancer cells, modification of cell membranes for use in drug delivery, and characterization of artificial tissues.



Atomic Force Microscope

The AFM is an extremely high-resolution microscope that uses a MEMS cantilever probe to scan a surface and measure inter-atomic forces, which it then converts into the surface topography. AFMs can have nanometer resolution several orders of magnitude higher than optical microscopes. We can operate an AFM in multiple modes. The simplest mode requires one real-time control loop, which maintains the force between probe and sample by controlling the probe-sample distance. More complex operation modes require the probe to be oscillated at the resonance frequency. Advanced modes may require up to three real-time control loops to maintain the resonance frequency, the amplitude of oscillation, and the probe-sample distance.  



AFM Controller

The AFM controller moves the probe in x and y (in the plane of the sample surface) while simultaneously measuring the probe-surface interaction force and correcting the probe-sample distance (z). As the probe moves, surface image is built pixel by pixel using the z values and the interaction force values at each x, y position. In the AFM, a laser bounces off the cantilever probe. We can measure the deflection of the cantilever, which is a measure of the probe sample force, using a position sensing photo-detector. It is common to oscillate the cantilever near its resonance frequency using a signal generator that excites a piezo material. We can measure the cantilever deflection to derive the amplitude and phase. Figure 2 shows the key components and operations schematically.

Our AFM controller must perform several functions. Some of the key functions include:

  • Scanning or moving the AFM probe in x, y directions through analog outputs based on user input
  • Setting the frequency of a sine wave generator through digital output and its amplitude through analog output
  • Acquiring analog input signals for in-phase and quadrature-phase and performing calculations on this signal to obtain amplitude and phase values
  • Correcting the probe’s z-position based on the probe-sample force signal

Additionally, our controller can also correct the frequency and amplitude of the sine wave generator based on the measured phase and amplitude.


Controller Design

We have experience with DSP-based controllers. These controllers work with open source Linux software, but it is difficult to modify the program and it does not have all the features required. We also have experience with proprietary controllers, but they are too expensive for our requirements. We developed some parts of the control on a microcontroller, but we found the coding of complex algorithms difficult to manage.


We have been using NI products for many years with excellent results. Domain experts can manage development instead of retaining software developers, which is a big advantage for a small team. Also, the development time is short. Therefore, we decided to build the controller using LabVIEW and the sbRIO-9627 controller.


We designed the controller in two parts: the user interface and the real-time loops that also interact with the external hardware. The user interface runs on the host, takes parameter inputs from the user, and displays the data acquired from the hardware. We use sbRIO (Single Board RIO) Real Time controller, connected by Ethernet to a PC with the display and user controls available, to run the host program. We implemented the real-time part in FPGA as several loops running in parallel. This scheme makes it possible to modify parameters on the fly. For example, we can change the z control settings during the scan operation. Crucial scan data is transferred from FPGA to host using FIFO. The real-time loops must run at a few kHz to acquire 1000×1000 sized images in a few minutes. We found that sbRIO-9627 has ample processing power and enough analog I/O and digital I/O for our application. We could run the closed loops significantly faster, but that will require upgrading the AFM mechanical setup.



Our Business Advantage

We may be the first company to develop a high-performance AFM in India, which has helped us connect with local research clients and offer targeted solutions. The price point we can achieve makes us highly competitive. In some cases, we can convince our clients to initiate projects that they would not have considered otherwise.


We are validating our AFM product with multiple users and have started marketing the product. We are also working on several client R&D projects. We believe we can use the power of LabVIEW software to easily make enhancements and customizations on our control software as required by these projects.


The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.


Author Information:

Dr. Ashwin Lal
Shilps Sciences Private Limited
1st Floor, 216/2, F Block, 10th Cross, Sahakarnagar
Bangalore 560092
Tel: +91 8197 246 248

Figure 1. The Lucent AFM model developed at Shilps Sciences is a table top system that comprises nano and micro positioning stages, a MEMS probe, and an optical assembly that is 500 mm × 300 mm × 600 mm in size.
Figure 2. In this schematic showing the AFM components, the grey part shows the controller functions.
Figure 3.(left) The AFM controller is designed in two parts running on host and FPGA. The host part is programmed on sbRIO RT and uses a PC monitor for display and inputs. The functions in FPGA are independent loops running in parallel.
(right) Part of the GUI shows some control settings and a sample image.
Figure 4. E. coli bacteria imaged with our AFM shows the nanometer flagella. For this image, the AFM cantilever was excited at 150 kHz at an amplitude of 10 nanometers and the frequency shift during interaction was about 5 Hz.