# Electronics Notes...

## Page Contents

## Charge, Current, Voltage

### Conventional Current And Charge

Historically positive charge moves through the circuit from the positive to negative terminals. This is called *conventional* current.
We now know that it is, in fact, the flow of electrons from the negative to positive terminals that is current. Due to the historical precedent,
current is still often shown as conventional current.

From Wikipedia: Conventional current flows from the positive pole (terminal) to the negative pole. Electrons flow from negative to positive. In a direct current (DC) circuit, current flows in one direction only, and one pole is always negative and the other pole is always positive. In an alternating current (AC) circuit the two poles alternate between negative and positive and the direction of the current (electron flow) reverses periodically.

.

Note that voltages are relative, which is why the negative terminal of the battery can be negative - it depends what the reference voltage you are measuring agains is - e.g. if ground is midway between the two terminals then they will have voltages -A and +A respectively.

Informally, **current is a flow of electric charge**.

Current, $i$, is the amount of charge, $q$, that moves through a point in the circuit at any time. $$i = \frac{\mathrm dq}{\mathrm dt}$$ Charge, $q$, is measured in Coulombs. One electron has a charge of $-1.6 \times 10^{-19}$ Coulombs. This is the smallest unit of charge possible.

### Voltage

Voltage, $V$, is the amount of work (in Joules) that must be done per unit charge to move between two points in a field. $$V_{ab} = \frac{\mathrm dw}{\mathrm dq}$$

### Ohm's Law

Ohm's law gives the relationship between voltage, current and resistance:

$$V = IR$$

### Kirchoff's Laws

#### Nodes, Branches and Loops

**Branch**: A branch represents a single element such as a resistor. I.e., any two terminal element.

**Node**: A node is the point of connection between 2 or more branches.

**Loop**: A loops is any closed path in a circuit.

#### The Laws...

Two important laws: *Kirchoff's voltage law* and *Kirchoff's current law*.

Kirchoff's current law says that the **sum of currents flowing into a node must equal the sum of currents leaving** a node.
This is often expressed in another way: the sum of currents entering a node must always be zero. This works because we
label, by convention, all currents entering the node as positive and all currents leaving the node as negative.

Kirchoff's voltage law says that the **sum of voltages around a closed circuit must be zero**.

Say, for example, that $V_1$ is 12V, R2 is $4 \Omega$, R3 is $6 \Omega$, $V_2$ is 3V and R5 is $1 \Omega$. Then we know $-12 + 4i + 6i - 4 + i = 0$. We can then work out the current in the circuit using KVL by re-arranging the formula.

## Resistance

Resistors control the current that flows through a part of a circuit, as described by Ohm's Law ($V = IR$). Using the formula one can see that as either resistance increases, current falls, and vice versa.

### Resistor Colour Codes

In the drawing to the left you can click on the value-boxes to change the colour bands on the resistor to find out the resistance represented by the colour encoding. Note it only shows a 4-band resistor. 5 and 6 colour bands are possible but not shown here.

Note: Sometimes the click event on the canvas doesn't fire... not quite sure why that is. If first click doesn't work, persevere :)

Some popular ways of remembering the resistor colour codes include
"__B__ad __B__oys __R__avish __O__ur __Y__oung __G__irls __B__ut __V__iolet __G__ives __W__illingly"
and my fav,
"__B__ad __B__ooze __R__ots __O__ur __Y__oug __G__uts, __B__ut __V__odka __G__oes __W__ell".

### Resistor's In Series

Resistors in series can be "collapsed" into an equivalent single resistor with a resistance that is the sum of all the resistances of the individual resistors.

Using *Kirchoff's voltage law*:
$$V_1 + V_2 + V3 - V_s = 0$$
Using $V = iR$ we can substitute in for the individual voltages across each resistor. Note that because
this is a closed loop the current though each resistor will be the same (as there is no path in which
the current can "split" up).
$$iR_1 + iR_2 + iR3 - V_s = 0$$
$$\therefore V_s = iR_1 + iR_2 + iR3$$
Now, $V_s$ can also be re-written using $V = iR$ as $V_s = iR_t$, where $R_t$ is the equivalent, total,
resistance of the resistors in series...
$$\therefore iR_t = iR_1 + iR_2 + iR3$$
$$\mathbf{\therefore R_t = R_1 + R_2 + R_3}$$

