1 of 64

Introduction to electronics and microcontrollers

by Nathan McCorkle for PortLabPDX’s October 19th meetup lecture

2 of 64

Electricity?

Presence and flow of electric charge, often for a useful purpose.

like powering a light

3 of 64

Symbols are Useful

Symbolic representations of

common building blocks help

communicate complex systems

4 of 64

Diodes Resistors Inductors Capacitors

  • Basic building blocks of ELECTRICAL systems.
  • Logic Elements like AND and OR can be made with diodes.
  • Transistors are the foundation of ELECTRONICS.
  • More complex elements can be made with the addition of transistors (NOT, AND, NAND, OR, NOR, XOR).

5 of 64

Diodes: one-way valves

6 of 64

Diodes: one-way valves

First were made of a chunk of crystal (rock) and a fine wire, hallmark device was a cat’s whisker detector-- the ‘crystal’ in crystal radio.

7 of 64

Diodes: one-way valves

  • cat’s whisker -- galena, pyrite
  • rectifier -- e.g. 200V 30A 175C 0.8V drop, 27ns recovery, max non-repetitive surge 300A
  • schottky -- e.g. 15V 9A 100C 0.25V drop, near instant recovery, max non-repetitive surge 2900A $3 (used in high-efficiency i.e. solar panels, or very fast circuits), near instant recovery
  • silicon -- cheap, hundreds of ns recovery
  • signal -- 100ns recovery
  • zener -- these can recover from repeated reverse-bias breakdown events (when the reverse voltage is greater than the one-way valve can withstand, general diodes break). This allows zeners to ‘bleed off’ excess voltage, diverting it from spiking into downstream components that could be damaged from over-voltage
  • avalanche -- similar to zener, have opposite temperature coefficient. Avalanches can runaway in reverse breakdown, zeners self-protect.

8 of 64

Diodes: LEDs

9 of 64

Capacitors

These store charge and can discharge it very quickly. These are used to power things like a camera flash, and an oscillator (clock tick or metronome) can be built by charging a capacitor and discharging it when full

10 of 64

Capacitors

11 of 64

Capacitors

electrolytic have higher current leakage, but are cheap and work pretty well if you aren’t running on batteries

capacitors are harder to control manufacturing tolerances on than inductors, so for circuits requiring precise signal filtering it is cheaper to use inductors instead (RL filter instead of RC or LC)

12 of 64

Resistors

photoresistors - resistance changes with illumination

can be made to have very fine tolerance i.e. 0.1%

13 of 64

Resistors

14 of 64

Inductors

Store energy in a magnetic field around the wire

RLC Java demo

http://ngsir.netfirms.com/englishhtm/RLC.htm

15 of 64

Inductors

16 of 64

Transistors

An electronic switch that can control much more power than applied.

Like a water faucet on a pressure washer, takes little effort to turn, but afterward the pressurized water can peel paint from a house or metal surface.

17 of 64

Transistors

18 of 64

Breadboard

Used for prototyping circuits with jumper wires and through-hole components.

To used smaller surface-mount components, a break-out board is needed.

19 of 64

Wire-wrap (historically used;prototyping)

20 of 64

Wire-wrap (historically used;prototyping)

21 of 64

Point-to-point

  • direct connection between components
  • main distinction from earlier methods is the use of solder at junctions

22 of 64

Point-to-point (Dead-bug)

  • used as an art-form, prototyping
  • reduces stray inductance and capacitance, useful for RF applications

23 of 64

Printed Circuit Board (PCB)

Using Computer Aided Drafting to lay out PCB traces

24 of 64

PCB - Printed Circuit Board

After the traces have been routed, the board made and populated (‘stuffed’).

25 of 64

Electronic Component Packages Through-hole components

  • Useful for prototyping because they can be easily used in breadboard sockets.
  • High-speed or high-frequency designs may require Surface Mount Technology (SMT) to minimize stray inductance and capacitance in wire leads, which would impair circuit function.
  • Ultra-compact designs may also dictate SMT construction

  • axial lead

  • radial lead
  • DIP - Dual in-line package DIP sockets

26 of 64

Electronic Component Packages Through-hole components

TO-220 - has heatsink mount, higher-power ability

Joint Electron Device Engineering Council (JEDEC) Transistor Outline Package 220

TO-92 - cheap, low-power only

27 of 64

Electronic Component Packages

Pin Grid Array (PGA) - older CPUs

28 of 64

Electronic Component Packages

surface mount device (smd)

‘’ technology (smt)

  • SOIC
    • pin spacing of 1.27 mm
    • occupies an area about 30–50% less than an equivalent DIP, with a typical thickness that is 70% less
  • SSOP - Shrink Small Outline Package
    • have "gull wing" leads protruding from the two long sides, and a lead spacing of 0.025 inches (0.635mm). 0.5mm lead spacing is less common, but not rare.
  • TSSOP - Thin SSOP (thinner body)
    • ExposedPad variant of small-outline packages can increase heat dissipation by as much as 1.5 times over a standard TSSOP, thereby expanding the margin of operating parameters. Additionally, the ExposedPad can be connected to ground, thereby reducing loop inductance for high frequency applications. The ExposedPad should be soldered directly to the PCB to realize the thermal and electrical benefits.
  • Quad Flat Package
    • Four sided, comes in many variants
  • BGA - ball grid array, used in many embedded devices CPUs/GPUs
    • solder balls don’t flex much, cracking often occurs (xbox red ring of death)
    • requires wave soldering (baking) to attach chip to circuit board, DIY using hacked toaster oven

ExposedPAD TSSOP with 16 pins

LQFP with 44 pins

29 of 64

Electronic Component Packages

Ball Grid Array (BGA)

  • used in many embedded devices CPUs/GPUs
  • solder balls don’t flex much, cracking often occurs

