Fast Auto-Approach to Control Stepper Motor with the MFLI Threshold Unit

February 22, 2017 by Romain Stomp

In many applications where the distance between two objects needs to be reduced to a predefined gap, the ability to control a stepper motor with clear stop conditions from different sensors is of high practical interest. Such functionality can be used to bring an optical lens to the appropriate working distance or to approach a scanning probe tip to the vicinity of the sample surface where short range interactions can be probed. This blog post describes some added benefit of using the newly released Threshold Unit available by clicking on the following icon in LabOne:


This new feature is free and all existing MFLI users (updated to LabOne 16.12 or higher) can already benefit from it. For the purpose of this post, the two following options provide better insights in a real-case scenario for an SPM auto-approach:

Condition Requirements for Auto-Approach

There are many different coarse and fine positioners on the market that come with position read-out, closed-loop positioning or the ability to control all step sizes and speed, but as long as a single step can be triggered from third-party equipment, the method described here is applicable. The four main criteria needed are the following:

  1. Control a single step motor from a TTL or analog sawtooth waveform (low voltage).
  2. Define stop condition upon which step motion remains on hold.
  3. Use fine motion scanner to control a withdraw condition to serve as a 'watchdog' (full piezotube scanner extension in the reverse direction).
  4. Single coarse motion step must be smaller than half scanner extension (otherwise withdraw condition would be out-of-range with a single step).

Steps 3 and 4 are of importance for scanning probe microscopy (SPM) applications but can be omitted for other applications if only step control is required (only coarse approach needed). The auto-approach mechanism described below consists of leaving the Z-feedback turned on (i.e., fine positioner fully extended since setpoint is not reached) while the coarse motor approaches: Z-feedback is withdrawn only when the sensor first detects the sample. It is sometimes referred to as 'fast auto-approach' as the tip landing is not checked after every single step (with a full extension then withdrawal for additional safety) but is approaching in a continuous fashion until it is detected, which is much faster.

Block Diagram for Z-Feedback and Stepper Motor

The MFLI can generate analog outputs as a standard function generator can do, but also TTL pulses referenced to some internal or external oscillators. This is readily available on Trigger Output 1 & 2 and is controlled from the DIO tab in LabOne. Now let's consider a cantilever motion oscillating at its free resonance frequency: when the cantilever tip approaches the sample it will eventually arrive in sufficiently strong interaction range that will induce a tip amplitude decrease as well as a resonance frequency de-tuning from its free standing value. We can therefore use either of these two phenomena to define a stop condition. Let's choose a drop in amplitude to 80% of the free swinging amplitude. As the actual amplitude R1 is constantly measured by the lock-in demodulator 1, this condition can be entered in the first Threshold Unit as:

\[TU1 < 0.8 R1\].

This first condition will detect when the sample is within reach and can for instance send a signal to a Z-feedback to withdraw (controlling tip height) but this would not stop the stepper motor. For this second event to occur, we need to define a second Threshold Unit TU2 condition such that its Input TUin2 corresponds to the TTL pulse train from a DIO line and its output corresponds to:

\[TU2 = TUin2. AND. Not(TU1)\],

which makes use of an AND logical gate as well as take the inverse response of TU1. In other words, this means that as long as TU1 is not fulfilled, TU2 will output the same value as its input (TUin2 which is the pulse train that drive the stepper motor) and stop as soon as TU1 condition is fulfilled. If we draw a block diagram from this, in the context of a sensing SPM tip and a coarse (stepper motor) and fine (XYZ-scanner) motion control, we can summarize it as follows:


Figure 1: Block diagram for an SPM auto-approach implemented using 2 Threshold Unit conditions.

Please note that in this implementation one trigger output is used to feed the TTL signal into the Threshold Unit (continuous) but only the actual output that holds the stop condition is fed into a stepper motor. In addition to the stop condition for the stepper motor, the first TU1 condition can also be used as a withdraw condition for the fine Z stage. The Z-feedback can be either implemented directly within the MFLI as an additional PID control loop (low-voltage signal before amplification) or used as a trigger condition with a third-party control unit.

Practical Implementation with LabOne

With the above general principle in mind, we can now configure LabOne to convince ourselves that the stop condition is indeed doing what we want. For this purpose, let's connect 2 BNC cable wired as follows (trigger output 2 is wired internally):

Output Input Comment
Signal Output 1 (+V) Signal Input 1 (+V) Simulate free resonance, R1 measurement
Trigger Output 1 Aux Input 1 TTL drive for stepper motor (monitored)
Trigger Output 2 Phase demod 4 Continuous TTL pulses @ frequency 4

There are several tabs to be configured and the monitoring of the stop condition is observed using the SW trigger armed to detect a falling edge in measured amplitude R1, which is displayed here:

Figure 2: LabOne SW trigger showing precise stop condition for TTL sequence. (Click to zoom)

The stop condition was set for R1 falling below a 50mV trigger level which was realized by simply reducing the drive output amplitude by half. Please enlarge Figure 2 to see the full parameter set for DIO, SW trigger and Threshold Unit tab overview.

Tips and Tricks for 'Smooth Landing' (SPM Use Case)

We have seen from the above SW trigger reaction time that the MFLI can react very precisely to pre-defined stop conditions. In real SPM experiments, there are a few tricks that might help ensure a smooth landing. Here are the most important one:

  • Reduce Filter Bandwidth for Threshold input (set by default at 473kHz): if there are too many 'false engage' this will remove high-frequency transient noise, which might be due to the actual motor motion.
  • Use large tip amplitude swing: large amplitude means greater averaging effect which will improve the SNR for the demodulator input. This will improve the quality of the threshold level to prevent false alarm. Once the tip has landed, it is of course recommended to adjust again the tip amplitude to the same order of magnitude as the decay length of the interaction.
  • Apply large bias voltage: this will increase the electrostatic force which is long range and will therefore allow the tip to probe some interaction from further away. This is sometimes referred to as the 'electrostatic cushion'.
  • Use large 'Disable timeout' for TU1 condition to leave enough time for manual intervention when a stop condition occurs. The user (or API program) can then disable the auto-approach mode after landing.


With the new Threshold Unit available for all MFLI users, sophisticated stop conditions can be obtained for controlling stepper motor with no manual intervention. In this post, we saw an example using an AND gate but other conditional logical outputs can be configured by the user, using several TU condition in a row. The benefit of having the TU condition directly available at the machine level allows for the fastest reaction time possible (< 1 us), which in practice is quasi-instantaneous considering the long piezoelectric inertia of such motors (i.e., typically > 100 us minimum). With all the recent added functionality, the MFLI and LabOne user interface can now answer many practical needs for SPM users, as long as the sensor remains below 5 MHz and if only single input/single output are needed:

  • 4 demodulators for multifrequency measurements
  • 4 PID controllers for phase and amplitude feedback (NC-AFM operation), Z-feedback (topography) or bias feedback (Kelvin probe)
  • Image mode with SW trigger in Grid mode for data alignment with scan engine
  • Auto-approach with Threshold Unit with control of third-party coarse and fine motor