Contents

Resources

PCB Sources

Here are some companies who will fab boards from uploaded Gerber files which can be produced in Fritzing. I have no idea about the quality of these services but I’m collecting them for future reference.

Software

Some ideas:

  • apt install easyspice executable is /usr/bin/easy_spice.

  • apt install ngspice ngspice-doc and then have a look at: file:///usr/share/doc/ngspice-doc/html/manual.html

  • apt install gspiceui

  • apt install simulide

  • apt install kicad

  • apt install fritzing - very cool. Many good commercial components in database. Breadboard, schematic, and PCB views. Couldn’t figure out a simulation mode.

  • qucs-s For some reason qucs-s isn’t in the normal repos but the devs are keeping Debian in mind.

  • Gnucap - used as an engine by others like gspiceui.

E Series Of Preferred Numbers

Why are electronic components mostly sized in strange ways? There is a sense to it which attempts to not cluster produced sizes in such a way that would provide big errors in some ranges. The increments are logarithmic in some clever way.

For example, the E24 scale divides an order of magnitude into 24 values like this.

1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1

This keeps any value you could need withing 5% tolerance of what is commonly available in these increments. This is why you often see resistors for 470 Ohms and 510 Ohms but not 490 Ohms. Or a capacitor of 560uF instead of something easier for humans to remember.

Resistors

Value Bands

When there are four marking bands, the first three bands specify the value. The first band’s color value is multiplied by 10. The second band’s value is added to that. The third band’s value is the exponent that 10 is raised to which should be multiplied by the previous total.

For five band resistors, the first three compose a three digit number, the fourth is the multiplier, and the fifth is the tolerance. Note that the tolerance is usually separated with more space than the other bands.

0 BLK 1 BRN 2 RED 3 ORG 4 YEL 5 GRN 6 BLU 7 VIO 8 GRY 9 WHT

Example:

  • BRN BLK RED = (BRN*10 + BLK) * 10^ RED = 1000 Ohms

  • YEL VIO BRN = (YEL*10 + VIO) * 10^ BRN = 47 * 10 = 470 Ohms

Tolerance Bands

The 4th band of a 4 band resistor indicates its accuracy. Gold at 5% seems like the most common.

GRY .05% VIO .10% BLU .25% GRN .5% BRN 1% RED 2% GLD 5% SLV 10%

A unit without a tolerance band should still be implicitly within 20%. Gold and silver are by far the most commonly used tolerances, gold being almost ubiquitous in my experience. Much less commonly gold and silver can also be order of magnitude signifiers - .1 an .01 respectively.

Digikey has a nice chart and calculator.

What if you get a very weird resistor, bigger than usual, and it has a yellow band outside of the gold band? For example, I have one that is BRN GRN BLK GLD YEL. I don’t know for sure but that seems like it may be one of these wire wound non-inductive resistors.

Ohmmeter Testing

Sounds easy, right? But I’ve had moments of confusion so here’s a conclusive summary and some examples of how this works with my meter (and many others).

The values that the meter shows are in the units that match the dial’s setting. So if it’s set at the 2K setting, that will be in "K" or kilo Ohms. If you have it set on 20M that will read in mega Ohms. If you have it on the 200 setting, the one with the audible low resistance continuity signal, it will read directly in Ohms. The values on the settings represent the maximum value that range can accommodate; so the 2000K setting can handle a 2 mega Ohm value but will produce kilo Ohm readings.

Let’s say I have a resistor that has YEL VIO BLK BLK BRN or possibly (reversed) BRN BLK BLK VIO YEL. But we’re not sure if the violet is really gray or blue or who-knows-what. It’s helpful to start with a best guess, in this case 4-7-0-(10*0) +/-1% Ω.

How should that appear on a meter? It would be nice if it came up as 470 Ω. But it mostly will not. My typical meter has settings for "20M", "2000K" (i.e.2M), "200K", "20K", "2K", and "200". If I suspect my resistor is 470 Ω then I should go to the smallest setting that is larger than the value. 200 is less than 470 so that won’t work; "2K" is larger than 470 so that’s the one to try. If the color band guess was correct, the reading should be something like ".468".

How about another: BRN GRY BLK YEL BRN, or maybe BRN YEL BLK GRY BRN? Maybe the GRY or YEL is wrong — hard to tell being microscopic and badly printed. The first interpretation should be "180 * 10,000 +/-1%" or 1.8M Ω. The second way to read it is "140 * 100,000,000 +/-1%" which is 14G Ω, a bit high.

