---
jupytext:
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
    jupytext_version: 1.17.1
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

```{code-cell} python3
:tags: [thebe-remove-input-init, auto-execute-page]

%pip install ipympl==0.9.3
```


# Transistors

## History of controlled sources

Up till now, we have seen components with two connections. Most of them behaved in a linear fashion, except for the diode. In this chapter we will focus on a device with multiple connections, which can be modelled as a controlled source. This device comes in a plurality of forms and is called the transistor. Before we look into this device, we will first look back in time.

One of the components which really started the revolution of electronics was the Thermionic Valve (English), also known as Vacuum Tube (American). This component, invented in 1904, made it possible to really amplify signals and was a key-component in many new systems (communication, television, measurement and control, computers).

### How the Thermionic Valve is constructed

The Thermionic valve consists of an envelope, usually made out of glass. This envelope is airtight, such that the inside can be under vacuum. This vacuum is necessary as the electrons will be moving through the device when its operational. (When an electron collides with a gas-molecule it will be absorbed.)
The electrons are generated at the “cathode”. The cathode can be constructed by taking a thin metal tube. The outside of the tube is covered with an alkaline metal (e.g. Barium or Strontium). When this tube is heated, a heater filament is placed inside the tube, the electrons will be released from the metal-coating. The electrons will “float” around the cathode.
There is another electrode inside the vacuum envelope, called the “anode”. When a voltage is applied between the anode (positive) and the cathode (negative), an electric current will start to the flow between the anode and the cathode. The electrons will be attracted to the positive anode.

```{figure} images/images_6/in_book/thermionic_valve_diode.svg
:name: fig:thermionic_valve_diode
Thermionic valve, a diode, showing the electrons flow and the basic components of the valve.
``` 

When the polarity is reversed, the electrons will stay at the cathode and no current will flow. This type of tube, with two electrodes, was the first useful diode.

Later a third electrode, shaped as a grid was added to the tube. This grid (a fine wire-mesh) was placed between the anode and the cathode. By changing the potential on this grid, the flow of electrons between the cathode and anode could be influenced. When the grid was slightly negative compared to the cathode, the electrons would be slowed down, lowering the current. The current flow is at its maximum when the potential of the grid is the same as the potential of the cathode.  When the potential of the grid becomes more and more negative, the current will eventually stop.

```{figure} images/images_6/in_book/thermionic_valve_triode.svg
:name: fig:thermionic_valve_triode
Thermionic valve, a triode, the grid can control the current ($I_a$) flowing between the Anode and the Cathode.
``` 

The grid can thus be used to modulate the current flow, while basically no energy is needed to control the grid. This invention made it possible to build circuits like amplifiers.


```{figure} images/images_6/in_book/thermionic_network.svg
:name: fig:thermionic_network
Network model of a thermionic valve.
``` 

Drawback of the thermionic valve is the need for a heater, which consumes quite some energy and the need for a vacuum envelope. These characteristics created a practical limit for miniaturisation, as well as for power efficiency. This encouraged people to develop other components, which resulted in the transistor.


###  History of the Transistor

The transistor was invented in 1947 and in the years following, it was further improved and different types were developed. The transistor is based on semiconductor material, first Germanium was used, nowadays Silicon is mostly used. Similar to the diode a Silicon substrate is used, which is modified by adding other molecules to the crystalline structure of the Silicon (remember the P-type and N-type material of the diode?).

In order to understand the physics of the transistor, we will first have a look at the Field Effect Transistor (FET), or more precise: the Junction-FET (JFET).

### The Junction Field Effect Transistor

The FET consists, in principle, of a block of N-type or P-type semiconductor material. For this explanation, we assume it is a piece of N-type material. The N-type material has a surplus of negative charge carriers, the electrons. When we connect wires on opposite sides of the block and we apply a voltage to these wires, there will be a current flowing. We will define the bottom side as source (similar to the cathode of the thermionic valve) and the top side as the drain (comparable to the anode of the thermionic valve).

In order to make the current flow controllable, an extra electrode is added to the substrate. This is done by effectively modifying a piece of the P-type material in N-type material. This will yield a diode-like structure (hence the name Junction-FET). In the drawing it can be seen that there are two PN-junctions. The P-areas are connected together, and the electric connection we call the gate (comparable to the grid in the valve).


```{figure} images/images_6/in_book/JFET_construction.svg
:name: fig:JFET_construction
Construction of a Junction-FET.
``` 

This PN junction will be reverse biased. A reverse biased diode has a broad depletion region. In the depletion region there are no free charge carriers, thus there will be no current flowing in that region.

The width of the depletion region can be changed by varying the potential. When the potential is made more negative with respect to the source connection the depletion region will increase its width. When the gate-potential is made even more negative, we will see that both depletion regions will touch each other, making it impossible for the electrons to flow from the source to the drain.

When the diodes are biased with zero volts, the depletion region is at its minimal width, thus the current flow from source to drain will be at its maximum.

```{figure} images/images_6/in_book/JFET_model.svg
:name: fig:JFET_model
Characteristic and network model of a N-type Junction-FET.
``` 

The situation where the gate will be positive compared to the source should not occur, as it will damage the device. Thus these diodes should never be forward biased!  
A small gate current (in the order of mA) will usually not damage the JFET. Check the datasheet for maximum values.

Concluding: This semiconductor device shows a lot of similarities with the thermionic valve. Hence the applications of this device are similar as for the thermionic valve, however, the JFET is smaller and more energy-efficient (there is no heater filament!), furthermore the device does not need a vacuum envelope.

### The bipolar transistor

Another category of transistors is the bipolar transistor. Still this is a transistor, like the FET, however the construction is different. The bipolar transistor consists of a stack of PN-junctions. There are two main-types the NPN-transistor and the PNP-transistor, the name indicating the order of stack of PN-junctions. In order to understand general operating principle we will look at the NPN-transistor.

### The NPN-transistor

In {numref}`fig:NPN_bipolar` you can see how a NPN-transistor is constructed. Nowadays, Silicon is mostly used for building transistors. In the first years of the transistor, Germanium was the most used material. The material is modified such that we get N-type and P-type material.


```{figure} images/images_6/in_book/NPN_bipolar.svg
:name: fig:NPN_bipolar
Basic construction of a NPN bipolar transistor.
``` 

The stack of N-type and P-type materials forms the transistor. There are two PN-junctions, sharing the same piece of P-type material. The outer connections are called the Collector (comparable to the drain or anode) and the Emitter (comparable to the source or cathode), the control connections is called the Base (comparable to the gate or grid).

In short, the current flowing between the Collector and the Emitter is controlled by the signal on the Base. The way this happens is a bit harder to understand, compared to the FET and the thermionic valve.

From the diode we know that it will conduct current when the P-type material has a positive potential compared to the N-type material. However, when looking at the way the transistor is constructed, the PN-junction between the Collector and Base will never conduct .... but in practice the P-type layer is not very thick. When the Base-Emitter junction is conducting (forward biased) there will be a lot of free charge carriers available. These charge carriers will move all around the material, and will move (diffuse) into to the Collector-Base junction as well. When they move into to the depletion region of this blocking junction they will make it possible to conduct current through this, actually, blocking diode.

