APP下载

Implementing an SPM controller with LabVIEW

2018-07-10BAIJianghuaJohnFreeoufAndresLaRosa

BAI Jiang-hua, John L Freeouf, Andres La Rosa

(Physics Department, Portland State University, Oregon 97201, USA)

Abstract: The purpose of this article is to reduce the barrier of developing a house-made scanning probe microscope (SPM). Here in this paper, we cover all the details of programming an SPM controller with LabVIEW. The main controller has three major sequential portions. They are system initialization portion, scan control and image display portion and system shutdown portion. The most complicated and essential part of the main controller is the scan control and image display portion, which is achieved with various parallel tasks. These tasks are scan area and image size adjusting module, Y-axis scan control module, X-axis scan and image transferring module, parameters readjusting module, emergency shutdown module, etc. A NI7831R FPGA board is used to output the control signals and utilize the Z-axis real-time feedback controls. The system emergency shutdown is also carried out by the FPGA module. Receiving the shutdown command from the main controller, the FPGA board will move the probe to its XYZ zero position, turn off all the high voltage control signals and also eliminate the possible oscillations in the system. Finally, how to operate the controller is also briefly introduced. That messy wires fly back and forth is the main drawback of LabVIEW programming. Especially when the program is complicated, this problem becomes more serious. We use a real example to show how to achieve complex functionalities with structural programming and parallel multi-task programming. The actual code showed in this paper is clear, intuitive and simple. Following the examples showed in this paper, readers are able to develop simple LabVIEW programs to achieve complex functionalities.

Key words: scanning probe microscope (SPM); LabVIEW; FPGA; multi-task programming; real-time cntrol

0 Introduction

Scanning probe microscopes (SPMs) are important tools in modern nanoscale research. House-made SPMs are popular because they are versatile, flexible, and able to perform non-standard measurements. Although SPMs can be used in quite different fields, the major technologies to build an SPM are similar. Usually, an SPM is comprised of a sensor which measures a certain kind of information about the sample, a piezo tube or piezo stage to manipulate theXYscans and control the distance between the tip and the sample (Zmotion), a sensor signal processing unit which picks up the sensor signal and feeds it to the control system, a control system, data processing system and other support electronics, as seen in Fig.1.

To build a house-made SPM successfully is not an easy job. Besides of building precise and stable hardware, one still needs a software system to control the whole scan process and implement theZdirection real-time controls. In order to facilitate the process of building a house-made SPM, in this article, we use a tested example to show the design and implementation of an SPM controller with LabVIEW.

Fig.1 Illustration showing working principle of an SPM

1 Program structure

As shown in Fig.2, the main control program has three major sequential portions. At first, the program initializes the system, which includes initializing the FPGA, setting the default parameters to the controller and locating the probe to its zero position. Another task in the initialization step is to move the scanning head down to the sample and let the probe engage the sample. The second portion of the program is to scan the sample and display the images. This part is the most sophisticated and important part of the whole program. Its details will be covered in section 3. The last portion of the program is to turn off the system safely. After the scanning, the scanning head of the SPM should be raised from the sample to protect the probe. High voltage control signals are applied to the scanning stage during the imaging process. After the scanning is done, before turning off the system, one should move the probe to its zeroXYZposition. Text to speech (TTS) technology is also incorporated in this example. With a speaker connected to the controller, voice notices about the SPM state and possible actions the operator may take are sent through the speaker. This greatly facilitates the operation of the SPM.

Fig.2 Controller structure with pseudo LabVIEW code

2 System initialization (portion I)

This controller uses a NI7831R FPGA board to output the control signals and read the sensor data. In the first step of the initialization, proportional (P), integral (I), derivative (D) and the set point of theZmotion controller can be set up. These parameters can be set to the old experienced values from former operations of the SPM. During the experiment, according to signal levels and sample properties, these values can be readjusted further. Low and High are used to set the boundaries of theZmotion. There are two reasons to set up boundaries. One is that the piezo has a limit in its output range. The other is that one wants to limit the output of the PID controller to eliminate possible oscillations. These two parameters can be readjusted again according to the roughness of the sample. LPTM is used to control the update rate of the voltage, which will control the speed of theZmotion eventually. PidTM is used to set the cycle time of theZmotion feedback controller. All these FPGA modules related parameters will be covered in detail in section 3.

