% !TeX root = main.tex
\chapter{Methods}\label{cha:methods}
This chapter covers the methodologies used during the project. To man dude! \todo[ta bort detta]

\section{Prestudy}
During the project efforts were made to find relevant research using Linköping University Library's\footnote{\url{https://liu.se/en/library}} and Google Scholar's\footnote{\url{https://scholar.google.se/}} search engines. Among the keywords used in searching were \emph{verification equipment}, \emph{test equipment}, \emph{automatic test}, \emph{automatic verification}, \emph{iso equipment}, \emph{electrical verification}, \emph{curve fitting}, \emph{double exponential function}, \emph{}, \emph{}

\todo[Skriv färdigt nyckelordsdelen]

Since the equipment intended for this project was untested before the project start, the first step was to hook it up and make some initial measurements to be able to decide the continuation of the project.

If the equipment seem to be mostly in line with the new standard requirements, the project plan was to go along the following path:
\begin{enumerate}
    \item Investigate test architectures suitable for automatic testing and verification.
    \item Design any utilities needed for the test and verification setup.
    \item Implement the test architecture and any necessary utilities.
    \item Measure and evaluate the system and the utilities.
\end{enumerate}

If the equipment proved to deviate to much from the standard requirement, the project should go along the following path:
\begin{enumerate}
    \item Investigate possible causes and fixes for the failure.
    \item Design any utilities needed for the equipment to pass.
    \item Implement these utilities.
    \item Measure and evaluate the system with these utilities manually.
\end{enumerate}

In either case, the following tasks should be considered if there is time:
\begin{enumerate}
    \item Investigate possible methods, or algorithms, that can automatically verify the pulse shapes and parameters.
    \item Implement a number of these methods.
    \item Evaluate these methods.
\end{enumerate}

\section{Initial measurement of the performance of the old equipment}
To decide the forthcoming of the project, the equipment first had to be checked for it's performance and if it is within the limits for use with the newer standard. Because there is no dummy loads available at this point of the project, only open load measurements could be done.

With exception for Pulse 3a and Pulse 3b, all of these pulses were measured with the use of the high voltage differential probe described in \autoref{sec:hv-diff-probe}. The pulses are measured both directly on each generator connected according to \autoref{fig:manual-measurement-hv-diff} and also through the coupling network CNA~200, as depicted in \autoref{fig:manual-measurement-hv-diff-cna}. 
\todo[figure of connection]
Pulse 3a and Pulse 3b was measured using the attenuators described in \autoref{sec:hv-attenuators} connected according to \autoref{fig:manual-measurement-hv-att}. Thanks to the 50-ohm attenuator this pulse could be measured in its matched state. The measurement in open state is a compromise, since there was no such attenuator available, and was made into a 1000-ohm attenuator instead.

\section{Test architecture}
\squareit{Alternatives and choices. Try finding articles on human error maybe. Make plenty of nice figures.}
The total number of tests needed to verify the testing equipment before each product test is 14, according to \autoref{tab:verification-list}. There are in total three different values for dummy loads, in practice these will be represented by three different high power dummy loads and two high frequency attenuators for pulse 3a and pulse 3b.

The following test architectures were considered, together with the external supervisor at the company. In the end the 3rd alternative was chosen, as explained in \autoref{result-test-architecture}. To design Alternative 3 some utilities needs to be designed, namely:
\begin{itemize}
    \item Relay box, the fixture with embedded attenuators that are to be attached to the front of the CNA.
    \item Match box, the dummy loads with some relays to be able to switch between them.
\end{itemize}

Additionally there needs to be some sort of measurement fixture for evaluating the verification equipment.

\subsection{Alternative 1 -- Human assisted}
The test can be performed semi-automatically by means of the existing equipment complemented by some dummy loads and, in the same manner the manual performance tests were executed. A computer could control the equipment and compare the results, by the assist of a human that can make the necessary reconnections between the tests.

The main advantage of this is that it would probably require the least amount of time for development of the automation software. It also doesn't need any extra hardware except from the dummy loads needed to do the verification.

The biggest disadvantage is that it would be very cumbersome to perform and also very prone to human error. If the verification list is studied carefully one can minimise is to five reconnections after the initial connections are made, for example in the following order: No load, \SI{2}{\ohm}, \SI{10}{\ohm}, \SI{50}{\ohm} low frequency, \SI{50}{\ohm} high frequency, \SI{1}{\kilo\ohm} high frequency.

\subsection{Alternative 2 -- Fully automatic rig external attenuators}
To accurately measure Pulse 3a and Pulse 3b, the probes should be attached as close as possible to the generator because of the high frequency, to avoid influence of the connecting wires. This could be accomplished by the means of a fixture that is attached directly to the generator, which can switch the pulses to the different loads or to the measurement outputs.

The dummy loads for all pulses, but Pulse 3a and Pulse 3b, will need to be put in a separate enclosure because of the power dissipation needed. The proposed architecture is depicted in \autoref{fig:automatic-rig-1}.

The advantage of this method is that the verification can be performed fully automatically, except for the initial connection of the test rig. This also uses the commercially created attenuators that are already available.

The disadvantage to this setup is that the fixture needs to be designed, making the development costs greater. The fixture that attaches to the generator will expose high voltage on its measurement connectors, making it a safety hazard.

\subsection{Alternative 3 -- Fully automatic rig with embedded attenuators}
To cope with the high voltage exposure, of alternative 1, the high frequency attenuators can be embedded inside the switching fixture, removing the need for high-voltage connectors. \autoref{fig:automatic-rig-2}.

The advantage of this, on top of the advantages of alternative 2, is that there is no longer need for external attenuators and that the connectors will no longer expose high voltage.

The disadvantage of this would be that the embedded attenuators might prove difficult to design. They need to be accurate up to high frequencies, be tolerable to high voltage, dissipate the power necessary and also be electrically safe.

\section{Design of dummy loads}
Each dummy load must withstand the applied test pulses, and preferably the worst possible test pulse for the specific dummy load even though it might not be intended. The dummy loads must have a tolerance of \SI{1}{\percent} or less and be non-inductive. \cite{iso-7637-2}

The dummy loads consists of one or more resistors. When determining whether the resistors withstands the test pulses, the parameters of interest are power dissipation, maximum voltage and maximum energy applied over time.

\subsection{Components}
At first the momentary worst case powers and voltages were calculated by hand, to the values seen in \autoref{tab:dummy_load_worst_case}. But to find components that can handle these momentary powers proved very difficult, and it is not necessary since the pulse power is varying over time and the impulse voltage does not stress the components as much as a constant voltage would do.

One manufacturer of thick film resistors, namely Vishay, specifies its overload capability in a graph with energy over time in the datasheet, which was easier to compare against using LTSpice to simulate the energies for the different loads, according to \autoref{graph:dummy_load_energy}. The simulated value was then divided by the value specified in the datasheet to get the minimum number of resistors required to share the load. Some possible combinations of available resistor values were considered to reach the desired load resistance, before the final configuration were decided according to \autoref{fig:final-dummy-loads}.

\todo[ltspice-bild på de tre olika dummy loadsen]

The voltages used in the calculations are specified in \autoref{tab:dummy_load_worst_case}, they are slightly higher than the specified voltages on the equipment to allow for some margins. The worst case voltage must always be tolerated to prevent arching or serious degrading of the components.

\begin{table}[h]
\begin{adjustbox}{width=\columnwidth,center}
    \centering
    \begin{tabular}{|l|r|r|r|r|r|r|} 
        \hline
        Dummy load (\si{\ohm}) & Pulse & $R_S$ (\si{\ohm}) & Generator voltage (\si{\volt}) & Peak voltage (\si{\volt}) & Peak power (\si{\watt}) & Mean power (\si{\watt}) \\
        \hline
        2   & Pulse 1 & 2 & 650 & 325 & 45 \si{\kilo} & 5 \\
        10  & Pulse 1 & 2 & 650 & 600 & 5 \si{\kilo} & 5   \\
        50  & Pulse 1 & 2 & 650 & 600 & 5 \si{\kilo} & 5   \\
        50  & Pulse 1 & 2 & 650 & 600 & 5 \si{\kilo} & 5   \\
        \hline
    \end{tabular}
\end{adjustbox}
    \caption{Calculated momentary worst cases for each dummy load.}
    \label{tab:dummy_load_worst_case}
\end{table}
\todo[Rätta till värdena i tabellen!]

\todo[input worst case table here]
\begin{table}
\label{tab:dummy_load_worst_case}
\end{table}

\todo[input graph of energy]

\subsection{PCB}
Since the dummy loads consists of many discrete resistors, it was decided to design a PCB to connect them. This also gives good mechanical control of the resistors and the possibility to design for good heat dissipation.

Because of the high voltages present on the board it was decided to keep a minimum of 3mm functional isolation creepage distance between all traces on the board, in line with the EN 60664-1 standard \cite{en-60664-1}. The board was perforated to allow for better air flow past the resistors. The mounting holes for the card was placed in a \SI[product-units=single]{105 x 105}{\milli\meter} square, allowing for a \SI{120}{\milli\meter} fan to be mounted on top of the card using mounting hardware.

A two layer board was chosen, and all of the traces were mirrored on both layers to get as much conductive cross sectional area as possible, and thus lowering the resistance and voltage drop in the traces. The PCB was ordered with \SI{60}{\micro\meter} thick copper layer to further extend the cross sectional areas. The width of the traces for the \SI{2}{\ohm} load was chosen as wide as possible, since the pulse currents are the highest for this one. \todo[kolla så detta är sant]

Both the circuit schematic and layout editing of the board were performed in the free EDA tool KiCad. Before ordering the PCB, it was printed in 1:1 scale and attached to a piece of card board. The card board was then populated with the components already at hand to ensure that the footprints are correct and that the placement of the components makes sense and does not collide.

\todo[Fin bild på designprocess av PCB, säkerhetsavstånd etc]

\subsection{Measurement}
When the dummy loads had been assembled, their resistances were determined using four wire resistance measurement directly at the PCB's connection points, as seen in \autoref{fig:four-wire-measurement}. With this technique, one can neglect the resistance in the cables used for measuring which can have a significant affect when measuring low resistance loads \cite{book:measurment-techniques}.


\section{Design of the switching fixture and embedded attenuators}
The chosen implementation requires a fixture that switches and attenuators, which purpose is to switch the pulse to the desired attenuator or to the dummy load. It must be able to handle the momentary pulse energies and voltages.

\subsection{Attenuators}

The target attenuation was decided to mimic the commercial attenuators, described in \autoref{theory_pat_attenuators}, where the \SI{50}{\ohm} has an attenuation of \SI{54.7}{\deci\bel} and the \SI{1000}{\ohm} has an attenuation of \SI{60.1}{\deci\bel}.

Only Pulse 3a and Pulse 3b were considered when designing these attenuators, since all other test pulses will be coupled to the separate dummy load.

The two attenuators were implemented as $\Pi$-attenuators. The values for the attenuators were retrieved from an online calculator\footnote{\url{https://chemandy.com/calculators/matching-pi-attenuator-calculator.htm}}, and then they were simulated in LTSpice to verify the values.

By dividing the attenuators into two $\Pi$-networks, the series resistance required will get a bit lower compared to realising them in a single $\Pi$-link. This is desirable because the parasitic capacitance, which is dependant of the resistor package and not the resistance, will influence a high value resistor at lower frequencies that it would on a low value resistor, as explained in \autoref{theory_parasitic_properties}.

A resistor with high pulse power and high voltage properties had to be chosen. Vishay's CRCW-HP series fitted this description and were easily available.

When the ideal resistor values had been derived, the maximum power dissipation and maximum voltage for each resistor was retrieved by simulation. Based on this, the minimum number of discrete resistors needed to withstand the pulse power was calculated. In the same way the minimum number of series resistors to withstand the maximum pulse voltage was calculated. These numbers are presented in \autoref{tab:methods_attenuator_constellations}.

With the minimum number of discrete resistors needed for each ideal resistor known, a constellation of available resistor values was constructed to approximate the nominal value with as few resistors as possible.

The \SI{54.7}{\deci\bel} attenuator was divided into two \SI{27.35}{\deci\bel} $\Pi$ attenuator links. When the closest values for the resistors had been chosen, using \SI{56}{\ohm} as shunt resistors and \SI{56}{\ohm} in series, the final attenuation was \SI{53.66}{\deci\bel} for the two links according to the simulation, seen in \autoref{fig:ltspice-att-ideal-54}. The input and output resistance was 

Nice graphs.

The \SI{60.1}{\deci\bel} attenuator was divided into one \SI{27.35}{\deci\bel} $\Pi$ attenuator links \SI{32.75}{\deci\bel}. When the closest values for the resistors had been chosen, using \SI{56}{\ohm} as shunt resistors and \SI{56}{\ohm} in series, the final attenuation was \SI{53.66}{\deci\bel} for the two links according to the simulation, seen in \autoref{fig:ltspice-att-ideal-54}. The input and output resistance was 
\autoref{discussion_attenuators}

\subsection{Desired vs implemented (simulation)}
Parasitic effects. (real life, back to simulation) \todo[kanske borde ligga under results?]

\subsection{PCB}
\todo[Fin bild på designprocess av PVB, säkerhetsavstånd etc]

\subsection{Measurement}

The stuff and things done when measuring the shitload yo. Also measured at the other point. Using oscilloscope bla. Hah.

\section{Analysis}