### Resistor's In Parallel

Resistors in parallel can also be "collapsed" into an equivalent single resistor...

Using *Kirchoff's current law* we can say that $i_t = i_1 + i_2 + i_3$. Using $V = iR$,
we can say the following:
$$\begin{array}{ccc}
V = i_1R_1 & V = i_2R_2 & V = i_3R_3 \\
\therefore i_1 = \frac{V}{R_1} & \therefore i_2 = \frac{V}{R_2} & \therefore i_3 = \frac{V}{R_3}
\end{array}$$
Subsituting the above back into $i_t = i_1 + i_2 + i_3$, gives us the following.
$$ i_t = \frac{V}{R_1} + \frac{V}{R_2} + \frac{V}{R_3}$$
And, of course, $i_t$ can also be re-written, giving the solution:
$$\frac{V}{R_t} = \frac{V}{R_1} + \frac{V}{R_2} + \frac{V}{R_3}$$
$$\mathbf{\therefore \frac{1}{R_t} = \frac{1}{R_1} + \frac{1}{R_2} + \frac{1}{R_3}}$$

### Voltage Divider

Using Ohm's law we know the following.
$$V_1 = iR_1 \implies i = \frac{V_1}{R_1}$$
$$V_2 = iR_2 \implies i = \frac{V_2}{R_2}$$
Using Kirchoff's voltage law, and substituting in the above, we know that,
$$\begin{align}
V_t & = V_1 + V_2 \\
& = iR_1 + iR_2 \\
& = i(R_1 + R_2)
\end{align}$$
This means that we can say,
$$i = \frac{V_t}{R_t} = \frac{V_1}{R_1} = \frac{V_2}{R_2}$$
Substituting $i = \frac{V_1}{R_1}$ into $V_t = i(R_1 + R_2)$ gives...
$$V_t = \frac{V_1}{R_1}(R_1+R_2)$$
$$\mathbf{\therefore V_1 = V_t \times \frac{R_1}{R_1+R_2}}$$
Substituting $i = \frac{V_2}{R_2}$ into $V_t = i(R_1 + R_2)$ gives...
$$V_t = \frac{V_2}{R_2}(R_1+R_2)$$
$$\mathbf{\therefore V_2 = V_t \times \frac{R_2}{R_1+R_2}}$$
In words, we can say that *the voltage across the second resistor is proportional to the ratio of the second resistance to the total resistance*.

One issue to be aware of is that any load placed across $R_2$, i.e., in parallel with $R_2$, will change the effective resistance of that node (remember resistors in parallel can be "collapsed" into an equivalent single resistor). Therefore, be aware that the load across $R_2$ will also influence the ratio of voltage division.

### Current Divider

$$i_tR_t = i_1R_1 $$ $$\begin{align} i_1 & = \frac{i_tR_1}{R_1} \\ & = \frac{\frac{R_1R_2}{R_1+R_2}}{R_1} \times i_t \\ & = \frac{R_2}{R_1+R_2} \times i_t \end{align}$$

### The Wheatstone Bridge

The Wheatstone Bridge is a circuit for measuring resistance very accurately. This material is based on the link to the Texas Instrument tutorial...

Using Kirchoff's voltage law around the loop consisting of $R_2$, $V_{out}$ and $R_4$ we get the following. $$-V_2 + V_{out} + V_4 = 0$$ $$\therefore V_{out} = V_2 - V_4$$ We can find the voltage across $R_2$ and $R_4$ by using the formula for voltage dividers: $R_1$ and $R_2$ are one voltage divider and $R_3$ and $R_4$ are the other voltage divider. Using the voltage divider formula we get the following two results: $$V_2 = \frac{R_2}{R_1+R_2} \times V_t, \qquad V_4 = \frac{R_4}{R_3+R_4} \times V_t$$ Here $V_t$ is the supply voltage. Substituting these into the first formula we get... $$ \begin{align} V_{out} & = \left(\frac{R_2}{R_1+R_2} \times V_t\right) - \left(\frac{R_4}{R_3+R_4} \times V_t\right) \\ & = \left(\frac{R_2}{R_1+R_2} - \frac{R_4}{R_3+R_4}\right) \times V_t \end{align} $$ If three out of the four resistances are known and the current across the $V_{out}$ branch is zero, the third resistance can be calculated.

