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 • Common microcontroller interfaces – UART, I2C, SPI – GPIOs • Drive Modes • Using Manufacturer Specific Interfaces • (Embedded) Computer Architecture 3
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
Voltmeters measure static and fluctuating voltages Source: Fluke 80 Series V User Manual, May 2004 Rev.2, 11/08, page 14 8
Oscilloscopes display time-variant voltage curves Source: https://www.adafruit.com/products/2145, 18.11.2015
Current • Voltage sources: Pump analogy • Closing the circuit – Charge Flow? Current is the charge flow rate in a circuit in Coulomb/s. 10
Current in practice • Current 𝒋 𝒖 : ℝ → ℝ • Different charged particles • Actual direction unknown • Closed electric circuit • Stopping large currents quickly is dangerous 11
Ammeters measure static and fluctuating currents Source: Fluke 80 Series V User Manual, May 2004 Rev.2, 11/08, page 25 12
Electronic Components • Correlate physical properties, e.g.: – 𝐽 𝑉 – 𝐽(𝑉, … ) Characteristic diagrams (I- U, …) • May have multiple connections • Mathematical models may exist 13
Voltage and Current Measurements 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 14
Common units and parameters 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 (Ω) 15
𝑆 = 𝑉 • R is constant 𝐽 Ohms Law • One free variable remains Resistance • Intrinsic property • Physical device: Resistor Resistor (circuit symbol) • Color of the rings encodes their value Resistor (picture)
Resistor Current-Voltage characteristic Source: Adapted from https://upload.wikimedia.org/wikipedia/commons/d/d7/FourIVcurves.svg, 19.11.15 𝐽(𝑉) = 𝑉 ⋅ 1 𝑆
Resistor color codes Source: http://www.digikey.com/- /media/Images/Marketing/Resources/Calcul ators/resistor-color-chart.jpg, 19.11.15 18
𝑜 𝐽 − 𝐽 1 − 𝐽 2 − 𝐽 3 = 0 𝑗 𝑙 = 0 Kirchhoffs 1st Law 𝑙=1 „The sum of currents into and out of any single node of a network is always zero.“ Source: http://www.elektronik-kompendium.de/sites/grd/0608011.htm, Pay attention to the direction of the 19.11.2015 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. Source: https://commons.wikimedia.org/wiki/File:Kirchhoff%27s_Current_Law.svg, 19.11.2015
𝑉2 + 𝑉1 − 𝑉 𝑟1 − 𝑉 𝑟2 = 0 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 𝑃ℎ𝑛𝑡 𝑀𝑏𝑥 𝜁 1 − 𝑆 1 ⋅ 𝑗 1 − 𝑆 2 ⋅ 𝑗 2 = 0 𝜁 2 − 𝜁 1 − 𝑆 2 ⋅ 𝑗 2 − 𝑆 3 ⋅ 𝑗 3 = 0 Source: https://en.wikipedia.org/wiki/File:Kirshhoff-example.svg, as of 19.11.2015
Resistor superposition Source: http://www.iris.uni-stuttgart.de/lehre/eggenberger/eti/, Chapter 8, as of 19.11.2015 Series circuit Parallel circuit 𝑜 1 𝑆 𝑢𝑝𝑢𝑏𝑚 = 𝑆 𝑢𝑝𝑢𝑏𝑚 = 𝑆 𝑙 1 𝑜 𝑆 𝑙 𝑙=1 𝑙=1
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
Current divider circuit Given I, R1 and R2, what are I1 and I2? 𝑜 1/ 1/𝑆 𝑘 𝑘=0 𝐽 1 = 𝐽 𝑆 1 Source: https://commons.wikimedia.org/wiki/File:Stromteiler.svg, as of 19.11.2015
(Light Emitting) Diodes – I-V Diagram Source: http://electronics.stackexchange.com/questions/76367/accounting-for- led-resistance, as of 19.11.15
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
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
Resistor-Diode and Diode I-V Diagram Source: Own work using LTSpice simulation program, IN4148 Diode
Common Sensors Resistive type Digital type • Used like a resistor • Analog – Digital conversion on-chip • Resistance will change • Digital signal with measure – PWM (Automotive) • Correlation can be non- – Manufacturer specific linear protocol – Bus (I2C, CAN, ...)
Microcontroller interfaces UART / Serial TIA-232-F I2C / TWI GND, Rx, Tx GND, TCL, SDA Point-to-Point Master-Slave-Bus SPI SCLK, MOSI, MISO, nSS / nCS GPIOs Master-Slave-Bus PxN, i.e. PB1 Selected Star or Daisy-Chaining 29
Using Manufacturer Specific Interfaces • Read Datasheet – Voltage levels – Timing requirements – Sample comm diagrams • Debugging tools (multimeter, oscilloscope protocol analyzer) • Real time requirements
(Embedded) Computer Architecture Bare metal Operating system • Avoid non-determination • Desktop OS are non- deterministic • Get maximum run time • Real time OS (RTOS) • Similar to OS-like solutions – Priority Scheduling – Preemption – Preemptive Scheduling – Priorities • System libraries run time is – Cyclic approach known / bounded – Event driven approach
Arduino Mega 2560 • 16 MHz ATmega2560 • 8 kB RAM • GPIO, max. 1 MHz • UART, I2C, SPI • ADC, (PWMDAC) • Bare Bones 34
Arduino Hardware Architecture USB/Programmer (ATmega16U2) ATmegaX: 8-Bit Harvard RISC 36 Source(s): https://nishantnath.com/2012/03/23/introduction-to-atmega-microcontrollers/, as of 23.05.16
Recommend
More recommend