When the current through the Base-Emitter is increasing, there will be more charge carriers available. Therefore more charge carriers will move to the Collector-Base junction, and this will increase the current flowing through Base-Collector junctions. From the outside it seems the current flowing from the Collector to the Emitter is increasing.

We can see here that the current flowing into the base, will influence the current flowing between Collector and the Emitter. Now the construction of the bipolar transistor is such that a small current through the Base, is sufficient to develop a much larger current in the Collector-Emitter circuit.

A practical model, describing the above situation is shown in {numref}`fig:transistor network simplified` . Here we can notice a fundamental difference between the thermionic valve and the JFET: the input is not just taking the potential, there is an electrical path carrying current between the control input (base) and the controlled current circuit (between collector and emitter). Furthermore we can see that the input voltage needs to be high enough to get the diode in conduction.

```{figure} images/images_6/in_book/transistor_network.svg
:name: fig:transistor_network
Transistor network model (large signal model)
``` 

:::{figure-start} images/nothing.svg
:name: fig:transistor network simplified
:alt: Nothing
:align: center
Simplified transistor characteristic of transistor network model (large signal model, {numref}`fig:transistor_network`) 
:::

```{code-cell} python3
:tags: [hide-input, thebe-init]

import numpy as np
import matplotlib.pyplot as plt

V_CE = np.linspace(0, 10, 500)

beta = 100
#V_knee = 0.6
G_sat = 5e-3   # A/V - common left-hand slope

I_B_values = [10, 20, 30, 40]

fig, ax = plt.subplots(figsize=(8, 5))

for i, I_B_uA in enumerate(I_B_values, start=1):

    I_B = I_B_uA * 1e-6
    # Common left-hand slope
    I_C_sat = beta * I_B
    V_knee = I_C_sat / G_sat

    I_C = I_C_sat * (1 - np.exp(-V_CE / V_knee))

    I_C_mA = I_C * 1e3

    ax.plot(V_CE, I_C_mA, linewidth=2)

    # Put IB labels beside each characteristic
    ax.text(
        9.5,
        I_C_mA[-1]+ 0.2,
        fr"$I_{{B{i}}}$",
        va="center",
        fontsize=12
    )

    ax.annotate(
    "Increasing $I_B$",
    xy=(10.6, 4.1),
    xytext=(10.6, 1.2),
    arrowprops=dict(arrowstyle="->"),
    rotation=90,
    va="center",
    ha="center",
    fontsize=12
)

ax.set_xlabel(r"$V_{CE}$", fontsize=13)
ax.set_ylabel(r"$I_{CE}$", fontsize=13)

ax.set_xlim(0, 11)
ax.set_ylim(0, 4.5)

ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)

plt.show()
```

:::{figure-end}
:::


The current flowing through the emitter is the sum of the base-current and the collector-current. The collector current is determined by the controlled current source, from which the value depends on the base-current. The conversion factor between the base-current and the collector-current is called the “current gain” for which often the symbol “β” is used. We can capture this in the following formulas:

$$
I_e = I_b + I_c
$$

$$
I_c = \beta * I_b
$$

$$
I_e = (\beta+ 1) * I_b
$$

### Complementary transistors

In the description above two basic types of transistors, the JFET and bipolar one, have been described. There are many other types which will operate in a similar way, but there could be differences in the potentials needed to have the device operate properly. For example, we had a look at the N-type JFET, which suggests there is a P-type JFET as well. The P-type JFET does exist, the diode created at the input has an opposite polarity, compared to the N-type JFET. However, the diode should still be in blocking mode. Thus in order to have a current flow between source and drain there should be a positive voltage on the gate.

Same applies to the bipolar transistor, the NPN is described above. The other configuration is the PNP transistor, here the current flow through the base is in the opposite direction compared to the NPN transistor.

These transistors which behave similar but opposite, are complementary. In a number of applications you can see that such a complementary pair is used. One to amplify the positive part of a signal, the other one for the negative part. In such a configuration one speaks of a complementary pair.

### MOSFET

We had a look at the JFET before, but there is another important category of FETs, the MOSFET. The name is an abbreviation for Metal Oxide Silicon Field Effect Transistor. The name originates from the construction where the control input (gate) is connected to a metalized area. This metalized area is insulated from the silicon by a thin insulating layer (Silicon-oxide). By applying a potential to the gate, the current flow through the silicon (connecting the drain to the source) can be controlled.

```{figure} images/images_6/in_book/MOSFET.svg
:name: fig:MOSFET
Basic structure of a MOSFET.
``` 

This type of FET is used a lot in digital circuits, as it can be miniaturized easily and behaves almost as an ideal switch. This type of FET is not the best choice for analog circuits.

Over time a large number of MOSFETs has been developed. There are N-type and P-type MOSFETs (complementary types), but within these categories there are Enhancement and Depletion MOSFETs. The Enhancement MOSFET will start to conduct when a signal is applied to the gate, while the Depletion MOSFETs will cease to conduct when a signal is applied to the gate. So the depletion type mosfet has similar behaviour as the JFET.

### Symbols

For all these different types of transistors, there are a number of different schematic symbols indicating the class of transistor. Furthermore, the transistors have a type-number. With this number it is possible to find the datasheet of the specific transistor and find out about its specific characteristics.

```{figure} images/images_6/in_book/transistor_symbols.svg
:name: fig:transistor_symbols
Schematic symbols for transistors.
``` 

## Transistor circuits

In general transistors can be used for a wide variety of applications. These applications are ranging from analog signal processing (for example linear amplifiers) to digital systems (e.g. micro-controllers) and from low power (e.g. portable electronics) to high power applications (e.g. energy conversion in power plants or for powering electric cars). In this section, a number of these applications are addressed briefly, as there are many details to take into account. This part of the chapter should be regarded as a short introduction into transistor circuits.

### Analog amplifiers

Signals can be amplified for different purposes, in one application it is sufficient to increase just the voltage-amplitude, for example when feeding a small signal to an Analog-to-Digital-Converter (ADC). The amplifier will make sure the full range of the ADC is used. 

*The ADC is described elsewhere in this book. It is a component which converts analog voltages into digital (binary) values, such that it can be handled by a microcontroller.*   

Another way of amplifying signals is to increase the power level (increase in voltage and current!), think about an audio amplifier. The small signal coming from the audio source should be amplified such that it can drive a couple of loudspeakers with sufficient volume (thus energy). We will have a brief look at both situations.

### Voltage amplification

Voltages to be amplified can most often be identified as AC-voltages, with other words the parts of the signal we are interested in are the variations or changes, and not the constant (DC offset) voltages. The DC-value of the signal could be zero volts, which means that the signal has positive and negative periods. From the description of the various transistors we learned that the input signal they can handle has some (strict) boundaries, for example only positive or only negative values. When an AC-signal with positive and negative periods is just added to the input of the transistor, chances are big that the signal will be distorted. Therefor we have to shift the signal. We will shift the signal to a level, such that both the negative and positive parts of the original signal will be within the operating range of the transistor. For this purpose as coupling capacitor is used, which allows the AC signal to pass, but isolates the DC-level on both sides of the capacitor.

