SDi OS SIG 61 Using External Sensors with

  • Slides: 54
Download presentation
SDi. OS SIG #61 Using External Sensors with i. OS Handheld Apps Mark Williamsen

SDi. OS SIG #61 Using External Sensors with i. OS Handheld Apps Mark Williamsen April 25, 2016

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough Synchrotron

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough Synchrotron Radiation Center, at Stoughton, WI

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough Photo

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough Photo licensed under the Creative Commons Attribution-Share. Alike 3. 0 License

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough Kaitoke

Outline • Board Work • Lab Work • Live Demo • Code Walkthrough Kaitoke Regional Park in New Zealand, photo from Wikipedia

Maker Culture • The Apple 1 was introduced at the Homebrew Computer Club in

Maker Culture • The Apple 1 was introduced at the Homebrew Computer Club in 1976 • A bicycle for the mind • But is there room today in Apple’s ecosystem for hobbyists? • Let’s find out… From the collection of the Computer History Museum, Mountain View, CA

i. OS Hardware • • Multi-touch display Still and video cameras with digital record

i. OS Hardware • • Multi-touch display Still and video cameras with digital record and playback Ambient light sensor Microphone(s) and loudspeaker(s) with digital record and playback Three-axis gyro and accelerometer Wi. Fi and Bluetooth with full network stack Four pushbutton (momentary) switches Two electrical connectors • Lightning (power and communications) • Mini-jack (stereo headphones and mic input)

i. OS Hardware • 4 -circuit 3. 5 mm headphone jack • • Tip

i. OS Hardware • 4 -circuit 3. 5 mm headphone jack • • Tip - Left audio output Ring 1 - Right audio output Ring 2 - Common/Ground Sleeve - Mic input with bias power • 2. 7 Vdc through 2. 2 KΩ • Handhelds sense presence of plug in jack • Also sense presence (or absence) of microphone automatically • Responds to momentary switch shorting the mic input (used for Play/Pause control) • Also supports proprietary protocol for transport controls (Forward, Rewind, etc. )

i. OS Hardware • Apps can read and write mic input gain as a

i. OS Hardware • Apps can read and write mic input gain as a float (0. 0… 1. 0) • Input gain actually has 16 steps • Apps can read but not write output level as a float (0. 0… 1. 0) • Output level actually has 16 steps (and off) set by user • Output level steps are about 4 d. B each (64 d. B total) • i. OS maintains two different output levels, one with headphones plugged in, the other without • Balance not adjustable, but is very good, say 0. 1 % at each step

i. Pod Touch Frequency Response 0. 5 input gain, 0. 5 output level 80

i. Pod Touch Frequency Response 0. 5 input gain, 0. 5 output level 80 60 Response (d. B) 40 20 0 -20 -40 20 200 Left Resp Frequency (Hz) Right Resp Left Bkg 2000 Right Bkg

i. Pod Touch 4 th Gen Attenuator Balance 82 62 Response (d. B) 42

i. Pod Touch 4 th Gen Attenuator Balance 82 62 Response (d. B) 42 22 2 -18 -38 1 2 3 4 5 6 Resp L 7 8 Bkg L 9 10 Resp R 11 Bkg R 12 13 14 15 16 17

i. Pad Mini 2 Frequency Response 0. 5 input gain, 0. 5 output level

i. Pad Mini 2 Frequency Response 0. 5 input gain, 0. 5 output level 80 60 Response (d. B) 40 20 0 -20 -40 20 200 Left Resp Frequency (Hz) Right Resp Left Bkg 2000 Right Bkg

i. Pad Mini 2 Attenuator Balance 80 60 Response (d. B) 40 20 0

i. Pad Mini 2 Attenuator Balance 80 60 Response (d. B) 40 20 0 -20 -40 1 2 3 4 5 6 Signal L 7 8 Bkg L 9 10 Signal R 11 Bkg R 12 13 14 15 16 17

Think Different • Audio interface uses standard signal levels: • tens of m. V

Think Different • Audio interface uses standard signal levels: • tens of m. V on input • hundreds of m. V on output • Standard connectors and cables, easily available at retail • Well-documented API, included with standard development tools • Standard development tools available for free • Subscription support available at low cost • Wave files in and out, can be pre-recorded or created on the target

Think Different • Use the i. OS audio interface to implement an AC bridge

