\documentclass[paper=A4]{article}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}

\usepackage{siunitx}
\sisetup{
     group-separator = {.},
     input-decimal-markers={.},
     output-decimal-marker = {.},
     group-minimum-digits=9}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{subfigure}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{multicol}
\usepackage{amsmath, amssymb}
\usepackage{tikz}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{eso-pic}

\definecolor{codegreen}{rgb}{0,0.6,0.4}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.6,0,0.82}
\definecolor{backcolour}{rgb}{0.92,0.92,0.92}

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{orange},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

\lstset{style=mystyle}

\hyphenpenalty=10000	%to stop cutting words in a paragraph

\pagestyle{fancy}
\fancyhf{}

\rhead{\includegraphics*[scale=0.013]{./Pictures/FaSTTUBe_Logo_ohneAuto.png}}
\rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
\lhead{Car 313, 01.05, Rev. 1}
\chead{\large TS Discharge Circuit Schematic}

\begin{document}

\begin{figure}[H]
	\centering
	\includegraphics[width=0.98\textwidth]{./Documents/DC.pdf}
	\caption{Schematic of the Discharge Circuit PCB}
\end{figure}

% DC Highlighting
\AddToShipoutPicture*{
\begin{tikzpicture}[remember picture, overlay]
  \fill[yellow, opacity=0.4] ([xshift=4.02cm,yshift=6.37cm]current page.center) rectangle ++(1.39cm,1.99cm);
  \fill[yellow, opacity=0.4] ([xshift=5.85cm,yshift=6.37cm]current page.center) rectangle ++(1.34cm,1.99cm);
\end{tikzpicture}
}

\section*{Discharge Time}

As seen in the schematic, for our discharge circuitry a PTC (PTCEL13R251NxE) is used.\cite{ptc_datasheet}
The total capacitance of the DC-link capacitor from the two inverters (Emsiso emDrive H100) that we are using is about \SI{200}{\micro\farad}, 
and the maximum voltage of the accumulator is 403.2V.\cite{emdriver_datasheet} Using the RC discharging circuit equation, we obtain the highest resistance that the PTC can have so that we are still within the 5s discharge limit.
\begin{align}
	V_C &= V_0 \cdot e^{-t/RC} \\
	\SI{60}{\volt} &= \SI{403.2}{\volt} \cdot e^{-\SI{5}{\second}/(R_{PTC} \cdot \SI{200}{\micro\farad})} \\
	R_{PTC} &\approx \SI{13123}{\ohm}
\end{align}

\begin{wrapfigure}{r}{0.4\textwidth}
	\includegraphics[width=\linewidth]{./Pictures/PTC-R-T.png}
	\caption{Resistance vs. Temperature for PTCEL13 (typical)}
	\label{fig:PTC_T_R}
\end{wrapfigure}

To calculate how many discharge attempts can be made before the discharge time exceeds \SI{5}{\second}, 
we first determine the temperature at which the PTC has a resistance of \SI{13123}{\ohm}. This value can be obtained from the PTC's datasheet (see Fig.~\ref{fig:PTC_T_R}).\cite{ptc_datasheet}

From the graph, the corresponding temperature is approximately \SI{165}{\celsius}. 
We assume the PTC reaches this temperature instantly after each discharge and that heat dissipation is negligible (since the thermal time constant $\tau_{th}$ is \SI{130}{\second}).

To determine the maximum allowable thermal energy before the PTC cools down, we assume an ambient temperature of \SI{45}{\celsius}. 
Given the thermal capacity $C_{th} = \SI{1.45}{\joule\per\kelvin}$, the maximum thermal energy that can be absorbed is:

\[
E = \Delta T \cdot C_{th} = (\SI{165}{\celsius} - \SI{45}{\celsius}) \cdot \SI{1.45}{\joule\per\kelvin} = \SI{174}{\joule}
\]

\newpage

Next, we calculate the energy dissipated in one discharge:

\begin{align}
	E &= \frac{1}{2} \cdot C \cdot V^2 \\
	  &= \frac{1}{2} \cdot \SI{200}{\micro\farad} \cdot (\SI{403.2}{\volt})^2 = \SI{16.26}{\joule}
\end{align}

Therefore, the number of discharges possible before the discharge time exceeds \SI{5}{\second} is:

\[
\frac{\SI{174}{\joule}}{\SI{16.26}{\joule}} \approx 10.7 \Rightarrow \textbf{10 discharges}
\]

\section*{Permanent TS Voltage}
We can find the equilibrium temperature by finding the temperature at which the heat loss is equal to the power emitted. 
To find that, we first convert the graph provided in the datasheet (fig. \ref{fig:PTC_T_R}) to a Look Up Table (LUT), a \hyperref[py_script]{python script} is then created 
with the two function listed below to find the equilibrium point. \\
($DF$: dissipation factor. For the PTC used: \SI{19.5}{\milli\watt/\kelvin}).

\begin{align}
	(T_{eq} - T_{amb})  \cdot DF = & P_{dissipated} \\
	V_{TS} ^ 2 / R_{PTC} =         & P_{created}
\end{align}

After the execution of the script, we can see that the power dissipation at equilibrium is about \SI{1.84}{\watt}. 
The equilibrium temperature and the corresponding resistance calculated is then \SI{139}{\celsius} and \SI{88.5}{\kilo\ohm} accordingly. 
We can see that this is smaller then the maximum temperature rated at \SI{165}{\celsius}.

To find whether the MOSFET STB10LN80K5 can survive the permanent TS voltage, we first have to calculate the current going through it. \cite{mosfet_datasheet}
\begin{align}
	I & = V/R = \SI{403.2}{\volt}/\SI{88.5}{\kilo\ohm} \\
	  & = \SI{4.56}{\milli\ampere}
\end{align}

Since the MOSFET drain current $I_D$ is rated for 8A, it will work under permanent TS voltage.

\newpage
\section*{Python script}
\label{py_script}
\lstinputlisting[language=python]{./Documents/ptc.py}

\bibliographystyle{plain}

\newpage
\renewcommand\refname{Reference}
\begin{thebibliography}{00}

  \bibitem{emdriver_datasheet} \textit{emDrive HXXX Datasheet}. \href{https://www.emdrive-mobility.com/portfolio/emdrive-h100/}{www.emdrive-mobility.com}
	\bibitem{ptc_datasheet} \textit{Vishay PTCEL13R251NxE Datasheet}. \href{https://www.vishay.com/docs/29165/ptcel_series.pdf}{www.vishay.com}, 09.2024
	\bibitem{mosfet_datasheet} \textit{ST STB10LN80K5 Datasheet}. \href{https://www.st.com/resource/en/datasheet/stb10ln80k5.pdf}{www.st.com}, 02.2016

\end{thebibliography}

\end{document}