Furtermore, the transistor should be biased, which means that when there is no signal applied, the transistor is adjusted (biased) such that it is able to move up and down with incoming signal.

In {numref}`fig:transistor_volt_amplification`  we see a basic setup for a linear amplifier with a transistor. Resistor $R_1$ and $R_2$ define a DC-voltage level, bias-level, on the base of the transistor. Coupling capacitor $C_1$ is there to couple the AC part of the input signal to the base, without disturbing the DC-bias.

```{figure} images/images_6/in_book/transistor_volt_amplification.svg
:name: fig:transistor_volt_amplification
Basic voltage amplifier with a transistor.
``` 

The AC input signal will modulate the voltage on the base. The biasing of the transistor, makes sure that the base-emitter diode will conduct at al times. Hence there will be a fixed offset between the base and the emitter of ~0.7V. The voltage on the emitter of the transistor will thus follow the input signal. With other words, the input signal and the emitter-voltage are in phase.


:::{figure-start} images/nothing.svg
:name: fig:volt_in_transistor_amp
:alt: Nothing
:align: center
Voltages in the transistor amplifier.
:::

```{code-cell} python3
:tags: [hide-input, thebe-init]

import numpy as np
import matplotlib.pyplot as plt

# -----------------------------
# Time axis
# -----------------------------
t = np.linspace(0, 10, 1000)

# -----------------------------
# Signal parameters
# -----------------------------
A_in = 0.20          # input amplitude
freq = 0.55          # frequency
omega = 2 * np.pi * freq

V_bias_base = 2      # DC bias at base
V_BE = 0.70          # base-emitter drop
V_out_avg = 5        # average collector/output voltage
gain = 4.5           # voltage gain

# -----------------------------
# Signals
# -----------------------------
v_in = A_in * np.sin(omega * t)
v_base = V_bias_base + v_in
v_emitter = v_base - V_BE
v_out = V_out_avg - gain * v_in   # inverted amplified output

# -----------------------------
# Plot
# -----------------------------
fig, ax = plt.subplots(figsize=(10, 6))

ax.plot(t, v_out, linewidth=2, label="Collector / output voltage")
ax.plot(t, v_base, linewidth=2, label="Base voltage")
ax.plot(t, v_emitter, linewidth=2, label="Emitter voltage")
ax.plot(t, v_in, linewidth=2, label="Input signal")

# Average / bias lines
ax.axhline(V_out_avg, linestyle="--", linewidth=1)
ax.axhline(V_bias_base, linestyle="--", linewidth=1)
#ax.axhline(V_bias_base - V_BE, linestyle="--", linewidth=1)
ax.axhline(0, linestyle="-", linewidth=1)

# Labels on right side
x_label = 10
ax.text(x_label, V_out_avg + 0.20, "Output voltage", ha="left", va="center")
ax.text(x_label + 0.06, V_out_avg - 0.2, "Average output voltage", ha="left", va="bottom")

ax.text(x_label, V_bias_base + 0.2, "Base voltage", ha="left", va="center")
ax.text(x_label + 0.06, V_bias_base - 0.2, "Bias voltage base", ha="left", va="bottom")

ax.text(x_label, (V_bias_base - V_BE) + 0.08, "Emitter voltage", ha="left", va="center")
ax.text(x_label, 0.10, "Input signal", ha="left", va="center")

# Mark 0.7 V difference between base and emitter
x_arrow = 0.8
ax.annotate(
    "",
    xy=(x_arrow, V_bias_base),
    xytext=(x_arrow, V_bias_base - V_BE),
    arrowprops=dict(arrowstyle="<->", linewidth=1.5)
)
ax.text(x_arrow - 0.15, V_bias_base - V_BE/2, "0.7 V", ha="right", va="center")

# Axes styling
ax.set_xlim(0, 10.5)
ax.set_ylim(-0.4, 7)
ax.set_xlabel("t (s)")
ax.set_ylabel("Voltage (V)")
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)

plt.tight_layout()
plt.show()
```

:::{figure-end}
:::


The changing voltage at the emitter, gives a changing voltage over resistor $R_4$ as well. As Ohm’s law applies for the resistor, we get a current through the resistor which has a DC-component, due to the biasing, and an AC-component, due to the input signal.

Transistors typically choosen for these applications have a current gain well above 100. Which means that the collector-current and the emitter-current are approximately the same, thus $I_c$~$I_e$. Thus the current through $R_3$ is (almost) equal to the current through $R_4$. The AC-current through $R_3$ will be converted in an AC-voltage by this resistor. This voltage ($V_4$) will be the output voltage of the amplifier.

When resistor $R_3$ has a higher value then resistor $R_4$, then the output voltage will have a higher amplitude compared to the input voltage. But the phase will be opposite (180 degrees) shifted. This can be reasoned as follows: When the input signal increases, the current through $R_4$ will increase (higher voltage drop over $R_4$). Assume the current through the emitter and the collector is the same. Resistor $R_3$ is tied on the top side to the supply-rail, thus a fixed voltage. When the current through the collector and thus the resistor increases, the voltage drop over the resistor must increase, this is only possible when the potential at the collector gets lower ($U(R_3) = U_{supply} – U_{collector}$).

With the same reasoning it can be seen that the gain of the circuit is largely determined by the ratio of $R_3$ and $R_4$. In practice there are some other factors which will influence the gain, but for a rough estimation one coulde use:

$$
Gain = \frac{U_{out}}{U_{in}} = \frac{R_{collector}}{R_{emitter}} = -\frac{R_3}{R_4}
$$

The “-” sign  indicates the phase inversion of the signal.


### Emitter follower

The current which can be supplied by amplifiers is limited. A lot of amplifiers, either built discrete with transistors or made with OPAMPs, are capable of amplifying the voltage in amplitude, but they cannot drive large currents (limit is often around 20 mA).
For driving loads which require more current, there is a need for a current-amplifier. For this the emitter-follower, based on the bipolar junction transistor (BJT) is an appropriate circuit. The circuit as a voltage gain of ~1, but the current gain is much higher.

```{figure} images/images_6/in_book/basic_emitter_follower.svg
:name: fig:basic_emitter_follower
Basic emitter follower circuit.
``` 

The basic emitter follower circuit is shown in {numref}`fig:basic_emitter_follower`. The power to the load ($R_{load}$) is delivered by the transistor. The base of the transistor is controlled by a driving circuit, this could be an OPAMP, or an ADC for example.
The current needed to drive $R_{load}$, is supplied by the voltage-source ($U_{supply}$) through the resistor. The voltage over $R_{load}$ is determined by the voltage on the base of the transistor. Basically the voltage at the emitter is following the voltage of the base, but with an offset of ~0.7 V.