Think Different • Use the i. OS audio interface to implement an AC bridge • Measure complex ratio of two impedances • First impedance is a known standard which varies little • Second impedance is a sensor which responds to physical conditions in the environment • Thermistor is a resistor whose value changes with temperature • Humistor is a capacitor whose value changes with relative humidity • So two sensors can be combined to form a complex impedance, which we can measure using i. OS

Wheatstone Bridge Leeds & Northrup model 83290, Robert A. Paselk Scientific Instrument Museum, Humboldt

Wheatstone Bridge Leeds & Northrup model 83290, Robert A. Paselk Scientific Instrument Museum, Humboldt State University.

Wheatstone Bridge R 1 Eb R 2 Ed R 3 R 4

Wheatstone Bridge R 1 Eb R 2 Ed R 3 R 4

Thévenin Equivalent Ed Wikipedia contributors. "Thévenin's theorem. " Wikipedia, The Free Encyclopedia, 8 Mar.

Thévenin Equivalent Ed Wikipedia contributors. "Thévenin's theorem. " Wikipedia, The Free Encyclopedia, 8 Mar. 2016. Web. 9 Mar. 2016.

Thévenin Equivalent

Thévenin Equivalent

Assumptions • Lumped component model (no distributed impedances) • Two-wire measurements (no Kelvin contacts)

Assumptions • Lumped component model (no distributed impedances) • Two-wire measurements (no Kelvin contacts) • So source impedance is part of the measurement • Physical dimensions are effectively zero compared to wavelength (no transmission line effects) • Sources, detector, and impedances are all linear, time-invariant

AC Bridge General Radio model 1650 -B, from the collection of Brooke Clarke.

AC Bridge General Radio model 1650 -B, from the collection of Brooke Clarke.

AC Bridge Eg Z 1 Z 2 Ed Z 3 Z 4 Wikipedia contributors.

AC Bridge Eg Z 1 Z 2 Ed Z 3 Z 4 Wikipedia contributors. "Electrical impedance. " Wikipedia, The Free Encyclopedia, 26 Feb. 2016. Web. 9 Mar. 2016.

Blumlein Bridge Eg Ratio Trans. 1 -R R Ed Z 1 Z 2 Blumlein

Blumlein Bridge Eg Ratio Trans. 1 -R R Ed Z 1 Z 2 Blumlein A. D. , UK Patent #323, 037, Accepted Dec. 13, 1929.

Stray Capacitance Eg Ratio Trans. 1 -R R Ed Z 1 Z 2

Stray Capacitance Eg Ratio Trans. 1 -R R Ed Z 1 Z 2

Three-Terminal Impedances • Shielded enclosure provides full Faraday cage. • Z 1 is precisely

Three-Terminal Impedances • Shielded enclosure provides full Faraday cage. • Z 1 is precisely controlled, may be resistance, inductance, or capacitance. • C 1 and C 2 are not controlled, are the same stray capacitances we accounted for on the previous slide. • Input and output connections are coaxial, interchangeable • Ideally suited for use in a Blumlein Bridge. Z 1 C 2 “New Three Terminal Capacitors. ” The General Radio Experimenter, Vol. 33, No. 8 -9, August-September 1959.

Three-Terminal Impedances • Standard capacitors introduced by General Radio in the 1960 s •

Three-Terminal Impedances • Standard capacitors introduced by General Radio in the 1960 s • Specified 0. 1% accuracy • Useful in calibrating AC bridges • Reproductions can still be purchased today General Radio Standard Air Capacitor Type No. 1403 -G, 10 p. F 0. 1%

