# Circuit Theory/Bode Plots

## Bode Plots

Bode plots plot the transfer function. Since the transfer function is a
complex number, both the magnitude and phase are plotted (in polar
coordinates). The independent variable ω is swept through a range of
values that center on the major defining feature such as time constant
or resonant frequency. A magnitude plot has dB of the transfer function
magnitude on the vertical axis. The phase plot typically has degrees on
the vertical axis.

!voltage across capacitor and resistor parallel combination is the
output
!Bode plot for V~CR~ compared to V~S~ which looks like a passive, low
pass filter with slope of -40dB/decade, the cut off frequency looks to
be 10^0^ = 1 radian/sec. The resistor dominates at DC and the capacitor
dominates at very high frequencies.

!find current through
R~3~

## MatLab tr and bode

### Example 1

Previously the
transfer function was found to be:

$$H(s) = \frac{\mathbb{V}_{cr}(s)}{\mathbb{V}_s(s)} = \frac{1}{CLs^2 + \frac{Ls}{R} + 1} = \frac{1}{s^2 + 2s + 1}$$
MatLab has a short hand notation method for entering this information
where the coefficients are listed (high power to low power)(numerator
first, then denominator). For this example

    f = tf([1],[1 2 1])

Leaving the colon off the end should display the transfer function. The
next step is to plot it:

    grid on
    bode(f)

The result is a low pass filter. Rather than understand how to create
these plots (not trivial), the goal is to interpret the plot .. (which
is almost the same thing). But at this point, the goal is to exercise
MatLab. !Bode diagram of R3 current versus V~s~, looks like a notch
filter at around 1K
radians/sec

### Example 2

Previously the transfer
function was found to be:

$$\frac{\mathbb{I}_o}{\mathbb{V}_s} = \frac{1000s^3 + 5*10^9s}{s^4 + 5*10^6*s^3 + 2.000015*10^{12}*s^2 + 3.5*10^{13}*s + 5*10^{13}}$$

    f = tf([1000 0 5*10^9 0],[1 5*10^6 2.000015*10^12 3.5*10^13 5*10^13])
    grid on
    bode(f)

### Magnitude Graph

Bode magnitude plots are dB which is both a measure of power and voltage
and current simultaneously. The vertical dB axis is not an approximation
or relative to anything. The vertical axis is an accurate number. The
horizontal, dependent axis could be radians/sec or Hz.

### Phase Graph

The Bode Phase Plot is a graph where the radial frequency is plotted
along the X axis, and phase shift of the circuit *at that frequency* is
plotted on the Y-axis. Axis could be in radians or degrees, frequency
could be in radians per second or Hz.

## Poles and Zeros

A transfer function has 7 features that can be realized in circuits.
Before looking at these features, the terms pole, zero and origin need
to be defined. Start with this definition of a transfer function:

$$H(j\omega) = \frac{Z(j\omega)}{P(j\omega)}$$

-   Zeros are roots in the numerator.
-   Poles are roots in the denominator.
-   The origin is where s = jω = 0 (no real part in a Bode analysis).
    When the frequency is zero, the input is DC. This is where after a
    long time caps open and inductors short.

The 7 possible features in a transfer function are:

-   A constant
-   Zeros at the origin (s in the numerator)
-   Poles at the origin (s in the denominator)
-   Real Zero (an s+a factor in the numerator)
-   Real Pole (an S+a factor in the denominator)
-   Complex conjugate poles
-   Complex conjugate zeros

The bode and bodeplot functions are available in the MatLab Control
system toolbox.
BodePlotGui does the
same thing and is discussed here. BodePlotGui was developed at
Swarthmore through an NSF grant. There is a summary of the Swathmore
Bode Diagram tutorial.

Circuit simulation software can plot bode diagrams
also.

## Bode Equation Format

let us say that we have a generic transfer function with poles and
zeros:

$$H(j\omega) = \frac{(\omega_A + j\omega)(\omega_B + j\omega)}{(\omega_C+ j\omega)(\omega_D + j\omega)}$$

Each term, on top and bottom of the equation, is of the form
$(\omega_N + j\omega)$. However, we can rearrange our numbers to look
like the following:

$$\omega_N(1 + \frac{j\omega}{\omega_N})$$

Now, if we do this for every term in the equation, we get the following:

$$H_{bode}(j\omega) = \frac{\omega_A \omega_B}{\omega_C \omega_D}
      \frac{(1 + \frac{j\omega}{\omega_A})(1 + \frac{j\omega}{\omega_B})}
           {(1 + \frac{j\omega}{\omega_C})(1 + \frac{j\omega}{\omega_D})}$$