Between the base and the emitter there is a diode (PN-junction) present. The voltage loss over a diode, is current dependent, but is generally around 0.7 V. Which means that :

$$
U_{load} = U_{emitter} = U_{base} – U_{be} = U_{base} – 0.7
$$

This offset is quite constant. When an AC-voltage is applied to the base the AC-voltage on the emitter will be the same, however with a small (almost) constant offset. Hence we assume the gain of the emitter-follower to be almost equal to one.

The current gain of the circuit is determined by the transistor. The current flowing into the base ($I_b$) is amplified by a factor β, this amplified current will be the emitter-current ($I_e$).

How much current is needed for the base? The amount of current depends on the current flowing through the load ($I_e$ or $I_{load}$) and the current gain. This can be shown with the following reasoning:

$$
I_{load} = I_e = (β+1) * I_b = \frac{U_{load}}{R_{load}}
$$

When β >> 1 then the factor (β + 1) is almost equal to β. Furthermore, if we assume that:

$$
U_{load} \approx U_{base}
$$

We can derive the apparent $R_{load}$ at the base, with other words the load-resistance as it appears at the base, we name it $R_{in}$:

$$
R_{in} = \frac{U_{base}}{I_{base}} =
\frac{U_{base}}{\frac{I_{load}}{β}} = 
\frac{U_{load}}{\frac{I_{load}}{β}} = 
 β * \frac{U_{load}}{I_{load}} = β * R_{load}
$$

From this we can learn that the load-resistance appears ~β times higher at the input of the base (and a higher resistance means less load).

A similar reasoning can be made from the point of view of the load ($R_{load}$). The apparent internal resistance of the source driving the load can be linked to the internal resistance of the driving circuit (resistance is not shown in the drawing). We name the internal driving resistance from the driving circuit: $R_{drive}$. Now we can see the driving circuit as a voltage source (“Thevenin voltage”) with a “Thevenin Resistance” which we name $R_{drive}$.

In order to look at the resistance we will assume a (little) change in the load-current $I_{load}$, $ΔI_{load}$.

Current needed through the load: 

$$
ΔI_{load} = ΔI_e = β * ΔI_b
$$

The voltage at the base of the transistor will drop due to this change in load-current. However, the voltage drop will be smaller, due to the current of the transistor, and hence the smaller change in current through the driving resistor ($R_{drive}$). In formulas it can be described as follows:

$$
R_{out} = \frac{ΔU_{out}}{ΔI_e} = 
\frac{R_{drive} * ΔI_b}{β * ΔI_b} = 
\frac{R_{drive}}{β}
$$

Thus, due to the extra transistor, the driving resistance $R_{drive}$ seems smaller by a factor of β. Which means that for the load it seems that it is driven from a source with low internal resistance.

Imagine that the load is not a pure resistance, but has some capacitance as well (it could be a coaxial cable for example). The source resistance in combination with the capacitance will form a low-pass RC-filter. The cut-off frequency of this filter will move up by a factor of β, when an emitter-follower is placed between the source and the combined capacitive and resistive load.


#### Emitter follower combined with an OPAMP

The majority of the OPAMPs can only supply a very limited amount of current. Their outputs are protected with an internal current-limiter, limiting the current to approximately 20 mA. In case the current capability of an OPAMP should be increased, one can make use of an emitter-follower.
Further improvements could be a push-pull stage with transistors, but this outside the scope of this book.

An OPAMP combined with an emitter-follower can be used to build a linear power stabilizer. A general circuit is shown in {numref}`fig:linear_voltage_regulator`.

```{figure} images/images_6/in_book/linear_voltage_regulator.svg
:name: fig:linear_voltage_regulator
Basic linear voltage regulator using an emitter-follower to boost the maximum current.
``` 

The OPAMP compares the output voltage with a stable reference voltage. This stable reference can be derived from a zener-diode. The output of the regulator circuit is sampled and fed back to the OPAMP input. The OPAMP compares the sampled output of the power stabilizer with the reference and regulates the current through the transistor, such that the output of the circuit will have the correct (and stable) voltage.

The output voltage is determined by the combination of the zener voltage and the value of $R_2$ and $R_3$. $R_1$ limits the current through the zener to a safe value. The associated formulas are shown below:

When the circuit is stable: $U_+ = U_- = U_{zener}$

$$
U_- = U_{zener} = U_{out} * \frac{R_2}{R_2+R_3}

U_{out} = U_{zener} * \frac{R_2+R_3}{R_2}
$$

The transistor in this will get warm, depending on the difference between the input-voltage and output voltage, and the current flowing through the resistor. A heatsink to keep the temperature within safe limits could be necessary.

It should be noted that this basic circuit does not contain any over-current protection. In order to make this circuit in a reliable power supply a current-limiting circuit should be added to protect the linear voltage regulator and the connected circuit as well.


### Transistor and FETs as a switch


Transistor can be used in linear circuits, for example amplifying an audio-signal or other analog signal, but nowadays linear amplification is more and more done with OPAMPs. Linear amplifiers with OPAMPs are easier to design, compared to transistor amplifiers. Similar OPAMPs could be used for switching signals, however, transistors have a big advantage here, they are capable of switching larger currents. And besides this, they are a more economic choice. So let's have a closer look at the application of transistors, and FETs, as a switch.

An ideal mechanical switch has two positions ON and OFF. In the ON-position the resistance should be very low (resistance in the switch will cause heating of the switch, leading to malfunctioning or fire), in the OFF-position the resistance should be infinite.

A transistor-switch should resemble similar behaviour as a normal switch, so a low resistance when switched ON and a high resistance when switched OFF. In order to achieve this, there is a difference between Field Effect Transistors (FET) and Bipolar Junction Transistors (BJTs). A FET can be controlled with a voltage, so basically no energy. A BJT needs to be controlled with a current, which involves some energy, all be it limited.

Another important difference is the direction of the current through the transistor (in this case the switch). A normal switch can pass current in both directions, switches based on transistors can only pass current in one direction. In practice this is hardly ever a problem.


#### The FET based switch

When a FET is used as a switch, one of the main-characteristics to take into account is the ON-resistance of the FET. This parameter can be found in the datasheet and is called $R_{ds(on)}$, the ON-resistance of the drain-source path, the path where the current through the switch will flow. The lower the value the better!  
In the datasheet you will find information about the gate-source voltage and its relation to the current flowing through the drain-source path. In order to switch the FET fully on, the control circuit should be capable of supplying a high enough voltage. Advantage is the high input resistance of the gate, the control circuit does not have to supply any signifcant current to control this electronic switch.

The load to be switched is very often connected between the positive supply rail and the drain of the FET. The electronic switch thus closes the connection between the load to ground. In {numref}`fig:MOSFET_switch` you can such a switch.


```{figure} images/images_6/in_book/MOSFET_switch.svg
:name: fig:MOSFET_switch
 General diagram of a (MOS)FET based switch.On the left switching an Ohmic load, on the right the configuration as an inverter.
``` 

