\begin{filecontents}[overwrite]{\jobname.bib}
\end{filecontents}

\documentclass{article}

\usepackage[backend=biber]{biblatex}

\addbibresource{\jobname.bib}

\usepackage{circuitikz}
\usepackage{siunitx}

\usepackage[a4paper, total={6in, 8in}]{geometry}

\usepackage{amsmath}
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}

\usepackage{cancel}

\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage{framed}
\usepackage{longtable,booktabs,array}
\usepackage{caption}

\title{Lab 1 \\\quad\\ \small performed 2025-01-27}
\author{Martin Kennedy}

\begin{document}
\maketitle

\section{Introduction}
Unlike DC signals, AC signals are time-varying, posing unique
challenges to recording, characterizing and otherwise studying them.

In this lab, we will examine the circuit depicted in fig.~\ref{fig:circ}, and
focus on comparing the measurement of one aspect of an AC signal --
the RMS voltage -- as seen by two tools: the Digital Multimeter (DMM),
and the oscillscope. We will use numerical and analytical methods to
model this circuit and derive expected RMS values for comparison.

Figure~\ref{fig:circ} depicts the circuit we are studying.

\begin{figure}[h]
  \caption{Our simple circuit}
  \label{fig:circ}
  \centering
  \begin{circuitikz}[american voltages]
    \draw
    (0,0) to [sV,l=$V_{in}$] (0,2)
    to (3,2)
    to [ R, l_=$R$ ] (3,0)
    to (0,0)
    ;
  \end{circuitikz}
\end{figure}

\section{Analytic Modeling Results}

In the course of our lab procedure, three different types of AC signals are provided at $V_{in}$:
\begin{enumerate}
\item
  \label{type:ac}
  A sinusoidal signal with no DC offset, at two different frequencies and magnitudes
\item
  \label{type:acoffset}
  The same sinusoidal signals as above, but with a small positive DC offset
\item
  \label{type:squarewave}
  A square wave voltage, at $25\%$ and $50\%$ duty cycles, with two different AC magnitudes.
\end{enumerate}

For a signal $x(t)$, we are given the following formula for its RMS voltage:

\begin{equation} \label{eq:rms}
X_{RMS} = \sqrt{\frac{1}{T}\int{x(t)^{2}dt}}
\end{equation}

I chose to analyze signal types ~\ref{type:ac} and
~\ref{type:acoffset}, to calculate the RMS AC voltages we expect to
see.

\subsection{Signal type ~\ref{type:ac}}

Signal type ~\ref{type:ac} can be modeled as:

\begin{equation}
  v_{\ref{type:ac}}(t) = V_m\cos{(\omega{t})}
\end{equation}

(We can arrive here from the general form,
$V_m\cos{(\omega{t}+\theta)}$, by shifting the beginning and end of
our measurement window by $-\theta$, as the oscilloscope will do when
it measures RMS voltages from a peak-to-peak cycle.)

Substituting $v_{\ref{type:ac}}$ into equation
~\ref{eq:rms}, the RMS voltage $V_{\ref{type:ac}RMS}$ can be
expressed as:

\begin{align*}
  V_{\ref{type:ac}RMS} \
  &= \sqrt{\frac{1}{T}\int_{0}^{T}{V_{m}^{2}\cos^{2}{(\omega{t})}dt}} \\
  &= V_{m}\sqrt{\frac{1}{T} \int_{0}^{T}{\frac{1}{2} + \frac{\cos{(2\omega{t})}}{2}dt}} \\
  &= V_{m}\sqrt{\frac{1}{T} \left[ \frac{t}{2} + \frac{1}{4\omega} \sin{(2\omega t)} \right]_{0}^T} \\
  &= V_{m}\sqrt{\frac{1}{T} \left( \frac{T}{2} + \frac{1}{4\omega} \cancel{\sin{(2\omega T)}} - \frac{1}{4\omega} \cancel{\sin{(0)}} \right)} \\
  &= V_{m}\sqrt{\frac{1}{\cancel{T}} \frac{\cancel{T}}{2}} \\
  &= \frac{V_{m}}{\sqrt{2}}. \numberthis \label{deriv:ac}
