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 (AFM) 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 different mechanisms.
78 In~\cite{CantiPiezzo01}, authors used piezoresistor integrated into the
79 cantilever. Nevertheless this approach suffers from the complexity of the
80 microfabrication process needed to implement the sensor in the cantilever.
81 In~\cite{CantiCapacitive03}, authors have presented an cantilever mechanism
82 based on capacitive sensing. This kind of technic also involves to instrument
83 the cantiliver which result in a complex fabrication process.
85 In this paper our attention is focused on a method based on interferometry to
86 measure cantilevers' displacements. In this method cantilevers are illuminated
87 by an optic source. The interferometry produces fringes on each cantilevers
88 which enables to compute the cantilever displacement. In order to analyze the
89 fringes a high speed camera is used. Images need to be processed quickly and
90 then a estimation method is required to determine the displacement of each
91 cantilever. In~\cite{AFMCSEM11}, the authors have used an algorithm based on
92 spline to estimate the cantilevers' positions.
94 The overall process gives
95 accurate results but all the computation are performed on a standard computer
96 using labview. Consequently, the main drawback of this implementation is that
97 the computer is a bootleneck in the overall process. In this paper we propose to
98 use a method based on least square and to implement all the computation on a
101 The remainder of the paper is organized as follows. Section~\ref{sec:measure}
102 describes more precisely the measurement process. Our solution based on the
103 least square method and the implementation on FPGA is presented in
104 Section~\ref{sec:solus}. Experimentations are described in
105 Section~\ref{sec:results}. Finally a conclusion and some perspectives are
110 %% quelques ref commentées sur les calculs basés sur l'interférométrie
112 \section{Measurement principles}
122 \subsection{Architecture}
124 %% description de l'architecture générale de l'acquisition d'images
125 %% avec au milieu une unité de traitement dont on ne précise pas ce
128 In order to develop simple, cost effective and user-friendly cantilever arrays,
129 authors of ~\cite{AFMCSEM11} have developped a system based of
130 interferometry. In opposition to other optical based systems, using a laser beam
131 deflection scheme and sentitive to the angular displacement of the cantilever,
132 interferometry is sensitive to the optical path difference induced by the
133 vertical displacement of the cantilever.
135 The system build by authors of~\cite{AFMCSEM11} has been developped based on a
136 Linnick interferomter~\cite{Sinclair:05}. It is illustrated in
137 Figure~\ref{fig:AFM}. A laser diode is first split (by the splitter) into a
138 reference beam and a sample beam that reachs the cantilever array. In order to
139 be able to move the cantilever array, it is mounted on a translation and
140 rotational hexapod stage with five degrees of freedom. The optical system is
141 also fixed to the stage. Thus, the cantilever array is centered in the optical
142 system which can be adjusted accurately. The beam illuminates the array by a
143 microscope objective and the light reflects on the cantilevers. Likewise the
144 reference beam reflects on a movable mirror. A CMOS camera chip records the
145 reference and sample beams which are recombined in the beam splitter and the
146 interferogram. At the beginning of each experiment, the movable mirror is
147 fitted manually in order to align the interferometric fringes approximately
148 parallel to the cantilevers. When cantilevers move due to the surface, the
149 bending of cantilevers produce movements in the fringes that can be detected
150 with the CMOS camera. Finally the fringes need to be
151 analyzed. In~\cite{AFMCSEM11}, the authors used a LabView program to compute the
152 cantilevers' movements from the fringes.
156 \includegraphics[width=\columnwidth]{AFM}
158 \caption{schema of the AFM}
163 %% image tirée des expériences.
165 \subsection{Cantilever deflection estimation}
168 As shown on image \ref{img:img-xp}, each cantilever is covered by
169 interferometric fringes. The fringes will distort when cantilevers are
170 deflected. Estimating the deflection is done by computing this
171 distortion. For that, (ref A. Meister + M Favre) proposed a method
172 based on computing the phase of the fringes, at the base of each
173 cantilever, near the tip, and on the base of the array. They assume
174 that a linear relation binds these phases, which can be use to
175 "unwrap" the phase at the tip and to determine the deflection.\\
177 More precisely, segment of pixels are extracted from images taken by a
178 high-speed camera. These segments are large enough to cover several
179 interferometric fringes and are placed at the base and near the tip of
180 the cantilevers. They are called base profile and tip profile in the
181 following. Furthermore, a reference profile is taken on the base of
182 the cantilever array.
184 The pixels intensity $I$ (in gray level) of each profile is modelized by :
188 I(x) = ax+b+A.cos(2\pi f.x + \theta)
191 where $x$ is the position of a pixel in its associated segment.
193 The global method consists in two main sequences. The first one aims
194 to determin the frequency $f$ of each profile with an algorithm based
195 on spline interpolation (see section \ref{algo-spline}). It also
196 computes the coefficient used for unwrapping the phase. The second one
197 is the acquisition loop, while which images are taken at regular time
198 steps. For each image, the phase $\theta$ of all profiles is computed
199 to obtain, after unwrapping, the deflection of cantilevers.
201 \subsection{Design goals}
204 If we put aside some hardware issues like the speed of the link
205 between the camera and the computation unit, the time to deserialize
206 pixels and to store them in memory, ... the phase computation is
207 obviously the bottle-neck of the whole process. For example, if we
208 consider the camera actually in use, an exposition time of 2.5ms for
209 $1024\times 1204$ pixels seems the minimum that can be reached. For a
210 $10\times 10$ cantilever array, if we neglect the time to extract
211 pixels, it implies that computing the deflection of a single
212 cantilever should take less than 25$\mu$s, thus 12.5$\mu$s by phase.\\
214 In fact, this timing is a very hard constraint. Let consider a very
215 small programm that initializes twenty million of doubles in memory
216 and then does 1000000 cumulated sums on 20 contiguous values
217 (experimental profiles have about this size). On an intel Core 2 Duo
218 E6650 at 2.33GHz, this program reaches an average of 155Mflops. It
219 implies that the phase computation algorithm should not take more than
220 $240\times 12.5 = 1937$ floating operations. For integers, it gives
223 %% to be continued ...
225 %% � faire : timing de l'algo spline en C avec atan et tout le bordel.
230 \section{Proposed solution}
234 \subsection{FPGA constraints}
236 A field-programmable gate array (FPGA) is an integrated circuit designed to be
237 configured by the customer. A hardware description language (HDL) is used to
238 configure a FPGA. FGPAs are composed of programmable logic components, called
239 logic blocks. These blocks can be configured to perform simple (AND, XOR, ...)
240 or complex combinational functions. Logic blocks are interconnected by
241 reconfigurable links. Modern FPGAs contains memory elements and multipliers
242 which enables to simplify the design and increase the speed. As the most complex
243 operation operation on FGPAs is the multiplier, design of FGPAs should not used
244 complex operations. For example, a divider is not an available operation and it
245 should be programmed using simple components.
247 FGPAs programming is very different from classic processors programming. When
248 logic block are programmed and linked to performed an operation, they cannot be
249 reused anymore. FPGA are cadenced slowly than classic processors but they can
250 performed pipelined as well as pipelined operations. A pipeline provides a way
251 manipulate data quickly since at each clock top to handle a new data. However,
252 using a pipeline consomes more logics and components since they are not
253 reusable, nevertheless it is probably the most efficient technique on FPGA.
254 Parallel operations can be used in order to manipulate several data
255 simultaneously. When it is possible, using a pipeline is a good solution to
256 manipulate new data at each clock top and using parallelism to handle
257 simultaneously several data streams.
259 %% contraintes imposées par le FPGA : algo pipeline/parallele, pas d'op math complexe, ...
262 \subsection{Considered algorithms}
264 Two solutions have been studied to achieve phase computation. The
265 original one, proposed by A. Meister and M. Favre, is based on
266 interpolation by splines. It allows to compute frequency and
267 phase. The second one, detailed in this article, is based on a
268 classical least square method but suppose that frequency is already
271 \subsubsection{Spline algorithm}
272 \label{sec:algo-spline}
273 Let consider a profile $P$, that is a segment of $M$ pixels with an
274 intensity in gray levels. Let call $I(x)$ the intensity of profile in $x
277 At first, only $M$ values of $I$ are known, for $x = 0, 1,
278 \ldots,M-1$. A normalisation allows to scale known intensities into
279 $[-1,1]$. We compute splines that fit at best these normalised
280 intensities. Splines are used to interpolate $N = k\times M$ points
281 (typically $k=4$ is sufficient), within $[0,M[$. Let call $x^s$ the
282 coordinates of these $N$ points and $I^s$ their intensities.
284 In order to have the frequency, the mean line $a.x+b$ (see equation \ref{equ:profile}) of $I^s$ is
285 computed. Finding intersections of $I^s$ and this line allow to obtain
286 the period thus the frequency.
288 The phase is computed via the equation :
290 \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]
293 Two things can be noticed :
295 \item the frequency could also be obtained using the derivates of
296 spline equations, which only implies to solve quadratic equations.
297 \item frequency of each profile is computed a single time, before the
298 acquisition loop. Thus, $sin(2\pi f x^s_i)$ and $cos(2\pi f x^s_i)$
299 could also be computed before the loop, which leads to a much faster
300 computation of $\theta$.
303 \subsubsection{Least square algorithm}
305 Assuming that we compute the phase during the acquisition loop,
306 equation \ref{equ:profile} has only 4 parameters :$a, b, A$, and
307 $\theta$, $f$ and $x$ being already known. Since $I$ is non-linear, a
308 least square method based an Gauss-newton algorithm must be used to
309 determine these four parameters. Since it is an iterative process
310 ending with a convergence criterion, it is obvious that it is not
311 particularly adapted to our design goals.
313 Fortunatly, it is quite simple to reduce the number of parameters to
314 only $\theta$. Let $x^p$ be the coordinates of pixels in a segment of
315 size $M$. Thus, $x^p = 0, 1, \ldots, M-1$. Let $I(x^p)$ be their
316 intensity. Firstly, we "remove" the slope by computing :
318 \[I^{corr}(x^p) = I(x^p) - a.x^p - b\]
320 Since linear equation coefficients are searched, a classical least
321 square method can be used to determine $a$ and $b$ :
323 \[a = \frac{covar(x^p,I(x^p))}{var(x^p)} \]
325 Assuming an overlined symbol means an average, then :
327 \[b = \overline{I(x^p)} - a.\overline{{x^p}}\]
329 Let $A$ be the amplitude of $I^{corr}$, i.e.
331 \[A = \frac{max(I^{corr}) - min(I^{corr})}{2}\]
333 Then, the least square method to find $\theta$ is reduced to search the minimum of :
335 \[\sum_{i=0}^{M-1} \left[ cos(2\pi f.i + \theta) - \frac{I^{corr}(i)}{A} \right]^2\]
337 It is equivalent to derivate this expression and to solve the following equation :
340 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] \\
341 - 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
344 Several points can be noticed :
346 \item As in the spline method, some parts of this equation can be
347 computed before the acquisition loop. It is the case of sums that do
348 not depend on $\theta$ :
350 \[ \sum_{i=0}^{M-1} sin(4\pi f.i), \sum_{i=0}^{M-1} cos(4\pi f.i) \]
352 \item Lookup tables for $sin(2\pi f.i)$ and $cos(2\pi f.i)$ can also be
355 \item The simplest method to find the good $\theta$ is to discretize
356 $[-\pi,\pi]$ in $nb_s$ steps, and to search which step leads to the
357 result closest to zero. By the way, three other lookup tables can
358 also be computed before the loop :
360 \[ sin \theta, cos \theta, \]
362 \[ \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] \]
364 \item This search can be very fast using a dichotomous process in $log_2(nb_s)$
368 Finally, the whole summarizes in an algorithm (called LSQ in the following) in two parts, one before and one during the acquisition loop :
370 \caption{LSQ algorithm - before acquisition loop.}
371 \label{alg:lsq-before}
373 $M \leftarrow $ number of pixels of the profile\\
374 I[] $\leftarrow $ intensities of pixels\\
375 $f \leftarrow $ frequency of the profile\\
376 $s4i \leftarrow \sum_{i=0}^{M-1} sin(4\pi f.i)$\\
377 $c4i \leftarrow \sum_{i=0}^{M-1} cos(4\pi f.i)$\\
378 $nb_s \leftarrow $ number of discretization steps of $[-\pi,\pi]$\\
380 \For{$i=0$ to $nb_s $}{
381 $\theta \leftarrow -\pi + 2\pi\times \frac{i}{nb_s}$\\
382 lut$_s$[$i$] $\leftarrow sin \theta$\\
383 lut$_c$[$i$] $\leftarrow cos \theta$\\
384 lut$_A$[$i$] $\leftarrow cos 2 \theta \times s4i + sin 2 \theta \times c4i$\\
385 lut$_{sfi}$[$i$] $\leftarrow sin (2\pi f.i)$\\
386 lut$_{cfi}$[$i$] $\leftarrow cos (2\pi f.i)$\\
390 \begin{algorithm}[ht]
391 \caption{LSQ algorithm - during acquisition loop.}
392 \label{alg:lsq-during}
394 $\bar{x} \leftarrow \frac{M-1}{2}$\\
395 $\bar{y} \leftarrow 0$, $x_{var} \leftarrow 0$, $xy_{covar} \leftarrow 0$\\
396 \For{$i=0$ to $M-1$}{
397 $\bar{y} \leftarrow \bar{y} + $ I[$i$]\\
398 $x_{var} \leftarrow x_{var} + (i-\bar{x})^2$\\
400 $\bar{y} \leftarrow \frac{\bar{y}}{M}$\\
401 \For{$i=0$ to $M-1$}{
402 $xy_{covar} \leftarrow xy_{covar} + (i-\bar{x}) \times (I[i]-\bar{y})$\\
404 $slope \leftarrow \frac{xy_{covar}}{x_{var}}$\\
405 $start \leftarrow y_{moy} - slope\times \bar{x}$\\
406 \For{$i=0$ to $M-1$}{
407 $I[i] \leftarrow I[i] - start - slope\times i$\\
410 $I_{max} \leftarrow max_i(I[i])$, $I_{min} \leftarrow min_i(I[i])$\\
411 $amp \leftarrow \frac{I_{max}-I_{min}}{2}$\\
413 $Is \leftarrow 0$, $Ic \leftarrow 0$\\
414 \For{$i=0$ to $M-1$}{
415 $Is \leftarrow Is + I[i]\times $ lut$_{sfi}$[$i$]\\
416 $Ic \leftarrow Ic + I[i]\times $ lut$_{cfi}$[$i$]\\
419 $\delta \leftarrow \frac{nb_s}{2}$, $b_l \leftarrow 0$, $b_r \leftarrow \delta$\\
420 $v_l \leftarrow -2.I_s - amp.$lut$_A$[$b_l$]\\
422 \While{$\delta >= 1$}{
424 $v_r \leftarrow 2.[ Is.$lut$_c$[$b_r$]$ + Ic.$lut$_s$[$b_r$]$ ] - amp.$lut$_A$[$b_r$]\\
426 \If{$!(v_l < 0$ and $v_r >= 0)$}{
427 $v_l \leftarrow v_r$ \\
428 $b_l \leftarrow b_r$ \\
430 $\delta \leftarrow \frac{\delta}{2}$\\
431 $b_r \leftarrow b_l + \delta$\\
433 \uIf{$!(v_l < 0$ and $v_r >= 0)$}{
434 $v_l \leftarrow v_r$ \\
435 $b_l \leftarrow b_r$ \\
436 $b_r \leftarrow b_l + 1$\\
437 $v_r \leftarrow 2.[ Is.$lut$_c$[$b_r$]$ + Ic.$lut$_s$[$b_r$]$ ] - amp.$lut$_A$[$b_r$]\\
440 $b_r \leftarrow b_l + 1$\\
443 \uIf{$ abs(v_l) < v_r$}{
444 $b_{\theta} \leftarrow b_l$ \\
447 $b_{\theta} \leftarrow b_r$ \\
449 $\theta \leftarrow \pi\times \left[\frac{2.b_{ref}}{nb_s}-1\right]$\\
453 \subsubsection{Comparison}
455 We compared the two algorithms on the base of three criterions :
457 \item precision of results on a cosinus profile, distorted with noise,
458 \item number of operations,
459 \item complexity to implement an FPGA version.
462 For the first item, we produced a matlab version of each algorithm,
463 running with double precision values. The profile was generated for
464 about 34000 different values of period ($\in [3.1, 6.1]$, step = 0.1),
465 phase ($\in [-3.1 , 3.1]$, step = 0.062) and slope ($\in [-2 , 2]$,
466 step = 0.4). For LSQ, $nb_s = 1024$, which leads to a maximal error of
467 $\frac{\pi}{1024}$ on phase computation. Current A. Meister and
468 M. Favre experiments show a ratio of 50 between variation of phase and
469 the deflection of a lever. Thus, the maximal error due to
470 discretization correspond to an error of 0.15nm on the lever
471 deflection, which is smaller than the best precision they achieved,
474 For each test, we add some noise to the profile : each group of two
475 pixels has its intensity added to a random number picked in $[-N,N]$
476 (NB: it should be noticed that picking a new value for each pixel does
477 not distort enough the profile). The absolute error on the result is
478 evaluated by comparing the difference between the reference and
479 computed phase, out of $2\pi$, expressed in percents. That is : $err =
480 100\times \frac{|\theta_{ref} - \theta_{comp}|}{2\pi}$.
482 Table \ref{tab:algo_prec} gives the maximum and average error for the two algorithms and increasing values of $N$.
486 \begin{tabular}{|c|c|c|c|c|}
488 & \multicolumn{2}{c|}{SPL} & \multicolumn{2}{c|}{LSQ} \\ \cline{2-5}
489 noise & max. err. & aver. err. & max. err. & aver. err. \\ \hline
490 0 & 2.46 & 0.58 & 0.49 & 0.1 \\ \hline
491 2.5 & 2.75 & 0.62 & 1.16 & 0.22 \\ \hline
492 5 & 3.77 & 0.72 & 2.47 & 0.41 \\ \hline
493 7.5 & 4.72 & 0.86 & 3.33 & 0.62 \\ \hline
494 10 & 5.62 & 1.03 & 4.29 & 0.81 \\ \hline
495 15 & 7.96 & 1.38 & 6.35 & 1.21 \\ \hline
496 30 & 17.06 & 2.6 & 13.94 & 2.45 \\ \hline
499 \caption{Error (in \%) for cosinus profiles, with noise.}
500 \label{tab:algo_prec}
504 These results show that the two algorithms are very close, with a
505 slight advantage for LSQ. Furthemore, both behave very well against
506 noise. Assuming the experimental ratio of 50 (see above), an error of
507 1 percent on phase correspond to an error of 0.5nm on the lever
508 deflection, which is very close to the best precision.
510 Obviously, it is very hard to predict which level of noise will be
511 present in real experiments and how it will distort the
512 profiles. Nevertheless, we can see on figure \ref{fig:noise20} the
513 profile with $N=10$ that leads to the biggest error. It is a bit
514 distorted, with pikes and straight/rounded portions, and relatively
515 close to most of that come from experiments. Figure \ref{fig:noise60}
516 shows a sample of worst profile for $N=30$. It is completly distorted,
517 largely beyond the worst experimental ones.
521 \includegraphics[width=9cm]{intens-noise20-spl}
523 \caption{Sample of worst profile for N=10}
529 \includegraphics[width=9cm]{intens-noise60-lsq}
531 \caption{Sample of worst profile for N=30}
535 The second criterion is relatively easy to estimate for LSQ and harder
536 for SPL because of $atan$ operation. In both cases, it is proportional
537 to numbers of pixels $M$. For LSQ, it also depends on $nb_s$ and for
538 SPL on $N = k\times M$, i.e. the number of interpolated points.
540 We assume that $M=20$, $nb_s=1024$, $k=4$, all possible parts are
541 already in lookup tables and only arithmetic operations (+, -, *, /)
542 are taken account. Translating the two algorithms in C code, we obtain
543 about 400 operations for LSQ and 1340 (plus the unknown for $atan$)
544 for SPL. Even if the result is largely in favor of LSQ, we can notice
545 that executing the C code (compiled with \tt{-O3}) of SPL on an
546 2.33GHz Core 2 Duo only takes 6.5µs in average, which is under our
547 desing goals. The final decision is thus driven by the third criterion.\\
549 The Spartan 6 used in our architecture has hard constraint : it has no
550 floating point units. Thus, all computations have to be done with
555 \subsection{VHDL design paradigms}
557 \subsection{VHDL implementation}
559 \section{Experimental results}
565 \section{Conclusion and perspectives}
568 \bibliographystyle{plain}
569 \bibliography{biblio}