1 \documentclass[12pt]{article}
4 \usepackage[latin1]{inputenc}
5 \usepackage[cyr]{aeguill}
6 %\usepackage{pstricks,pst-node,pst-text,pst-3d}
15 \usepackage{subfigure}
20 \usepackage[ruled,lined,linesnumbered]{algorithm2e}
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
23 \newcommand{\noun}[1]{\textsc{#1}}
25 \newcommand{\tab}{\ \ \ }
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%% my bib path.
30 \title{Using FPGAs for high speed and real time cantilever deflection estimation}
32 \author{ Raphaël COUTURIER\\
33 Laboratoire d'Informatique
34 de l'Universit\'e de Franche-Comt\'e, \\
36 90016~Belfort CEDEX, France\\
38 Laboratoire d'Informatique
39 de l'Universit\'e de Franche-Comt\'e, \\
41 90016~Belfort CEDEX, France\\
42 \and Gwenhaël Goavec\\
59 {\it keywords}: FPGA, cantilever, interferometry.
62 \section{Introduction}
65 %% quelques ref commentées sur les calculs basés sur l'interférométrie
67 \section{Measurement principles}
70 \subsection{Architecture}
72 %% description de l'architecture générale de l'acquisition d'images
73 %% avec au milieu une unité de traitement dont on ne précise pas ce
76 %% image tirée des expériences.
78 \subsection{Cantilever deflection estimation}
81 As shown on image \ref{img:img-xp}, each cantilever is covered by
82 interferometric fringes. The fringes will distort when cantilevers are
83 deflected. Estimating the deflection is done by computing this
84 distortion. For that, (ref A. Meister + M Favre) proposed a method
85 based on computing the phase of the fringes, at the base of each
86 cantilever, near the tip, and on the base of the array. They assume
87 that a linear relation binds these phases, which can be use to
88 "unwrap" the phase at the tip and to determine the deflection.\\
90 More precisely, segment of pixels are extracted from images taken by a
91 high-speed camera. These segments are large enough to cover several
92 interferometric fringes and are placed at the base and near the tip of
93 the cantilevers. They are called base profile and tip profile in the
94 following. Furthermore, a reference profile is taken on the base of
97 The pixels intensity $I$ (in gray level) of each profile is modelized by :
101 I(x) = ax+b+A.cos(2\pi f.x + \theta)
104 where $x$ is the position of a pixel in its associated segment.
106 The global method consists in two main sequences. The first one aims
107 to determin the frequency $f$ of each profile with an algorithm based
108 on spline interpolation (see section \ref{algo-spline}). It also
109 computes the coefficient used for unwrapping the phase. The second one
110 is the acquisition loop, while which images are taken at regular time
111 steps. For each image, the phase $\theta$ of all profiles is computed
112 to obtain, after unwrapping, the deflection of cantilevers.
114 \subsection{Design goals}
117 If we put aside some hardware issues like the speed of the link
118 between the camera and the computation unit, the time to deserialize
119 pixels and to store them in memory, ... the phase computation is
120 obviously the bottle-neck of the whole process. For example, if we
121 consider the camera actually in use, an exposition time of 2.5ms for
122 $1024\times 1204$ pixels seems the minimum that can be reached. For a
123 $10\times 10$ cantilever array, if we neglect the time to extract
124 pixels, it implies that computing the deflection of a single
125 cantilever should take less than 25$µ$s, thus 12.5$µ$s by phase.\\
127 In fact, this timing is a very hard constraint. Let consider a very
128 small programm that initializes twenty million of doubles in memory
129 and then does 1000000 cumulated sums on 20 contiguous values
130 (experimental profiles have about this size). On an intel Core 2 Duo
131 E6650 at 2.33GHz, this program reaches an average of 155Mflops. It
132 implies that the phase computation algorithm should not take more than
133 $240\times 12.5 = 1937$ floating operations. For integers, it gives
136 %% to be continued ...
138 %% à faire : timing de l'algo spline en C avec atan et tout le bordel.
143 \section{Proposed solution}
147 \subsection{FPGA constraints}
149 %% contraintes imposées par le FPGA : algo pipeline/parallele, pas d'op math complexe, ...
152 \subsection{Considered algorithms}
154 Two solutions have been studied to achieve phase computation. The
155 original one, proposed by A. Meister and M. Favre, is based on
156 interpolation by splines. It allows to compute frequency and
157 phase. The second one, detailed in this article, is based on a
158 classical least square method but suppose that frequency is already
161 \subsubsection{Spline algorithm}
162 \label{sec:algo-spline}
163 Let consider a profile $P$, that is a segment of $M$ pixels with an
164 intensity in gray levels. Let call $I(x)$ the intensity of profile in $x
167 At first, only $M$ values of $I$ are known, for $x = 0, 1,
168 \ldots,M-1$. A normalisation allows to scale known intensities into
169 $[-1,1]$. We compute splines that fit at best these normalised
170 intensities. Splines are used to interpolate $N = k\times M$ points
171 (typically $k=3$ is sufficient), within $[0,M[$. Let call $x^s$ the
172 coordinates of these $N$ points and $I^s$ their intensities.
174 In order to have the frequency, the mean line $a.x+b$ (see equation \ref{equ:profile}) of $I^s$ is
175 computed. Finding intersections of $I^s$ and this line allow to obtain
176 the period thus the frequency.
178 The phase is computed via the equation :
180 \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]
183 Two things can be noticed. Firstly, the frequency could also be
184 obtained using the derivates of spline equations, which only implies
185 to solve quadratic equations. Secondly, frequency of each profile is
186 computed a single time, before the acquisition loop. Thus, $sin(2\pi f
187 x^s_i)$ and $cos(2\pi f x^s_i)$ could also be computed before the loop, which leads to a
188 much faster computation of $\theta$.
190 \subsubsection{Least square algorithm}
192 Assuming that we compute the phase during the acquisition loop,
193 equation \ref{equ:profile} has only 4 parameters :$a, b, A$, and
194 $\theta$, $f$ and $x$ being already known. Since $I$ is non-linear, a
195 least square method based an Gauss-newton algorithm must be used to
196 determine these four parameters. Since it is an iterative process
197 ending with a convergence criterion, it is obvious that it is not
198 particularly adapted to our design goals.
200 Fortunatly, it is quite simple to reduce the number of parameters to
201 only $\theta$. Let $x^p$ be the coordinates of pixels in a segment of
202 size $M$. Thus, $x^p = 0, 1, \ldots, M-1$. Let $I(x^p)$ be their
203 intensity. Firstly, we "remove" the slope by computing :
205 \[I^{corr}(x^p) = I(x^p) - a.x^p - b\]
207 Since linear equation coefficients are searched, a classical least
208 square method can be used to determine $a$ and $b$ :
210 \[a = \frac{covar(x^p,I(x^p))}{var(x^p)} \]
212 Assuming an overlined symbol means an average, then :
214 \[b = \overline{I(x^p)} - a.\overline{{x^p}}\]
216 Let $A$ be the amplitude of $I^{corr}$, i.e.
218 \[A = \frac{max(I^{corr}) - min(I^{corr})}{2}\]
220 Then, the least square method to find $\theta$ is reduced to search the minimum of :
222 \[\sum_{i=0}^{M-1} \left[ cos(2\pi f.i + \theta) - \frac{I^{corr}(i)}{A} \right]^2\]
224 It is equivalent to derivate this expression and to solve the following equation :
227 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] \\
228 - 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
231 Several points can be noticed :
233 \item As in the spline method, some parts of this equation can be
234 computed before the acquisition loop. It is the case of sums that do
235 not depend on $\theta$ :
237 \[ \sum_{i=0}^{M-1} sin(4\pi f.i), \sum_{i=0}^{M-1} cos(4\pi f.i) \]
239 \item Lookup tables for $sin(2\pi f.i)$ and $cos(2\pi f.i)$ can also be
242 \item The simplest method to find the good $\theta$ is to discretize
243 $[-\pi,\pi]$ in $N$ steps, and to search which step leads to the
244 result closest to zero. By the way, three other lookup tables can
245 also be computed before the loop :
247 \[ 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] \]
249 \item This search can be very fast using a dichotomous process in $log_2(N)$
253 Finally, the whole summarizes in an algorithm (called LSQ in the following) in two parts, one before and one during the acquisition loop :
255 \caption{LSQ algorithm - before acquisition loop.}
256 \label{alg:lsq-before}
258 $M \leftarrow $ number of pixels of the profile\\
259 I[] $\leftarrow $ intensities of pixels\\
260 $f \leftarrow $ frequency of the profile\\
261 $s4i \leftarrow \sum_{i=0}^{M-1} sin(4\pi f.i)$\\
262 $c4i \leftarrow \sum_{i=0}^{M-1} cos(4\pi f.i)$\\
263 $nb_s \leftarrow $ number of discretization steps of $[-\pi,\pi]$\\
265 \For{$i=0$ to $nb_s $}{
266 $\theta \leftarrow -\pi + 2\pi\times \frac{i}{nb_s}$\\
267 lut\_sin[$i$] $\leftarrow sin \theta$\\
268 lut\_cos[$i$] $\leftarrow cos \theta$\\
269 lut\_A[$i$] $\leftarrow cos 2 \theta \times s4i + sin 2 \theta \times c4i$\\
270 lut\_sinfi[$i$] $\leftarrow sin (2\pi f.i)$\\
271 lut\_cosfi[$i$] $\leftarrow cos (2\pi f.i)$\\
276 \caption{LSQ algorithm - during acquisition loop.}
277 \label{alg:lsq-during}
279 $\bar{x} \leftarrow \frac{M-1}{2}$\\
280 $\bar{y} \leftarrow 0$, $x_{var} \leftarrow 0$, $xy_{covar} \leftarrow 0$\\
281 \For{$i=0$ to $M-1$}{
282 $\bar{y} \leftarrow \bar{y} + $ I[$i$]\\
283 $x_{var} \leftarrow x_{var} + (i-\bar{x})^2$\\
285 $\bar{y} \leftarrow \frac{\bar{y}}{M}$\\
286 \For{$i=0$ to $M-1$}{
287 $xy_{covar} \leftarrow xy_{covar} + (i-\bar{x}) \times (I[i]-\bar{y})$\\
289 $slope \leftarrow \frac{xy_{covar}}{x_{var}}$\\
290 $start \leftarrow y_{moy} - slope\times \bar{x}$\\
291 \For{$i=0$ to $M-1$}{
292 $I[i] \leftarrow I[i] - start - slope\times i$\tcc*[f]{slope removal}\\
295 $I_{max} \leftarrow max_i(I[i])$, $I_{min} \leftarrow min_i(I[i])$\\
296 $amp \leftarrow \frac{I_{max}-I_{min}}{2}$\\
298 $Is \leftarrow 0$, $Ic \leftarrow 0$\\
299 \For{$i=0$ to $M-1$}{
300 $Is \leftarrow Is + I[i]\times $ lut\_sinfi[$i$]\\
301 $Ic \leftarrow Ic + I[i]\times $ lut\_cosfi[$i$]\\
304 $\theta \leftarrow -\pi$\\
305 $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]$\\
306 \For{$i=1-n_s$ to $n_s$}{
307 $\theta \leftarrow \frac{i.\pi}{n_s}$\\
308 $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]$\\
310 \lIf{$val_1 < 0$ et $val_2 >= 0$}{
311 $\theta_s \leftarrow \theta - \left[ \frac{val_2}{val_2-val_1}\times \frac{\pi}{n_s} \right]$\\
313 $val_1 \leftarrow val_2$\\
319 \subsubsection{Comparison}
321 \subsection{VDHL design paradigms}
323 \subsection{VDHL implementation}
325 \section{Experimental results}
331 \section{Conclusion and perspectives}
334 \bibliographystyle{plain}
335 \bibliography{biblio}