(xbox red ring of death)

  • requires wave soldering (baking) to attach chip to circuit board,

DIY using hacked toaster oven

30 of 64

Electronic Component Packages

Land Grid Array (LGA) socket - late-generation CPUs (2011 pins )

31 of 64

Electronic Component Packages

Low Insertion Force socket - 1.8” hard drives, previously 80386 CPUs

32 of 64

Electronic Component Packages

Zero Insertion Force socket - Much more expensive than LIF

BGA chips are supported, used with Flexible Flat Cable (FFC) in embedded devices

33 of 64

Microcontroller vs

laptop computer

34 of 64

Microcontrollers

  • Immensely complex topology of electrical and electronic components. Arranged as a computer.
  • Setup in a way such that it can perform complex logical and mathematical operations, and receive, move, store, and transmit data.

$0.44

35 of 64

Microcontrollers

  • ATMega AVR microcontroller PCB, freeduino design

36 of 64

Microcontrollers

  • Memory, so you can have time to think and process multiple pieces of information

37 of 64

ATMega Microcontroller functional block diagram

But wait there’s more!!

38 of 64

AVR

CPU

functional

block

diagram

But wait there’s more!!

39 of 64

Microcontrollers

This is starting to look like we could branch out and enter recursive loops for weeks of learning. Whole reference books worth of sub-systems/peripherals.

Know the basic system, be good about looking up jargon.

Remember, computers operate in binary, 0 or 1, high voltage or low voltage… this largely reduces real-world noise from messing up data or operations.

Setting one of these up right must be really complex, right?

40 of 64

Microcontrollers - programming

The microcontroller has many useful peripherals but often fewer pins broken-out from the Integrated Circuit package. The configuration depends on user need.

41 of 64

Microcontrollers - programming

Magic numbers from the datasheet, what page was that on? Hrmm, this is getting hard.

42 of 64

Microcontrollers - programming

Arduino to the layman’s rescue!

Unzip the 1 zip-file download, and forget about magic numbers.

43 of 64

44 of 64

Microbial Fuel Cell example

resistance value should be a little higher since there is no load in a mud battery (mfc)

45 of 64

Microbial Fuel Cell example

46 of 64

Microbial Fuel Cell example

47 of 64

Electroencephalography (EEG) example

Electrodes

Mastoid (Ground), the bone behind your ear.

Nasion (+/-), the ridge between your nose and forehead, between eyebrows.

Inion (-/x), the point where your skull ends at the back of your head.

48 of 64

Electroencephalography (EEG) example

From Instructables user cah6 - circuit can also do Electrocardiography (ECG)

http://www.instructables.com/id/DIY-EEG-and-ECG-Circuit/

49 of 64

Electroencephalography (EEG) example

Fast Fourier Transform of the microphone signal using Processing framework

50 of 64

Electroencephalography (EEG) example

Playing a simple game, paddle position depends on brain frequency

51 of 64

Electroencephalography (EEG) example

From Instructables user cah6 - http://www.instructables.com/id/DIY-EEG-and-ECG-Circuit/

The circuit will use 3 electrodes - 2 to measure a voltage difference across your scalp, and one as a reference to ground.

52 of 64

Electroencephalography (EEG) example

Frequency response of completed circuit

53 of 64

Electroencephalography (EEG) example

Stage 1 - Instrumentation Amplifier

  • Inputs are 2 voltages.

  • Output is the difference between the two multiplied by some gain, G.

  • Instrumentation amplifiers, however, are not perfect. On real amplifiers, the output is slightly skewed if both input voltages are offset the same by some amount.

  • A perfect amplifier would take as inputs 2.1V and 2.2V, and output 0.1V*G.

  • A real one is influenced by this common offset, and will change the output slightly accordingly.

  • The Common Mode Rejection Ratio (CMRR) is a value given to the amplifier that corresponds to how well it ignores the common offset between inputs.
  • A higher CMRR is better, and will output something closer to what a perfect amplifier would.

54 of 64

Electroencephalography (EEG) example

Stage 2 - 60Hz Notch Filter (filters U.S. AC power related noise)

  • The notch filter is most sensitive to changes in the 12 ohm resistor.

55 of 64

Electroencephalography (EEG) example

Stage 2 - 60Hz Notch Filter, frequency vs gain response

56 of 64

Electroencephalography (EEG) example

Stage 3 - 7Hz High Pass Filter (HPF)

  • filters skin galvanic response, tradeoff is reduces gamma/delta wave a lot
  • Below the cutoff frequency the 2 pole HPF gain falls off much faster than a simpler resistor/capacitor circuit. In this circuit, reduces data by a factor of about 56 by the time it gets to 1Hz, while a single pole would only reduce it by a factor of about 7.5.

57 of 64

Electroencephalography (EEG) example

Stage 3 - 7Hz High Pass Filter (HPF)

58 of 64

Electroencephalography (EEG) example

Stage 4 - 31Hz Low Pass Filter (LPF)

  • beta waves cut-off at 30Hz

59 of 64

Electroencephalography (EEG) example

Stage 4 - 31Hz Low Pass Filter (LPF)

60 of 64

Electroencephalography (EEG) example

Stage 5 - 1Hz High Pass Filter (HPF) and gain of 83-455

61 of 64

Electroencephalography (EEG) example

Stage 6 - 60Hz Notch Filter and into the computer microphone

Even with all the previous filtering stages, the data will still at this point contain a good amount of 60 Hz noise. Even after adding another 70Hz notch filter, the final data will still have a small amount of noise

62 of 64

EEG + Transcranial Magnetic Stimulation

63 of 64

Other Biotech Uses

Seperation of DNA

fragments via an electrical

potential

64 of 64

PCR

DNA xerox machine.

Essentially an electronics project