The load to be switched can be a heavy load (low resistance), but this circuit can be used to build an logic inverter as well. In that case the resistance Rd between the drain and the supply very often has a higher value, few hundred Ohms till a few $k\Omega$.

In the circuit you will notice a resistor between the gate and the ground. Strictly speaking this resistor is not necessary, because the control-circuit will control the potential on the gate. However, when such a resistor is not present, and the control circuit gets disconnected from the gate, the potential at the gate will be undefined. This could cause unwanted switching of the load. With the gate resistor to ground, the gate will have a defined potential of zero Volts when the control circuit gets accidentally disconnected.


#### Switching inductive loads

A load which will be switched can be resistive (so a pure resistor) but loads can be inductive as well. Examples are (small) motor, electromagnets (electric valves) and relays.
When such a load has been powered on, an electromagnetic field is build up in the coil. When the power to such a load is switched of, the coil will generate and induction voltage (sometimes referred to as elektromotive force). This voltage will be of opposite polarity compared to the polarity when the device is switched on with the FET.
If no precautions are taken, this induction voltage can reach very high levels and damage the switching FET and possibly other parts of the system.  
In order to tame this peak, it is possible to add an RC-series network in parallel with the inductive load, in such a situation such a RC-combination is called a “snubber-network”.
While the snubber-network is an option, more often a diode is used to suppress the peak. This protection-diode is connected in parallel with the inductive load. The polarity of the diode is such, that when the load is switched on with the FET, it will not conduct, but when the power is switched off, it can conduct in opposite direction. The situation is shown in {numref}`fig:protection_diode`.

```{figure} images/images_6/in_book/protection_diode.svg
:name: fig:protection_diode
Protection diode added to a switched inductive load.
``` 

In {numref}`fig:protection_diode` you can see that when the inductive load is energized that the diode is not conducting. When the load is switched off, the stored energy in the inductor will cause an induction voltage. This induction voltage has a polarity such that the diode can conduct. The stored energy will be converted to heat (dissipated) in the diode.



#### Using bipolar transistors for switching


In the previous part we have seen how a (MOS)FET can be used to switch a load. An important factor there is that the control circuit can supply a high enough voltage to switch on the FET completely. This can be a challenge in circuits where the control-circuit (micro-controller) is powered by a low voltage, like 3.3Volts.

Another option to switch loads is to use a bipolar transistor. The voltage needed to switch on a transistor equals the base-emitter junction voltage (~0.7 V). Advantage is that this voltage is low compared to the FET switching voltage, drawback is that some current needs to be supplied to the base.

When the transistor is used as a switch, the base current is either zero (switch is open) or sufficient current should be supplied to the base, such that the transistor is “saturated”. This means that the transistor is fully conducting. The voltage drop between the collector and the emitter is then around 200 mV. This voltage drop can often be neglected, so the transistor can be regarded as a closed switch.

The current needed to drive the transistor into saturation, is typically around 1 mA. However, this current depends on the type of transistor, and the maximum current the transistor should be capable of switching. The datasheet of the specific transistor will give information on this.

```{figure} images/images_6/in_book/bipolar_switch.svg
:name: fig:bipolar_switch
Electronic switch circuit based on a bipolar transistor.
``` 

A typical transistor switching circuit is shown in {numref}`fig:bipolar_switch`. Note that there is a resistor ($R_1$) to ground as well, the purpose of this resistor is to have the input at a defined potential when the switch circuit gets disconnected from the control circuit. Resistor $R_2$ will limit the current to the base, control circuits very often supply a voltage. There should be a resistor to limit the base-current, otherwise the resistor will be damaged.

When an inductive load (motor, relay etc.) has to be switched, a protection diode is necessary.

#### Switching on the high side

When loads have to be switched electronically you will often notice that the switch will be between the load and the GND. In general, this configuration is the easiest to implement. However, sometimes the switch needs to be between the positive supply voltage and the load (other side of the load is permanently connected to GND).

In these types of circuits we very often see a PNP-transistor instead of the NPN-transistor. A PNP transistor functions basically the same as a NPN-transistor, but the direction of the currents is reversed. This means the controlled current flows from the emitter to the collector. The current through the base flows “out of the base” instead of “into the base”. The direction of the currents is shown in {numref}`fig:PNP-NPN_transistor`, comparing the PNP and the NPN transistor.

```{figure} images/images_6/in_book/PNP-NPN_transistor.svg
:name: fig:PNP-NPN_transistor
Comparison between the PNP and NPN transistor.
``` 

For switching applications the transistor is either in off-state (no current flowing), this is the case when the voltage drop over the emitter to the base is less then 0.7 V. Or the transistor is saturated, this is the case when the voltage drop over the emitter-base junction is ~0.7 V.  

```{figure} images/images_6/in_book/PNP_transistor.svg
:name: fig:PNP_transistor
Electronic switch based on a PNP transistor.
``` 

In {numref}`fig:PNP_transistor` you can see the basic switch circuit with a PNP transistor. When the control voltage is between $U_{supply}$ and ($U_{supply}$ – 0.7 V) the PNP transistor is not conducting (switch is open). When the control voltage is below ($U_{supply}$ – 0.7 V) the PNP transistor is conducting, thus the switch is closed. Resistor $R_2$ will limit the current flowing through the base to a safe value. Resistor $R_2$ will set the transistor in the OFF-state in case the control circuit gets disconnected.  
As you can see, in this configuration, the output voltage of the control circuit, needs to be capable of supplying a control voltage close to the supply-voltage ($U_{supply}$). When the supply-voltage to the load is the same as the supply voltage to the control circuit, this not a problem. But in some applications the voltage to be switched is (much) higher then the supply voltage of the control circuit. In those situations a second transistor is used to “transfer” the switching signal to the higher supply voltage. An example of such a circuit is shown in {numref}`fig:high_side_switch`.

```{figure} images/images_6/in_book/high_side_switch.svg
:name: fig:high_side_switch
Transistor high side switch circuit, which can be controlled by a low control-voltage.
``` 


The transfer of the switch signal to the high side is done by means of the NPN transistor $Q_2$. This transistor determines if a current can flow through the base of the PNP transistor $Q_1$ towards ground. When $Q_2$ is not conducting, resistor $R_1$ determines the potential on the base of $Q_1$, which will be close to $U_{supply}$. When a control signal will create a base-current for $Q_2$, through resistor $R_3$, a current will start to flow through the base of $Q_1$ and $R_2$. This current will switch on the PNP transistor, delivering power to the load.

Here we had a closer look at high-side switches with bipolar transistors. Similar circuits can be build with FETs. In this case P-type FETs will be used instead of N-type FETs. Going into these details and possible circuits is outside the scope of this book, however a lot of resources can be found online.


#### Combined high-side and low-side switching:  the H-bridge


An electronic switch can be used in may applications. For example switching small DC-motors, for example for robotics. A DC-motor will start to spin when a high enough voltage is applied. When the voltage is increased, the motor will rotate faster. (For controlling the speed very often PWM is used.) In order to change the direction of the rotation the polarity of the voltage to the motor should be reversed. For this type of application the H-bridge was designed.