To make the main program concise and simple, we code the subroutines as parallel tasks. These tasks are triggered by occurrences, which are supported by LabVIEW. We also use a notifier to transfer data from the scanning task to the main program. Occurrence and notifier examples can be found in Ref.[1]. One can also code the parallel tasks as LabVIEW subroutines with a layered model[2-3]. The main difference is that all subroutines will be saved into different LabVIEW VIs. Here, to show everything in one VI file, we code all the functional modules as parallel tasks. The functionalities of all the tasks will be explained in the following sections. In order to eliminate messy cross screen wires, local variables are used extensively to pass parameters and handle across different modules, as shown in Fig.3.

Fig.3 The first step of the initialization, initializing the FPGA and assigning the parallel task handles

As shown in Figs.4 and 5, the second step of the initialization is to set and reset all the indicators of the controller. At the same time, the relativeZposition will also be displayed. One extra function is that the operator can control theZposition manually. This is useful for nanoindentation and testing of the system. By click the Cnst button, one can input the Z_Cnst values to control theZposition manually. Emergency stop capability is also activated in this step. If the operator wants to turn off the SMP, he can click the EmergencyStop button, then the controller will reset all control signals to their default values and prompt the operator to turn off the system safely.

TTS technology is also implemented at this step. The controller will tell the operator the current state of the microscope through a voice message. A lot of local variables are used in this program. How to use local variable efficiently and effectively can be found in Ref.[4].

