Source |
Travail personnel \begin{frame}{Successive Approximation -- example of a 4-bit ADC}
\noindent\begin{tikzpicture}[x=0.05\textwidth,y=0.05\textwidth]
\useasboundingbox (-6.5,-8.5) rectangle (13.5,6.5);
\path(0,0) node[anchor=south west,inner sep=0pt](im){\includegraphics[width=.5\textwidth]{20191120_sar}};
\path (0,5)node[anchor=east,blue]{$clk$};
\path (-3,-7) coordinate(origo);
\draw [black, very thick, -latex'] (origo) -- node[anchor=north]{\small\slshape\bfseries time} ++(10.5,0);
\draw [black, very thick, -latex'] (origo) -- node[anchor=south,rotate=90]{\small\slshape\bfseries voltage} ++(0,6);
%\grid{-10,-10}{14,10}
%\draw[green] (-6.5,-8.5) rectangle (13.5,6.5);
\path(7.5,-1)node[anchor=north west,inner sep=2pt,rounded corners=2mm,draw=black,fill=LemonChiffon1,text width=0.30\textwidth]{%
\scriptsize %
\begin{tabular}{lr}
\multicolumn{2}{c}{Resolution:}\\
$\SI{5}{\volt}\times\sfrac{1}{2}$ & \SI{2.5000}{\volt}\\
$\SI{5}{\volt}\times\sfrac{1}{4}$ & \SI{1.2500}{\volt}\\
$\SI{5}{\volt}\times\sfrac{1}{8}$ & \SI{0.6250}{\volt}\\
$\SI{5}{\volt}\times\sfrac{1}{16}$ & \SI{0.3125}{\volt}\\
\dots & \\
$\SI{5}{\volt}\times\sfrac{1}{1024}$ & \SI{0.0049}{\volt}\\
\end{tabular}};
\edef\vin{4.0}
\foreach[count=\v,
evaluate=\v as \startframe using int(1+6*(\v-1)),
evaluate=\v as \lastframe using int(\startframe+5)]
\vin in {0,0.5,1.0,1.3,2.0,2.6,3.0,4.0,4.5,5.0}%
{
\only<\startframe-\lastframe>{
\path (0,1)node[anchor=east,Chartreuse4]{\scriptsize$V_{in}=\SI{\vin}{\volt}$};
\draw [Chartreuse4,line width=0.3mm] ($(origo)+\vin*(0,1)$) -- ++(10,0)node[pos=-0.07,anchor=east]{\scriptsize$V_{in}=\SI{\vin}{\volt}$};
}
\foreach[%
count=\i,%
evaluate=\i as \frame using int(\startframe+\i),%
remember=\val as \lastval (initially 0),%
evaluate=\lastval as \vcmp using 5*(\lastval+\val)/16,%
]%
\val in {8,4,2,1,0}
{
\pgfmathbin{16+\val+\lastval}
\edef\bitstring{\pgfmathresult}
\pgfmathsetmacro{\keep}{ifthenelse(\vin >= \vcmp,1,0)}
\only<\frame-\lastframe>{%
\draw [blue,line width=0.3mm] ($(origo)+\vcmp*(0,1)+{\i-1}*(2,0)$) -- ++(2,0)
node[pos=0.5,anchor=south,inner sep=2pt,fill=white,opacity=.7]{\tiny$\SI{\vcmp}{\volt}$}
node[pos=0.5,anchor=south,inner sep=2pt]{\tiny$\SI{\vcmp}{\volt}$}
node[pos=0.5,anchor=north,inner sep=2pt,fill=white,opacity=.7]{\tiny 0b\StrRight{\bitstring}{4}}
node[pos=0.5,anchor=north,inner sep=2pt]{\tiny 0b\StrRight{\bitstring}{4}};
}
\only<\lastframe>{%
\ifthenelse{\equal{\val}{0}}%
{
\path (im.south west) node[anchor=north west,inner sep=2pt,blue,rounded corners=1mm,fill=yellow!60]{\small result: 0b\StrRight{\bitstring}{4}\quad $V_{in} \approx \SI{\vcmp}{\volt}$};
}%
}
\only<\frame>{%
\foreach[count=\j,evaluate=\j as \x using 0.6*(\j-1)+1.5,evaluate=\j as \k using int(\j + 1)] \bit in {3,2,1,0}
{
\ifthenelse{\equal{\i}{\j}}%
{
\path (\x,3.6) node[anchor=south,inner sep=0pt,red]{\StrChar{\bitstring}{\k}};
}%
{
\path (\x,3.6) node[anchor=south,inner sep=0pt,blue]{\StrChar{\bitstring}{\k}};
}
}
\draw[blue,line width=.3mm] (5.5,2.3) -- (6,3.5)node[anchor=south west,inner sep=0pt,blue]{\scriptsize$V_{cmp}=\SI{\vcmp}{\volt}$};
\ifthenelse{\equal{\val}{0}}%
{}%
{
\ifthenelse{\equal{\keep}{1}}%
{
\path (7.0,5.2)node[anchor=south,red]{\scriptsize$V_{in} >= V_{cmp}\,\,\Rightarrow\,\,$ keep bit};
}
{
\path (7.0,5.2)node[anchor=south,red]{\scriptsize$V_{in} < V_{cmp}\,\,\Rightarrow\,\,$ drop bit};
}
}
}
\pgfmathsetmacro{\val}{ifthenelse(\vin >= \vcmp,int(\lastval+\val),int(\lastval))}
}
}
\end{tikzpicture}
\end{frame}
|