BUILDING YOUR OWN SMART DEVICE 1 Agenda Introduction to - - PowerPoint PPT Presentation

building your own smart device
SMART_READER_LITE
LIVE PREVIEW

BUILDING YOUR OWN SMART DEVICE 1 Agenda Introduction to - - PowerPoint PPT Presentation

iLab 2 BUILDING YOUR OWN SMART DEVICE 1 Agenda Introduction to Electronics Voltage and current Units and parameters Resistance: Ohms Law and Kirchhoff's Laws (Light Emitting) Diodes Common Sensor types 2 Agenda


slide-1
SLIDE 1

BUILDING YOUR OWN SMART DEVICE

iLab 2

1

slide-2
SLIDE 2

Agenda

  • Introduction to Electronics

– Voltage and current – Units and parameters – Resistance: Ohms Law and Kirchhoff's Laws – (Light Emitting) Diodes

  • Common Sensor types

2

slide-3
SLIDE 3

Agenda

  • Common microcontroller interfaces

– UART, I2C, SPI – GPIOs

  • Drive Modes
  • Using Manufacturer Specific Interfaces
  • (Embedded) Computer Architecture

3

slide-4
SLIDE 4

Voltage in practice

  • Voltage 𝒗 𝒖 : ℝ → ℝ
  • Always measured between two points
  • 𝑣 𝑢 = 𝑑 where 𝑑 ∈ ℝ

DC Voltage

  • 𝑣 𝑢 = û sin 2𝜌𝑔𝑢

AC Voltage

  • Touching >50V AC or >120V DC can harm you

7

slide-5
SLIDE 5

Voltmeters measure static and fluctuating voltages

Source: Fluke 80 Series V User Manual, May 2004 Rev.2, 11/08, page 14 8

slide-6
SLIDE 6

Oscilloscopes display time-variant voltage curves

Source: https://www.adafruit.com/products/2145, 18.11.2015

slide-7
SLIDE 7

Current

  • Voltage sources: Pump analogy
  • Closing the circuit

– Charge Flow?

Current is the charge flow rate in a circuit in Coulomb/s.

10

slide-8
SLIDE 8

Current in practice

  • Current 𝒋 𝒖 : ℝ → ℝ
  • Different charged particles
  • Actual direction unknown
  • Closed electric circuit
  • Stopping large currents quickly is dangerous

11

slide-9
SLIDE 9

Ammeters measure static and fluctuating currents

Source: Fluke 80 Series V User Manual, May 2004 Rev.2, 11/08, page 25 12

slide-10
SLIDE 10

Electronic Components

  • Correlate physical properties, e.g.:

– 𝐽 𝑉 – 𝐽(𝑉, … )  Characteristic diagrams (I-U, …)

  • May have multiple connections
  • Mathematical models may exist

13

slide-11
SLIDE 11

Voltage and Current

Measurements

14 Source: https://commons.wikimedia.org/wiki/File:Masc henregel.svg, 19.11.15 Source: Adapted from http://www.elektronik-kompendium.de/sites/grd/0201113.htm, 19.11.15

slide-12
SLIDE 12

Common units and parameters

15

Name Symbol SI-Unit Formula Voltage U or u(t) or V V Current I or i(t) A Electric Power P W 𝑄 = 𝑉 ⋅ 𝐽 Electric Energy W Ws, J 𝑋 = 𝑄 ⋅ 𝑢 Electrical resistance R Ohm (Ω) 𝑆 = 𝑉/𝐽

slide-13
SLIDE 13

Ohms Law

  • R is constant
  • One free variable remains
  • Intrinsic property
  • Physical device: Resistor
  • Color of the rings encodes

their value

Resistance

𝑆 = 𝑉 𝐽 Resistor (circuit symbol) Resistor (picture)

slide-14
SLIDE 14

Source: Adapted from https://upload.wikimedia.org/wikipedia/commons/d/d7/FourIVcurves.svg, 19.11.15

𝐽(𝑉) = 𝑉 ⋅ 1 𝑆

Resistor Current-Voltage characteristic

slide-15
SLIDE 15

Resistor color codes

Source: http://www.digikey.com/- /media/Images/Marketing/Resources/Calcul ators/resistor-color-chart.jpg, 19.11.15 18

slide-16
SLIDE 16

Kirchhoffs 1st Law

„The sum of currents into and out of any single node of a network is always zero.“ Pay attention to the direction of the current-arrows:

  • Arrows into a node are positive
  • Arrows out of a node are negative

Kirchhoffs 1st law holds for all nodes in a circuit.

𝑗𝑙

𝑜 𝑙=1

= 0

Source: http://www.elektronik-kompendium.de/sites/grd/0608011.htm, 19.11.2015

𝐽 − 𝐽1 − 𝐽2 − 𝐽3 = 0

Source: https://commons.wikimedia.org/wiki/File:Kirchhoff%27s_Current_Law.svg, 19.11.2015

slide-17
SLIDE 17

Kirchhoffs 2nd Law

„The sum of Voltages in any closed loop through a cirquit is always zero.“ Source: http://www.elektronik-kompendium.de/sites/grd/0608011.htm, as of 19.11.2015

