\documentclass[10pt]{article}
\usepackage[english]{babel}
% \usepackage[a4paper,top=2cm,bottom=2cm,left=2cm,right=2cm,marginparwidth=1.75cm]{geometry}
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage{multicol}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{listings}
\usepackage{xcolor}

\newenvironment{Figure}
  {\par\medskip\noindent\minipage{\linewidth}}
  {\endminipage\par\medskip}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.97,0.97,0.95}

\lstdefinestyle{mystyle}{
  backgroundcolor=\color{backcolour},   
  commentstyle=\color{codegreen},
  keywordstyle=\color{magenta},
  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}

\graphicspath{{images/}}

\title{B00st converter}

\author{
    van Iterson, Arne\\
    Student Number: 1798423
    \and
    Selier, Tom\\
    Student Number: 1808444
  }

\begin{document}
\maketitle
\begin{abstract}
  This report describes the design, testing methods and behaviour of a DC-DC Boost converter using BS170 MOSFETs built by students of the University of Applied Sciences Utrecht. 
\end{abstract}
\begin{multicols}{2}
  \section{Introduction}
  Students of the Electrical Engineering department of the University of Applied Sciences Utrecht are to design a DC-DC Boost converter in the fifth semester during the Hardware Design course. 
  \\\\
  The goal of the project is to design a DC-DC Boost converter on breadboard that can step up a voltage of around $3V$ to any voltage between $3.3V$ and $7.5V$. The converter should be able to deliver a current of $50mA$ at any given voltage. The entire system is to be controlled by a STM32F4 series microcontroller which should provide a way to control the output voltage through software. 
  
  An example circuit and a couple of components are provided and mandatory to use, such as the inductor, the capacitor and the MOSFETs. Apart from these components, the circuit can be altered and or extended to the student's liking to improve its function as long as the final circuit is able to deliver the required current and voltage.

  \section{Circuit Description}
  According to The Art of Electronics \cite{Horowitz_Hill_2022}, the simplest implementation of a step-up or boost converter consists of just four components; An inductor, a switch, a diode and a capacitor connected as follows: 
  \begin{Figure}
    \centering
    \includegraphics[scale=0.5]{AOE_BOOSTCONV.png}
    \captionof{figure}{Basic boost converter}
    \label{fig:boost_converter}
  \end{Figure}

  It describes the function of a boost converter as follows: 
  \begin{quote}
    During switch conduction (...) the inductor current ramps up; when the switch is turned off, the voltage at point Y rises rapidly as the inductor attempts to maintain constant current. The diode turns on, and the inductor dumps current into the capacitor. The output voltage can be much larger than the input voltage.
  \end{quote}

  The image below shows the final circuit used. As shown, the circuit includes just a few modification to the example circuit provided.
    \begin{Figure}
      \centering
      \includegraphics[scale=0.38]{SCHEMATIC_FULL.png}
      \captionof{figure}{Final version of the boost converter}
      \label{fig:schematic_full}
    \end{Figure}

    The circuit has been through several iteration throughout the project, however, the following key components have not been changed throughout: 
    \begin{list}{-}{}
      \item The inductor, a $1 mH$ inductor
      \item The diode, a $1N5817$
      \item The capacitor, a $220\mu F$ capacitor
      \item The MOSFETs, BS170 series
    \end{list}

    In the example circuit, there was only one MOSFET and it was directly controlled by the MCU. This circuit was able to reach a voltage of $7.5V$, but not at the required current. This is due to the fact that the BS170 series MOSFET has a fairly high $R_{DS(on)}$ of $1.2\Omega$ \cite{Onsemi_2022}. To increase the output current, a second MOSFET was added to the circuit. This way, the $R_{DS(on)}$ is halved, effectively doubling the current at which the inductor can be charged if we neglect the resistance of the inductor itself. The downside of adding a second MOSFET is that it also doubles its input capacitance, however, with an additional circuit modification this can be overcome.

    A second addition to the circuit is the push-pull driver on the gate of the MOSFETs. The driver consists of two NPN transistors that are controlled by inverted signals from the MCU, this way the MOSFET gates are quickly switched between $0V$ and $3.3V$. The push-pull driver was chosen over a pull-down resistor because it would cause several issues; A low resistor value would quickly discharge the gate capacitance, but it would also decrease the driving current when turning the MOSFET on. A high resistor value would have little effect on the gate capacitance. The push-pull driver solves both of these issues by quickly discharging the gate capacitance by connecting them to ground while not effecting the driving current when turning the MOSFET on. This way, the MOSFETs are switched faster, increasing the efficiency of the circuit.

    The final addition is a voltage divider of $15k\Omega$ and $10k\Omega$ on the output, this simply lowers the output voltage to a level that can be read using the ADC on the MCU and is used for control loop feedback. 

    \subsection{Control}
    \label{control}
    The system is controlled by the STM32F407 on the HU development board. The board provides the required PWM signals to control the MOSFETs and the ADC to read the output voltage. The program provides a small interface in which the user can view and control the duty cycle and frequency of the switching and read the current output voltage. The program also implements a simple PI control loop to control the output voltage, however it is not yet fully functional and requires more tuning. 

    \begin{Figure}
      \centering
      \includegraphics[scale=0.25]{FW_CONTROL_1.png}
      \captionof{figure}{Display readout of PWM Control registers, frequency and duty cycle}
      \label{fig:ui1}
    \end{Figure}

    \begin{Figure}
      \centering
      \includegraphics[scale=0.25]{FW_CONTROL_2.png}
      \captionof{figure}{Display readout of ADC value and converted voltage}
      \label{fig:ui2}
    \end{Figure}

    \begin{Figure}
      \centering
      \includegraphics[scale=0.25]{FW_CONTROL_3.png}
      \captionof{figure}{Display readout of target and current output voltage}
      \label{fig:ui3}
    \end{Figure}

  \section{Methodology} \label{section:methodology}
    To characterize the system, several tests have been performed. The 
    characteristics of interest are the following:
    \begin{enumerate}[nosep]
        \item Efficiency
        \item Noise
        \item Ripple characteristics
        \item Start up
    \end{enumerate}
    In this section a test or measurement will be described for each of the above 
    characteristics. 

    Each of the characteristics have been tested at two different output voltages
    and various load currents. The different voltages are $7V$ and $3.3V$. The 
    chosen load currents are $10$, $20$, $30$, $40$ and $50 mA$. These values 
    were chosen to characterize the circuit over a broad range of conditions. 
    Lastly, the switching frequency (PWM frequency to the MOSFETs) of the STM 
    was locked to $30kHz$. The switching frequency was found by testing the efficiency
    of the circuit.

    For all tests, the data was handled in a simular way. For test 2 through 4,
    an oscilloscope was set up on the output voltage. The probe was set to 
    10x attenuation to minimize it's influence on the circuit. The oscilloscope's 
    settings are set to get the signal full screen, and the acquire settings were 
    adjusted so that it would store 20,000 points. Then, at each measurement 
    .csv (comma seperated values) was stored on a USB drive. 
    
    After the measurements were collected, they were processed using a python 
    script. The major functions are listed at each test.


  \subsection{Efficiency} \label{section:efficiency}
    \begin{Figure}
      \centering
      \includegraphics[scale=0.34]{SCHEMATIC_EFFICIENCY.png}
      \captionof{figure}{Circuit with multimeters}
      \label{fig:schematic_efficiency}
    \end{Figure}
    To measure the efficiency of the circuit, four measurements were taken.
    A current and a voltage measurement were taken at the supply and load,
    respectively. The measurements were taken as shown in figure 
    \ref{fig:schematic_efficiency}. The energy used by the supply and the load 
    can be calculated using equation \ref{eq:power}. Then, using equation
    \ref{eq:efficiency}, efficiency can be calculated.
    \begin{equation}
      \label{eq:power}
      P [W] = U[V] \cdot I[A]
    \end{equation} 
    \begin{equation}
      \label{eq:efficiency}
      \eta[\%] = \frac{P_{load}[W]}{P_{supply}[W]} \cdot 100\%
    \end{equation}
  

  \subsection{Noise}
    To measure the noice of the circuit an oscilloscope probe was placed on the
    variable resistor in figure \ref{fig:schematic_full}. Over the period of 1 
    millisecond, 20,000 points were measured. 

    Noise has several metrics in which it can be quantized. Two metrics were
    calculated, the standard devation (SD) and the peak to peak noise. 


  \subsubsection{Peak to peak}\label{section:peak_to_peak}
    Peak to peak is the simplest way to look at noise. The signal has a stationary
    mean over the period of 1 millisecond. Thus, the highest measured value can be
    subtracted from the lowest measured value.

