Crystal Radio

      \|/
       |
       |
       |
   c*--*---*--->|---+
   c       |        |
   c       |        v  *
   c      ---      +-+/|
   c     ----->    | | |
   c      ---      +-+\|
   c       |        ^  *
   c       |        |
   c*--*---*--------+
       |
       |
       |
      ---
      ///

Voltage Divider

Using two resistors $R_{1}$ and $R_{2}$ an input voltage $V_{in}$ can be lowered to a resulting voltage $V_{out}$ according to the formula:

$$
\begin{eqnarray*}
V_{out} &=& \frac{V_{in} * R_{2}}{R_{1} + R_{2}}
\end{eqnarray*}
$$

using the following circuit diagram:

                                
      * -------*                
      |        |                
      |        *                
      |        \                
      |        / R1             
      |        \                
   +  *        *                
               |                
  Vin          *-------*        
               |       | +      
   -  *        *       *        
      |        /          Vout  
      |        \ R2    *        
      |        /       | -      
      *--------*-------*        
                                                         

The equation has four parameters $V_{in}$, $V_{out}$, $R_{1}$ and $R_{2}$ such that when three parameters are known, the fourth parameter can be obtained by solving the equation.

Antenna Length Calculations

The optimal length $l$ for an antenna designed to receive signals with a frequency of $\lambda Mhz$ is given by the formula:

$$
\begin{eqnarray*}
l &=& \frac{300}{\lambda}
\end{eqnarray*}
$$

For instance, for a $2.4GHz$ signal, the optimal length will be:

$$
\begin{eqnarray*}
l &=& \frac{300}{2400} \\
&=&0.125m \\
&=&125mm
\end{eqnarray*}
$$

However, since the wavelength can be represented as a sine function, any multiple of $l$ will still be able to pick up the signal efficiently.

Autofire

Autofire is a game feature that allows the player to flick a hardware switch in order to make the game character shoot at the fastest possible rate thereby alleviating the player's need to mash the fire button repeatedly. Many (retro) consoles do not benefit from a built-in autofire switch. Alternative or addon controllers often had an autofire button.

On all consoles, the hardware buttons are no more than a momentary single press single throw (SPST) switch that closes a circuit and (usually) instructs the microprocessor to execute the corresponding action (ie: shoot).

As such, a circuit can be built using a NE555 timer that will rapidly make the connection between the two leads in parallel with the original hardware button.

For this mini-project, an astable circuit based on the NE555 timer is built:

                    Vcc
                     +
                     |
+--------------+-----+
|              |     |
R1         +---+-----+---+
|          |   4     8   |
+----------+ 7         3 +------+ Vout
|          |             |
R2         |    NE555    |
|          |             |
+----+-----+ 6         5 +------+
|    |     |   2     1   |      |
|    |     +---+-----+---+      |
C1   |         |     |          C2 = 10nF
|    +---------+     |          |
+--------------------+----------+
                     |
                    GND

where:

  • $R_{1}$ and $R_{2}$ are resistors,
  • $C_{1}$ and $C_{2}$ are capacitors where $C_{2}$ is fixed at $10 nF$,
  • $V_{cc}$ is the input voltage, and
  • $V_{out}$ is the output voltage that will fluctuate between high and low at the desired frequency,
  • $GND$ is ground.

The formula to calculate the frequency at which the output voltage switches between high and low is given by:

$$
f = \frac{1.44}{(R_{1} + 2 R_{2})C_{1}}
$$

The period $T$ is the time covered for one cycle, high and low:

           T
     |<--------->|
     |           |
     | T1    T0  |
     |<--->|<--->|
     |     |     |
     +-----+     +-----+
     |     |     |     |
     |     |     |     |
-----+     +-----+     +-----

where, $T_{1}$ (the time $V_{out}$ spends as high) is given by:

$$
T_{1} = 0.694 (R_{1} + R_{2}) C_{1}
$$

respectively $T_{2}$ (the time $V_{out}$ spends as low) is given by:

$$
T_{0} = 0.694 R_{2} C_{1}
$$

Empirically, a button press by a player on the hardware buttons has variable $T_{1}$ and $T_{2}$ and it does not matter whether the player spends more time with the button held down than with the button depressed when the player mashes the button.

Nevertheless, for simplicity, let us assume that the mark space ratio $M$, defined (as the ratio between the time that the button is being held down and the time that button is released):

$$
M = \frac{T_{1}}{T_{0}}
$$

is equal to $1$, meaning an equal time of the button being held down and released.

In this case, the mark space ratio will be $1$ such that we can write $T_{1} = T_{0}$ and substituting with the formulas for $T_{1}$ respectively $T_{0}$, we obtain:

