]> AND Private Git Repository - dmems12.git/blob - dmems12.tex
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
légère modif
[dmems12.git] / dmems12.tex
1
2 \documentclass[10pt, conference, compsocconf]{IEEEtran}
3 %\usepackage{latex8}
4 %\usepackage{times}
5 \usepackage[utf8]{inputenc}
6 %\usepackage[cyr]{aeguill}
7 %\usepackage{pstricks,pst-node,pst-text,pst-3d}
8 %\usepackage{babel}
9 \usepackage{amsmath}
10 \usepackage{url}
11 \usepackage{graphicx}
12 \usepackage{thumbpdf}
13 \usepackage{color}
14 \usepackage{moreverb}
15 \usepackage{commath}
16 \usepackage{subfigure}
17 %\input{psfig.sty}
18 \usepackage{fullpage}
19 \usepackage{fancybox}
20
21 \usepackage[ruled,lined,linesnumbered]{algorithm2e}
22
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
24 \newcommand{\noun}[1]{\textsc{#1}}
25
26 \newcommand{\tab}{\ \ \ }
27
28
29
30 \begin{document}
31
32
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}
38 %% \and
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}
44 %% }
45
46
47
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}
54 }
55
56
57
58
59
60
61 \maketitle
62
63 \thispagestyle{empty}
64
65 \begin{abstract}
66
67   
68
69 {\it keywords}: FPGA, cantilever, interferometry.
70 \end{abstract}
71
72 \section{Introduction}
73
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.
84
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.
93
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
99 FGPA.
100
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
106 presented.
107
108
109
110 %% quelques ref commentées sur les calculs basés sur l'interférométrie
111
112 \section{Measurement principles}
113 \label{sec:measure}
114
115
116
117
118
119
120
121
122 \subsection{Architecture}
123 \label{sec:archi}
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
126 %% qu'elle est.
127
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.
134
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.
153
154 \begin{figure}    
155 \begin{center}
156 \includegraphics[width=\columnwidth]{AFM}
157 \end{center}
158 \caption{schema of the AFM}
159 \label{fig:AFM}   
160 \end{figure}
161
162
163 %% image tirée des expériences.
164
165 \subsection{Cantilever deflection estimation}
166 \label{sec:deflest}
167
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.\\
176
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.
183
184 The pixels intensity $I$ (in gray level) of each profile is modelized by :
185
186 \begin{equation}
187 \label{equ:profile}
188 I(x) = ax+b+A.cos(2\pi f.x + \theta)
189 \end{equation}
190
191 where $x$ is the position of a pixel in its associated segment.
192
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.
200
201 \subsection{Design goals}
202 \label{sec:goals}
203
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.\\
213
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
221 $3000$ operations.
222
223 %% to be continued ...
224
225 %% � faire : timing de l'algo spline en C avec atan et tout le bordel.
226
227
228
229
230 \section{Proposed solution}
231 \label{sec:solus}
232
233
234 \subsection{FPGA constraints}
235
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.
246
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.
258
259 %% contraintes imposées par le FPGA : algo pipeline/parallele, pas d'op math complexe, ...
260
261
262 \subsection{Considered algorithms}
263
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
269 known.
270
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
275 \in [0,M[$. 
276
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=3$ is sufficient), within $[0,M[$. Let call $x^s$ the
282 coordinates of these $N$ points and $I^s$ their intensities.
283
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.
287
288 The phase is computed via the equation :
289 \begin{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]
291 \end{equation}
292
293 Two things can be noticed. Firstly, the frequency could also be
294 obtained using the derivates of spline equations, which only implies
295 to solve quadratic equations. Secondly, frequency of each profile is
296 computed a single time, before the acquisition loop. Thus, $sin(2\pi f
297 x^s_i)$ and $cos(2\pi f x^s_i)$ could also be computed before the loop, which leads to a
298 much faster computation of $\theta$.
299
300 \subsubsection{Least square algorithm}
301
302 Assuming that we compute the phase during the acquisition loop,
303 equation \ref{equ:profile} has only 4 parameters :$a, b, A$, and
304 $\theta$, $f$ and $x$ being already known. Since $I$ is non-linear, a
305 least square method based an Gauss-newton algorithm must be used to
306 determine these four parameters. Since it is an iterative process
307 ending with a convergence criterion, it is obvious that it is not
308 particularly adapted to our design goals.
309
310 Fortunatly, it is quite simple to reduce the number of parameters to
311 only $\theta$. Let $x^p$ be the coordinates of pixels in a segment of
312 size $M$. Thus, $x^p = 0, 1, \ldots, M-1$. Let $I(x^p)$ be their
313 intensity. Firstly, we "remove" the slope by computing :
314
315 \[I^{corr}(x^p) = I(x^p) - a.x^p - b\]
316
317 Since linear equation coefficients are searched, a classical least
318 square method can be used to determine $a$ and $b$ :
319
320 \[a = \frac{covar(x^p,I(x^p))}{var(x^p)} \]
321
322 Assuming an overlined symbol means an average, then :
323
324 \[b = \overline{I(x^p)} - a.\overline{{x^p}}\]
325
326 Let $A$ be the amplitude of $I^{corr}$, i.e. 
327
328 \[A = \frac{max(I^{corr}) - min(I^{corr})}{2}\]
329
330 Then, the least square method to find $\theta$ is reduced to search the minimum of :
331
332 \[\sum_{i=0}^{M-1} \left[ cos(2\pi f.i + \theta) - \frac{I^{corr}(i)}{A} \right]^2\]
333
334 It is equivalent to derivate this expression and to solve the following equation :
335
336 \begin{eqnarray*}
337 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] \\
338 - 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
339 \end{eqnarray*}
340
341 Several points can be noticed :
342 \begin{itemize}
343 \item As in the spline method, some parts of this equation can be
344   computed before the acquisition loop. It is the case of sums that do
345   not depend on $\theta$ :
346
347 \[ \sum_{i=0}^{M-1} sin(4\pi f.i), \sum_{i=0}^{M-1} cos(4\pi f.i) \] 
348
349 \item Lookup tables for $sin(2\pi f.i)$ and $cos(2\pi f.i)$ can also be
350 computed.
351
352 \item The simplest method to find the good $\theta$ is to discretize
353   $[-\pi,\pi]$ in $N$ steps, and to search which step leads to the
354   result closest to zero. By the way, three other lookup tables can
355   also be computed before the loop :
356
357 \[ 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] \]
358
359 \item This search can be very fast using a dichotomous process in $log_2(N)$ 
360
361 \end{itemize}
362
363 Finally, the whole summarizes in an algorithm (called LSQ in the following) in two parts, one before and one during the acquisition loop :
364 \begin{algorithm}[h]
365 \caption{LSQ algorithm - before acquisition loop.}
366 \label{alg:lsq-before}
367
368    $M \leftarrow $ number of pixels of the profile\\
369    I[] $\leftarrow $ intensities of pixels\\
370    $f \leftarrow $ frequency of the profile\\
371    $s4i \leftarrow \sum_{i=0}^{M-1} sin(4\pi f.i)$\\
372    $c4i \leftarrow \sum_{i=0}^{M-1} cos(4\pi f.i)$\\
373    $nb_s \leftarrow $ number of discretization steps of $[-\pi,\pi]$\\
374
375    \For{$i=0$ to $nb_s $}{
376      $\theta  \leftarrow -\pi + 2\pi\times \frac{i}{nb_s}$\\
377      lut\_sin[$i$] $\leftarrow sin \theta$\\
378      lut\_cos[$i$] $\leftarrow cos \theta$\\
379      lut\_A[$i$] $\leftarrow cos 2 \theta \times s4i + sin 2 \theta \times c4i$\\
380      lut\_sinfi[$i$] $\leftarrow sin (2\pi f.i)$\\
381      lut\_cosfi[$i$] $\leftarrow cos (2\pi f.i)$\\
382    }
383 \end{algorithm}
384
385 \begin{algorithm}[h]
386 \caption{LSQ algorithm - during acquisition loop.}
387 \label{alg:lsq-during}
388
389    $\bar{x} \leftarrow \frac{M-1}{2}$\\
390    $\bar{y} \leftarrow 0$, $x_{var} \leftarrow 0$, $xy_{covar} \leftarrow 0$\\
391    \For{$i=0$ to $M-1$}{
392      $\bar{y} \leftarrow \bar{y} + $ I[$i$]\\
393      $x_{var} \leftarrow x_{var} + (i-\bar{x})^2$\\
394    }
395    $\bar{y} \leftarrow \frac{\bar{y}}{M}$\\
396    \For{$i=0$ to $M-1$}{
397      $xy_{covar} \leftarrow xy_{covar} + (i-\bar{x}) \times (I[i]-\bar{y})$\\
398    }
399    $slope \leftarrow \frac{xy_{covar}}{x_{var}}$\\
400    $start \leftarrow y_{moy} - slope\times \bar{x}$\\
401    \For{$i=0$ to $M-1$}{
402      $I[i] \leftarrow I[i] - start - slope\times i$\tcc*[f]{slope removal}\\
403    }
404    
405    $I_{max} \leftarrow max_i(I[i])$, $I_{min} \leftarrow min_i(I[i])$\\
406    $amp \leftarrow \frac{I_{max}-I_{min}}{2}$\\
407
408    $Is \leftarrow 0$, $Ic \leftarrow 0$\\
409    \For{$i=0$ to $M-1$}{
410      $Is \leftarrow Is + I[i]\times $ lut\_sinfi[$i$]\\
411      $Ic \leftarrow Ic + I[i]\times $ lut\_cosfi[$i$]\\
412    }
413
414    $\theta \leftarrow -\pi$\\
415    $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]$\\
416    \For{$i=1-n_s$ to $n_s$}{
417      $\theta \leftarrow \frac{i.\pi}{n_s}$\\
418      $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]$\\
419
420      \lIf{$val_1 < 0$ et $val_2 >= 0$}{
421        $\theta_s \leftarrow \theta - \left[ \frac{val_2}{val_2-val_1}\times \frac{\pi}{n_s} \right]$\\
422      }
423      $val_1 \leftarrow val_2$\\
424    }
425
426 \end{algorithm}
427
428
429 \subsubsection{Comparison}
430
431 \subsection{VHDL design paradigms}
432
433 \subsection{VHDL implementation}
434
435 \section{Experimental results}
436 \label{sec:results}
437
438
439
440
441 \section{Conclusion and perspectives}
442
443
444 \bibliographystyle{plain}
445 \bibliography{biblio}
446
447 \end{document}