\begin{lstlisting}[language=Python, caption={Peak to peak function}]
def PK_PK(all_data, ch):
  output_pk = []
  for data in all_data:
      maximum = max(data[ch + 1])
      minimum = min(data[ch + 1])
      pk_pk = maximum-minimum
      output_pk.append(pk_pk)
  return output_pk
\end{lstlisting}


  \subsubsection{Standard Deviation}\label{section:standard_devation}
    The second metric used to measure noise was the standard deviation (SD). 
    Unlike peak to peak, it gives a better impression of the average noise over 
    a longer period. SD can be calculated using equation \ref{eq:sd}.

    \begin{equation}
      \label{eq:sd}
      \sigma = \sqrt{\frac{1}{N}\sum^{N-1}_{i=0}(x[i] - \mu)^2}
    \end{equation}

    \noindent Where $x[i]$ is each voltage measurement, $\mu$ is the mean of the 
    signal and $N$ is the total amount of samples.

\begin{lstlisting}[language=Python, caption={SD function}]
def SD(all_data, ch):
  output_SD = []
  for data in all_data:
      N = len(data[ch + 1])
      MU = sum(data[ch + 1])/N
      x = 0
      for val in data[ch + 1]:
          x += (val-MU)**2
      SD = sqrt((1/N) * x)
      output_SD.append(SD)
  return [output_load, output_SD]
