%! TEX root = ../thesis.tex
\chapter{Results}

This Chapter summaizes all of the resulting Workflow that has been developed during this Bachelor Thesis Work.
Mainly the Firmware Changes compared to the state at wich it was left off after the previously taken Internship \cite{poweritupgrade}

\section{Firmware}

The PowerIt Firmware was updated to allow for the Calibration Procedure (described in \ref{calib}) and the Rgulation of its 1.8V output. That resulted in a new Version of the I2C Protocol between the Monitoring System and PowerIts.

\subsection{PI2CProto v2}
The new Commmunication protocoll is based on the old one, and while the from the Host send Commands are compatible with version 1 the returned Message is not. 
And just like in the old Version a Master can send a message to the PowerIt with the in the \verb|command_t| struct described structure:

\begin{mintylst}{cpp}
    pi2c::command_t tosend { <crc>, 2, <CMD>, <optional_data0>, <optional_data1> };
\end{mintylst}

Here the \verb|<CMD>| can be \verb|CMD_SET| for setting a value in the corresponding table (fig. \ref{registerbuffer}), using \verb|<optional_data0>| as address and \verb|<optional_data1>| as value.

Reading a number of bytes from the table can be accomplished with \verb|CMD_READ|, giving the address to start and number of bytes in that order.

While reading the complete Table is done with the \verb|CMD_READALL| command.

THe \verb|<crc>| byte is the CRC8 value of all following bytes inside \verb|command_t|

\subsection{I2C mapped Register-Table}
When sending or reading values to or from the PowerIt, the address requireed is one of the 152 bytes documented in this table.
\input{./tabs/registerbuffer}

\section{Calibration\label{calib}}

One of the goals of this Bachelor Thesis is to provide anyone required to calibrate a PowerIt Board with a comprehensive guide of, and inside into this process. 

\subsection{Calibration-Table}

Of important note is that al calibration values of each PowerIt can be mapped via the naming and uuid scheme provided either by the corresponding stickers or the STM32-Chips internal uuid (accessible through address \verb|0x8c|, see figure \ref{registerbuffer}).
There now also exists a global calibration Database, which will be loaded by the system on startup.

An example entry for each PowerIt entry looks like figure \ref{pitdb-example}

\begin{figure}[H]
    \begin{mintyfig}[title={example entry of pitdb.yaml}, label=pitdb-example]{yaml}
        ---
        uuid: 'default'
        name: 'Bxx'
        poly18i: [-3.0, 25.0, 0.0]
        poly48i: [0.0, 227.27, 0.0]
        poly10v: [0.0, 4.0, 0.0]
        poly18v: [0.0, 1.0, 0.0]
        poly48v: [0.0, 27.386, 0.0]

    \end{mintyfig}
\end{figure}

\begin{figure}
    \centering
    \minty[minted options={lastline=10}, label=pitdb]{yaml}{pitstop/pitdb.yaml}
\end{figure}

\subsection{How to calibrate a PowerIt Board}

The Calibration process is based on the PItSTOP Python scripts\footnote{
 %TODO: insert repo, and link to docs
    \href{https://acereca.ddns.net:11443/acereca/pitstop}{PItSTOP Repo}
}.
These are split into \verb|server| and \verb|aggregator|. While the Server is handling the translation between raw I$^2$C data, and the JSON formatted result, the Aggregator takes this JSON and calculates a calibration.

Using the script any one of the following Values can be tested and calibrated:
\begin{itemize}
    \item Input Voltage (\verb|pitstop.Aggregator.test_v_48()|)
    \item Input Current (\verb|pitstop.Aggregator.test_i_48()|)
    \item 9.6V Output Voltage (\verb|pitstop.Aggregator.test_v_10()|)
    \item 1.8V Output Voltage (\verb|pitstop.Aggregator.test_v_18()|)
    \item 1.8V Output Current (\verb|pitstop.Aggregator.test_i_18()|)
\end{itemize}

\subsubsection{Setting up the Test Environment}
The simplest way to setup your environment consists of cloning the PItSTOP Project onto your Client:
\begin{mintylst}{bash}

    > git clone https://url.to.pitstop

\end{mintylst}
then substituting the \verb|rsync| target:
\begin{mintylst}[label={makefile}]{makefile}
    all:
        rsync --progress ./*.py /remote.url/
\end{mintylst}

, to be your server (should be a RaspberyyPi connected to the PowerIt) 

\subsubsection{Running a Test}
Runnig the test requires the following commands
\\
Serverside:
\begin{mintylst}{bash}
    > python server.py
\end{mintylst}
Clientside:
\begin{mintylst}{bash}
    > python aggregator.py
\end{mintylst}
Now just following the instructions given, the selected test can be run:
\begin{mintylst}{text}
    Setting up calibration test for {}
    Please be sure to:
     - connect the {} to the RaspberryPi running server.py.
     - connect the PowerIt to the RaspberyyPi as described in the documentation
     - and be sure to connect the {} to the {} Terminal.

    Continue (y/N): y

    What is the Name given to the connected PowerIt? [Bxx]: B05
\end{mintylst}


\section{Regulation}

    \subsection{Distance Wafer Resistance Model (DWRM)}\label{sec:dwrm}

        Although the through SWRM gained functions approximate the real world, it is not exact enough.
        In a wafer, the distance between reticles and voltage connector (see \autoref{fig:mainpcb}) are resulting in additional resistance.

        Therefore we adapt the DWRM after Circuit~\ref{fig:retmodelshell} in which each different Distance requires additional Resistors.

        \begin{figure}[H]
            \centering
            \includegraphics[width=.5\columnwidth]{tikz/reticlepower_2}
            \caption{Modified model of the to measure resistances and their currents.
            Similar to SWRM \(R_0\) describes the resistance of a connection between the PowerIt Output, up to the FET (depicted as switch), while \(R_1\) is a Resistance between FET and Reticles. But additionally \(R_{0+}\) described a Resistance, that depends on the distance between reticle and voltage connector. 
            The measurement is done between output terminals on the PowerIt and pins on a Analog readout board}%
            \label{fig:retmodelshell}
        \end{figure}

        With this model the voltage is now expected to change depending on the reticles distance instead of being the same. The distances inside a wafer are visualized in \autoref{fig:retmodelrdist}

        \begin{figure}[H]
            \centering
            \hspace*{-.14\columnwidth}
            \includegraphics[width=1.2\columnwidth]{../pitstop/20180821/reticel_rtheo.pdf}
            \caption{Distances of reticles to the nearest voltage supplying connection for DWRM, distance is in reticle-side length}%
            \label{fig:retmodelrdist}
        \end{figure}