Fig.4 The second step of the initialization, setting the indicators and testing the system (case #1)

Fig.5 The second step of the initialization, setting the indicators and testing the system (case # 2)

All the graph indicators used in this example have some kind of properties such as range and contrasts. These parameters can be set as static at the beginning of the program, or set as dynamically changed. Fig.4 shows the default case. Fig.5 shows how these parameters are dynamically updated according to real-time measured values.

The third step of the initialization is to move the probe to itsXYstart point, as shown in Fig.6. Two for loops are used to drive the stage to theXYstart position gradually. After the probe moves to the start position, again a voice message will tell the operator the status of the SPM. Then, the operator is able to adjust the parameters again, before a scan.

Fig.6 The second step of the initialization, moving the probe to the start position

One can see theYcontrols are scaled up 163.835 times. Here, we use a 16-bit DAC, whose input goes from -32 768 to 32 767 digitally. Accordingly, the output side of the DAC goes from -10 V to +10 V. We use a high voltage (HV) amplifier, which has a gain of 20, to drive the piezo. After this scaling, the displayed control voltage will match the actual control voltage applied on the piezo. Now suppose the control input is 100 V. The conversion equation is shown below.

If one uses different DACs or HV amplifiers, this scale factor should be changed according to the specific numbers to keep the displayed values and actual output values to be the same.

TheZcontrol is scaled up by -163.835 times. The reason is that if a positive voltage is applied on the piezo, the piezo extends along theZdirection, while the probe moves downward.

3 Scan control and image display (portion II)

Fig.7 shows the main structure of the scan control and image display part of the controller. This is the most complicated and essential part of the whole SPM controller. But we code this part with parallel tasks triggered by appropriate timing and relations. Eventually, the whole portion looks very simple. Another benefit of this kind of programming is that the modification and test of the system become very easy.

Since house-made SPMs are mainly used for training, teaching and research purposes, a simple software structure makes the teaching and modification of the program easier.

As shown in Fig.7, the first step of the process is to rescale the image.

This is important because the operator may want to scan different areas, such as 256×256, 512×512, 1 024×1 024, etc. This rescale process is carried out by the task T1. The second step is to scan along theYdirection, which is carried out by the task T2. The third step is to scan theXdirection and save one line of the image, which is carried out by the task T3. The fourth step is to receive data from the task T3 and save one line of the image in the main program. Feedback nodes and arrays are used to build the images line by line. The feedback node examples can be found[5]. The fifth step is carried out by the task T4, in which the operator can readjust all the parameters again during the scan process.

This is very important because, during the scan process, the operator can adjust the parameters to obtain the best images. After the execution of the for loop, a full image is obtained. Then the final step is carried out by the task T5, in which the operator is prompt to choose to turn off the system or to have a new scan.

Fig.7 Scan the sample and display the image

3.1 Parallel task T1

As shown in Fig.8, the parallel task T1 is implemented with a while loop. As shown in Fig.2, in the main program all parallel tasks’ handles should be initialized. One needs to make sure the main program is running before all the parallel tasks.

In order to achieve this, a 20 s delay is added in the frame before the while loop. Property nodes are used to adjust the image scales and sizes. LabVIEW property node examples can be found in Ref.[6]. One wants to readjust the sizes of the images and also wants to change the contrasts of the images, so this task is very important to obtain clearer images.

Fig.8 Task T1, adjust image sizes and scales

3.2 Parallel task T2

The parallel task T2 drives the probe scanning along theYdirection. Here a simple raster scan algorithm is applied. The output of theYcontrol is a ramp signal. A Boolean switch is used to control the signal to ramp up or ramp down. When the switch is True the probe scans upward; When the switch is False the probe scans downward. As shown in Fig.9, Y_STOP and Y_START control theYdirection scanning range. Y_FINAL is an indicator showing the real-time position of the probe along theYdirection. How these parameters will affect the operation of the SMP will be covered in section 7.

Fig.9 Task T2, scan along the Y direction

3.3 Parallel task T3

As shown in Fig.10, the parallel task T3 drives the probe scanning along theXdirection. Again, a simple raster scan algorithm is applied. A Boolean switch is used to control scan forward or backward. When the switch is TRUE the probe scans forward. When the switch is FALSE the probe scans backward. The scale equation of the control signals is the same as the one used in Section 4B. X_FINAL is the real-time indicator showing the location of the probe along theXdirection.

The frame after theX-axis control signal output is a delay module. The Hold(mS) control will determine the actual delay time in milliseconds. This is an important factor to control the scan speed. Suppose one choose the delay to be 2 ms and a 512×512 scan area. Then the scan rate is about 1 Hz. It would take about 9 min to finish a full scan. The time to scan one line is 512×2=1 024 ms ≈1 Hz, and the time to scan the full image is 1 024×512≈524 s≈9 min. The frame after the time delay is to display the real-time sensor signals and the topography. After one line scan, the one line image data will be saved into a notifier, which will trigger the main program to read and save the data. After successfully saving the data, the main program will trigger the task T4, as shown in Fig.7.

Fig.10 Task T3, scan along X direction and display real-time signals

3.4 Parallel task T4

Usually, after one line scan, the operator may want to adjust the parameters again to have a better response. As shown in Fig.11, the task T4 allows the operators to readjust the parameters, such as P, I, D, Setpoint and feedback cycle time. One is also able to switch the scanning mode to manual control.

Fig.11 Task T4, readjust controller parameters

3.5 Parallel task T5

The task T5 notices the operators that one scan has finished. After this, the operator may turn off the microscope or blow up a portion of the image to have a new scan. As shown in Fig.12, the task T5 utilizes the TTS technology and sends the voice message to the speaker with a sequence. Another very import process carried out by the task T5 is to move the scanning head up. During the scanning process, the distance between the probe and the sample is several nanometers. After the scan is done, the probe should raise up from the sample, so the probe would not be damaged accidentally. The program achieves this by writing the Setpoint to the highest possible position, 32 767. Driven by the feedback controller, the probe will raise up and disengage the sample.

Fig.12 Task T5, notice the operator that the scan has finished

4 System shut down (portion III)

After a full image scan, the probe raises up electrically by the piezo. This action will retrieve the probe from the sample by several micrometers. When a Stop command is issued in the task T5, the system shutdown procedure initiates. As shown in Fig.13, the first step of the shutdown sequence is to mechanically move the scanning head up. This may take about 1 min, eventually, the scanning head will raise up from the sample by about 10 mm. The second step of the sequence is to move theXYto their zero position. During these steps, the parallel tasks related to scan and imaging should be turned off. As shown in Section 3, all parallel tasks have turn off options. After the EmergencyStop or Stop buttons are clicked, if tasks T1, T2, T3, T4 and T5 trigger again, these tasks will be terminated.

Fig.13 System shutdown procedure

The third step of the sequence is to trigger the task T7 and make sureXYZdriving signals return to zero. The task T7 is used to turn off all the indicators and LEDs. In real machine operations, when the power is turned off, all indicators should be off. Running the task T7 to turn off all the indicators, let the virtual machine look like a real machine, as shown in Fig.14.

Fig.14 Task T7, turns off all the indicators

In order to facilitate the operations of the SPM, we utilize the TTS technology in this example. At various points, voice notices will be sent out by the speaker to prompt the operators to select the appropriate actions. Fig.15 shows the speech SDK, which is used to send out the voice messages. This SDK is quite simple. It uses an invoke node to call the TTS function embedded in the operating system and send out the text message in voice. Invoke note examples can be found in Ref.[7].

Fig.15 Speech SDK

5 FPGA module

Fig.16 shows the front panel of the FPGA module. In this example, we use a NI7831R FPGA board to output the control signals and input the sensor signals. Most times, the users would not access the FPGA module directly. During normal operations, the main controller would talk to the FPGA by interrupt or FPGA nodes. Detailed LabVIEW FPGA program examples can be found in Ref.[8]. Here, we only describe the functionality of the major controls and indicators of the FPGA module. The P, I, D, Setpoint, PidTM, Low and High are feedback control parameters. X_OUT and Y_OUT are real-timeXYcontrol signals. The Search button is used to engage the sample surface during the probe approach process. TF_AMP shows the real-time TF sensor signals. X_BACK and Y_BACK are used to show the probe’s real-timeXYposition during an emergency stop incident.

Fig.16 Front panel of the FPGA module

5.1 Z-axis raster scan

Fig.17 shows theZ-axis scan process. This part is relatively straightforward. The piezo is raised up at first. As the scanning head is lowered down mechanically, the piezo is moving downward and upward.

Fig.17 Z direction ramp scan module

Combining the coarse mechanical approach and the fine piezo sweep, the total effect of the probe movement would be the one as shown in Fig.18.

Fig.18 Probe approach curve

Along theZdirection, the piezo has a range from -30 mm to +30 mm. This design is very important,especially when the probe is really close to the sample surface. The fine piezo sweep along theZ-axis may protect the probe from the sudden crash to the sample due to a coarse mechanical approach. During this whole process, the real-time TF signal is monitored by the controller as well. When the probe is close enough to the sample surface, the TF signal level will drop significantly. When the signal level reaches the Setpoint, the approach process stops, while the feedback control theZmotion will start.

5.2  Z-axis feedback control

As shown in Fig.17, during theZ-axis approaching process, the TF signal is monitored in real time. When the TF signal reaches the set point, theZ-axis raster scan process stops. Then the feedback control shown in Fig.19 will execute.

Fig.19 Z direction feedback module

We employ a PID feedback controller and manual controller inside of the while loop. LabVIEW PID controller examples can be found in Ref.[9]. When the Cnst button is clicked, the manual controller is selected. The FPGA module will read the command from the main control through Z_Cnst, and output theZcontrol signal. In order to remove the possible oscillation, we set the output boundary of the PID controller through the Low and High controls. The frame after the feedback controller is used to drive theZdisplacement to zero. When the operator clicks the Stop command, this frame will drive the probe to its zero position along theZdirection to bring the SPM to a safe stop.

Real-time control is an independent discipline. It includes a lot of topics, such as system modeling, system response, frequency analysis, controller design, etc. Control related stuff can be found inRefs.[9-10]. Here, in this example, we use a simple PID controller. Generally, controller output range, feedback update rate, dead zone setup and possible integral windup are the most important issues a beginner should pay attention to. In this example, we use the Low and High controls to set up the controller output range. We use the PidTM to control the update rate of the feedback loop. The dead zone and integral saturation methods are implemented in the PID subVI. The control issues are out of the scope of this paper. Interested readers can check in Ref.[10].

5.3 X-axis and Y-axis controls

In this example, theXYscans are controlled by the software. As shown in Fig.20, the FPGA module just reads theXYcommand from the main controller and outputs theXYcontrol signals to the HV amplifiers. When the operator wants to stop the SPM, the two while loops after theXYcontrols are used to drive the probe to its zero positions along theXandYdirections. TheXYmotion controller is running in parallel with theZmotion controller. The reason is that theZmotion controller updates much fast thanXYmotion controller. This way we can fully employ the parallel capabilities of the FPGA board.

Fig.20 XY control signal output module

6 Operation of SPM controller

The major part of the front panel of the SPM controller is shown in Fig.21. Most of the controls are located around the upright corner. The indicators and displays are located on the left and the bottom.

6.1 Setting scan related parameters

Before running the SPM, the operator needs to set the X_STOP, X_START, Y_STOP and Y_START parameters. These parameters will control the scan area. Next, the operator needs to set the X_STEPS and Y_STEPS values. These will control the image size. Hold(mS) will set the scan rate, which is covered in Section 3.3. After the parameters are set properly, one can click the RUN FPGA and 2 START POINT buttons. Then the controller will drive the probe to its start position.

Fig.21 Front panel of SPM controller

6.2 Finding sample surface

The next step is to control theZposition and find the sample surface. Initially, the probe is about 10 mm above the sample surface. In order to engage the sample, the operator should click the Search button. Then the scanning head will be lowered down mechanically and the piezo will also extend and contract periodically trying to find the surface. The relative piezo position will be shown by the Z_Bar vertical indicator. The distance between the probe and the sample surface will look like the one, as shown in Fig.18. During this process, one may want to adjust the P, I and D parameters and the Setpoint. In this example, a quartz crystal tuning fork (TF) is used to measure the interaction between the probe and the sample. If the amplitude of the TF is used to be the feedback signal, one can read the real-time TF signal from the TF window. Suppose the TF signal is around 5 000, one can set the Setpoint to be about 4 000. All the feedback parameters can be adjusted again in the future. This approaching process may take about one minute or two. After the sample surface is found, the Z_Bar indicator will stop moving up and down periodically. Instead, the Z_Bar indicator will stay around a fix position. Now all the feedback parameters and the Setpoint can be adjusted again to make the Z_Bar position stable. When all these are done, one is able to take a scan.

6.3 Taking an image

When the Start Scan button is hit, the SPM will start the scan process, and the images will be displayed line by line in the image window. The bead on the top of the image window will move left and right to show the probe’s real-timeXposition. The bead on the left of the image window will move up and down to show the probe’s real-timeYposition. Again, during the scan process, one can readjust the P, I, D, Setpoint, PidTM and Hold(mS) parameters to obtain the best image quality.

6.4 Turning off SPM controller

After a full image is obtained, one can click CONTINUE button to have a new scan or click the STOP button to shut down the SPM. At any time of the operation, one can click the EMERGENCY STOP button to shut down the SPM safely.

7 Conclusion

An SPM is a fairly complicated system, which has a lot of components, such as motors, piezo, signal process unit, etc. An SPM controller should control all the components properly and let them work together to finish the process.

To control an SPM effectively is not easy. Some beginners can barely program a LabVIEW controller with nested wires and messy icons. Eventually, the program becomes very difficult to read and maintain.

The purpose of this article is to reduce the barrier of developing house-made SPMs. Building a modular and elegant controller is a big part of this effort. The controller shown in this paper is intuitive and simple. A NI7831R FPGA board is used to output the control signals and utilize theZ-axis real-time feedback controls. Readers may use different hardwares, such as microcontrollers to finish the real-time controls. Readers can follow the example showen in this article to build their own SPM controller with few modifications.

The structural method and parallel programming method applied in this article are good examples showing how to achieve complex functionalities with simple programming. Local variables and feedback nodes are extensively used in this example to remove the nested wires across screens. Property nodes, parallel task blocks and LabVIEW occurrence and notifiers are used to achieve modular programming. The main program is a sequence of three modules. All specific tasks are programmed as parallel modules. Finally, according to the process, all the modules are synchronized with LabVIEW occurrences and notifiers. In this example, each major module is accomplished in one screen area, without any cross scree wire. Each module can be modified separately, without influencing the performance of other modules. Eventually, the whole program is very easy to read and maintain.