\end{lstlisting}


  \subsection{Ripple characteristics} \label{section:ripple}
    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{RIPPLE.png}
      \captionof{figure}{Close up of a ripple}
      \label{fig:ripple}
    \end{Figure}
    A significant source of the noise was caused by a specific ripple, shown in
    figure \ref{fig:ripple}. 
    This ripple coincided with the MOSFETs opening or closing.
    
    To further characterize this behaviour a close up measurement was taken.
    The oscilloscope was set to AC-coupling and the settigns were adjusted
    for the ripple to be full screen. Then, two additional characteristics can 
    be calculated. The ripple's peak to peak voltage and the ripple's (most prevalent) 
    frequency. The peak to peak value can be calculated using the method described in 
    section \ref{section:peak_to_peak}.

    To measure the frequency of the signal using an FFT, it had to be pre-processed 
    first using a Hamming window, this eliminates sharp edges at the edge of the 
    measurement, causing unwanted frequencies to appear in the frequency domain. 
    \begin{equation} 
      \label{eq:hamming}
      % 0.54 - 0.46 * cos(2*np.pi*(n/N))
      w(i) = 0.54 - 0.46 \cdot cos \left(2 \pi \frac{i}{N} \right)
    \end{equation}
    Where $i$ is the current sample and $N$ is the total amount of samples. Each
    sample in the signal can be multiplied by the corresponding value in the window,
    preparing the signal for the FFT.

\begin{lstlisting}[language=python, caption={Hamming function}]
def window(y):
  N = len(y)
  hamming = []
  for n in range(N):
      hamming.append(
        0.54 - 0.46 * cos(2*np.pi*(n/N)))
  y = [hamming[i]*x for i, x in enumerate(y)]
  return y
\end{lstlisting}