$$
0.694 (R_{1} + R_{2}) C_{1} =  0.694 R_{2} C_{1} 
$$

Let $p=0.694$ for simplicity and solving:

\begin{eqnarray*}
p (R_{1} + R_{2}) C_{1} &\equiv& p R_{2} C_{1} \Rightarrow \\
R_{1} + R_{2} &\equiv& R_{2} \Rightarrow \\
R_{1} &\equiv& 0
\end{eqnarray*}

meaning that for a mark space ratio $M=1$, the value of the resistor $R_{1}$ must be $0$; in other words, the $R_{1}$ resistor is shorted (tersely, the wire itself will imply some resistance that will just be ignored).

Pedantically, the period $T$ should be equal to the CPU clock time because a higher frequency would simply not be perceived by the CPU however, the period $T$ could also be equal to the frames per second rating since a higher frequency could not be perceived on the screen.

In the end, various games accept different button mash speeds such that the period $T$ could be chosen as any value close to the FPS. In this case, let $T=0.02ms$ ($20ms$) and $M=1$ which would mean that the button will be pressed for $T_{1}=10ms$ and then depressed for $T_{0}=0.01s$ ($10ms$) and then pressed again, …

For $R_{1}=0$ both equations for $T_{1}$ and $T_{0}$ reduce to:

$$
0.01 &\equiv& 0.694 R_{2} C_{1} 
$$

and solving for $R_{2}$:

\begin{eqnarray*}
R_{2} &\equiv& \frac{0.01}{0.694 C_{1}}
\end{eqnarray*}

That is, taking values for the capacitor $C_{1}$ we can obtain the necessary value for the resistor $R_{2}$. For instance, taking a capacitor of $1 \mu F$ ($0.000001 F$), the value for $R_{2}$ is obtained:

\begin{eqnarray*}
R_{2} &\equiv& \frac{0.01}{0.694 0.000001} \\
&\approx& 11409.221892 \ldots \Omega
\end{eqnarray*}

And, as it always is the case with engineering, nobody is going to produce a $11409.221892 \ldots \Omega$ resistor, just for you. One can plot $C_{1}$ vs $R_{2}$ and select points on the curve in order to hopefully obtain practical values for $C_{1}$ and $R_{2}$:

So, let's see: when $C_{1} \approx 8 \mu F$ then $R_{2} \approx 2k \Omega$. Of course, were the values $C_{1}=8*10^{-6}$ and $R_{2}=2000$ to be substituted in the original formulas, $T = T_{1} + T_{0} \approx 11.10ms$ which is not exactly the initial goal of $10ms$ - but good enough to simulate a repeated button press!

Consoles will definitely not mind variations of the order of milliseconds when it comes to button mashing however, if leeway is to be given, then $R_{2}$ could perhaps be substituted by a variable resistor such that the period $T$ could become adjustable.

Transistor as a Switch

A 2N3904 BJT (base-junction transmitor) transistor can be used as a low-voltage switch in a circuit instead of a relay. The schematic is built around $3.3V$ which is the standard voltage used by most IoT devices.

The value of the base resistor $R_{b}$ that must be used in order to run the transistor at saturation can be calculating. Let the following circuit be a guide for the calculations:

                                    
                                    +--------+ Vcc
                                    /
+------------------+                \
^       ^          |                /
|       |          \                |  | Ic
|    Vb = Ib * Rb  / Rb             |  v
|       |          \        Ib      C
|       |          |        ->    |/
Vi      v          +---+---------B|\  hFE
|                      ^            E
|                      | Vbe        |
|                      v            |
+-----------------------------------+
                                    |
                                    - GND

We have an input voltage $V_{i}$ such as the $3.3V$ from a GPIO pin equal to the sum of the base-emitter voltage of the NPN transistor $V_{be}$ and the base voltage $V_{b}$:

$$
\begin{eqnarray*}
V_{i} &=& V_{b} + V_{be}
\end{eqnarray*}
$$

using Ohm's law, it is known that:

$$
\begin{eqnarray*}
V_{b} &=& I_{b} * R_{b}
\end{eqnarray*}
$$

Substituting, the following relation is obtained:

$$
\begin{eqnarray*}
R_{b} &=& \frac{V_{i} - V_{be}}{I_{b}}
\end{eqnarray*}
$$

In order to guarantee that the transistor operates in the saturation region, the base current is multipled by a factor of $3$, such that:

$$
\begin{eqnarray*}
R_{b} &=& \frac{V_{i} - V_{be}}{3 * I_{b}}
\end{eqnarray*}
$$