𝑉2 + 𝑉1 − 𝑉𝑟1 − 𝑉𝑟2 = 0

Source: https://en.wikipedia.org/wiki/File:Kirshhoff-example.svg, as of 19.11.2015

𝜁1 − 𝑆1 ⋅ 𝑗1

𝑃ℎ𝑛𝑡 𝑀𝑏𝑥

− 𝑆2 ⋅ 𝑗2 = 0 𝜁2 − 𝜁1 − 𝑆2 ⋅ 𝑗2 − 𝑆3 ⋅ 𝑗3 = 0

slide-18
SLIDE 18

Resistor superposition

Series circuit 𝑆𝑢𝑝𝑢𝑏𝑚 = 𝑆𝑙

𝑜 𝑙=1

Parallel circuit 𝑆𝑢𝑝𝑢𝑏𝑚 = 1 1 𝑆𝑙

𝑜 𝑙=1

Source: http://www.iris.uni-stuttgart.de/lehre/eggenberger/eti/, Chapter 8, as of 19.11.2015

slide-19
SLIDE 19

Voltage divider circuit

Known: U Wanted: R1 and R2 such that U1 and U2 are what we want

  • Choose two of: I, R1, R2
  • Then solve:

𝑉1 = 𝑉 𝑆1 𝑆𝑘

𝑜 𝑘=0

  • Loading the output also

changes U1 and U2

Source: https://commons.wikimedia.org/wiki/File:Einfacher- unbelasteter-Spannungsteiler.svg, as of 19.11.2015

slide-20
SLIDE 20

Current divider circuit

Given I, R1 and R2, what are I1 and I2? 𝐽1 = 𝐽 1/ 1/𝑆𝑘

𝑜 𝑘=0

𝑆1

Source: https://commons.wikimedia.org/wiki/File:Stromteiler.svg, as of 19.11.2015

slide-21
SLIDE 21

(Light Emitting) Diodes – I-V Diagram

Source: http://electronics.stackexchange.com/questions/76367/accounting-for- led-resistance, as of 19.11.15

slide-22
SLIDE 22

LEDs I-V Diagram, Case specs

Source: http://www.electronics.dit.ie/staff/tscarff/DT089_Physical_Computing_1 /LEDS/Leds.htm, as of 19.11.15

slide-23
SLIDE 23

How to actually use LEDs

  • 𝐽𝐸𝑗𝑝𝑒𝑓 𝑊

𝐸 = 𝐽𝑇 𝑓

𝑊𝐸 𝑜⋅𝑊𝑈 − 1

  • Current rises exponentially with voltage
  • Diodes will break if the 𝐽𝐺 current is exceeded
  • Linearize & shift this using a Resistor in Series
  • Kirchhoff‘s 1st gives: 𝐽𝑀𝐹𝐸 = 𝐽𝑆 so let 𝐽 = 𝐽𝐺

𝑛𝑏𝑦

  • Choose suitable R such that the LED is only at about

80% 𝐽𝐺

𝑛𝑏𝑦 when the circuit is operating

slide-24
SLIDE 24

Resistor-Diode and Diode I-V Diagram

Source: Own work using LTSpice simulation program, IN4148 Diode

slide-25
SLIDE 25

Common Sensors

Resistive type

  • Used like a resistor
  • Resistance will change

with measure

  • Correlation can be non-

linear Digital type

  • Analog – Digital

conversion on-chip

  • Digital signal

– PWM (Automotive) – Manufacturer specific protocol – Bus (I2C, CAN, ...)

slide-26
SLIDE 26

Microcontroller interfaces

I2C / TWI GND, TCL, SDA Master-Slave-Bus GPIOs PxN, i.e. PB1

29

UART / Serial TIA-232-F GND, Rx, Tx Point-to-Point SPI SCLK, MOSI, MISO, nSS / nCS Master-Slave-Bus Selected Star or Daisy-Chaining

slide-27
SLIDE 27

Using Manufacturer Specific Interfaces

  • Read Datasheet

– Voltage levels – Timing requirements – Sample comm diagrams

  • Debugging tools (multimeter, oscilloscope

protocol analyzer)

  • Real time requirements
slide-28
SLIDE 28

(Embedded) Computer Architecture

Bare metal

  • Avoid non-determination
  • Get maximum run time
  • Similar to OS-like solutions

– Preemption – Priorities – Cyclic approach – Event driven approach

Operating system

  • Desktop OS are non-

deterministic

  • Real time OS (RTOS)

– Priority Scheduling – Preemptive Scheduling

  • System libraries run time is

known / bounded

slide-29
SLIDE 29

Arduino Mega 2560

  • 16 MHz ATmega2560
  • 8 kB RAM
  • GPIO, max. 1 MHz
  • UART, I2C, SPI
  • ADC, (PWMDAC)
  • Bare Bones

34

slide-30
SLIDE 30

Arduino Hardware Architecture

36

ATmegaX: 8-Bit Harvard RISC

Source(s): https://nishantnath.com/2012/03/23/introduction-to-atmega-microcontrollers/, as of 23.05.16

USB/Programmer (ATmega16U2)