Let’s assume the 1,800,000 Ω or 1800 kOhms. This is just under the 2000K setting so use that. The reading comes in between 1350 and 1430. That’s not what was expected! The problem with this measurement is that I’m holding the leads of the meter in my hands and my body has a certain (pretty high) resistance that for values like this are non-negligible. After connecting the resistor to clips so that it can be measured without touching it, the reading bops around from 1783 to 1805 which is what is expected.

How about BRN ORG BLK BLK BRN, possibly BRN BLK BLK ORG BRN. This one seems most reasonable to assume 130 Ω. Setting it upon the meter, I get a "1 ." which means it’s not even close. Maybe the other way was right after all — 100 * 1e3 which is 100k Ω. This means that the dial must be set to "200K". Then the reading comes up "100.2" which seems to confirm it.

What about BRN RED BLK BLK BRN or BRN BLK BLK RED BRN. The first way is 120 Ω and the second way is 10K Ω. On the 20K setting I get 10.01 which confirms the second reading.

Note that HF chokes can look exactly like resistors. I had some with 4 bands BRN BLK BRN SLV that were definitely not 90-100 Ω. They measured more like 3 Ω. So if your resistance is absurdly low for the markings, consider that the component may not be a resistor.

Series And Parallel

In series, resistors just add up in a pretty intuitive way.

In parallel resistance takes this form.

1/Rtotal = 1/R1 + 1/R2 + 1/R3

In GeoGad this is easily computed. Here are two 8 Ω resistors plus a 4 Ω.

[8 8 4] inv sum inv

Answer is 2 Ω.

Here is how to compute the equivalent resistance of five 470 Ω resistors in parallel.

470 5 :* inv sum inv

Answer is 94 Ω.

Diodes

Diodes restrict the flow of current to a particular direction - they are the electronic equivalent of check valves.

Polarity

Since polarity is a diode’s one job, they are definitely polarized.

  • Anode + Positive side

    • Fat part of diagram triangle

  • Cathode - Negative side

    • Band painted/screened on body

    • Colored glass end

    • Pointy part of diagram triangle plus vertical line

Specific Diodes

  • 1N4001 - used to rectify wall current so designed to be plenty fast switching for 60Hz.

  • 1N4148 - switching time down to 4 nanoseconds, very fast.

Zener Diodes

These are also called breakdown diodes. They conduct in one direction unless the voltage is over a threshold when their blocking stops functioning. This allows them to protect sensitive low voltage components from surges of high voltage. The symbol for zener diodes is like a regular diode but there are little extensions off the cathode bar; ironically, these extensions are isomorphic to an S and not a Z.

Light Emitting Diodes (LEDs)

Polarity

  • Anode + Positive side

    • Round lens case at base

    • Fat part of diagram triangle

    • Longer lead - not always reliable

    • Thin blade on leadframe inside plastic lens package (usually)

    • On LED light strips I’ve seen long gray dashes on white a wire jacket

    • Soldered to square shaped pad on PCB

  • Cathode - Negative side

    • Flat spot on lens case at base

    • Dot painted/screened on lens or lens holder

    • Pointy part of diagram triangle plus vertical line

    • Shorter lead - not always reliable

    • Thicker blade, called the post, on the leadframe inside plastic lens package (usually)

    • Contains the semiconductor die with any reflective cavity features

    • Soldered to round shaped pad on PCB, when other one is square shaped

Voltage Drop

Often shown on datasheets as Vf (forward voltage). This is the voltage lost from the power supply’s or battery’s nominal value. I’ve been told that these are reasonable values.

  • red = 1.7V, my red jumbos measured at 0.5V

  • yellow/green = 2.2V

  • white = 3.6V

That is a load of bollocks and you should either not care what it is, or measure it yourself.

Measuring Directly With A Power Source And Voltmeter

Normally the LEDs I acquire come from random cannibalized sources and I do not know the Vf drop. Amazingly, you can check it empirically by turning it into a de facto solar panel. Hook the LED up to a multimeter on DC low range (2V on mine - not 20V or 200mV, etc). Hold the LED very near a very bright light (normal 7 watt household LED light bulb works fine) and the multimeter should reflect the voltage drop useful for LED resistance calculations.

Put negative lead of LED on negative terminal of the battery. Measure the voltage from the positive lead of the LED to the positive lead of the battery. Subtract this value from the voltage between the two battery terminals. This will be the LED’s voltage drop.

Ideal Operating Current

It’s good to know this based on the rating as they were purchased. But if you don’t know it’s reasonable to assume that the reference current is usually 0.020A i.e. 20mA. 25-30mA is usually maximum continuous current.