A H-bridge is a circuit which contains four switches, two on the high side, two on the low side. This configuration allows the voltage (or power) to a load to be switched on or off, and to change the polarity of the voltage to a load. The on/off switching to the load can be done at a high frequency (Pulse Width Modulated (PWM) signal), in order to regulate the power to the load. In figure 20, you can see the concept of such a H-bridge. The principle of PWM is explained elsewhere in this chapter.

```{figure} images/images_6/in_book/H-bridge_concept.svg
:name: fig:H-bridge_concept
Concept of a H-bridge.
``` 

In the bridge only two pairs of switches can be switched on simultaneous, either $S_1 + S_4$ or $S_2 + S_3$. The switches $S_1 + S_3$ or $S_2 + S_4$ should never be switched on simultaneous, as this will short the power supply $U_{dc}$ to ground (!).
When switch $S_1 + S_4$ are switched on the current through the load will follow the path of arrow 1. When switch $S_2 + S_3$ are switched on the current will follow the path of arrow 2. Changing the direction of the current only makes sense when a device is polarity-sensitive, for example a DC-motor.

In a practical circuit the switches will be replaced by FETs or BJTs, such that it can be controlled with a micro-controller. The control circuit very often includes protection circuits against voltage spikes from inductive loads, and prevents the situation where the switches could short the power supply. These complete circuits can be found as Integrated Circuits (IC), like the L298N.
The basic circuit with BJTs is shown in {numref}`fig:H-bridge_circuit`.

```{figure} images/images_6/in_book/H-bridge_circuit.svg
:name: fig:H-bridge_circuit
Example of a H-bridge circuit.
``` 

#### Switching to regulate power – PWM

A lot of systems nowadays contain a digital micro-controller, while they have to react in analog way. For example the speed control of a motor, or the intensity of a light-source. For this a real digital-to-analog converter (DAC) could be used, but there is another way to create a semi-analog signal. This method is called Pulse Width Modulation, or PWM.

A PWM-signal is first of all a pulse signal. It switches between an off-state, or low-state, (0 Volt) and an on-state (high-state), in the on-state the voltage often equals the power supply voltage of the micro-controller.
The pulses are generated at a fixed frequency, very often a few kHz, although the frequency could be considerable higher or lower. While the frequency is fixed, the width of the pulse (time it is high) is variable. In {numref}`fig:PWM_transistor` you can see a diagram of a PWM-signal.

```{figure} images/images_6/in_book/PWM_transistor.svg
:name: fig:PWM_transistor
Pulse width modulated signal.
``` 

As the frequency remains constant, the period-time T will be constant. During this period the signal will be high $t_{on}$ and low during $t_{off}$. The ratio between the time the signal is high and the time the signal is low can be varied, the ratio is called the duty-cycle (δ).

$$ 
\delta = \frac{t_{\mathrm{on}}}{t_{\mathrm{on}} + t_{\mathrm{off}}}\cdot 100\% = \frac{t_{\mathrm{on}}}{T}\cdot 100\% 
$$

The duty-cycle determines the average value of the signal over time. When the low-voltage equals 0 Volt, the average voltage is:

$$
U_{avg} = δ * U_{high}
$$

A micro-controller is very well capable of generating such a signal, very often there is a special circuit inside the micro-controller, to generate a PWM-signal autonomous. The duty-cycle can often be varied in steps well below 1 %.

In order to make the PWM signal into a real analog signal, it should be filtered with a low-pass filter (integrator).

It is possible to generate complex waveforms using PWM. The PWM-frequency should be considerable higher then the frequency of the resulting waveform which should be generated. An example, on how to generate a sinewave is shown in {numref}`fig:PWM_sine`. The blue line shows the increasing average value over time.

```{figure} images/images_6/in_book/Pwm.svg
:name: fig:PWM_sine
A sinewave generated by changing the duty-cycle of a PWM-signal.  
Created by CyrilB, under CC BY-SA 2.5, original link: https://upload.wikimedia.org/wikipedia/commons/7/72/Pwm.svg
```  


## Transistors in practice

There is a wide variety of bipolar transistors and field effect transistors to choose from. They are optimised for different applications, for example high-power systems, or high frequency systems, but there are general purpose transistors as well.

Depending on the application they can have a specific pin-out and package. The packages are standardized, but still there is a lot of variation. Therefor they have a code, starting with “TO”, followed by a number and sometimes some extra letters to indicate small variations.
While the packages are standardized, the pinout e.g. which pin is base, emitter and collector, depends on the type of transistor. Always check the specific datasheet! In {numref}`fig:transistor_packages` you will see some examples of transistor-packages.

```{figure} images/images_6/in_book/transistor_packages.svg
:name: fig:transistor_packages
Examples of a few common transistor packages.
```  

### Heat dissipation in transistors

An important factor is the amount of power the transistor (BJT or FET) can dissipate. Remember, the voltage drop over the transistor multiplied with the current through the resistor gives you the power-dissipation in the device. This power is converted to heat. In general a transistor should not get much warmer then 125 °C, or 398 K.
While the maximum amount of power dissipated is limited, the maximum can be found in the datasheet of the transistor, the temperature should remain within the safe range as well. In order to keep the transistors temperature at a safe level, it can be mounted on a heatsink.
A heatsink is often made of aluminium and has a structure such that the heat can be transferred to the environment.
Especially high power transistors are in packages which can be easily mounted to a heatsink. In order to determine the correct size of a heatsink some thermal calculations have to be done.

In the datasheet you will find thermal resistance of the junction (the silicon doing the real work) to the case, and the thermal resistance to the junction the environment. The thermal resistance is expressed in Kelvin per Watt [K/W].

Assume we have a transistor where the voltage drop from the collector to the emitter $U_{ce}$ equals 10 V, and the current through the device ($I_e$) is 0.15 A. Then the power dissipated in the transistor is:

$$
P = U_{ce} * I_e = 10 V * 0.15 A = 1.5 W
$$

In the datasheet we find a thermal resistance of the junction to ambient ($R_{thj-amb}$) of 100 K/W. The temperature increase above ambient of the transistor is:

$$
dT = P * R_{thj-amb} = 1.5 W * 100 K/W = 150 K
$$

So the temperature of the transistor would increase with 150 K due to the power dissipated. When we assume an ambient temperature of 25°C (298K) the transistor would reach a temperature of 175°C (448K). This temperature is too high for the transistor. Therefor a heatsink can be used.

The setup with the heatsink can be drawn schematically as seen in {numref}`fig:transistor_heat_transfer`.

```{figure} images/images_6/in_book/transistor_heat_transfer.svg
:name: fig:transistor_heat_transfer
Schematic drawing of the heat-transfer between the junction and the ambient.
```  

For this example we assume the following values:  
$P_{junction}$ = 1.5 W  
$R_{th, j-case}$ = 10 K/W  
$R_{th,heatsink}$ = 8 K/W  
$T_{amb}$ = 293 K  

Then the temperatur of the junction in this situation will be:

