# Crystal Radio

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

# Voltage Divider

Using two resistors and an input voltage can be lowered to a resulting voltage according to the formula:

using the following circuit diagram:


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


The equation has four parameters , , and such that when three parameters are known, the fourth parameter can be obtained by solving the equation.

# Antenna Length Calculations

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

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

However, since the wavelength can be represented as a sine function, any multiple of 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:

• and are resistors,
• and are capacitors where is fixed at ,
• is the input voltage, and
• is the output voltage that will fluctuate between high and low at the desired frequency,
• is ground.

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

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

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

where, (the time spends as high) is given by:

respectively (the time spends as low) is given by:

Empirically, a button press by a player on the hardware buttons has variable and 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 , defined (as the ratio between the time that the button is being held down and the time that button is released):

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

In this case, the mark space ratio will be such that we can write and substituting with the formulas for respectively , we obtain:

Let for simplicity and solving:

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

Pedantically, the period should be equal to the CPU clock time because a higher frequency would simply not be perceived by the CPU however, the period 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 could be chosen as any value close to the FPS. In this case, let () and which would mean that the button will be pressed for and then depressed for () and then pressed again, …

For both equations for and reduce to:

and solving for :

That is, taking values for the capacitor we can obtain the necessary value for the resistor . For instance, taking a capacitor of (), the value for is obtained:

And, as it always is the case with engineering, nobody is going to produce a resistor, just for you. One can plot vs and select points on the curve in order to hopefully obtain practical values for and :

So, let's see: when then . Of course, were the values and to be substituted in the original formulas, which is not exactly the initial goal of - 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 could perhaps be substituted by a variable resistor such that the period 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 which is the standard voltage used by most IoT devices.

The value of the base resistor 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 such as the from a GPIO pin equal to the sum of the base-emitter voltage of the NPN transistor and the base voltage :

using Ohm's law, it is known that:

Substituting, the following relation is obtained:

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

Also, knowing that BJT behave typically as a forward-biased diode with an approximate voltage drop of , it is obtained that . Now, since the base-emitter voltage is usually negligible by comparison to the input voltage , the formula reduces to:

Finally, to determine , the following relation is given:

where is the DC gain of the transistor and is the current flowing through the collector.

Substituting for the following formula is obtained:

from where the value of the base resistor can be determined as a relation between the input voltage , the DC gain of the transistor () and the collector current (also the load current).

As an example, let us assume that the device to be powered requires the load current , that the device should be toggled from a GPIO pin capable of supplying and that the DC gain of the transistor .

In that case the value of the base resistor is:

or .

The value for the load 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:

• , and are all parameters that are given by the transistor specifications.

Knowing that every load has an internal resistance and applying Ohm's law in quadrant , the load current can be determined as:

## 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 () 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 which is insufficient to power a device (connected to pins and ).


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

+ - (b)
|
- GND


When the GPIO () is pulled high, the BJT transistor will allow up to to flow from through the collector and to the emitter thereby powering a device (connected to pins and ).

## 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 () 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

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