Let's say that we don't know the resistance of $R_3$. If we set all the other resistors to be equal so that $R_1 = R_2 = R_4$, then the above formula simplified to the following.... $$V_{out} = \left(\frac{1}{2} - \frac{R_k}{R_u+R_k}\right) \times V_t$$ Where $R_k$ is the known resistance and $R_u$ is the unknown resistance. This assumes that $R_u$ is roughly equal to $R_1$ and that all $R_k$ resistors are very closely matched.

A simple re-arrangement gives us... $$V_{out} = \frac{1}{2} \times V_t - \frac{R_k}{R_u+R_k} \times V_t$$

In the above, $V_{out}$, $V_t$, and $R_k$ are all known. We know $V_{out}$ because we can measure it and the other known parameters are already set apriori. With more simple re-arrangement we get... $$0.5V_t - V_{out} = \frac{R_k}{R_u+R_k} \times V_t $$ $$\therefore \frac{0.5V_t - V_{out}}{V_t} = \frac{R_k}{R_u+R_k} $$ $$\therefore \frac{V_t}{0.5V_t - V_{out}} = \frac{R_u + R_k}{R_k} $$ $$\therefore \frac{V_t \cdot R_k}{0.5V_t - V_{out}} = R_u + R_k $$ $$\therefore \mathbf{R_u = \frac{V_t \cdot R_k}{0.5V_t - V_{out}} - R_k} $$

And now we can calculate the unknown resistance... why is this useful? Because *this unknown resistance is our sensor*.
It could be a thermistor, LDR, or whatever... something that changes resistance due to the thing we're trying to measure.

One thing to note is that the $V_{out}$ of the Wheatstone Bridge is non-linear as the figure to the left shows: $V_{out}$ does not change linearly with changes in the unknown resistance $R_u$! In the figure I just picked pretty arbitrary values for the various knowns.

So... why use this rather complex arrangement to measure an unknown resistance when we could do
the same using a simple voltage divider? The answer lies in the *sensitivity* of the measurement
system. This is covered in the next section.

### Power

When current flows through a resistor it disipates power in the form of heat. When it flows through an LED it disipates power in the form of both heat and light.

Power, measured in **watts**, is defined as:
$$
P = VI = I^2R = \frac{V^2}{R}
$$

Resitors usually have a power rating (the power they can disipate) associated with them. This means that if you know the resistor's power rating you can calculate the maximum voltage or current you can put across/through them without breaking the resistor.

## Switches

Switches are defined by the number of poles and throws they have...

**Poles**: A switch pole refers to the number of separate circuits that the switch controls.

**Throw**: The number of throws indicates how many different output connections each switch pole can connect its input to.
Think of it as how many places a single source can be "thown to".

## Capacitance

A capacitor consists of two conducting plates separated by an insulator (a.k.a. a dialectric).

When connected to a voltage source, the source creates a positive charge on one plate and a negative one on the other plate:

Charge stored is proportional to applied voltage:
$$
q = Cv \implies C = \frac{q}{v}
$$
Where $C$ is called the **capacitance** of the capacitor and is measured in Farads (F).
By re-arranging the above we can see that **capacitance is the charge per volt that
the capacitor can store**. Thus, the more charge that the capacitor stores per volt, the
higher its capacitance is. This quanitity is dependent on the type of dialectric used,
the surface area of each plate and the distance between the plates.

Recall that current is the amount of charge that moves past a point per unit time. Thus,
by differentiating w.r.t time, the above, we get the current-voltage relationship of a cap:
$$
i = C\frac{\mathrm{d}v}{\mathrm{d}t}
$$
This gives us in important property of caps. Because for DC current the voltage does not change,
$\frac{\mathrm{d}q}{\mathrm{d}t}$ is zero, so a **capacitor is an open circuit to DC**! (But it
does charge).
Because of the definition of a derivative, we also know that the voltage across a cap must
be smooth - i.e., it cannot change abruptly.

Note that real capacitors dissipate their energy over time - they "leak"