$$
T_j = T_{amb }+ P * R_{th} = T_{amb} + P * (R_{th, j-case} + R_{th,heatsink}) =  293 + 1.5 (10 + 8) = 320K
$$

The temperature of 320K (47°C) is well below the maximum temperature of the junction. The heatsink is thus able to cool the transistor sufficiently.

 
### Phototransistor

The purpose of the packaging of a transistor is to protect the silicon-junction (and the tiny connecting wires) against physical damage. But the package shields the junction from environmental light as well. When light hits the PN-junction, the photons can free up extra electrons in the semiconductor material. In the photodiode this results in an increasing leakage current. In a transistor the photons can create a base-current. Very often this is an unwanted effect, but some special transistor exploit this effect: the phototransistor.

The phototransistor is placed in a special package with a window or a lens which allows light to reach the base-emitter junction. The (tiny) current which is generated there will allow a current to flow between the collector and the emitter.
The base of the transistor is very often omitted, thus the phototransistor has only two pins, the collector and the emitter.

```{figure} images/images_6/in_book/phototransistor.svg
:name: fig:phototransistor
Phototransistor, drawing and schematic symbol.
```  

The advantage of the phototransistor compared to a photo-diode is that photo-current is amplified in the device. This current can often be used to directly switch a small load, or create a logic (low or high) signal which can be read out by a micro-controller.

The disadvantage of this transistor is the less accurate transfer of light intensity to current and the lower speed.


### Open collector outputs


As transistors and FETs are used in a wide variety of integrated circuits (ICs). Very often these ICs have some sort of interaction with the environment. For example they control an actuator or they sense the presence of light or magnetic fields. In order to interface with the rest of the system, they can make use of an open-collector output.

An open-collector output exposes the collector of an internal transistor to the outside world. The emitter of this internal transistor is connected to ground. Advantage of this system is that it doesn't have to supply a specific voltage.

A good example of a sensor with an open-collector output is the magnetic field sensor. While it is called a sensor, it is actually a sensor-system. It contains the sensor, interface-electronics and an output-stage. In {numref}`fig:magnetic_field_sensor` you can see a schematic drawing of such a sensor.  


```{figure} images/images_6/in_book/magnetic_field_sensor.svg
:name: fig:magnetic_field_sensor
Schematic drawing of a magnetic field sensor with an open-collector output.
```  


These sensors are very often contained in a small package, similar to the package of a small transistor. They only need three connections to the outside world, a power supply pin, an output-pin and a GND connection.

How does such a system work?  
Inside the enclosure there is a sensor and an amplifier/comparator. The signal from the sensor is amplified and compared with a threshold. As soon as the sensor level reaches the threshold, the NPN transistor gets a signal on its base. The output transistor starts to conduct.  
When the sensor is interfaced to a digital input-pin of a micro-controller, the output pin of the sensor is connected to the micro-controller and a pull-up resistor. When the sensor switches on, the digital input-pin switches from a high to low value.  
In {numref}`fig:magnetic_field_sensor` we can see a big advantage of the open-collector pin: The sensor itself is powered from a 12 V source, while the micro-controller is powered bij +3.3 V. Normally a 12 V output of a sensor would damage the micro-controller. By using the pull-up resistor from the 3.3 V line, the output of the sensor switches between 3.3 V and (almost) GND-level.

## Transistor exercises


`````` {exercise} BJT transistor switch
```{figure} images/images_6/in_book/bipolar_switch.svg
---
name: fig:transistor_exercise1
width: 500px
align: center
---
A transistor switch is constructed, based on a BJT. The BJT has the following characteristics:  
$hfe$ = 120  
$U_{be}$ = 0.65 V  
$V_{ce(sat)}$ = 0.2V @ $I_b$ = 1mA   
$I_{c(max)}$ = 200mA (continuous)  
$P_{max}$ = 625mW  

```

````` {dropdown} 🖊️ Exercise: BJT transistor switch
The BJT will switch a resistive load. The switching is controlled by a micro-controller. Resistor $R_1$ has a value of 10 kOhm.

a.) Calculate the value of resistor $R_2$, when the micro-controller has a high output voltage of 3.3V.

```{admonition} Tip 
:class: tip dropdown
Model the micro-controller as a voltage source. Check which current path is controlling the transistor.
```

```{admonition} ✅ answer for $R_2$ 
:class: dropdown, seealso
Resistor $R_1$ has no influence, it will only draw some power from the output pin of the micro-controller. Resistor $R_2$ is connected on one side to the +3.3V of the micro-controller, the other side is connected to the base. $U_{be}$ is 0.65V thus:

$U_{R_2}$ = 3.3 – 0.65 = 2.65 V

To switch the transistor a base current of 1 mA is needed thus:

$R_2$ = 2.65 V / 1 mA = 2650 Ohm (standard value is 2.7 kOhm, which will be okay)

```

b.) Calculate the value of resistor $R_2$, when the micro-controller has a high output voltage of 5V?
```{admonition} Tip for working with diodes in a circuit
:class: tip dropdown
Model the micro-controller as a voltage source. Check which current path is controlling the transistor.
```
```{admonition} ✅ answer for $R_2$
:class: dropdown, seealso
In this case, resistor $R_1$ has no influence as well. The drop over $R_2$ will be:

$U_{R_2}$ = 5 – 0.65 = 4.35V

The base-current must be 1mA, thus:

$R_2$ = 4.35V / 1mA = 4.35 kOhm (this means a standard value of 3.9 kOhm, or, when available 4.3 kOhm)
```

c.) What is the minimum resistance of the LOAD-resistor? The LOAD is powered by +12V.
```{admonition} Tip for LOAD resistor
:class: tip dropdown
Calculate the actual voltage drop over the LOAD-resistor. 
```
```{admonition} ✅ answer for LOAD resistor
:class: dropdown, seealso
When the transistor is conducting, and saturated, the voltage drop over $V_{ce}$ = 0.2V ($V_{ce(sat)}$).

The total voltage drop over the LOAD will be: $U_{supply} – V_{ce}$ = 12 – 0.2 = 11.8V

The maximum current through the transistor is 200mA. Thus $R_{load}$ = 11.8/0.2 = 59 Ohm

Check if the maximum power is not exceeded: $P = U * I = V_{ce(sat)} * I_{max}$ = 0.2 * 0.2 = 40mW

So yes, the minimum LOAD resistance is 59 Ohm.

Please note: When the transistor should be capable of switching the maximum current of 200 mA, the base current has to be increased. The current gain of the transistor is 120, in order to properly switch a current of 200 mA, the base current should be at least: 200 mA / 120 = 1.7 mA. In practice, a higher current is chosen to make sure the transistor is fully saturated under all circumstances.