Flicker Noise • Arises from history-dependent physical fluctuations • Characterized by PSD (power spectral

Flicker Noise • Arises from history-dependent physical fluctuations • Characterized by PSD (power spectral density) of 1/f below a corner frequency fc • Various strategies are possible: • • Large-scale excitation (LSE) Double sampling Choppers before and after gain AC bridge with PSD (phasesynchronous detector) Schmid H, “Offset, flicker noise, and ways to deal with them”, draft chapter from the book Circuits at the Nanoscale: Communications, Imaging and Sensing, CRC Press, Boca Raton, 2008.

Generalized AC Bridge, In Balance EL EM Z 1 Z 2 ER

Generalized AC Bridge, In Balance EL EM Z 1 Z 2 ER

Generalized AC Bridge, Not Balanced EL EM Z 1 Z 2 ER

Generalized AC Bridge, Not Balanced EL EM Z 1 Z 2 ER

Generalized AC Bridge, Not Balanced EL EM Z 1 Z 2 ER

Generalized AC Bridge, Not Balanced EL EM Z 1 Z 2 ER

Outboard Hardware • Impedance Converter • 100 MΩ input impedance • 2. 2 KΩ

Outboard Hardware • Impedance Converter • 100 MΩ input impedance • 2. 2 KΩ output impedance • Uniform response in audio passband • Adequate headroom and linearity as bridge detector • Appears to satisfy Apple’s parameters • Special low-cutoff JFET

Outboard Hardware • Gain 7. 2 d. B at 1 k. Hz • 0.

Outboard Hardware • Gain 7. 2 d. B at 1 k. Hz • 0. 8% THD at 100 m. V out • Compact form factor • PB switch shown, to generate remote control event • Receives bias power from handheld device

Temperature Sensor • US Sensor NTC thermistor 105 RG 1 • 1 MΩ nominal

Temperature Sensor • US Sensor NTC thermistor 105 RG 1 • 1 MΩ nominal at 25˚ C • Available in broad range of nominal values • Response is more or less logarithmic • Steinhart-Hart equation gives temperature in terms of measured resistance.

Humidity Sensor • Humirel HS 1101 humistor • Capacitance cell responds to relative humidity.

Humidity Sensor • Humirel HS 1101 humistor • Capacitance cell responds to relative humidity. • Nominal value 180 p. F at 55% RH • More or less linear from 10% RH (167 p. F) to 90% RH (195 p. F) • Time constant about 5 sec. • Vendor gives a cubic polynomial for C as a function of RH.

i. OS Socket Server App • Uses AVAudio. Player and AVAudio. Recorder APIs •

i. OS Socket Server App • Uses AVAudio. Player and AVAudio. Recorder APIs • Performs stimulus/response measurement with AC bridge • Exposes UDP socket server • Listens for requests at predetermined port • Fulfills requests and reports back to client • Plots stimulus in purple, response in green

Waveform Analysis • Stimulus is 100 msec of silence, followed by two measurements of

Waveform Analysis • Stimulus is 100 msec of silence, followed by two measurements of 200 msec each, total 500 msec • Response is analyzed from 150 to 250 msec, and from 350 to 450 msec • So response can slip by up to 50 msec and still maintain accuracy Left Output Right Output Mic Input 0 100 200 300 milliseconds 400 500

Waveform Analysis • Discrete Fourier transform at single frequency, in units of radians/sec •

Waveform Analysis • Discrete Fourier transform at single frequency, in units of radians/sec • Frequencies which are multiples of 10 Hz can be analyzed with sampleaccurate matched filter over 4410 samples • Excitation harmonics are integrated out • 50/60 Hz and their harmonics are also integrated out

Mac OS Socket Client App • Packages measurement setup as a JSON tree •

Mac OS Socket Client App • Packages measurement setup as a JSON tree • Sends the setup to server at predetermined port • Accepts server’s reply and presents to user • Logs replies to disk for further analysis

Shared State • Client state is serialized as a composite tree structure, to send

Shared State • Client state is serialized as a composite tree structure, to send request to server • Contains stimulus values for two measurements, at fixed frequency • Complex values are represented as tuples, with real and imaginary part • Units of measure are DAC counts, as 16 bit signed integers { } "seq": 4, "freq": 1000, "meas": [{ "right": [0, 0], "left": [8000, 0] }, { "right": [16000, 0], "left": [0, 0] }]

Shared State { • Server performs requested measurements • New keys ‘mic’ and ‘bkg’

Shared State { • Server performs requested measurements • New keys ‘mic’ and ‘bkg’ are appended to state tree • Server state is serialized, to send reply to client • Units of measure are ADC counts, as double floats } "seq": 4, "freq": 1000, "meas": [{ "mic": [-4706. 649431371992, 12720. 94578873261], "bkg": [-5. 478341985690049, 1. 458796989869293], "right": [0, 0], "left": [8000, 0] }, { "mic": [2937. 437244031467, 1638. 538649897043], "bkg": [-4. 732831036299513, 2. 932683927083855], "right": [16000, 0], "left": [0, 0] }]

Vendors • Apple Computer • Digi. Key • Ebay • Fry’s • Mouser

Vendors • Apple Computer • Digi. Key • Ebay • Fry’s • Mouser

References Ahmed Bakir, “Beginning i. OS Media App Development” Paul Brokaw, AN-202 Jim Williams,

References Ahmed Bakir, “Beginning i. OS Media App Development” Paul Brokaw, AN-202 Jim Williams, AN-43 Apple TN-2277 “Networking and Multitasking” Alan Blumlein, UK Patent 323, 037 “Alternating Current Bridge Circuits”, accepted Dec. 13, 1929 • John Scofield, “AC Method for Measuring Low-Frequency Resistance Fluctuation Spectra”, Rev. Sci. Instrum. 58 (6), June 1987 • Arfken & Weber, “Mathematical Methods for Physicists”, 5 th ed. • • •

Thank you! • SDi. OS • i. Tec. SD • UCSD Extension • SDSU

Thank you! • SDi. OS • i. Tec. SD • UCSD Extension • SDSU • Quantum Design

Wheatstone Bridge • In use since before 1843 • Measures DC resistance and related

Wheatstone Bridge • In use since before 1843 • Measures DC resistance and related properties • Ratiometric, so excitation and detector gain fall out • Extended for AC use by Maxwell (1865) and Blumlein (1926) • Compares four resistances: if three are known to good precision, the fourth can be computed • Typically balanced before each measurement • May be balanced manually or automatically Wikipedia contributors. "Wheatstone bridge. " Wikipedia, The Free Encyclopedia, 5 Dec. 2015. Web. 8 Mar. 2016.

Leakage Paths R 1 Eb R 2 Ed R 3 R 4

Leakage Paths R 1 Eb R 2 Ed R 3 R 4

Blumlein Bridge Tegam model DT 72 B decade ratio transformer. Princeton Applied Research model

Blumlein Bridge Tegam model DT 72 B decade ratio transformer. Princeton Applied Research model HR-8, offered by Recycled. Goods. com.

Applications • NBS Gas Thermometer • Locates grounded mercury menisci of precision manometer. •

Applications • NBS Gas Thermometer • Locates grounded mercury menisci of precision manometer. • Reference capacitors made with Au film evaporated onto polished Fu. Si • Stable to within 1 x 10 -17 Farad Guildner L A and Edsinger R E, “Measurement of Capacitance to a Grounded Surface With a Transformer Ratio-Arm Bridge”, NBS Journal of Research, Vol. 69 C, No. 1, Jan-March 1965.

Applications • IIT Low Temperature Group • AC Mutual Inductance Bridge • Compares CMN

Applications • IIT Low Temperature Group • AC Mutual Inductance Bridge • Compares CMN sample to carbon resistors Koch R F, “Cryogenic Thermometry – Methods and Instrumentation”, Master’s Thesis, Illinois Institute of Technology, 1968.

Applications • 400 Hz bridge measures Pt thermometers • Resolution of 2 u. Ohm

Applications • 400 Hz bridge measures Pt thermometers • Resolution of 2 u. Ohm (20 u. Deg) • Error <= 3 u. Ohm Cutkosky R D, “An A-C Resistance Thermometer Bridge”, NBS Journal of Research, Vol. 74 C, No. 1 -2, Jan-June 1970.

Applications • Cornell Low Temperature Group • LCMN Thermometer uses AC bridge with rf

Applications • Cornell Low Temperature Group • LCMN Thermometer uses AC bridge with rf SQUID detector • 0. 1 u. K sensitivity at 1 m. K Parpia J M, et. al. , “The Temperature and Pressure Dependence of the Normal Fraction of Superfluid 3 He-B”, Journal of Low Temperature Physics, Vol. 61, No. 5/6, 1985.

Single-Chip Solutions • AD 7745/AD 7746 • 24 -bit Capacitance-to. Digital Converter • Resolution:

Single-Chip Solutions • AD 7745/AD 7746 • 24 -bit Capacitance-to. Digital Converter • Resolution: 4 a. F • Accuracy: 4 f. F • Range: ± 4 p. F AD 7745/AD 7746 Data Sheet, Analog Devices, 2005.

Single-Chip Solutions • LDC 1612/LDC 1614 • 28 -bit Inductance-to. Digital Converter • Intended

Single-Chip Solutions • LDC 1612/LDC 1614 • 28 -bit Inductance-to. Digital Converter • Intended for position and proximity sensing LDC 1612, LDC 1614 Data Sheet, Texas Instruments, 2005.