Calculating LED Resistor Values

LEDs and diodes generally need a resistor (or some kind of resistance) to keep the circuit from essentially being a short.

Resistance = (Voltage_PS - Voltage_LED) / Desired_Current
Current = (Voltage_PS - Voltage_LED) / Resistance
Resistance = (12 - Voltage_LED) / .020A

Capacitors

Physics

The charge a capacitor can store is the capacitance times the voltage. Somehow Farads times Volts equals Coulombs. That means that Farads times Volts divided by seconds equals Amps.

The energy in a capacitor is the capacitance multiplied by voltage, squared, divided by two.

Capacitors in parallel are equivalent to the sum of the individual components. The total capacitance in series is the inverse of the sum of the inverse capacitances. So if you have a 240pF capacitor and a 560pF the total capacitance would be calculated from this equation.

1/Ct = 1/Ca + 1/Cb = Cb/Ca * Cb + Ca/Ca*Cb = (Ca + Cb) / Ca * Cb
Ct = Ca * Cb / (Ca + Cb)
C = 240 * 560 / (240 + 560) = 134400 / 800 = 168pF

In general it is a good practice to add decoupling (aka "bypass") capacitors in parallel (the bypass) with the power supply to every IC to protect it from fluctuations. For ICs, a sane value is usually 0.1 μF. Capacitors are also useful for smoothing out chops in DC current produced by a diode rectifier (where 2 diodes guide the current one polarity, and then 2 other ones take it for the reverse polarity).

Note that while it may seem sensible to think of a capacitor as something with capacitance, they may additionally have other properties. Equivalent series resistance or ESR is the resistance of the capacitor itself. This resistance can produce heat and shorten the life of the component. It would seem to be a property that should, in some critical situations, be carefully considered.

Polarity

Capacitors sometimes have polarity, usually when their values get large. This is convenient because their packages are larger and thus there is usually more room to print the polarity in some obvious way. If the capacitor is not polarized, the diagram will just show two parallel lines making a gap in the path as the symbol.

  • Anode + Positive side

    • Straight part of circuit diagram, often with a helpful +.

    • Longer leg if they’re different lengths.

    • Crimp on one side of an in line can (maybe not true if "BIPOLAR" is printed on the can too).

    • Printed stripe on box shaped package, usually SMD tantalum; this is different from the normal convention that the markings mark the cathode.

    • Chamfer on one end of a SMD block.

    • Small funnel-shaped protrusion from body onto one of the leads.

    • One lead is offset from (not directly under) the body of a normal looking capacitor.

  • Cathode - Negative side

    • Shorter leg if they’re different.

    • Curved part of circuit diagram, curving away from the other plate.

    • Printed band off to one side as seen from top on can type.

    • Printed band on side of canister, often with minus signs and arrows directions as part of the graphic.

    • Printed cross hatching half of circle on PCB artwork.

Marking Values

A two digit label on a capacitor is in picoFarads.

A three digit label is not just that value in pF. The third number is the number of zeros you’d tack onto the first two numbers to produce the value in picoFarads. Some examples.

  • 22 is simply 22pF. Easy.

  • 3 is simply 3pF. Also easy.

  • 202 would be 2000pF or 2 nanoFarads or .002 μF or 2e-9 Farads.

  • 104 would be 100000pF or 0.1 μF.

  • 121 would be 120pF. This reminds me of decameters where it takes longer to say a distance the fancy way than the obvious way.

  • 330 seems like it could be written 331 as with 121, but 330 is simply 330pF.

A Letter after the value is the tolerance code.

  • B +/- 0.10pF

  • C +/- 0.25pF

  • D +/- 0.50pF

  • F +/- 1.00pF or 1%

  • G +/- 2.00pF or 2%

  • J +/- 5%

  • K +/- 10%

  • M +/- 20%

  • Z +80%/-20%

This excellent capacitor resource says an absurd amount about obscure capacitor polarity and value markings.

Multimeter Testing

Does your fancy multimeter have a capacitor measurement ability? Mine does. It does not appear to matter which sockets you put the leads in as long as one is on top and one is on the bottom. For testing a capacitor labeled 104, it is expected to be 0.1 μF. If I put the setting on the 2 μF setting it should read something like .096. Like with resistance, the units of the setting are what is shown and the number is the maximum value valid with that setting.

Note that you need to wait a few seconds for capacitance readings to settle down to the correct value.

Packages