Also, knowing that BJT behave typically as a forward-biased diode with an approximate voltage drop of $\approx 0.6V$, it is obtained that $V_{i} - V_{be} \approx 0.6V$. Now, since the base-emitter voltage $V_{be}$ is usually negligible by comparison to the input voltage $V_{i}$, the formula reduces to:

$$
\begin{eqnarray*}
R_{b} &=& \frac{V_{i}}{3 * I_{b}}
\end{eqnarray*}
$$

Finally, to determine $I_{b}$, the following relation is given:

$$
\begin{eqnarray*}
$I_{b}$ &=& \frac{I_{c}}{hFE}
\end{eqnarray*}
$$

where $hFE$ is the DC gain of the transistor and $I_{c}$ is the current flowing through the collector.

Substituting for $R_{b}$ the following formula is obtained:

$$
\begin{eqnarray*}
R_{b} &=& \frac{V_{i} * hFE}{3 * I_{c}}
\end{eqnarray*}
$$

from where the value of the base resistor can be determined as a relation between the input voltage $V_{i}$, the DC gain of the transistor ($hFE$) and the collector current $I_{c}$ (also the load current).

As an example, let us assume that the device to be powered requires the load current $I_{c} \approx 100mA = 0.1A$, that the device should be toggled from a GPIO pin capable of supplying $3.3V$ and that the DC gain of the transistor $hFE = \beta = 100$.

In that case the value of the base resistor $R_{b}$ is:

$$
\begin{eqnarray*}
R_{b} &=& \frac{3.3V * 100}{3 * 0.1A} \\
&=& \frac{3300}{0.3} \\
&=& 11000 \Ohm
\end{eqnarray*}
$$

or $R_{b} = 11k\Ohm$.

The value for the load $I_{c}$ can be determined using the same schematic:

                                    
                                    +--------+ Vcc
                                    |   Ql   ^
                                    /        |
+------------------+                \ Rl   Vcc-Vce
^       ^          |                /        |
|       |          |           | Ic |        |
|       |          |           v    |        v
|       |          \                +--------+ 
|    Vb = Ib * Rb  / Rb             |        ^
|       |          \        Ib      C        |
|       |          |        ->    |/         |
Vi      v          +---+---------B|\  hFE   Vce
|                      ^            E        |
|                      | Vbe        |        |
|                      v            |        v
+-----------------------------------+--------+
                                    |
                                    - GND

where:

  • $Vbe$, $hFE = \beta$ and $Vce$ are all parameters that are given by the transistor specifications.

Knowing that every load has an internal resistance $R_{l}$ and applying Ohm's law in quadrant $Q_{l}$, the load current $I_{c}$ can be determined as:

$$
\begin{eqnarray*}
I_{c} &=& \frac{V_{cc} - V_{ce}}{R_{l}}
\end{eqnarray*}
$$

Example

Assume the following circuit:

          
 +--------- S2 +----------+
 |         3.3V           |
 - GND                    |
                          C
                        |/
 +--- S1 +----+/\/+----B|  2N3904
 |    0V     460kOhm    |\
 |                        E
 - GND                    |
                          |
                          + + (a) 864.7uV

                          + - (b)
                          |
                          - GND

When the GPIO ($S_{1}$) pin is pulled low, for instance, programatically by controlling the GPIO pin through software, the current flowing between the collector and emitter of the 2N3904 NPN BJT transistor is as low as $864.7\muV$ which is insufficient to power a device (connected to pins $a$ and $b$).

          
 +--------- S2 +----------+
 |         3.3V           |
 - GND                    |
                          C
                        |/
 +--- S1 +----+/\/+----B|  2N3904
 |   3.3V  Rb=460kOhm   |\
 |                        E
 - GND                    |
                          |
                          + + (a) 2.966V

                          + - (b)
                          |
                          - GND

When the GPIO ($S_{1}$) is pulled high, the BJT transistor will allow up to $2.966V$ to flow from $S_{2}$ through the collector and to the emitter thereby powering a device (connected to pins $a$ and $b$).

PCB Design

Given the required components consisting in just a resistor and a transistors, various PCB designs can made. Small modules can be created by using a 2N3904 transistor and an surface-mounted resistor using a dual-layer PCB. Larger modules would use a standard long resistor on the base but are still sufficiently small to serve most applications.

Shortcomings

The problem with the transistor switch is that the 2N3904 transistor will not allow a high amperage to flow through the junction such that the switch is best used to trigger digital buttons rather than act as a relay. Under no circumstance should a transistor switch be used to operate mains voltages ($220-110V$) and apparatus that might require entire amperes of power. For the latter case, a reed relay such as the R1 series from Rayex Electronics should be used instead of a transistor switch.


fuss/physics/electronics.txt · Last modified: 2020/04/08 20:18 by office

Access website using Tor Access website using i2p


For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.