\begin{lstlisting}[language=python, caption={FFT function}]
def Freq(all_data, ch):
output_freq = []
for data in all_data:
    # FFT
    # using realfft, 
    # because the signal only has real parts 
    y = np.fft.rfft(data[ch + 1])

    # Window
    y = window(y)

    # Calculate the bins
    dt = data[1][1] - data[1][0]
    x = np.fft.rfftfreq(len(data[ch+1]), dt)
    
    # find the maximum, max() and np.argmax() 
    # are not playing nice with 
    # imaginary numbers
    maximum = 0
    max_idx = 0
    offset = 1  # Skip the first bin, DC offset
    for idx, val in enumerate(y[offset:]):
        mag = sqrt(val.real**2 + val.imag**2)
        if mag > maximum:
            maximum = mag
            max_idx = idx + offset
    
    # get the frequency of the maximum
    output_freq.append(x[max_idx])

return output_freq
\end{lstlisting}

  \subsection{Start up} \label{section:start_up}
    The last characteristics is the start up, specifically the different rise times
    under load. The voltage was measured at the output as the supply was turned on.

    Different rise times can be defined. First off, $\tau$ and $2 \tau$ were
    defined as $63\%$ and $95\%$ respectively. Further more, 'rise time' was defined
    as $90\%$, a metric used often in control theory. 

    A problem that occured during the measurements, is that the aforementioned 
    ripples and noise would cause erroneous readings. As such, the signal was
    filtered using a low pass filter ($\tau = 0.2ms$), reducing the high frequencies from the 
    signal. 

\begin{lstlisting}[language=python, caption={LPF snippet}]
initial = data[3][0]
dt = data[1][1] - data[1][0]

x_filter = [initial]
for i in range(1, len(data[3])):
    x_dot_filter = \
      (data[3][i] - x_filter[i-1])/0.0002
    x_filter.append(
      x_filter[i-1] + x_dot_filter*dt)
