NETW 1010 IOT Design: An Embedded System Overview Sensors Dr. Eng. Amr T. Abdel-Hamid Fall 2016 Embedded System Hardware Embedded Systems Embedded system hardware is frequently use d in a loop (“hardware in a loop“): Dr. Amr Talaat cyber-physical systems What are Sensors? Embedded Systems American National Standards Institute (ANSI) Definition A device which provides a usable output in response to a specified measurand Input Signal Output Signal Sensor A sensor acquires a physical parameter and converts it int o a signal suitable for processing (e.g. optical, electrical, mechanical) Dr. Amr Talaat A transducer Microphone, Loud Speaker, Biological Senses (e.g. touc h, sight,…ect) Detectable Phenomenon Embedded Systems Stimulus Acoustic Biological & Chemical Electric Magnetic Quantity Wave (amplitude, phase, polarization), Spectrum, Wave Velocity Fluid Concentrations (Gas or Liquid) Charge, Voltage, Current, Electric Field (amplitude, phase, polarization), Conductivity, Permittivity Magnetic Field (amplitude, phase, polarization), Flux, Permeability Dr. Amr Talaat Optical Refractive Index, Reflectivity, Absorption Thermal Temperature, Flux, Specific Heat, Thermal Conductivity Mechanical Position, Velocity, Acceleration, Force, Strain, Stress, Pressure, Torque Discretization of time Embedded Systems Digital computers require discrete sequences of ph ysical values s : DT DV Discrete time domain Dr. Amr Talaat Sample-and-hold circuits Physical Principles Amperes’s Law Embedded Systems A current carrying conductor in a magnetic field experiences a force (e.g. galvanometer) Curie-Weiss Law There is a transition temperature at which ferromagnetic mat erials exhibit paramagnetic behavior Faraday’s Law of Induction A coil resist a change in magnetic field by generating an opp osing voltage/current (e.g. transformer) Photoconductive Effect Dr. Amr Talaat When light strikes certain semiconductor materials, the resist ance of the material decreases (e.g. photoresistor) Choosing a Sensor Embedded Systems Dr. Amr Talaat Temperature Sensor Embedded Systems Temperature sensors appear in building, chemic al process plants, engines, appliances, computer s, and many other devices that require temperat ure monitoring Many physical phenomena depend on temperatu re, so we can often measure temperature indire ctly by measuring pressure, volume, electrical re sistance, and strain Dr. Amr Talaat Temperature Sensor Embedded Systems Bimetallic Strip Metal A L L 0[1 (T - T0)] δ Metal B Application Dr. Amr Talaat Thermostat (makes or breaks electrical connection with defl ection) Temperature Sensor Embedded Systems Resistance temper ature device. R R 0[1 (T - T0)] R R0 e 1 1 T T0 Dr. Amr Talaat Light Sensor Embedded Systems Light sensors are used in cameras, infrared d etectors, and ambient lighting applications Dr. Amr Talaat Sensor is composed of photoconductor such a s a photoresistor, phot odiode, or phototransi stor I p + n V - Magnetic Field Sensor Embedded Systems Magnetic Field sens ors are used for po wer steering, secur ity, and current me asurements on tra nsmission lines Dr. Amr Talaat Hall voltage is prop ortional to magneti c field VH I B n q t I (protons) + + + + + + + + + + + + + + + x x x x x x x x x B x x x x x x x x x - - - - - - - - - - - - - - - + VH - CO2 Gas Sensor Embedded Systems CO2 sensor measures gas eous CO2 levels in an env ironment Measures CO2 levels in th e range of 0-5000 ppm Dr. Amr Talaat Monitors how much infrar ed radiation is absorbed by CO2 molecules Infrared Source IR Detector Signals Embedded Systems Sensors generate signals Definition: a signal s is a mapping from the time domain DT to a value domain DV: s: DT DV DT : continuous or discrete time domain DV : continuous or discrete value domain. Dr. Amr Talaat Sample-and-hold circuits Embedded Systems Clocked transistor + capacitor; Capacitor stores sequence values Dr. Amr Talaat e(t) is a mapping ℝ ℝ h(t) is a sequence of values or a mappin gℤℝ 1 6 The Sampling Theorem Embedded Systems Obviously, the more samples we take the better those samples approximate the original function The Nyquist sampling theorem: A continuous bandlimited function can be completely re presented by a set of equally spaced samples, if the sa mples occur at more than twice the frequency of the hi ghest frequency component of the function Dr. Amr Talaat 1 7 The Sampling Theorem Embedded Systems Dr. Amr Talaat In other words, to adequately capture a function with maximum frequency F, we need to sample i t at frequency N = 2F. N is called the Nyquist limit. The Nyquist sampling theorem applied to CDs Most humans can hear to 20 kHz Some to 22 kHz CDs are sampled at 44.1 kHz Although not twice the “highest frequency component”, it is twice the “highest freque ncy component” that can be (generally) he ard Aliasing Embedded Systems 2 t 2 t e3 (t ) sin 0.5 sin 8 4 Dr. Amr Talaat 2 t 2 t 2 t e4 (t ) sin 0.5 sin 0.5 sin 8 4 1 Periods of 8,4,1 Indistinguishable if sampled at integer times, ps=1 Matlab deo Aliasing (2) Embedded Systems Reconstruction impossible, if not sampling frequently eno ugh How frequently do we have to sample? Nyquist criterion (sampling theory): Aliasing can be avoided if we restrict the frequencies of the incoming signal to less than half of the sampling rate. ps < ½ pN where pN is the period of the “fastest” sine wave or fs > 2 fN where fN is the frequency of the “fastest” sine wave Dr. Amr Talaat fN is called the Nyquist frequency, fs is the sampling rate. Anti-aliasing filter Embedded Systems A filter is needed to remove high frequencies g (t ) e(t ) e4(t) changed into e3(t) Ideal filter Dr. Amr Talaat Realizable filter fs /2 fs Examples of Aliasing in computer graphics Embedded Systems Original Sub-sampled, no filtering Dr. Amr Talaat http://en.wikipedia.org/wiki/Image: Moire_pattern_of_bricks_small.jpg Discretization of values: A/D-converters Embedded Systems Digital computers require digital form of physical values s: DT DV Discrete value domain Dr. Amr Talaat A/D-conversion; many methods with different speeds. Flash A/D converter Embedded Systems * Encodes input nu mber of most sign ificant ‘1’ as an u nsigned number, e.g. “1111” -> “100”, “0111” -> “011”, “0011” -> “010”, “0001” -> “001”, “0000” -> “000” (Priority encoder) . Dr. Amr Talaat * Frequently, the case h(t) > Vref would not be decoded Assuming 0 h(t) Vref Embedded Systems Encoding of voltage intervals Dr. Amr Talaat “11“ “10“ “01“ “00“ Vref /4 Vref /2 3Vref /4 Vref h(t) Resolution Resolution (in bits): number of bits produced Embedded Systems Resolution Q (in volts): difference between two in put voltages causing the output to be incremente d by 1 VFSR Q n with Dr. Amr Talaat Q: resolution in volts per step VFSR: difference between largest and smallest voltage n: number of voltage intervals Example: Q = Vref /4 for the previous slide, assuming * to be absent Resolution and speed of Flash A/D-converter Embedded Systems Parallel comparison with reference voltage Speed: O(1) Hardware complexity: O(n) Applications: e.g. in video processing Dr. Amr Talaat Higher resolution: Successive approximation Embedded Systems h(t) V- Dr. Amr Talaat Key idea: binary search: Set MSB='1' if too large: reset MSB Set MSB-1='1' if too large: reset MSB-1 w(t) Speed: O(log2(n)) Hardware complexity: O(log2(n)) with n= # of distinguished voltage levels; slow, but high precision possible. Successive approximation (2) Embedded Systems V 1100 Vx h(t) 1011 1010 1000 V- Dr. Amr Talaat t Quantization Noise Embedded Systems Assuming “rounding“ (truncating) towards 0 h( t) w(t) Dr. Amr Talaat w(t)-h(t) Quantization Noise Embedded Systems h( t) w(t) h(t)-w(t) Assuming “rounding“ (truncating) towards 0 Dr. Amr Talaat Quantization noise for audio signal Embedded Systems e.g.: 20 log(2)=6.02 decibels Dr. Amr Talaat effective signal voltage signal to noise ratio (SNR) [db] 20 log effective noise voltage Signal to noise for ideal n-bit converter : n * 6.02 + 1.76 [dB] e.g. 98.1 db for 16-bit converter, ~ 160 db for 24-bit converter Additional noise for non-ideal converters Signal to noise ratio Embedded Systems effective signal voltage signal to noise ratio (SNR) [db] 20 log10 effective noise voltage e.g.: 20 log10(2)=6.02 decibels Dr. Amr Talaat Signal to noise for ideal n-bit converter : n * 6.02 + 1.76 [dB] e.g. 98.1 db for 16-bit converter, ~ 160 db for 24-bit converter Additional noise for non-ideal converters Digital-to-Analog (D/A) Converters Embedded Systems Various types, can be quite simple, e.g.: Dr. Amr Talaat Current ~ no. represented by x Embedded Systems Loop rule: x0 I 0 8 R V Vref 0 I 0 x0 In general: I i xi Junction rule: I I Vref 8 R Vref 2 3 i R i i Dr. Amr Talaat I x3 Vref R x2 Vref 2 R x1 Vref 4 R x0 I ~ nat (x), where nat(x): natural number represented by x; Vref 8 R Vref 8 R 3 xi 2i i 0 Output voltage ~ no. represented by x Embedded Systems Loop rule*: y R1 I ' 0 Junction rule°: I I' y R1 I 0 ° * From the previous slide I Vref 8 R 3 xi 2i i 0 Dr. Amr Talaat Hence: 3 R1 R1 i y Vref xi 2 Vref nat ( x) 8 R i 0 8 R Op-amp turns current I ~ nat (x) into a voltage ~ nat (x) Output generated from signal e3(t) Embedded Systems * * Assuming “zero-order hold” Dr. Amr Talaat Possible to reconstruct input signal?