%%% lorem.tex --- 
%% 
%% Filename: lorem.tex
%% Description: 
%% Author: Ola Leifler
%% Maintainer: 
%% Created: Wed Nov 10 09:59:23 2010 (CET)
%% Version: $Id$
%% Version: 
%% Last-Updated: Wed Nov 10 09:59:47 2010 (CET)
%%           By: Ola Leifler
%%     Update #: 2
%% URL: 
%% Keywords: 
%% Compatibility: 
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%%% Commentary: 
%% 
%% 
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%%% Change log:
%% 
%% 
%% RCS $Log$
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%%% Code:
% !TeX root = main.tex

\chapter{Methods}\label{cha:methods}
This chapter covers the methodologies used during the project.

\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;

\squareit{ \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 och presera dem på ett snyggt men platseffektivt sätt]

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{Examination and initial measurement of the old equipment}
To decide the forthcoming of the project, the equipment first had to be checked to see if its performance were 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.

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.

\todo[försök hitta källor på följande påståenden]

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 minimize it 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 \cite{some_good_reference_for_measurement_techniques} \todo[find source to this]. 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}.

\todo[Fint schema här]

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}.

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}

\todo[Fint schema här]

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 only high for a very short time. 

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 graph of energy]

\subsection{PCB}
\label{sec:dummy_load_pcb}
Since the dummy loads consists of many discrete resistors, it was decided to design a PCB, printed circuit board, 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 \mbox{EN 60664-1} standard \cite{en_60664_1}. The board was perforated to allow for better air flow past the resistors, improoving the heat dissipation. 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 power dissipation 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 without violating the functional isolation distance.

Both the circuit schematic and layout editing of the board were performed in the free EDA, Electronic Design Automation, tool KiCad\footnote{KiCad EDA \url{http://kicad-pcb.org/}}.

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, see \autoref{fig:dummy_load_card_board}.

When the PCB was delivered, it was visually inspected before assembling. Some modification was made to improve the isolation distance by drilling away the plating and pads of the ventilation holes.

\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 the 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 and should not distort the pulse.

\subsection{Attenuators}
\todo[Massa illustrationer i den här delen]

The target attenuation was decided to mimic the commercial attenuators, described in \autoref{theory_pat_attenuators}, where the \SI{50}{\ohm} attenuator has an attenuation of \SI{54.7}{\deci\bel} and the \SI{1000}{\ohm} attenuator 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{$\Pi$ attenuator calculator \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 realizing them in a single $\Pi$-link. This is desirable because the parasitic capacitance, which is dependent 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.

When the ideal resistor values had been derived, the energy over time and maximum voltage for each resistor was retrieved by simulation, as seen in \autoref{fig:ideal_attenuator_maximum_power}. Based on this, the minimum number of discrete resistors needed to withstand the pulse energy 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.

When the number of resistors and its constellations was decided, all of the discrete ideal resistors were replaced with non-ideal models in the simulation software. Then the attenuators were checked in frequency domain, as well as how the pulses were affected in time domain.

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

Since the attenuators consits of SMD, surface-mount device, resistors, it was decided to design a PCB for this purpose. This also gives good control of the lengths of the conductors, which is of importance when designing for higher frequencies.

First, the circuit is drawn in the schematic part of the EDA tool KiCad\footnote{KiCad EDA \url{http://kicad-pcb.org/}}. When this is done, the schematic is exported to the PCB layout.

The measurement connectors that will be accessible on the outside of the encapsulation must safe at all times. This involves keeping a minimum creepage distance of \SI{6}{\milli\meter} to any trace that carry a high voltage, according to the regulations in \mbox{EN 60664-1} \cite{en_60664_1}. The EDA tool has functionality for design rule checking, DRC, but there are some limitations in this function that inhibit its use for this case. The DRC in KiCad only allows to set the clearance for a specified net to all other nets. In this case it is only desired to restrict the clearance between the high voltage traces to the traces that are to be considered safe. It is allowed for one high voltage trace to be close to another high voltage trace, only the functional isolation of \SI{3}{\milli\meter} applies here, and it is also allowed for the output signal and the output ground to be close to each other. To aid the design process without the DRC, the high voltage traces was placed on the top layer of the PCB, while all signal traces were placed on the bottom layer. To ensure that enough clearance was kept to the relay pad's, the \SI{6}{\milli\meter} clearance was added to the package footprint as a ring on a user layer in the EDA, as seen in \autoref{fig:kicad_footprint}. This is not an enforced rule, but it helps during the manual design process.

To attach the relay card fixture to the \SI{4}{\mm} banana connectors on the CNA~200, three banana plugs was designed to be screwed directly to the PCB. This makes the conductors as short as possible, and also act as mechanical fastening of the PCB to the case.

Before the PCB was sent for manufacturing, it was also printed in 1:1 scale as the dummy load PCB described in \autoref{sec:dummy_load_pcb}. This also helps to ensure the critical positioning of the \SI{4}{\mm} banana connectors that will attach to the test equipment, as seen in \autoref{fig:relay_card_card_board_equipment}.

When the PCB was delivered, it was visually inspected before assembling. Some modifications were required to fulfill the clearance criteria, these were made using a rotary multitool to machine away the undesired part of the traces.

\subsection{Measurement of the relay box}
Since the relay card will be used in measuring pulses with short rise times, it is of importance to know that it does not distorts the signal too much. It is desired to measure the magnitude response in the frequency domain, as well as the test pulse in time domain.

To measure the magnitude response, a so called S21 measurement was performed using the network analyzer ZVL that is introduced in \autoref{sec:rohde_schwarz_zvl}. To be able to connect the network analyzer, a fixture was made to mimic the front panel of the CNA~200. A programmable relay card was used to control the relays during the testing. The setup can be seen in \autoref{fig:relay_card_measurement_s21}.

This setup proved to be unstable, as moving the coaxial wires and the grounding wire greatly affected the results for the higher frequencies. Because of the unstable results early in the measuring process, a modification was made to shorten the ground connection by attaching a braid as close as the attenuator grounds as possible and then grounding it directly to the fixture case, as depicted in \autoref{fig:relay_card_modification}. All subsequent measurements were performed with this modification.

The signal was measured for each output terminal through each of the attenuators to get the magnitude response for the intended use. To see how well the design suppresses unconnected signals, the magnitude response was also measured when the signal was disconnected completely, i.e. all the control relays were open. In addition to this, the magnitude response was also measured with all but the relays on the current terminal closed, to see if there was any overhearing on the circuit board from the other terminals and the traces after the relays. An illustration of the measurements can be seen in \autoref{fig:relay_card_measurement_sketch}. The results were saved both as an image and as raw data in the form of complex numbers in a CSV, coma separated values, file to allow for further analysis and plotting.

A single relay was also measured using the network analyzer to get a perception of its high frequency properties. The setup was made by soldering coaxial cable directly to the relay, with as short connecting wires as possible to prevent any influence on the result from the wires. The setup can be seen in \autoref{fig:relay_s21}.

To measure the test pulses through the attenuators, the relay card was connected to the CNA~200 and the pulses were measured on the intended connectors using an oscilloscope, as seen in \autoref{fig:relay_card_measurement_time}. The results were saved both as an image and as data points in a CVS file, for further analysis.

To have something to compare the results to, the commercial attenuators were also measured in frequency domain with the ZVL and in time domain using the oscilloscope.

\section{Analysis}

Didn't have no time for this. Yet...

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% lorem.tex ends here

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "demothesis"
%%% End: 