```

`````` 

`````` {exercise} linear power regulator
```{figure} images/images_6/in_book/linear_voltage_regulator.svg
---
name: fig:transistor_exercise2
width: 500px
align: center
---
A linear power regulator is constructed with an OPAMP, bipolar transistor and zener diode.  
The supply should give a stable supply of 3.3V at a maximum current of 0.5A. 
The reference zener used has a zener-voltage of 3.0V. 
Input voltage of the supply is 12V.
```

````` {dropdown} 🖊️ Exercise: BJT transistor switch
The chosen transistor, a  BD139, has the following characteristics:  
$U_{ce(max)}$ = 80V  
$P_{max}$ = 12.5W  
$I_{c(max)}$ = 1.5A  
$R_{th(junction-ambient)}$ = 100 K/W   
$R_{th(junction-case)}$ = 10 K/W   
$T_{j(max)}$ = 150ºC  
$T_{amb}$ = 22ºC  

The OPAMP can be assumed to be ideal.

a.) Calculate the value of $R_1$, when the current through the zener diode should be 5mA.

```{admonition} ✅ answer for $R_1$ 
:class: dropdown, seealso
The circuit is powered with 12V, the zener will break-down (zener-voltage) of 3V.  
This will give a voltage drop of 12V – 3V = 9V over $R_1$.   
OPAMP is ideal, so there will only be current flowing through the zener (5mA)

$R_1 = U_{R_1} / I$ = 9V / 5mA = 1800 Ohm  (this is a standard resistor value)

```

b.) Calculate the values of $R_2$ and $R_3$, scuh that the output voltage will be 3.3V.
```{admonition} Tip for $R_2$ and $R_3$
:class: tip dropdown
$R_2$ and $R_3$ form a voltage divider. The voltage connected to the inverting input of the OPAMP should be equal to the zener-voltage when Uout is 3.3V.
```
```{admonition} ✅ answer for $R_2$ and $R_3$
:class: dropdown, seealso
The OPAMP will regulate the transistor, such that the voltage on its inverting and non-inverting will be equal, thus 3V.

This means the junction between $R_2$ and $R_3$ should be equal to 3V when $U_{out}$ is 3.3V.

$U_{-} = U_{out} * R_3 / (R_2 + R_3)$

3.0 = 3.3 * $R_3$ / ($R_2$ + $R_3$) →  3.0* ($R_2$ + $R_3$)  = 3.3 * $R_3$  
   → 3 * $R_2$ = 0.3 * $R_3$ → 10*$R_2$ = $R_3$

So, a suitable combination could be 1 kOhm for $R_2$ and 10 kOhm for $R_3$.

```

c.) What is the maximum power-dissipation in the transistor?
```{admonition} Tip for power dissipation
:class: tip dropdown
What is the maximum current the supply should provide?  
What is the voltage drop over the transistor?
```
```{admonition} ✅ answer for power dissipation
:class: dropdown, seealso
The maximum current from the supply is specified as 0.5 A. The voltage drop over the transistor is the difference between the collector- and emitter-voltage.

$U_{ce} = U_{in} – U_{out}$ = 12 – 3.3 = 8.7V

$I_{max}$ = 0.5A (which is within the maximum of the transistor!)

Power-dissipation: $P = U_{ce} * I_{max} $= 8.7 * 0.5 = 4.35 W


```

d.) Calculate the maximum temperature of the junction of the transistor, when it is not attached to a heatsink.
```{admonition} Tip for max temperature
:class: tip dropdown
Do not forget to include the ambient temperature in your calculation.
```
```{admonition} ✅ answer for max temperature
:class: dropdown, seealso
The power dissipated in the transistor (maximum) is 4.35W. The thermal resistance from the junction to the ambient is 100 K/W.

The temperature increase is: dT = P * $R_{th(ja)}$ = 4.35 W * 100 K/W = 435K

This is the increase above ambient temperature, thus the maximum temperature will be:

$T_{amb}$ = 22ºC → 295K

$T_j = T_{amb} + dT$ = 295 K + 435 K = 730K (457ºC) ←  This is TOO HOT!
```

e.) Calculate the thermal resistance of a heatsink, when the transistor junction should be 80ºC max.
```{admonition} Tip for thermal resistance
:class: tip dropdown
Check the maximum increase of the temperature above the ambient temperature.
```
```{admonition} ✅ answer for thermal resistance
:class: dropdown, seealso
The ambient temperature is 23ºC, the maximum increase in temperature is:

$dT_{max} = T_{max} – T_{amb}$ = 80ºC – 23ºC = 57ºC

The power dissipated is 4.35W, thus  
$R_{th,j-c}+R_{th(heatsink)} = dT_{max} / P_{max} $= 57ºC / 4.35W = 13.1K/W.  
So $R_{th(heatsink)}$ is (maximally) 3.1K/W. 



```

`````` 


`````` {exercise} transistor influencing filter's cut-off frequency
```{figure} images/images_6/in_book/transistor_exercise3.svg
---
name: fig:transistor_exercise3
width: 500px
align: center
---
A high-impedance source (Thevenin equivalent is drawn) generates a signal which has to be transferred with a coaxial cable. A) First the source is directly connected to the coaxial-cable. B) later on a transistor is added.
```

````` {dropdown} 🖊️ Exercise: transistor influencing filter's cut-off frequency
Given are the following characteristics:  
–	$U_b$ = +6V  
–	$U_{th,dc}$ = 3V  
–	$U_{th,ac}$ = 1V  
–	$R_{th}$ = 500 kOhm  
–	coax length 2m, capacitance 150pF/m  

a.) The source, combined with the coaxial cable creates a filter ({numref}`fig:transistor_exercise3`A) . What is the cut-off frequency of this filter?

```{admonition} Tip for cut-off frequency
:class: tip dropdown
Calculate the capacitance of the total length of the coaxial cable. Replace the cable in the schematic with this capacitance between the 500kOhm resistor and ground.
```

```{admonition} ✅ answer for cut-off frequency
:class: dropdown, seealso
The coaxial cable will create a capacitor with a capacitance of: 2m * 150pF = 300pF

For the cut-off frequency, the DC source has no influence. This system will behave as a traditional RC-filter, thus:

fc = 1 / (2π*RC) = 1 / (2π * 500k * 300p) = 1061 Hz
```

b) Now a transistor is added {numref}`fig:transistor_exercise3`B, between the high-impedance source, and the coaxial cable. The current gain of the transistor is 200. Calculate the cut-off frequency of this system.

```{admonition} Tip for cut-off frequency with transistor
:class: tip dropdown
For the coaxial cable, it seems the transistor will lower the source-resistance ($R_{th}$).
```

```{admonition} ✅ answer for cut-off frequency with transistor
:class: dropdown, seealso
The source-resistance will be lowered by the current gain of the transistor, when observed from the coaxial cable. So, for the coaxial cable the source resistance will be:

$R_{th} = R_{th} / β$ = 500 kOhm / 200 = 2.5 kOhm

Thus the new cut-off frequency will be:  
$f_c$ = 1 / (2π*RC) = 1 / (2π * 2.5k * 300p) = 212 kHz

The cut-off frequency only influences the AC-part, the DC-output out Uout will be lowered with the voltage drop of $U_{be}$, so $U_{out,dc}$ will be: 3V – 0.7V = 2.3V.


```


`````` 