Lab1/Lab1.tex

497 lines
19 KiB
TeX

\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}
We will be providing multiple variations on three different types of
AC signals at $V_{in}$.
We selected a resistor ${R=\SI{7.5}{\kohm}}$, with a $5\%$ precision
band; note that the exact resistance value of the resistor really
isn't important, since we are not studying its characteristics; we
only need its impedance to be much larger than the 50-ohm internal
resistance of our function generator.
\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}
\subsection{Signal type ~\ref{type:ac} (sinusoidal AC)}
Given frequency $\omega$ (rad./s) and magnitude (peak amplitude) $V_m$, 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} (sinusoidal AC with DC offset)}
Given frequency $\omega$ (rad./s), peak amplitude $V_m$ and DC offset $V_b$, we
can model signal type ~\ref{type:acoffset} 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*}
\begin{quote}
Note: I won't show it here, but general, for a periodic signal made
of two components $v = v_a + v_b$, where the two components are of
different frequencies, it can be shown from Equation ~\ref{eq:rms}
that the RMS voltage $V_{RMS}$ of the combined signal is equal to
the root of the sum of the squares of the RMS voltages of its
additive components, i.e.
\begin{equation*}
\label{eq:rms_sq_comp}
V_{RMS} = \sqrt{{V_{aRMS}}^{2} + {V_{bRMS}}^{2}}.
\end{equation*}
\end{quote}
\subsection{Signal type ~\ref{type:squarewave} (square wave)}
Given magnitude $V_{m}$, frequency $\frac{1}{T}$ (Hz), and duty cycle
$D$, our square wave (type ~\ref{type:squarewave}) can be modeled as:
\begin{equation}
0 < t \leq T, \quad v_{\ref{type:squarewave}}(t) = \\
\begin{cases}
V_{m} & 0 \leq t < D T \\
-V_{m} & D T \leq t < T
\end{cases}
\end{equation}
This time, the integration is trivial: at any time,
$v_{\ref{type:squarewave}}(t)$ is either $V_{m}$ or $-V_{m}$, so
$(v_{\ref{type:squarewave}}(t))^{2}={V_{m}}^{2}$:
\begin{equation*}
V_{\ref{type:squarewave}RMS} = \sqrt{\frac{1}{T} \int_{0}^{T}{(V_{m})^{2}dt} } = \sqrt{\frac{1}{\cancel{T}} \cancel{T} {V_{m}}^{2}} = V_{m}. \
\numberthis \label{deriv:squarewave}
\end{equation*}
We will reference these three derivations in our ``Experimental Results'' section below.
\section{Numerical Modeling Results}
For the numerical modeling, I opted to simulate signals types
~\ref{type:ac} (sinusoidal AC about 0V) and ~\ref{type:squarewave}
(square wave).
In LTSpice, I assembled the circuit shown in Figure
~\ref{fig:ac_2v_100hz_diag}; for the first signal, I specified a
transient simulation from 0.1s to 0.2s:
\begin{figure}[h]
\caption{Our first sinusoidal signal circuit, simulated in LTSpice}
\label{fig:ac_2v_100hz_diag}
\centering
\includegraphics[width=0.6\textwidth]{lab1_ac_2v_100hz_diag}
\end{figure}
I then used Ctrl+click on the signal label \texttt{V(n001)} to pull up
the Waveform dialog shown in Figure ~\ref{fig:ac_2v_100hz_num},
yielding a numerically-derived RMS voltage:
\begin{figure}[h!]
\caption{This LTSpice dialog shows us measurements of our interval; of most interest is RMS}
\label{fig:ac_2v_100hz_num}
\centering
\includegraphics[width=0.3\textwidth]{lab1_ac_2v_100hz_num}
\end{figure}
I had to adjust the size length of the transient simulation to get an
easily-viewable result.
For the square-wave values: I switched from the \texttt{SINE} command
to \texttt{PULSE}; this command requires a rise-time and fall-time,
which are set as low as possible to mimic a true square-wave; in
addition, we specify the duty cycle and frequency indirectly, instead
by specifying the on time and period, as seen in Figure
~\ref{fig:pulse_ltspice}.
\begin{figure}[h]
\caption{The LTSpice \texttt{PULSE} command menu}
\label{fig:pulse_ltspice}
\centering
\includegraphics[width=\textwidth]{lab1_ltspice_pulse}
\end{figure}
The results of the numerical modeling are compiled below, in Tables
~\ref{table:comparison_ac} and ~\ref{table:comparison_squarewave}.
\section{Experimental Results}
\begin{figure}[h]
\caption{Breadboard, with resistor $R$ connected to our DMM, scope and function generator}
\label{fig:breadboard}
\centering
\includegraphics[width=\textwidth]{lab1breadboard}
\end{figure}
The circuit we implemented can be seen in
Figure~\ref{fig:breadboard}. This configuration connects one resistor
leg with the signal lead of the oscilloscope, the positive lead each
of the function generator and DMM; repeat the same with the other
resistor leg, the ground lead of the scope, and the negative leads of
each the DMM and function generator. In effect, all pieces of
equipment are placed in parallel, consistent with any other procedure
for measuring the facets of a signal's voltage.
(Our circuit builder was Peyton; our checker was Will; I was grouped
with these two as there were an odd number of students.)
We used this configuration for the entire lab procedure, and adjusted
both our function generator and oscilloscope through the variations of
the three different signal types; in all three cases, we first used
the oscilloscope to read the period and magnitude of the signal, and
then used the DMM to measure the signal's RMS voltage.
Note: our use of the oscilloscope for magnitude measurements will
later be identified as a key source of error.
\subsection{Experiment ~\ref{type:ac} (sinusoidal AC)}
Given a read period of $T$ seconds, we calculate the frequency as
$\frac{1}{T}$ Hz. For the RMS voltage, we use the formula derived at
Equation ~\ref{deriv:ac}:
\begin{equation*}
V_{\ref{type:ac}RMS} = \frac{V_{m}}{\sqrt{2}}
\end{equation*}
\begin{longtable}[]{@{}lllllllll@{}}
\toprule
\caption {Voltage measurements and period for ~\ref{type:ac} (sinusoidal AC)}
\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 & 100.1 Hz & 1.48 V & 1.4236 V \\
2V & 50 kHz & 2.05 V & 19.95 us & 50.13 kHz & 1.45 V & 1.4112 V \\
5V & 100 Hz & 5.11 V & 10.01 ms & 99.90 Hz & 3.61 V & 3.5522 V \\
5V & 50 kHz & 5.11 V & 20.01 us & 49.98 kHz & 3.61 V & 3.5451 V \\
\end{longtable}
Comparing the calculated and measured RMS values:
\begin{longtable}[]{@{}llll@{}}
\toprule\noalign{}
\caption {RMS Error for ~\ref{type:ac} (sinusoidal AC)}
\endhead
\bottomrule\noalign{}
\endlastfoot
& Calc. RMS & Meas. RMS & Error \% \\
Case 1 & 1.48 V & 1.4236 V & 3.81 \% \\
Case 2 & 1.45 V & 1.4112 V & 2.68 \% \\
Case 3 & 3.61 V & 3.5522 V & 1.60 \% \\
Case 4 & 3.61 V & 3.5451 V & 1.80 \% \\
\end{longtable}
\subsection{Experiment ~\ref{type:acoffset} (sinusoidal AC with DC offset)}
Given a read period of $T$ seconds, we calculate the frequency as
$\frac{1}{T}$ Hz. For this signal's RMS voltage, we use the formula derived at
Equation ~\ref{deriv:acoffset}:
\begin{equation*}
V_{\ref{type:acoffset}RMS} = \sqrt{\frac{V_{m}^{2}}{2} + V_{b}^{2}}
\end{equation*}
\begin{longtable}[]{@{}lllllllll@{}}
\toprule
\caption {Voltage measurements and period for ~\ref{type:acoffset} (sinusoidal AC with DC offset)}
\endhead
\bottomrule
\endlastfoot
Set Mag. & Set Freq. & DC bias & Read Mag. & Read Period & Calc. Freq. & Calc. RMS & Meas. RMS \\
2V & 100 Hz & 2V & 2.13 V & 10.00 ms & 100.0 Hz & 2.50 V & 2.44 V \\
2V & 100 Hz & -5V & 2.11 V & 9.996 ms & 100.0 Hz & 5.22 V & 5.19 V \\
5V & 100 Hz & 2V & 5.15 V & 9.998 ms & 100.0 Hz & 4.15 V & 4.05 V \\
5V & 100 Hz & -5V & 5.20 V & 9.997 ms & 100.0 Hz & 6.21 V & 6.16 V \\
\end{longtable}
Comparing the calculated and measured RMS values:
\begin{longtable}[]{@{}llll@{}}
\toprule\noalign{}
\caption {RMS Error for ~\ref{type:acoffset} (sinusoidal AC with DC offset)}
\endhead
\bottomrule\noalign{}
\endlastfoot
& Calc. RMS & Meas. RMS & Error \% \\
Case 1 & 2.50 V & 2.44 V & 2.40 \% \\
Case 2 & 5.22 V & 5.19 V & 0.57 \% \\
Case 3 & 4.15 V & 4.05 V & 2.41 \% \\
Case 4 & 6.21 V & 6.16 V & 0.81 \% \\
\end{longtable}
\subsection{Experiment ~\ref{type:squarewave} (square wave)}
Given a read period of $T$ seconds, we calculate the frequency as
$\frac{1}{T}$ Hz. As we saw when deriving Equation
~\ref{deriv:squarewave}, this signal's RMS voltage is the same as its
magnitude.
\begin{longtable}[]{@{}lllllllll@{}}
\toprule
\caption {Voltage measurements and period for ~\ref{type:squarewave} (square wave)}
\endhead
\bottomrule
\endlastfoot
Set Mag. & Set Freq. & Duty & Read Mag. & Read Period & Calc. Freq. & Calc. RMS & Meas. RMS \\
2V & 100 Hz & 25\% & 2.11 V & 10.00ms & 100.0 Hz & 2.11 V & 2.02 V \\
2V & 100 Hz & 50\% & 2.13 V & 10.00ms & 100.0 Hz & 2.13 V & 2.01 V \\
5V & 100 Hz & 25\% & 5.20 V & 9.998ms & 100.0 Hz & 5.20 V & 5.04 V \\
5V & 100 Hz & 50\% & 5.20 V & 9.999ms & 100.0 Hz & 5.20 V & 5.01 V \\
\end{longtable}
Comparing the calculated and measured RMS values:
\begin{longtable}[]{@{}llll@{}}
\toprule\noalign{}
\caption {RMS Error for ~\ref{type:squarewave} (square wave)}
\endhead
\bottomrule\noalign{}
\endlastfoot
& Calc. RMS & Meas. RMS & Error \% \\
Case 1 & 2.11 V & 2.02 V & 4.27 \% \\
Case 2 & 2.13 V & 2.01 V & 5.63 \% \\
Case 3 & 5.20 V & 5.04 V & 3.08 \% \\
Case 4 & 5.20 V & 5.01 V & 3.65 \% \\
\end{longtable}
Notably, this is the first time we have a >5\% error value; we will
review this item in TODO WHERE?
\section{Data Comparison}
Here, I publish the modeling results for ~\ref{type:ac} (sinusoidal AC
about 0V).
\begin{longtable}[]{@{}lllll@{}}
\toprule\noalign{}
\caption {RMS Voltage comparison for ~\ref{type:ac} (sinusoidal AC)}
\label {table:comparison_ac}
\endhead
\bottomrule\noalign{}
\endlastfoot
RMS & Case 1 & Case 2 & Case 3 & Case 4 \\
Analytic (A) & 1.48 V & 1.45 V & 3.61 V & 3.61 V \\
Numerical (N) & 1.4125 V & 1.4124 V & 3.5311 V & 3.5311 V \\
Experimental (E) & 1.4236 V & 1.4112 V & 3.5522 V & 3.5451 V \\
A-N error & 4.78 \% & 2.66 \% & 2.23 \% & 2.23 \% \\
A-E error & 3.96 \% & 2.75 \% & 1.63 \% & 1.83 \% \\
N-E error & 0.78 \% & 0.09 \% & 0.59 \% & 0.39 \% \\
\end{longtable}
Next, I publish the modeling results for ~\ref{type:squarewave}
(square-wave AC).
\begin{longtable}[]{@{}lllll@{}}
\toprule\noalign{}
\caption {RMS Voltage comparison for ~\ref{type:squarewave} (square-wave AC)}
\label {table:comparison_squarewave}
\endhead
\bottomrule\noalign{}
\endlastfoot
RMS & Case 1 & Case 2 & Case 3 & Case 4 \\
Analytic (A) & 2.11 V & 2.13 V & 5.20 V & 5.01 V \\
Numerical (N) & 1.9999 V & 1.9999 V & 4.9997 V & 4.9997 V \\
Experimental (E) & 2.02 V & 2.01 V & 5.04 V & 5.01 V \\
A-N error & 5.51 \% & 6.50 \% & 4.01 \% & 4.01 \% \\
A-E error & 4.46 \% & 5.97 \% & 3.17 \% & 1.96 \% \\
N-E error & 1.00 \% & 0.50 \% & 0.80 \% & 1.97 \% \\
\end{longtable}
\section{Conclusions}
Before completing the lab report out and making firm conclusions, I'd
like to address our two analysis questions:
\begin{quote}
PSpice: In the transient simulation profile: what is the role of
``Maximum Step Size''? Create an example and include waveform images
to illustrate your point.
\end{quote}
Returning to our simulation of a 5V sinusoidal waveform with no DC
bias at 50kHz: the larger we allow the ``Step Size'' to go, the fewer
timesteps LTSpice will take when performing its numerical simulation,
and thus the less precise our RMS value is / the less close it is to
$\frac{5}{\sqrt{2}} \approx 3.53553 ...$. In Figures
~\ref{fig:ltspice_large_timestep},
~\ref{fig:ltspice_large_timestep_num},
~\ref{fig:ltspice_small_timestep}, and
~\ref{fig:ltspice_small_timestep_num}, we can see that restricting the
timestep size down to $\SI{1}{\ns}$ brings our RMS voltage much closer
to $\frac{5}{\sqrt{2}} \approx 3.53553$.
\begin{figure}[h]
\caption{The LTSpice simulation with no defined ``Maximum Step Size''}
\label{fig:ltspice_large_timestep}
\centering
\includegraphics[width=0.6\textwidth]{lab1_ltspice_large_timestep}
\end{figure}
\begin{figure}[h]
\caption{The RMS value of the simulation with no defined ``Maximum Step Size''}
\label{fig:ltspice_large_timestep_num}
\centering
\includegraphics[width=0.3\textwidth]{lab1_ltspice_large_timestep_num}
\end{figure}
\begin{figure}[h]
\caption{The LTSpice simulation with a ``Maximum Step Size'' of $\SI{1}{\ns}$}
\label{fig:ltspice_small_timestep}
\centering
\includegraphics[width=0.6\textwidth]{lab1_ltspice_small_timestep}
\end{figure}
\begin{figure}[h]
\caption{The RMS value of the simulation under a ``Maximum Step Size'' of $\SI{1}{\ns}$}
\label{fig:ltspice_small_timestep_num}
\centering
\includegraphics[width=0.3\textwidth]{lab1_ltspice_small_timestep_num}
\end{figure}
As for the second question:
\begin{quote}
Considering your experimental data, explain why we can conclude that
the DMM is showing the true RMS regardless of the waveform.
\end{quote}
We have arrived independently at RMS voltage values multiple ways, and
have discovered that no waveform yields a particularly higher error
for RMS voltage than any other; in fact, more specifically, the
highest error values are associated only with our analytical
derivation, which relies on an oscilloscope-derived magnitude reading.
I'll review the oscilloscope-derived magnitude problem in a moment,
but I wanted to finish my point abaout the suitability of the DMM to
produce RMS voltage measurements: the lack of particularly high error
values when comparing experimental (DMM) RMS values for any of our
various waveforms indicates that the DMM's suitability does not,
within reason, depend on the waveform it's measuring.
As for our error: our largest cases of error are when comparing our
experimental and numerical results to our analytical results for 2V
square-wave AC. Despite setting the function generator to 2V, our
oscilloscope nevertheless read a peak-to-peak magnitude of 4.22 and
4.26V (so, a peak-magnitude 2.11V of 2.13V, respectively). This likely
has to do with how the oscilloscope regisers peak-to-peak voltages,
relying on hazy extremes; but also, notably, because we had our
oscilloscope in 10X mode, reducing its signal sensitivity / resolution.
\nocite{*}
\printbibliography
\end{document}