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=3$ 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. Firstly, the frequency could also be
222 obtained using the derivates of spline equations, which only implies
223 to solve quadratic equations. Secondly, frequency of each profile is
224 computed a single time, before the acquisition loop. Thus, $sin(2\pi f
225 x^s_i)$ and $cos(2\pi f x^s_i)$ could also be computed before the loop, which leads to a
226 much faster computation of $\theta$.
228 \subsubsection{Least square algorithm}
230 Assuming that we compute the phase during the acquisition loop,
231 equation \ref{equ:profile} has only 4 parameters :$a, b, A$, and
232 $\theta$, $f$ and $x$ being already known. Since $I$ is non-linear, a
233 least square method based an Gauss-newton algorithm must be used to
234 determine these four parameters. Since it is an iterative process
235 ending with a convergence criterion, it is obvious that it is not
236 particularly adapted to our design goals.
238 Fortunatly, it is quite simple to reduce the number of parameters to
239 only $\theta$. Let $x^p$ be the coordinates of pixels in a segment of
240 size $M$. Thus, $x^p = 0, 1, \ldots, M-1$. Let $I(x^p)$ be their
241 intensity. Firstly, we "remove" the slope by computing :
243 \[I^{corr}(x^p) = I(x^p) - a.x^p - b\]
245 Since linear equation coefficients are searched, a classical least
246 square method can be used to determine $a$ and $b$ :
248 \[a = \frac{covar(x^p,I(x^p))}{var(x^p)} \]
250 Assuming an overlined symbol means an average, then :
252 \[b = \overline{I(x^p)} - a.\overline{{x^p}}\]
254 Let $A$ be the amplitude of $I^{corr}$, i.e.
256 \[A = \frac{max(I^{corr}) - min(I^{corr})}{2}\]
258 Then, the least square method to find $\theta$ is reduced to search the minimum of :
260 \[\sum_{i=0}^{M-1} \left[ cos(2\pi f.i + \theta) - \frac{I^{corr}(i)}{A} \right]^2\]
262 It is equivalent to derivate this expression and to solve the following equation :
265 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] \\
266 - 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
269 Several points can be noticed :
271 \item As in the spline method, some parts of this equation can be
272 computed before the acquisition loop. It is the case of sums that do
273 not depend on $\theta$ :
275 \[ \sum_{i=0}^{M-1} sin(4\pi f.i), \sum_{i=0}^{M-1} cos(4\pi f.i) \]
277 \item Lookup tables for $sin(2\pi f.i)$ and $cos(2\pi f.i)$ can also be
280 \item The simplest method to find the good $\theta$ is to discretize
281 $[-\pi,\pi]$ in $N$ steps, and to search which step leads to the
282 result closest to zero. By the way, three other lookup tables can
283 also be computed before the loop :
285 \[ sin \theta, cos \theta, \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] \]
287 \item This search can be very fast using a dichotomous process in $log_2(N)$
291 Finally, the whole summarizes in an algorithm (called LSQ in the following) in two parts, one before and one during the acquisition loop :
293 \caption{LSQ algorithm - before acquisition loop.}
294 \label{alg:lsq-before}
296 $M \leftarrow $ number of pixels of the profile\\
297 I[] $\leftarrow $ intensities of pixels\\
298 $f \leftarrow $ frequency of the profile\\
299 $s4i \leftarrow \sum_{i=0}^{M-1} sin(4\pi f.i)$\\
300 $c4i \leftarrow \sum_{i=0}^{M-1} cos(4\pi f.i)$\\
301 $nb_s \leftarrow $ number of discretization steps of $[-\pi,\pi]$\\
303 \For{$i=0$ to $nb_s $}{
304 $\theta \leftarrow -\pi + 2\pi\times \frac{i}{nb_s}$\\
305 lut\_sin[$i$] $\leftarrow sin \theta$\\
306 lut\_cos[$i$] $\leftarrow cos \theta$\\
307 lut\_A[$i$] $\leftarrow cos 2 \theta \times s4i + sin 2 \theta \times c4i$\\
308 lut\_sinfi[$i$] $\leftarrow sin (2\pi f.i)$\\
309 lut\_cosfi[$i$] $\leftarrow cos (2\pi f.i)$\\
314 \caption{LSQ algorithm - during acquisition loop.}
315 \label{alg:lsq-during}
317 $\bar{x} \leftarrow \frac{M-1}{2}$\\
318 $\bar{y} \leftarrow 0$, $x_{var} \leftarrow 0$, $xy_{covar} \leftarrow 0$\\
319 \For{$i=0$ to $M-1$}{
320 $\bar{y} \leftarrow \bar{y} + $ I[$i$]\\
321 $x_{var} \leftarrow x_{var} + (i-\bar{x})^2$\\
323 $\bar{y} \leftarrow \frac{\bar{y}}{M}$\\
324 \For{$i=0$ to $M-1$}{
325 $xy_{covar} \leftarrow xy_{covar} + (i-\bar{x}) \times (I[i]-\bar{y})$\\
327 $slope \leftarrow \frac{xy_{covar}}{x_{var}}$\\
328 $start \leftarrow y_{moy} - slope\times \bar{x}$\\
329 \For{$i=0$ to $M-1$}{
330 $I[i] \leftarrow I[i] - start - slope\times i$\tcc*[f]{slope removal}\\
333 $I_{max} \leftarrow max_i(I[i])$, $I_{min} \leftarrow min_i(I[i])$\\
334 $amp \leftarrow \frac{I_{max}-I_{min}}{2}$\\
336 $Is \leftarrow 0$, $Ic \leftarrow 0$\\
337 \For{$i=0$ to $M-1$}{
338 $Is \leftarrow Is + I[i]\times $ lut\_sinfi[$i$]\\
339 $Ic \leftarrow Ic + I[i]\times $ lut\_cosfi[$i$]\\
342 $\theta \leftarrow -\pi$\\
343 $val_1 \leftarrow 2\times \left[ Is.\cos(\theta) + Ic.\sin(\theta) \right] - amp\times \left[ c4i.\sin(2\theta) + s4i.\cos(2\theta) \right]$\\
344 \For{$i=1-n_s$ to $n_s$}{
345 $\theta \leftarrow \frac{i.\pi}{n_s}$\\
346 $val_2 \leftarrow 2\times \left[ Is.\cos(\theta) + Ic.\sin(\theta) \right] - amp\times \left[ c4i.\sin(2\theta) + s4i.\cos(2\theta) \right]$\\
348 \lIf{$val_1 < 0$ et $val_2 >= 0$}{
349 $\theta_s \leftarrow \theta - \left[ \frac{val_2}{val_2-val_1}\times \frac{\pi}{n_s} \right]$\\
351 $val_1 \leftarrow val_2$\\
357 \subsubsection{Comparison}
359 \subsection{VHDL design paradigms}
361 \subsection{VHDL implementation}
363 \section{Experimental results}
369 \section{Conclusion and perspectives}
372 \bibliographystyle{plain}
373 \bibliography{biblio}