Integrate both sides of the above equation to get:
$$
v = \frac{1}{C} \int_{t_o}^t i\ \mathrm{d}t + v(t_0)
$$
**Capacitors resist abrupt changes in voltage**, which is why the function
as low pass filters.

### Charging Through A Resistor

When a capacitor, with a capacitance $C$, charges in series through a resistor of resistance $R$ ohms,
in $RC$ seconds it will charge to 63% of the supply voltage and in
$5 \times RC$ seconds it charges to over 99% [Ref].
You get an *exponentially decreasing current flow* as the *resistor draws current*
from the battery and the *capacitor stores the current's flowing charge* [Ref].
$$
\tau \ \text{(in seconds)} = RC
$$

Recall KVL: the sum of voltages around a closed circuit must be zero. The dotted arrow in the diagram above shows a direction around a closed ciruit, which by KVL means that: $$ +V - IR - \frac{Q}{C} = 0 \implies V = IR + \frac{Q}{C} $$ Recall that $I = \frac{dQ}{dt}$, so therefore, $$ V = \frac{\mathrm{d}Q}{\mathrm{d}t}R + \frac{Q}{C} \\ \therefore \ \frac{\mathrm{d}Q}{\mathrm{d}t} = \frac{V}{R} - \frac{Q}{RC} $$ ... TODO ...

### Capacitors In Series

$$ \frac{1}{C_{eq}} = \frac{1}{C_1} + \frac{1}{C_2} + \cdots + \frac{1}{C_n} $$

### Capacitors In Parallel

$$ C_{eq} = C_1 + C_2 + \cdots + C_n $$

## Inductors

An inductor is a coil of wire, sometimes round a feris core, that **stores energy in its magnetic field**.
Its strength depends on the number of turns in the coil and the type of core material and its
cross-sectional area.

Inductors **oppose the change of current** flowing though them. They are measured in "Henrys".
The formula below defines inductance, L. Inductance is the voltage generated per unit change in
current.
$$
v = L \frac{\mathrm{d}i}{\mathrm{d}t}
$$
Integrating both sides and re-arranging we can get:
$$
i = \frac{1}{L}\int_{t_0}^{t} v(t)\ \mathrm{d}t - i(t_0)
$$

### Inductors In Series

$$ L_{\text{eq}} = L_1 + L_2 + \cdots + L_n $$

### Inductors In Parallel

$$ \frac{1}{L_{\text{eq}}} = \frac{1}{L_1} + \frac{1}{L_2} + \cdots + \frac{1}{L_n} $$ So, for 2 inductors in parallel: $$ L_{\text{eq}} = \frac{L_1L_2}{L_1 + L_2} $$

## Diodes

Diodes let current flow in one direction, but not the other, and always drop the same voltage across them no matter the src voltage.

Diodes drop the same voltage across them no matter the voltage source rating. So, for example, silicon diode needs about 0.7V to fwd bias, but won't let the voltage drop across it exceed this. So if you don't protect it with a resistor it will allow too much current to flow an potentially overheat!

### References

- Diodes and Diode Circuits.
- Accounting for LED resistance, StackExchange.

## 555 Timer

The total resistance R_{A} + R_{B} will determine the time it takes
for the transistor to charge, assuming we keep capacitance constant.

Recall charge time for a cap to charge to 63% of the voltage across is is $\tau = RC$. So by varying either the resistors or the capacitor the period of the pulse train output on pin 3 can be varied.

## Bipolar Transistors

NPN transistors consist of two N-type (negatively doped - excess electroncs) silicon "chunks"
sandwiching a P-type (positively doped - exess holes or lacking electrons) as shown below. They are
**current controlled**.

By forward biasing the emitter to base junction with even a small current, the transistor's resistance between the emitter and collector quickly decreses, allowing a relatively large current to from from the emitter to collector.

NPN transistors can typically handle up to about 0.8 A. Thus, they are **low current**
devices. For large currents MOSFETs are used (later section).

**Saturation region** is where the maximum collector current flows and the transistor
is basically a closed switch from collector to emitter.

**Active mode / region** is where there is an almost lear relationship between the
terminal currents at the base, collector and emitter.

**Cut-off region** is where the transistor acts like an open switch.