\end{lstlisting}


  \section{Results}
    In this section the results from section \ref{section:methodology} will be 
    discussed, as well as discuss some probable causes for unknown or unintended 
    results.


  \subsection{Efficiency}
    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{EFFICIENCY_PERCENTAGE.jpg}
      \captionof{figure}{Efficiency vs load}
      \label{fig:efficiency}
    \end{Figure}
    \noindent The results for the efficiency measurements, as described in section 
    \ref{section:efficiency} are displayed in figure \ref{fig:efficiency}. 
    The $7V$ measurements follow a predictable curve, however, the $3.3V$ makes
    an unexplained jump back to a higher percentage.


  \subsection{Noise} \label{section:result_noise}
    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{SNR_LOADVSPKPK.jpg}
      \captionof{figure}{Noise $V_{pp}$ vs load}
      \label{fig:noise_pkpk}
    \end{Figure}
    \noindent The results for the noise measurements, as described in section 
    \ref{section:peak_to_peak} are displayed in figure \ref{fig:noise_pkpk}.
    The peak to peak voltage is a significant fraction of the output voltage,
    with $3V$ peaking at $33\%$. It seems there is a relation between peak to
    peak voltage and the output voltage as well, as $7V$ has more noise than
    $3.3V$
    
    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{SNR_LOADVSSD.jpg}
      \captionof{figure}{Noise SD vs load}
      \label{fig:noise_sd}
    \end{Figure}
    \noindent The results for the noise measurements, as described in section 
    \ref{section:standard_devation} are displayed in figure \ref{fig:noise_sd}.
    Although the voltage peaks are high, the standard deviation of the noise is 
    in the range of millivolts. The trend that a higher output voltage has more 
    noise is continued in this graph.


  \subsection{Ripple} \label{section:ripple_result}
    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{RIPPLE_LOADVSPKPK.jpg}
      \captionof{figure}{Ripple $V_{pp}$ vs load}
      \label{fig:ripple_pkpk}
    \end{Figure}
    \noindent The results for the ripple measurements, as described in section 
    \ref{section:ripple} are displayed in figure \ref{fig:ripple_pkpk}. The 
    voltage level in the graph  seems to confirm that the peak to peak noise, 
    seen in section \ref{section:result_noise} is caused by the ripple. 

    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{RIPPLE_LOADVSFREQ.jpg}
      \captionof{figure}{Frequency ripple vs load}
      \label{fig:ripple_freq}
    \end{Figure}
    \noindent The frequency of the ripple is roughly $38 MHz$ and independant of
    the load. To figure out if this ripple is caused by the combination of the 
    inductor and the capactitor the following equation can be used.
    \begin{equation}
      f = \frac{1}{2 \pi \sqrt{LC}}
    \end{equation}
    Using the values from figure \ref{fig:schematic_full}, the resonating frequency
    of the circuit should be around $27kHz$. Thus, this cannot be the cause of
    the high frequency. As the frequency of the ripple is magnitudes higher
    than the LC-circuit's resonant frequency, what is seen is most likely the
    Self Resonating Frequency (SRF) of the inductor. Typically the SRF is
    $>10 MHz$, so that could be a probable source of the high frequencies.

    
    \subsection{Start Up}
    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{TRANSIENT_RISE_10_MA.jpg}
      \captionof{figure}{Start up 10 mA}
      \label{fig:start_10}
    \end{Figure}
    
    \begin{Figure}
      \centering
      \includegraphics[scale=0.5]{TRANSIENT_RISE_50_MA.jpg}
      \captionof{figure}{Start up 50 mA}
      \label{fig:start_50}
    \end{Figure}

    \begin{center}
    \captionof{table}{$10 mA$}
    \label{table:start_10}
    \begin{tabular}{llll}
    Metric  & $\tau$ & $2\tau$ & Rise time \\
    Percentage [$\%$] & 63 & 95 & 90 \\
    Time [$s$] & 0.031 & 0.075 & 0.053 \\
    \end{tabular}
    \end{center}
    
    \begin{center} 
    \captionof{table}{$50 mA$}
    \label{table:start_50}
    \begin{tabular}{llll}
    Metric  & $\tau$ & $2\tau$ & Rise time \\
    Percentage [$\%$] & 63 & 95 & 90 \\
    Time [$s$] & 0.033 & 0.048 & 0.043 \\
    \end{tabular}
    \end{center}
    
    \noindent The results for the start up  measurements, as described in section 
    \ref{section:start_up} are displayed in figure \ref{fig:start_10} and 
    \ref{fig:start_50}, and table \ref{table:start_10} and \ref{table:start_50}.

    Counterintuitively, the rise time is shorter with a higher load. 
      

  \section{Conclusion}
  In conclusion, the circuit does what it's supposed to do. It regulates well between
  $7V$ and $3.3V$ and it's able to supply the required loads. The efficiency of
  the circuit is respectable, with a peak efficiency of $86\%$ and a lowest 
  efficiency of $78\%$. The output noise is a problem, and it would be too high
  for normal use. Lastly, the PI controller works, but can easily be saturated and
  become unstable. 
  
  \subsection{Recommendations}
  The circuit can be improved in several ways. The most significant improvement would be to replace the breadboard in favour of a soldered PCB, this would significantly improve the stability of the system and reduce noise. During testing, it was found that Heisenberg's uncertainty principle was enough to influence the behaviour of the circuit. Simply observing the output voltage was enough to make it fluctuate.
  \\\\
  Using MOSFETs with a lower $R_{DS(on)}$ compared to the BS170 would allow the inductor to charge quicker, increasing the efficiency of the circuit.
  \\\\
  The current push-pull driver could be replaced with a dedicated gate driver, such as the IR2125 IGBT Driver IC. This would allow for a more stable and faster switching of the MOSFETs, while reducing the amount of IO used on the MCU. 
  \\\\
  As mentioned in section \ref{control}, the control loop can be improved. The current implementation of the PI controller is rather unstable and requires more tuning. 
\end{multicols}

\bibliographystyle{IEEEtran}
\bibliography{main}

\end{document}