This is the format that we are calling \"Bode Equations\", although they
are simply another way of writing an ordinary frequency response
equation.

## DC Gain

The constant term out front:

$$\frac{\omega_A \omega_B}{\omega_C \omega_D}$$

is called the \"DC Gain\" of the function. If we set $\omega \to 0$, we
can see that everything in the equation cancels out, and the value of H
is simply our DC gain. DC then is simply the output when the input\'s
frequency is zero.

## Break Frequencies

in each term:

$$(1 + \frac{j\omega}{\omega_N})$$

the quantity $\omega_N$ is called the \"Break Frequency\". When the
radial frequency of the circuit equals a break frequency, that term
becomes (1 + 1) = 2. When the radial frequency is much higher than the
break frequency, the term becomes much greater than 1. When the radial
Frequency is much smaller than the break frequency, the value of that
term becomes approximately 1.

### Approximations

Bode diagrams are constructed by drawing straight lines (on log paper)
that approximations of what are really curves. Here is a more precise
definition.

The term \"much\" is a synonym for \"At least 10 times\". \"Much
Greater\" becomes \"At least 10 times greater\" and \"Much less\"
becomes \"At least 10 times less\". We also use the symbol \"\<\<\" to
mean \"is much less than\" and \"\>\>\" to mean \"Is much greater
than\". Here are some examples:

-   1 \<\< 10
-   10 \<\< 1000
-   2 \<\< 20 Right!
-   2 \<\< 10 WRONG!

For a number of reasons, Electrical Engineers find it appropriate to
approximate and round some values very heavily. For instance,
manufacturing technology will never create electrical circuits that
perfectly conform to mathematical calculations. When we combine this
with the \<\< and \>\> operators, we can come to some important
conclusions that help us to simplify our work:

If A \<\< B:

-   A + B = B
-   A - B = -B
-   A / B = 0

All other mathematical operations need to be performed, but these 3
forms can be approximated away. This point will come important for later
work on bode plots.

Using our knowledge of the Bode Equation form, the DC gain value,
Decibels, and the \"much greater, much less\" inequalities, we can come
up with a fast way to approximate a bode magnitude plot. Also, it is
important to remember that these gain values are not constants, but rely
instead on changing frequency values. Therefore, the gains that we find
are all *slopes* of the bode plot. Our slope values all have units of
\"decibel per decade\", or \"db/decade\", for short.

## At Zero Radial Frequency

At zero radial frequency, the value of the bode plot is simply the DC
gain value *in decibels*. Remember, bode plots have a log-10 magnitude
Y-axis, so we need to convert our gain to decibels:

$$Magnitude = 20\log_{10}(DC Gain)$$

## At a Break Point

We can notice that each given term changes its effect as the radial
frequency goes from below the break point, to above the break point.
Let\'s show an example:

$$(1 + \frac{j\omega}{5})$$

Our breakpoint occurs at 5 radians per second. When our radial frequency
is *much less* than the break point, we have the following:

$$Gain = (1 + 0) = 1$$

$$Magnitude = 20\log_{10}(1) = 0db/decade$$

When our radial frequency is equal to our break point we have the
following:

$$Gain = |(1 + j)| = \sqrt{2}$$

$$Magnitude = 20\log_{10}(\sqrt{2}) = 3db/decade$$

And when our radial frequency is much higher (10 times) our break point
we get:

$$Gain = |(1 + 10 j)| \approx 10$$

$$Magnitude = 20\log_{10}(10) = 20db/decade$$

However, we need to remember that some of our terms are \"Poles\" and
some of them are \"Zeros\".

### Zeros

Zeros have a positive effect on the magnitude plot. The contributions of
a zero are all positive:

Radial Frequency \<\< Break Point : 0db/decade gain.\
Radial Frequency = Break Point : 3db/decade gain.\
Radial Frequency \>\> Break Point : 20db/decade gain.

### Poles

Poles have a negative effect on the magnitude plot. The contributions of
the poles are as follows:

Radial Frequency \<\< Break Point : 0db/decade gain.\
Radial Frequency = Break Point : -3db/decade gain.\
Radial Frequency \>\> Break Point : -20db/decade gain.

## Conclusions

To draw a bode plot effectively, follow these simple steps:

1.  Put the frequency response equation into bode equation form.
2.  identify the DC gain value, and mark this as a horizontal line
    coming in from the far left (where the radial frequency conceptually
    is zero).
3.  At every \"zero\" break point, increase the slope of the line
    upwards by 20db/decade.
4.  At every \"pole\" break point, decrease the slope of the line
    downwards by 20db/decade.
5.  at every breakpoint, note that the \"actual value\" is 3db off from
    the value graphed.

And then you are done! 
