2 \documentclass[10pt, conference, compsocconf]{IEEEtran}
5 \usepackage[utf8]{inputenc}
6 %\usepackage[cyr]{aeguill}
7 %\usepackage{pstricks,pst-node,pst-text,pst-3d}
16 \usepackage{subfigure}
21 \usepackage[ruled,lined,linesnumbered]{algorithm2e}
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
24 \newcommand{\noun}[1]{\textsc{#1}}
26 \newcommand{\tab}{\ \ \ }
33 %% \author{\IEEEauthorblockN{Authors Name/s per 1st Affiliation (Author)}
34 %% \IEEEauthorblockA{line 1 (of Affiliation): dept. name of organization\\
35 %% line 2: name of organization, acronyms acceptable\\
36 %% line 3: City, Country\\
37 %% line 4: Email: name@xyz.com}
39 %% \IEEEauthorblockN{Authors Name/s per 2nd Affiliation (Author)}
40 %% \IEEEauthorblockA{line 1 (of Affiliation): dept. name of organization\\
41 %% line 2: name of organization, acronyms acceptable\\
42 %% line 3: City, Country\\
43 %% line 4: Email: name@xyz.com}
48 \title{Using FPGAs for high speed and real time cantilever deflection estimation}
49 \author{\IEEEauthorblockN{Raphaël Couturier\IEEEauthorrefmark{1}, Stéphane Domas\IEEEauthorrefmark{1}, Gwenhaël Goavec-Merou\IEEEauthorrefmark{2} and Michel Lenczner\IEEEauthorrefmark{2}}
50 \IEEEauthorblockA{\IEEEauthorrefmark{1}FEMTO-ST, DISC, University of Franche-Comte, Belfort, France\\
51 \{raphael.couturier,stephane.domas\}@univ-fcomte.fr}
52 \IEEEauthorblockA{\IEEEauthorrefmark{2}FEMTO-ST, Time-Frequency, University of Franche-Comte, Besançon, France\\
53 \{michel.lenczner@utbm.fr,gwenhael.goavec@trabucayre.com}
69 {\it keywords}: FPGA, cantilever, interferometry.
72 \section{Introduction}
74 Cantilevers are used inside atomic force microscope which provides high
75 resolution images of surfaces. Several technics have been used to measure the
76 displacement of cantilevers in litterature. For example, it is possible to
77 determine accurately the deflection with optic
78 interferometer~\cite{CantiOptic89}, pizeoresistor~\cite{CantiPiezzo01} or
79 capacitive sensing~\cite{CantiCapacitive03}. In this paper our attention is
80 focused on a method based on interferometry to measure cantilevers'
81 displacements. In this method cantilevers are illiminated by an optic
82 source. The interferometry produces fringes on each cantilevers which enables to
83 compute the cantilever displacement. In order to analyze the fringes a high
84 speed camera is used. Images need to be processed quickly and then a estimation
85 method is required to determine the displacement of each cantilever.
86 In~\cite{AFMCSEM11} {\bf verifier ref}, the authors have used an algorithm based
87 on spline to estimate the cantilevers' positions. The overall process gives
88 accurate results but all the computation are performed on a standard computer
89 using labview. Consequently, the main drawback of this implementation is that
90 the computer is a bootleneck in the overall process. In this paper we propose to
91 use a method based on least square and to implement all the computation on a
94 The remainder of the paper is organized as follows. Section~\ref{sec:measure}
95 describes more precisely the measurement process. Our solution based on the
96 least square method and the implementation on FPGA is presented in
97 Section~\ref{sec:solus}. Experimentations are described in
98 Section~\ref{sec:results}. Finally a conclusion and some perspectives are
103 %% quelques ref commentées sur les calculs basés sur l'interférométrie
105 \section{Measurement principles}
108 \subsection{Architecture}
110 %% description de l'architecture générale de l'acquisition d'images
111 %% avec au milieu une unité de traitement dont on ne précise pas ce
114 %% image tirée des expériences.
116 \subsection{Cantilever deflection estimation}
119 As shown on image \ref{img:img-xp}, each cantilever is covered by
120 interferometric fringes. The fringes will distort when cantilevers are
121 deflected. Estimating the deflection is done by computing this
122 distortion. For that, (ref A. Meister + M Favre) proposed a method
123 based on computing the phase of the fringes, at the base of each
124 cantilever, near the tip, and on the base of the array. They assume
125 that a linear relation binds these phases, which can be use to
126 "unwrap" the phase at the tip and to determine the deflection.\\
128 More precisely, segment of pixels are extracted from images taken by a
129 high-speed camera. These segments are large enough to cover several
130 interferometric fringes and are placed at the base and near the tip of
131 the cantilevers. They are called base profile and tip profile in the
132 following. Furthermore, a reference profile is taken on the base of
133 the cantilever array.
135 The pixels intensity $I$ (in gray level) of each profile is modelized by :
139 I(x) = ax+b+A.cos(2\pi f.x + \theta)
142 where $x$ is the position of a pixel in its associated segment.
144 The global method consists in two main sequences. The first one aims
145 to determin the frequency $f$ of each profile with an algorithm based
146 on spline interpolation (see section \ref{algo-spline}). It also
147 computes the coefficient used for unwrapping the phase. The second one
148 is the acquisition loop, while which images are taken at regular time
149 steps. For each image, the phase $\theta$ of all profiles is computed
150 to obtain, after unwrapping, the deflection of cantilevers.
152 \subsection{Design goals}
155 If we put aside some hardware issues like the speed of the link
156 between the camera and the computation unit, the time to deserialize
157 pixels and to store them in memory, ... the phase computation is
158 obviously the bottle-neck of the whole process. For example, if we
159 consider the camera actually in use, an exposition time of 2.5ms for
160 $1024\times 1204$ pixels seems the minimum that can be reached. For a
161 $10\times 10$ cantilever array, if we neglect the time to extract
162 pixels, it implies that computing the deflection of a single
163 cantilever should take less than 25$\mu$s, thus 12.5$\mu$s by phase.\\
165 In fact, this timing is a very hard constraint. Let consider a very
166 small programm that initializes twenty million of doubles in memory
167 and then does 1000000 cumulated sums on 20 contiguous values
168 (experimental profiles have about this size). On an intel Core 2 Duo
169 E6650 at 2.33GHz, this program reaches an average of 155Mflops. It
170 implies that the phase computation algorithm should not take more than
171 $240\times 12.5 = 1937$ floating operations. For integers, it gives
174 %% to be continued ...
176 %% � faire : timing de l'algo spline en C avec atan et tout le bordel.
181 \section{Proposed solution}
185 \subsection{FPGA constraints}
187 %% contraintes imposées par le FPGA : algo pipeline/parallele, pas d'op math complexe, ...
190 \subsection{Considered algorithms}
192 Two solutions have been studied to achieve phase computation. The
193 original one, proposed by A. Meister and M. Favre, is based on
194 interpolation by splines. It allows to compute frequency and
195 phase. The second one, detailed in this article, is based on a
196 classical least square method but suppose that frequency is already
199 \subsubsection{Spline algorithm}
200 \label{sec:algo-spline}
201 Let consider a profile $P$, that is a segment of $M$ pixels with an
202 intensity in gray levels. Let call $I(x)$ the intensity of profile in $x
205 At first, only $M$ values of $I$ are known, for $x = 0, 1,
206 \ldots,M-1$. A normalisation allows to scale known intensities into
207 $[-1,1]$. We compute splines that fit at best these normalised
208 intensities. Splines are used to interpolate $N = k\times M$ points
209 (typically $k=4$ is sufficient), within $[0,M[$. Let call $x^s$ the
210 coordinates of these $N$ points and $I^s$ their intensities.
212 In order to have the frequency, the mean line $a.x+b$ (see equation \ref{equ:profile}) of $I^s$ is
213 computed. Finding intersections of $I^s$ and this line allow to obtain
214 the period thus the frequency.
216 The phase is computed via the equation :
218 \theta = atan \left[ \frac{\sum_{i=0}^{N-1} sin(2\pi f x^s_i) \times I^s(x^s_i)}{\sum_{i=0}^{N-1} cos(2\pi f x^s_i) \times I^s(x^s_i)} \right]
221 Two things can be noticed :
223 \item the frequency could also be obtained using the derivates of
224 spline equations, which only implies to solve quadratic equations.
225 \item frequency of each profile is computed a single time, before the
226 acquisition loop. Thus, $sin(2\pi f x^s_i)$ and $cos(2\pi f x^s_i)$
227 could also be computed before the loop, which leads to a much faster
228 computation of $\theta$.
231 \subsubsection{Least square algorithm}
233 Assuming that we compute the phase during the acquisition loop,
234 equation \ref{equ:profile} has only 4 parameters :$a, b, A$, and
235 $\theta$, $f$ and $x$ being already known. Since $I$ is non-linear, a
236 least square method based an Gauss-newton algorithm must be used to
237 determine these four parameters. Since it is an iterative process
238 ending with a convergence criterion, it is obvious that it is not
239 particularly adapted to our design goals.
241 Fortunatly, it is quite simple to reduce the number of parameters to
242 only $\theta$. Let $x^p$ be the coordinates of pixels in a segment of
243 size $M$. Thus, $x^p = 0, 1, \ldots, M-1$. Let $I(x^p)$ be their
244 intensity. Firstly, we "remove" the slope by computing :
246 \[I^{corr}(x^p) = I(x^p) - a.x^p - b\]
248 Since linear equation coefficients are searched, a classical least
249 square method can be used to determine $a$ and $b$ :
251 \[a = \frac{covar(x^p,I(x^p))}{var(x^p)} \]
253 Assuming an overlined symbol means an average, then :
255 \[b = \overline{I(x^p)} - a.\overline{{x^p}}\]
257 Let $A$ be the amplitude of $I^{corr}$, i.e.
259 \[A = \frac{max(I^{corr}) - min(I^{corr})}{2}\]
261 Then, the least square method to find $\theta$ is reduced to search the minimum of :
263 \[\sum_{i=0}^{M-1} \left[ cos(2\pi f.i + \theta) - \frac{I^{corr}(i)}{A} \right]^2\]
265 It is equivalent to derivate this expression and to solve the following equation :
268 2\left[ cos\theta \sum_{i=0}^{M-1} I^{corr}(i).sin(2\pi f.i) + sin\theta \sum_{i=0}^{M-1} I^{corr}(i).cos(2\pi f.i)\right] \\
269 - A\left[ cos2\theta \sum_{i=0}^{M-1} sin(4\pi f.i) + sin2\theta \sum_{i=0}^{M-1} cos(4\pi f.i)\right] = 0
272 Several points can be noticed :
274 \item As in the spline method, some parts of this equation can be
275 computed before the acquisition loop. It is the case of sums that do
276 not depend on $\theta$ :
278 \[ \sum_{i=0}^{M-1} sin(4\pi f.i), \sum_{i=0}^{M-1} cos(4\pi f.i) \]
280 \item Lookup tables for $sin(2\pi f.i)$ and $cos(2\pi f.i)$ can also be
283 \item The simplest method to find the good $\theta$ is to discretize
284 $[-\pi,\pi]$ in $nb_s$ steps, and to search which step leads to the
285 result closest to zero. By the way, three other lookup tables can
286 also be computed before the loop :
288 \[ sin \theta, cos \theta, \]
290 \[ \left[ cos 2\theta \sum_{i=0}^{M-1} sin(4\pi f.i) + sin 2\theta \sum_{i=0}^{M-1} cos(4\pi f.i)\right] \]
292 \item This search can be very fast using a dichotomous process in $log_2(nb_s)$
296 Finally, the whole summarizes in an algorithm (called LSQ in the following) in two parts, one before and one during the acquisition loop :
298 \caption{LSQ algorithm - before acquisition loop.}
299 \label{alg:lsq-before}
301 $M \leftarrow $ number of pixels of the profile\\
302 I[] $\leftarrow $ intensities of pixels\\
303 $f \leftarrow $ frequency of the profile\\
304 $s4i \leftarrow \sum_{i=0}^{M-1} sin(4\pi f.i)$\\
305 $c4i \leftarrow \sum_{i=0}^{M-1} cos(4\pi f.i)$\\
306 $nb_s \leftarrow $ number of discretization steps of $[-\pi,\pi]$\\
308 \For{$i=0$ to $nb_s $}{
309 $\theta \leftarrow -\pi + 2\pi\times \frac{i}{nb_s}$\\
310 lut$_s$[$i$] $\leftarrow sin \theta$\\
311 lut$_c$[$i$] $\leftarrow cos \theta$\\
312 lut$_A$[$i$] $\leftarrow cos 2 \theta \times s4i + sin 2 \theta \times c4i$\\
313 lut$_{sfi}$[$i$] $\leftarrow sin (2\pi f.i)$\\
314 lut$_{cfi}$[$i$] $\leftarrow cos (2\pi f.i)$\\
318 \begin{algorithm}[ht]
319 \caption{LSQ algorithm - during acquisition loop.}
320 \label{alg:lsq-during}
322 $\bar{x} \leftarrow \frac{M-1}{2}$\\
323 $\bar{y} \leftarrow 0$, $x_{var} \leftarrow 0$, $xy_{covar} \leftarrow 0$\\
324 \For{$i=0$ to $M-1$}{
325 $\bar{y} \leftarrow \bar{y} + $ I[$i$]\\
326 $x_{var} \leftarrow x_{var} + (i-\bar{x})^2$\\
328 $\bar{y} \leftarrow \frac{\bar{y}}{M}$\\
329 \For{$i=0$ to $M-1$}{
330 $xy_{covar} \leftarrow xy_{covar} + (i-\bar{x}) \times (I[i]-\bar{y})$\\
332 $slope \leftarrow \frac{xy_{covar}}{x_{var}}$\\
333 $start \leftarrow y_{moy} - slope\times \bar{x}$\\
334 \For{$i=0$ to $M-1$}{
335 $I[i] \leftarrow I[i] - start - slope\times i$\\
338 $I_{max} \leftarrow max_i(I[i])$, $I_{min} \leftarrow min_i(I[i])$\\
339 $amp \leftarrow \frac{I_{max}-I_{min}}{2}$\\
341 $Is \leftarrow 0$, $Ic \leftarrow 0$\\
342 \For{$i=0$ to $M-1$}{
343 $Is \leftarrow Is + I[i]\times $ lut$_{sfi}$[$i$]\\
344 $Ic \leftarrow Ic + I[i]\times $ lut$_{cfi}$[$i$]\\
347 $\delta \leftarrow \frac{nb_s}{2}$, $b_l \leftarrow 0$, $b_r \leftarrow \delta$\\
348 $v_l \leftarrow -2.I_s - amp.$lut$_A$[$b_l$]\\
350 \While{$\delta >= 1$}{
352 $v_r \leftarrow 2.[ Is.$lut$_c$[$b_r$]$ + Ic.$lut$_s$[$b_r$]$ ] - amp.$lut$_A$[$b_r$]\\
354 \If{$!(v_l < 0$ and $v_r >= 0)$}{
355 $v_l \leftarrow v_r$ \\
356 $b_l \leftarrow b_r$ \\
358 $\delta \leftarrow \frac{\delta}{2}$\\
359 $b_r \leftarrow b_l + \delta$\\
361 \uIf{$!(v_l < 0$ and $v_r >= 0)$}{
362 $v_l \leftarrow v_r$ \\
363 $b_l \leftarrow b_r$ \\
364 $b_r \leftarrow b_l + 1$\\
365 $v_r \leftarrow 2.[ Is.$lut$_c$[$b_r$]$ + Ic.$lut$_s$[$b_r$]$ ] - amp.$lut$_A$[$b_r$]\\
368 $b_r \leftarrow b_l + 1$\\
371 \uIf{$ abs(v_l) < v_r$}{
372 $b_{\theta} \leftarrow b_l$ \\
375 $b_{\theta} \leftarrow b_r$ \\
377 $\theta \leftarrow \pi\times \left[\frac{2.b_{ref}}{nb_s}-1\right]$\\
381 \subsubsection{Comparison}
383 We compared the two algorithms on the base of three criterions :
385 \item precision of results on a cosinus profile, distorted with noise,
386 \item number of operations,
387 \item complexity to implement an FPGA version.
390 For the first item, we produced a matlab version of each algorithm,
391 running with double precision values. The profile was generated for
392 about 34000 different values of period ($\in [3.1, 6.1]$, step = 0.1),
393 phase ($\in [-3.1 , 3.1]$, step = 0.062) and slope ($\in [-2 , 2]$,
394 step = 0.4). For LSQ, $nb_s = 1024$, which leads to a maximal error of
395 $\frac{\pi}{1024}$ on phase computation. Current A. Meister and
396 M. Favre experiments show a ratio of 50 between variation of phase and
397 the deflection of a lever. Thus, the maximal error due to
398 discretization correspond to an error of 0.15nm on the lever
399 deflection, which is smaller than the best precision they achieved,
402 For each test, we add some noise to the profile : each group of two
403 pixels has its intensity added to a random number picked in $[-N,N]$
404 (NB: it should be noticed that picking a new value for each pixel does
405 not distort enough the profile). The absolute error on the result is
406 evaluated by comparing the difference between the reference and
407 computed phase, out of $2\pi$, expressed in percents. That is : $err =
408 100\times \frac{|\theta_{ref} - \theta_{comp}|}{2\pi}$.
410 Table \ref{tab:algo_prec} gives the maximum and average error for the two algorithms and increasing values of $N$.
414 \begin{tabular}{|c|c|c|c|c|}
416 & \multicolumn{2}{c|}{SPL} & \multicolumn{2}{c|}{LSQ} \\ \cline{2-5}
417 noise & max. err. & aver. err. & max. err. & aver. err. \\ \hline
418 0 & 2.46 & 0.58 & 0.49 & 0.1 \\ \hline
419 2.5 & 2.75 & 0.62 & 1.16 & 0.22 \\ \hline
420 5 & 3.77 & 0.72 & 2.47 & 0.41 \\ \hline
421 7.5 & 4.72 & 0.86 & 3.33 & 0.62 \\ \hline
422 10 & 5.62 & 1.03 & 4.29 & 0.81 \\ \hline
423 15 & 7.96 & 1.38 & 6.35 & 1.21 \\ \hline
424 30 & 17.06 & 2.6 & 13.94 & 2.45 \\ \hline
427 \caption{Error (in \%) for cosinus profiles, with noise.}
428 \label{tab:algo_prec}
432 These results show that the two algorithms are very close, with a
433 slight advantage for LSQ. Furthemore, both behave very well against
434 noise. Assuming the experimental ratio of 50 (see above), an error of
435 1 percent on phase correspond to an error of 0.5nm on the lever
436 deflection, which is very close to the best precision.
438 Obviously, it is very hard to predict which level of noise will be
439 present in real experiments and how it will distort the
440 profiles. Nevertheless, we can see on figure \ref{fig:noise20} the
441 profile with $N=10$ that leads to the biggest error. It is a bit
442 distorted, with pikes and straight/rounded portions, and relatively
443 close to most of that come from experiments. Figure \ref{fig:noise60}
444 shows a sample of worst profile for $N=30$. It is completly distorted,
445 largely beyond the worst experimental ones.
449 \includegraphics[width=9cm]{intens-noise20-spl}
451 \caption{Sample of worst profile for N=10}
457 \includegraphics[width=9cm]{intens-noise60-lsq}
459 \caption{Sample of worst profile for N=30}
463 The second criterion is relatively easy to estimate for LSQ and harder
464 for SPL because of $atan$ operation. In both cases, it is proportional
465 to numbers of pixels $M$. For LSQ, it also depends on $nb_s$ and for
466 SPL on $N = k\times M$, i.e. the number of interpolated points.
468 We assume that $M=20$, $nb_s=1024$, $k=4$, all possible parts are
469 already in lookup tables and only arithmetic operations (+, -, *, /)
470 are taken account. Translating the two algorithms in C code, we obtain
471 about 400 operations for LSQ and 1340 (plus the unknown for $atan$)
472 for SPL. Even if the result is largely in favor of LSQ, we can notice
473 that executing the C code (compiled with \tt{-O3}) of SPL on an
474 2.33GHz Core 2 Duo only takes 6.5µs in average, which is under our
475 desing goals. The final decision is thus driven by the third criterion.\\
477 The Spartan 6 used in our architecture has hard constraint : it has no
478 floating point units. Thus, all computations have to be done with
483 \subsection{VHDL design paradigms}
485 \subsection{VHDL implementation}
487 \section{Experimental results}
493 \section{Conclusion and perspectives}
496 \bibliographystyle{plain}
497 \bibliography{biblio}