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

\usepackage[a4paper, left=2cm, rightr2cm, 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}

\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, 23.04, 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}

\begin{tikzpicture}[remember picture, overlay]
	% Draw a yellow semi-transparent rectangle
	\fill[yellow, opacity=0.4] ([xshift=3.1cm,yshift=6.8cm]current page.center) rectangle ++(1.37cm,1.86cm);
	\fill[yellow, opacity=0.4] ([xshift=4.88cm,yshift=6.8cm]current page.center) rectangle ++(1.25cm,1.86cm);
\end{tikzpicture}

\section*{Discharge Time}

As seen in the Schematic, for our discharge circuitry a PTC (PTCEL13R251NxE) is used. 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. 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=1\linewidth]{./Pictures/PTC-R-T.png}
	\caption{Resistance vs. Temperature for PTCEL13 (typical)}
	\label{fig:PTC_T_R}
\end{wrapfigure}

To Calculate how much discharge attempts we can have before the discharge reaches 5s, we first see at what temperature the PTC the resistance of \SI{13123}{\ohm} have. We can get this from the datasheet \cite{ptc_datasheet} of the PTC (fig. \ref{fig:PTC_T_R}).

As seen in the datasheet, the temperature is about \SI{165}{\celsius}. Assuming that the temperature rises instantly after the discharge, and the heat dissipation is negligible (since the thermal time constant $\tau_{th}$ is \SI{130}{\second}). As we are calculating the lest amount of precharge allowed, we assume the temperature of the environment to be \SI{45}{\celsius}. Since the thermal capacity $C_{th}$ is \SI{1.45}{\joule/\kelvin}, we can see that the total energy that we can generate from discharge is $E = \SI{120}{\kelvin} \cdot \SI{1.45}{\joule/\kelvin} = \SI{174}{\joule}$.

We then calculate how much energy in produced in one discharge:

\begin{align}
	E = & \frac{1}{2} \cdot C \cdot V^2 \\
	=   & \SI{16.26}{\joule}
\end{align}

Therefore, the total amount of discharge we can carry out before the time exceeds \SI{5}{\second} is $\SI{174}{\joule} / \SI{16.26}{\joule} = 10.7$ --- ten times.

\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 python script (listed below) is then created with the two function listed below to find the equilibrium point. (Here is the $DF$ the dissipation factor, and with this PTC it is \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.

\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. \cite{mosfet_datasheet}

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

\bibliographystyle{plain}

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

	\bibitem{ptc_datasheet} \textit{Vishay PTCEL13R251NxE}. \href{https://www.vishay.com/docs/29165/ptcel_series.pdf}{https://www.vishay.com/docs/29165/ptcel\_series.pdf}, 09.2024
	\bibitem{mosfet_datasheet} \textit{ST STB10LN80K5}. \href{https://www.st.com/resource/en/datasheet/stb10ln80k5.pdf}{https://www.st.com/resource/en/datasheet/stb10ln80k5.pdf}, 02.2016

\end{thebibliography}

\end{document}