Surface mount capacitors are put in packages that have designations like 0402 which is 0.4mm x 0.2mm. Or 0603 (0.6mm x 0.3mm).

Op Amp

It is called an operational amplifier because it first saw heavy use in the first computers — which were analog. The operational amplifier was a component that allowed many different configurations to perform many different (math) operations, hence the name. They can work on DC and AC signals.

Circuit gain is dependent on the passive feedback components rather than the active amplifier. This is called negative feedback and is a defining property of op amps.

The major use today AFAIK is as an analog transducer signal conditioning amplifier. They can be also used to create a line driver, one bit A/D comparator, level shifter, low Hz oscillator, sine wave generator, filter, signal conditioner, actuator driver, current source, voltage source, and maybe more. Since op amps are known for noise: shot noise, thermal (Johnson) noise, flicker noise, burst noise, and avalanche noise, it might be possible to use one to create a random number generator. Or cool guitar effects.

  • A huge book from MIT on nothing but op amps. Really a damn good source for design considerations.

  • LM358 - two independent, high gain operational amplifiers in one package using shared power supply.

  • LMx58 Series - Spec sheet

Connections

There are 5 leads to an opamp. * The non-inverting input is positive. Negligible current flow. * The inverting input is negative (since negative numbers invert). Negligible current flow. * An output. * A power supply positive pin. * A power supply negative pin.

If you have a 1.00V non inverting input, and a 1.01V inverting input, the output will want to be the difference amplified to some huge gain (1e6 times or so). So in that example, 10kV; which means that it will saturate at the power V+ level producing what is in effect a comparator. In other words, if the signals are different by a tiny amount, the circuit will be made. (Not that using opamps is an ideal comparator - there are special purpose such devices).

The normal way that opamps are used is with a feedback resistor between the output and the inverting input. With this the output will be modulated so that the inverting input voltage will match the non-inverting input. Another way to think of that is if the output is just shorted right to the inverting input, the output will be set to match the non-inverting input exactly — this is called a "buffer" and is not too exciting. But it establishes the operation for when you do start fiddling with resistances of the negative feedback. Also, since no current flows to the inputs, any current flow is coming from the V+ supply, not the inputs. This means you can use a voltage producing sensor like a strain gauge without pulling any current that could damage it. The current you might need to drive a dial to read the gauge’s value will come from the V+ supply. High impedance signal, low impedance output.

Transistors

The "gate" is the terminal which controls the main current. VTH is the threshold voltage needed between the gate and the downstream terminal. Below VTH the current between the power terminals is negligible.

IGBT

Insulated Gate Bipolar Transistors. Features a very fast switching speed. Current flows from a "collector" to a "emitter". VTH is usually between 3V and 8V. IGBTs can switch greater amounts of current than MOSFETs.

MOSFET

Metal Oxide Semiconductor Field-Effect Transistors. Current flows from a "drain" to a "source". VTH is usually between 0.5V and 1.0V. Generally switch quicker than IGBTs and are usually cheaper. Better for small to medium motor control.

DC Motors

This is the clear and obvious choice if your intended power supply is a battery, solar power, or any other source of DC power. Here are some things that are true about DC motors.

  • Torque is approximately proportional to current. (See Ampère’s force law). The proportionality constant is usually called KT, measured in Nm/A or lb-in/amp.

  • The intercept of the current vs. torque plot is usually called I0 and is the "no-load current". This is the minimum current needed to get the motor moving at all.

  • Speed is approximately proportional to voltage. The proportionality constant is usually called KV, measured in RPM/volt.

  • The intercept of the voltage vs rotational speed plot is usually called Va and is the voltage drop across the armature as a result of the intrinsic armature resistance Ra. To compute this, Va = (I-I0)*Ra .

  • Motor speed = KV * (V-Va)

  • (t * ω) = (V-Va)(I-I0)

  • Motors with high KT are good for higher torques while a high KV are better for higher speeds.

  • Normally a motor controller drawing very little current uses electrical switches to release a much greater amount of power to drive the motor.

  • A controller can use pulse width modulation (PWM) to control the motor. Choosing the right pulse frame frequency is important. If an optimal frame frequency is unspecified, 50Hz (i.e. 20ms) is a good guess. Frequencies between 30Hz and 20kHz are audible to humans, so to avoid that, you’ll need to think about going higher than 20kHz. In that case, it’s important that the switching components be responsive enough.

Brushed DC Motors

