\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\graphicspath{ {./img/} }
\usepackage[a4paper, margin=35mm]{geometry}

\begin{document}

\section{Oscillating Circuits}

A discussion of synthesizer oscillators requires an introduction to simple oscillating circuits.
We will discuss the most basic oscillating circuits, then we will move on to oscillators with easily-tunable
frequencies. Then we will tackle the most complex issue for the purposes of musical synthesis: \textit{voltage control.}
This is the important part! If we can control an oscillator's frequency by voltage, then we can make another circuit
change its voltage, like a sequencer for example. Let's check it out!

\subsection{Passive Oscillators}

The simplest oscillators are those which rely on \textit{passive components}, electrical components which do not
generate power or 'add amplitude' to a signal. These are components like resistors, inductors, and capacitors which
only dissipate, store, or release already-existing power introduced by another component. An 
example of a non-passive component would be a power supply or a transistor. Passive components tend to be governed by
simpler rules that are easier to understand and exploit.

The simplest oscillating circuit to my knowledge is the Resistor-Inductor-Capacitor or RLC circuit. It's not an 
'RIC' circuit because the letter I commonly represents current in electrical engineering, so we use L to indicate 
inductors or inductance. 

The diagram above depicts an RLC-circuit, with each component in series. We can come up with an equation to describe its behavior,
but first we need to know how each component responds to voltage and current. \textbf{Resistors} are governed by \textbf{Ohm's Law}:
\[
	V = IR, \hspace{8mm} I = \frac{V}{R},
\]
where $R$ is resistance, measured in Ohms ($\Omega$). Resistors are called \textbf{linear components} because their voltage-current
response is linear i.e. an increase in voltage or current causes a linear increase in the other.
\textbf{Inductors} are governed by:
\[
	V = L\frac{di}{dt}, \hspace{8mm} i = \frac{1}{L} \int V \,dt
\]
where $L$ is inductance, measured in Henries (H). Note that this means that the voltage across an inductor responds to a change
in current. If a current is constant, then the voltage vanishes. But if we change the current, a voltage is generated across the
inductor. That means if we send an \textit{alternating current} which is always changing through the inductor, then we will get a 
voltage across the inductor. This is unusual because an inductor is essentially just a short-circuit and yet when a changing
current passes through it, it will have a voltage like a resistive element! You could say that inductors \textit{resist a change
in current} in this sense of resistance.

\pagebreak

Finally, \textbf{Capacitors} are governed by the equation:
\[ i = C\frac{dv}{dt}, \]
where $C$ is the capacitance of the component, measured in Farads (F). Here, the capacitor's behavior is similar but the relationship is sort of reversed or
flipped, if you will. Now, if we have a constant voltage across the capacitor then no current will flow. This makes sense because
a capacitor is essentially made from two conductive plates seperated from one another by a non-conductive material. This is
effectively a break in the circuit, as indicated by the standard electrical symbol for a capacitor.
But if we change the voltage across the capacitor, it starts to conduct! changing the voltage 
somehow forces current to flow between the plates! It's no mystery, this is due to some complicated rules of physics known generally
as \textit{electrodynamics}, but that's for another time.

Okay. We can connect these three equations mathematically by utilizing \textbf{Kirchoff's Laws of Voltage and Current}. This sounds
a little complicated but it relies on some straightforward principles. The core idea is that any current which enters a wire junction
(usually called a \textit{node}) must exit the junction in some way. For many reasons, another logical rule that follows from this 
is that the voltages across each component in a loop must sum to zero. If this were not true, it would result in charge pooling
somewhere in the wire, which is almost always impossible. Here's the laws:

\begin{itemize}
	\item \textbf{KIRCHOFF'S CURRENT LAW:} All current entering a node must exit i.e. the sum of currents entering/leaving a node 
		must always be \textit{zero.}
	\item \textbf{KIRCHOFF'S VOLTAGE LAW:} The sum of component voltages over any loop of wire must be zero.
\end{itemize}

If the current entering each node must also be leaving it, in our RLC circuit this means the current through each node is the same.
This is because the circuit is a closed loop! If the current were not the same across each node, then it would have to pool somewhere
or escape into thin air. We can express this mathematically:
\[i_{R} + i_{L} + i_{C} = 0.\]
We know the equations for the current through a resistor and capacitor:
\[\frac{v}{R} + i_{L} + C\frac{dv}{dt} = 0.\]
We know that voltage across an inductor is proportional to the change in current. If we integrate with respect to time,
we can get a figure for the current through an inductor:
\[i_{L} = \frac{1}{L} \int v \,dt\]
\[\frac{v}{R} + \frac{1}{L} \int v \,dt + C\frac{dv}{dt} = 0.\]
Now we just differentiate:
\[C\frac{d^{2}v}{dt^{2}} + \frac{1}{R}\frac{dv}{dt} + \frac{1}{L} v =0,\] or
\[av'' + bv' +cv = 0; \hspace{6mm} a=C,\hspace{4mm}b=\frac{1}{R},\hspace{4mm}c= \frac{1}{L}.\]
I would like to state here that the variable $v$ is a function dependent on time, so it should be written as $v(t)$ for clarity. We
prefer to be unclear here, because it is less cluttered to write equations that way. Just keep this in mind.

What we have stumbled upon here is a truth that I find quite exciting but it has been the nightmare of many underclassmen electrical
engineers forced to learn this before finishing their math coursework (who could I possibly be talking about here?): This circuit
is governed by a \textbf{homogenous second-order ordinary differential equation!}
\pagebreak
Unfortunately we cannot go over the basics of ODE's here. Like many stressed undergraduate engineers before you, you will have
to take my word as gospel. A homogenous second-order ODE is basically an equation where the function ($v$ in this case)
is not defined directly in terms of an independent variable like time or $x$ or space etc, 
but in terms of its own differentials. This equation is \textit{second-order} because the function is defined in terms of its
second differential. If you are very clever, you may already be thinking of how one might solve such an equation to find
$v(t)$ in terms of $t$ alone and not in terms of its differentials. If you are even cleverer, you may be thinking about 
the classic function $f(t) = e^{x},$ because its differential/integral is itself. If you are some kind of genius, you may even
be considering also the trigonometric functions (sine, cosine, not so much tangent here), because they have a similar property.
This will put you on the right track. Going
forward, you will find that the equations that govern these circuits involve many natural exponentials and sine waves 
because of this property.
Most ordinary differential equations are solved using complicated techniques that involve relating differentials with 
natural exponentials and waves. I cannot get into specifics here but if you are interested, I would keep this property in mind.

OKAY. Back to the equation. Our equation can be represented by something called its \textit{characteristic equation:}
\[ar^{2} + br + c = 0.\]
This is just a representation of the equation that represents the order of each differential by a power of the variable \textit{r}.
If we solve it like a polynomial we get the quadratic formula:
\[r_{1,2} = \frac{-b \pm \sqrt{b^{2} - 4ac}}{2a}.\]
You might realize that it is possible for the root of our characteristic equation to be complex ($r=\lambda + \mu i$). 
When this is the case, our solution is of the form:
\[v(t) = C_{1}e^{\lambda t}\cos(\mu t) + C_{2}e^{\lambda t}\sin(\mu t),\]
where $C_{1}, C_{2}$ are constants determined by the \textit{initial conditions} of the system. Once all the math is done,
we will take a break to build some intuition for all this nonsense. The important part is that the reason this is a solution has
to do with the fact that the differentials of exponentials and sine waves are equal to themselves or related to themselves.

Now we can start getting specific with our constants. If we assume our system begins with the components already charged 
(meaning we have allowed a current source to keep a constant voltage across the components for enough time for the capacitor
to be charged to the positive voltage $V_{+}$), then we can say $v_{0} = V_{+}.$ If it has sat for a long long time, then
there will be no change in voltage, so also we can say $v'_{0} = 0.$ So:
\[v(0) = V_{+} = C_{1}, \hspace{8mm} v'(0) = 0 = \lambda C_{1} + \mu C_{2},\]
\[C_{1} = V_{+}, \hspace{8mm} C_{2} = - \frac{\lambda}{\mu} V_{+}.\]

We can keep defining constants and it will quickly cause your mind to cloud over. The point here is that if we charge up this
circuit and then let it run, the voltage and current will oscillate back and forth. 
I have included below a graph of a potential oscillation. The frequency of this oscillation is determined
by the constant $\mu$, which is equal to the inverse of the root of the
product of inductance and capacitance ($\mu=\frac{1}{\sqrt{LC}}$).
In electrical engineering, it is usually called the \textbf{angular frequency} and is more commonly
denoted with the greek character $\omega$. We found the constants $C_{1},C_{2}$ to show that they are dependent on the
initial voltage we charge the circuit to, as well as the properties of the three components. We have shown mathematically
that the behavior of the circuit under certain parameters (such that $b^{2} < 4ac$) will be oscillatory in nature. But why does
the circuit oscillate sometimes?

\pagebreak

\begin{center}
\includegraphics[scale=0.3]{natural-RLC}
\end{center}

Well, recall that an inductor generates a voltage once the current through it changes, and that a capacitor 
begins conducting current once the voltage across it changes. When we charge the capacitor to some voltage and then close the
circuit, the voltage across the capacitor suddenly becomes the voltage across the resistor as well. When there is a voltage
across a resistor which is connected in a loop, then a current must flow. Conversely, the moment the circuit is closed it 
forces the voltage to drop because a current must flow through the resistor. If the capacitor were alone in series with the resistor,
then it would simply discharge to a voltage of 0. 

As the capacitor pushes current through the inductor, the inductor begins to respond. Initially it acts as a short, but as the 
current through it changes, it begins to generate a voltage. That voltage causes the inductor to push current 
into the capacitor again, charging it. Then once the inductor has discharged its stored energy, the capacitor is recharged
and it begins to conduct again. This continues until all of the electrical energy is dissipated through the resistor
(and realistically also through the resistances in the capacitor and inductor) as heat until there is none left. Kind of cool!

If we tuned the capacitance and inductance properly, we could get one of these circuits to oscillate at an audible frequency.
This would not be an ideal circuit for music making, and there are two big reasons for this:

\begin{itemize}
	\item{The circuit will only oscillate for a short period after it is triggered, preventing us from ever using it
		to play any sustained note.}
	\item{YOU CAN'T TUNE THE FREQUENCY! You would need a variable inductor or transformer, and those solutions quickly 
		become impractical. Unless you like plucky drone music, you're out of luck here.}
\end{itemize}

I'm sure there are many other kinds of passive oscillating circuits, but I think we have done enough here. Next we will 
consider \textit{active oscillators.}

\pagebreak

\subsection{Active Oscillators}

\end{document}