\end{align*}

\subsection{Signal type ~\ref{type:acoffset}}

Signal type ~\ref{type:acoffset} can be modeled as:

\begin{equation}
  v_{\ref{type:acoffset}}(t) = V_m\cos{(\omega{t})}+V_{b}
\end{equation}

Thus, substituting $v_{\ref{type:acoffset}}$ into equation
~\ref{eq:rms}, the RMS voltage $V_{\ref{type:acoffset}RMS}$ can be
expressed as:

\begin{align*}
  V_{\ref{type:acoffset}RMS} \
  &= \sqrt{\frac{1}{T}\int_{0}^{T}{ \left( V_{m} \cos{(\omega{t})} + V_{b} \right)^{2} dt}} \\
  &= \sqrt{\frac{1}{T} \left( V_{m} \right)^{2} \int_{0}^{T}{\cos^{2}{(\omega{t})} + 2 \frac{V_{b}}{V_{m}} \cos{(\omega{t})} + \left( \frac{V_{b}}{V_{m}} \right)^{2} dt}} \\
  &= V_{m}\sqrt{\frac{1}{T} \int_{0}^{T}{\frac{1}{2} + \frac{\cos{(2\omega{t})}}{2} + 2 \frac{V_{b}}{V_{m}} \cos{(\omega{t})} + \left( \frac{V_{b}}{V_{m}} \right)^{2} dt}} \\
  &= V_{m}\sqrt{\frac{1}{T} \left[ \frac{t}{2} + \frac{1}{4\omega} \sin{(2\omega t)} + \frac{2 V_{b}}{\omega V_{m}} \sin{(\omega t)} + t \left( \frac{V_{b}}{V_{m}} \right)^{2} \right]_{0}^T} \\
  &= V_{m}\sqrt{\frac{1}{T} \left( \frac{T}{2} + \frac{1}{4\omega} \cancel{\sin{(2\omega T)}} + \frac{2 V_{b}}{\omega V_{m}} \cancel{\sin{(\omega T)}} + T \left( \frac{V_{b}}{V_{m}} \right)^{2} - \frac{1}{4\omega} \cancel{\sin{(0)}} - \frac{2 V_{b}}{\omega V_{m}} \cancel{\sin{(0)}}\right)} \\
  &= V_{m}\sqrt{\frac{1}{\cancel{T}} \left( \cancel{T} \right) \left( \frac{1}{2} + \left( \frac{V_{b}}{V_{m}} \right)^{2} \right)} \\
  &= V_{m}\sqrt{\frac{1}{2} + \left( \frac{V_{b}}{V_{m}} \right)^{2}} \\
  &= \sqrt{\frac{V_{m}^{2}}{2} + V_{b}^{2}}. \numberthis \label{deriv:acoffset}
\end{align*}

\section{Numerical Modeling Results}
\section{Experimental Results}
\section{Data Comparison}
\section{Conclusions}

\begin{longtable}[]{@{}lllllllll@{}}
\toprule
\endhead
\bottomrule
\endlastfoot
Set Mag. & Set Freq. & Read Mag. & Read Period & Calc. Freq. & Calc. RMS & Meas. RMS \\
2V       & 100 Hz    & 2.10 V    & 9.994  ms   & XXXXXHz     & .....V    & 1.4236 V  \\
2V       & 50 kHz    & 2.05 V    & 19.947 us   & a           & d         & 1.4112 V  \\
5V       & 100 Hz    & 5.11 V    & 10.007 ms   & b           & e         & 3.5522 V  \\
5V       & 50 kHz    & 5.11 V    & 20.005 us   & c           & f         & 3.5451 V  \\
\end{longtable}


\nocite{*}
\printbibliography

\end{document}