Brushes are also called commutators and the process where the current is reversed in the windings to keep the induction forces pointed in the right direction is called commutation. The fact that the brushes are a friction contact surface means they will eventually be consumed and need maintenance, a significant problem with this kind of motor for applications with long life cycles. Also the commuter has mass which robs from the potential payload that the energy could otherwise be applied to moving. And the commuter’s sparking is also a potential for EMF and electrical noise.

Permanent Magnet DC (PMDC) motors are the most popular brushed motors. These motors have relatively stable (permanently) magnetic fields making the ratio of speed to voltage KV pretty much constant.

PMDCs are simple and have many useful properties, but the magnetic field diminishes over time resulting in a loss of torque and speed. This problem is exacerbated when the motor is subjected to large startup currents.

Series-Wound DC (SWDC) motors have "field windings". Instead of the magnetic field being generated by a permanent magnet, it is generated by an electromagnet. As the name implies, these magnetic field windings are wired in series to the rotor windings that produce the torque. Because an increase in current increases the magnetic field in addition to increasing the torque, SWDC motors can be much stronger than similar form factors of PMDC motors. This sounds well and good, but the problem is speed control. Because the magnetic field is changing along with the current, it’s hard to keep the speed stable.

Shunt-Wound DC (SHWDC) motors put the field windings in parallel to the rotor windings. These don’t have the torque of series wound motors, but their superior speed control properties can be important.

Control of brushed DC motors that only need to turn in one direction can be achieved with a MOFSET that can just open and close as needed with signal pulses (PWM). One problem is that when the power supply is shut off, the motor, which acts like an inductor, can generate EMF that pulls hard on the open switch, possibly damaging the controlling transistor. This is where a flyback diode in parallel with the motor can help. With that, the current can just cycle back if the motor motor inductance keeps the voltage high (with reverse polarity).

Controlling a brushed DC motor in either direction arbitrarily is trickier. You basically need four switches, two that turn on a path (in and out of the motor) for one direction’s polarity and two that do the other direction. This arrangement is called an H-bridge. The L298 is an example of an H-bridge (two of them) in an IC package. The L9110 is similar but the IC also includes the flyback diodes which generally route around the 4 transistors in an H-bridge.

Brushless DC Motors

A BLDC motor is basically like a traditional brushed DC motor but the commutation is done electrically, not mechanically. Without mechanical contact between the rotor and stator, this kind of motor can be more durable and efficient. In the typical BLDC configuration, current passes through windings on the stator while the rotor is composed of magnets. There are usually many more windings than in brushed designs, and these stator windings comprise many iron core electromagnets arranged around the perimeter. These electro magnets are energized in sequence to continuously pull the rotor magnets.

Although different forms are possible, most BLDC motors are 3 phase. This means that the electromagnets are divided into 3 groups and each group has its own distinct energizing schedule. So if there are 6 winding "slots" and the BLDC motor is 3 phase, there are 2 linked A poles that fire together, 2 linked B poles, and 2 linked C poles.

The main difference between BLDC motors and AC motors is that BLDC current is constant when the winding set is energized, while AC motors have sinusoidal current.

At slow speeds, BLDC can become jumpy as the rotor hops from one winding set to another. There are more expensive "slotless" BLDC motors with more windings that try to ameliorate this problem.

The number of magnets in the rotor is fixed to the number of "poles" listed on the spec sheet (maybe poles= magnetsx2). The more poles, the greater the torque. An "integral slot" motor has the number of slots is a whole multiple of the poles. The motor is called "fractional slot" when this is not the case; this configuration can help reduce "cogging" or the jumpiness of BLDC motors. For example, a 6 slot stator with 3 phases, A, B, and C is a fractional slot BLDC motor if there are 4 magnetic rotor poles. It would be integral if there were 3 or 6 rotor poles.

There are two physical configurations of BLDC motors. The most ordinary looking one is the "inrunner" where the magnets are inside. The main difference between a normal inrunner BLDC motor and similar sized brushed motors is that the former will usually have 3 wires (3 phase) and the latter 2 (+ and -). The other configuration is the "outrunner" where the magnets are surrounding the windings and shaft. The magnets are always considered the "rotor" but this is strange when the shaft, considered a part of the stator on outrunners, will look like it’s turning. I believe the real motor shaft must be mounted fixed and the "shaft" that looks like it’s turning is really attached to the outer, spinning, motor case. Here is a good example.

AC Motors

Rather than controlling speed by increasing voltage, AC motors are generally controlled by increasing the frequency of supplied power.

Batteries

LiPo batteries have an "S" number that represents the number of 3.7V cells. So a 3S LiPo battery will produce 11.1V.