2008EECS194-51 Dealing with Analog Signals A Microcontroller View Jonathan Hui University of California, Berkeley.

Slides:



Advertisements
Similar presentations
Interfacing to the Analog World
Advertisements

Georgia Tech Digital Back-end µHRG interface Curtis Mayberry School of Electrical and Computer Engineering Georgia Institute of Technology January 13 th,
Chung-Ta King National Tsing Hua University
Sistemi Elettronici Programmabili13-1 MULTI OSC + CLOCK FILTER LVD POWER SUPPLY CONTROL 8 BIT CORE ALU PROGRAM MEMORY RAM I2CI2C PORT A SPI PORT B 16-BIT.
CE 478: Microcontroller Systems University of Wisconsin-Eau Claire Dan Ernst Analog to Digital (and back again) Interfacing a microprocessor-based system.
4-Integrating Peripherals in Embedded Systems (cont.)
Data Acquisition Risanuri Hidayat.
Analog to Digital Conversion. 12 bit vs 16 bit A/D Card Input Volts = A/D 12 bit 2 12 = Volts = Volts = 2048 −10 Volts = 0 Input Volts.
Analog Comparator Positive input chooses bet. PB2 and Bandgap Reference. Negative input chooses bet. PB3 and the 8 inputs of the A/D. ACME= Analog Comparator.
Oscilloscope Watch Teardown. Agenda History and General overview Hardware design: – Block diagram and general overview – Choice of the microcontroller.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 11: Sampling, ADCs, and DACs Oct 12, 2010 Slides adapted.
1 Analog to Digital Conversion Lecture 8. 2 In These Notes... Analog to Digital Converters –ADC architectures –Sampling/Aliasing –Quantization –Inputs.
Interfacing Analog and Digital Circuits
Data acquisition and manipulation
Data Acquisition Systems ACES Presentation Brad Ellison March 11, 2003.
Analogue to Digital Conversion
Introduction to Data Conversion
Analog to Digital Converters (ADC)
EET260: A/D and D/A converters
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 11: Sampling, ADCs, and DACs Oct 11, 2011 Slides adapted.
June 2008 WEI - L05 sense 1 Wireless Embedded InterNet working Foundations of Ubiquitous Sensor Networks Triggers and Sensing David E. Culler University.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Data Acquisition. Data Acquisition System Analog Signal Signal Conditioner ADC Digital Processing Communication.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Sampling, ADCs, and DACs Some slides adapted from Mark Brehob, Jonathan.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Sampling, ADCs, and DACs and more Some slides adapted from Prabal.
 Principles of Digital Audio. Analog Audio  3 Characteristics of analog audio signals: 1. Continuous signal – single repetitive waveform 2. Infinite.
Digital audio. In digital audio, the purpose of binary numbers is to express the values of samples that represent analog sound. (contrasted to MIDI binary.
Ni.com Data Analysis: Time and Frequency Domain. ni.com Typical Data Acquisition System.
Data Converters ELEC 330 Digital Systems Engineering Dr. Ron Hayne
1 4-Integrating Peripherals in Embedded Systems (cont.)
Digital to Analogue Converter
CS4101 嵌入式系統概論 Analog-to-Digital Converter 金仲達教授 國立清華大學資訊工程學系 ( Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008 )
Data Acquisition Systems
ELN5622 Embedded Systems Class 7 Spring, 2003 Aaron Itskovich
CPE 323 Introduction to Embedded Computer Systems: ADC12 and DAC12 Instructor: Dr Aleksandar Milenkovic Lecture Notes.
ELE2MIC Lecture 21 The AVR Sleep Modes ATMEGA128’s Analog to Digital Converter –Features –Block Diagram –Clock Source –Input Sources –Interrupts –BandGap.
MSP430 Semester Project ECE 300 Circuits. MSP Bit RISC Micro-controller Low Power 12 Bit A/D Converter 6 Digital I/O ports (8 lines per port) 2.
SIGMA-DELTA ADC SD16_A Sigma-Delta ADC Shruthi Sujendra.
Revised: Aug 1, ECE 263 Embedded System Design Lessons HC12 Analog-to-Digital (ATD) Converter System.
3/2/2015IoET - L05 sense1 Wireless Embedded InterNet working Foundations of Ubiquitous Sensor Networks Triggers and Sensing David E. Culler University.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 11: Sampling, ADCs, and DACs Oct 9, 2012 Slides adapted from.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Sampling, ADCs, and DACs and more Some slides adapted from Prabal.
Data Acquisition ET 228 Chapter 15 Subjects Covered Analog to Digital Converter Characteristics Integrating ADCs Successive Approximation ADCs Flash ADCs.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Module Introduction Purpose  This training module provides an overview of the analog interfaces.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 1P. 1Winter Quarter Data Acquisition System Fundamentals Lab 1.
UBI >> Contents Lecture 8 SAR ADC MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior (PT) Pedro Dinis Gaspar, António.
Analog Capture- Port E. Digital to Analog and Analog to Digital Conversion D/A or DAC and A/D or ADC.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Sampling, ADCs, and DACs Some slides adapted from Mark Brehob, Jonathan.
Analog/Digital Conversion
Lab 3: ADC.
ECE 2799 Electrical and Computer Engineering Design ANALOG to DIGITAL CONVERSION Prof. Bitar Last Update:
Embedded Systems Design 1 Lecture Set C Interfacing the MCS-51 to: –D/A Converter –A/D Converter.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Sampling, ADCs, and DACs and more Some slides adapted from Prabal.
0808/0809 ADC. Block Diagram ADC ADC0808/ADC Bit μP Compatible A/D Converters with 8-Channel Multiplexer The 8-bit A/D converter uses successive.
ADC 1 Analog to Digital Converter. ADC 2 ADC Features n General Features -Supports 8 or 10-bit resolution Modes, -Track period fully programmable up to.
8-1 Embedded Systems Analog to Digital Conversion Lecture 8.
Networked Embedded Systems Sachin Katti & Pengyu Zhang EE107 Spring 2016 Lecture 13 Interfacing with the Analog World.
Chapter 7 ADC, DAC, and Sensor Interfacing 1. Microcontroller Connection to Sensor via ADC 2.
Recall the Container Thermometer
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
Prof. Chung-Ta King Department of Computer Science
Digital Acquisition of Analog Signals – A Practical Guide
MSP430 Teaching Materials
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
CSCI1600: Embedded and Real Time Software
MSP432™ MCUs Training Part 6: Analog Peripherals
Prof. Chung-Ta King Department of Computer Science
CSCI1600: Embedded and Real Time Software
Presentation transcript:

2008EECS Dealing with Analog Signals A Microcontroller View Jonathan Hui University of California, Berkeley

2008EECS An Analog World Everything in the physical world is an analog signal –Sound, light, temperature, gravitational force Need to convert into electrical signals –Transducers: converts one type of energy to another Electro-mechanical, Photonic, Electrical, … –Examples Microphone/speaker Thermocouples Accelerometers

2008EECS An Analog World Transducers –Allow us to convert physical phenomena to a voltage potential in a well-defined way.

2008EECS Going From Analog to Digital What we want How we have to get there SoftwareSensorADC Physical Phenomena VoltageADC Counts Engineering Units Physical Phenomena Engineering Units

2008EECS Sampling Basics How do we represent an analog signal? –As a time series of discrete values  On the MCU: read the ADC data register periodically VCounts

2008EECS Sampling Basics What do the sample values represent? –Some fraction within the range of values  What range to use? Range Too Small Range Too Big Ideal Range

2008EECS Sampling Basics Resolution –Number of discrete values that represent a range of analog values –MSP430: 12-bit ADC 4096 values Range / 4096 = Step Larger range  less information Quantization Error –How far off discrete value is from actual –½ LSB  Range / 8192 Larger range  larger error

2008EECS Sampling Basics Converting: ADC counts  Voltage Converting: Voltage  Engineering Units

2008EECS Sampling Basics Converting values in 16-bit MCUs vtemp = adccount/4095 * 1.5; tempc = (vtemp-0.986)/ ;  tempc = 0 Fixed point operations –Need to worry about underflow and overflow Floating point operations –They can be costly on the node

2008EECS Sampling Basics What sample rate do we need? –Too little: we can’t reconstruct the signal we care about –Too much: waste computation, energy, resources Example: –2-bytes per sample, 4 kHz  8 kB / second –But the mote only has 10 kB of RAM…

2008EECS Shannon-Nyquist Sampling Theorem If a continuous-time signal contains no frequencies higher than, it can be completely determined by discrete samples taken at a rate: Example: –Humans can process audio signals 20 Hz – 20 KHz –Audio CDs: sampled at 44.1 KHz

2008EECS Sampling Basics Aliasing –Different frequencies are indistinguishable when they are sampled. Condition the input signal using a low-pass filter –Removes high-frequency components –(a.k.a. anti-aliasing filter)

2008EECS Sampling Basics Dithering –Quantization errors can result in large-scale patterns that don’t accurately describe the analog signal –Introduce random (white) noise to randomize the quantization error. Direct Samples Dithered Samples

2008EECS Analog-to-Digital Basics So, how do you convert analog signals to a discrete values? A software view: 1.Set some control registers : Specify where the input is coming from (which pin) Specify the range (min and max) Specify characteristics of the input signal (settling time) 2.Enable interrupt and set a bit to start a conversion 3.When interrupt occurs, read sample from data register 4.Wait for a sample period 5.Repeat step 1

2008EECS Block Diagram (MSP430)

2008EECS ADC Features Texas Instruments MSP430 Atmel ATmega 1281 Resolution12 bits10 bits Sample Rate200 ksps76.9 ksps Internally Generated Reference Voltage 1.5V, 2.5V, Vcc1.1V, 2.56V Single-Ended Inputs1216 Differential Inputs014 (4 with gain amp) Left Justified OptionNoYes Conversion ModesSingle, Sequence, Repeated Single, Repeated Sequence Single, Free Running Data Buffer16 samples1 sample

2008EECS ADC Core Input –Analog signal Output –12-bit digital value of input relative to voltage references Linear conversion

2008EECS SAR ADC SAR = Successive-Approximation-Register –Binary search to find closest digital value

2008EECS SAR ADC SAR = Successive-Approximation-Register –Binary search to find closest digital value 1 Sample  Multiple cycles

2008EECS SAR ADC 1 Sample  Multiple cycles

2008EECS Sample and Conversion Timing Timing driven by: –TimerA –TimerB –Manually using ADC12SC bit Signal selection using SHSx Polarity selection using ISSH

2008EECS Voltage Reference Voltage Reference Generator –1.5V or 2.5V –REFON bit in ADCCTL0 –Consumes energy when on –17ms settling time External references allow arbitrary reference voltage Want to sample Vcc, what Vref to use? InternalExternal Vref+ 1.5V, 2.5V, VccVeRef+ Vref- AVssVeRef-

2008EECS Sample Timing Considerations Port 6 inputs default to high impedance When sample starts, input is enabled –But capacitance causes a low-pass filter effect  Must wait for the input signal to converge

2008EECS Software Configuration How it looks in code: ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP;

2008EECS Inputs and Multiplexer 12 possible inputs –8 external pins (Port 6) –1 Vref+ (external) –1 Vref- (external) –1 Thermistor –1 Voltage supply External pins may function as Digital I/O or ADC. –P6SEL register Is this a multiplexor as you saw in CS150?

2008EECS Conversion Memory 16 sample buffer Each buffer configures sample parameters –Voltage reference –Input channel –End-of-sequence CSTARTADDx indicates where to write next sample

2008EECS Conversion Modes Single-Channel Single-Conversion –Single channel sampled and converted once –Must set ENC (Enable Conversion) bit each time Sequence-of-Channels –Sequence of channels sampled and converted once –Stops when reaching ADC12MCTLx with EOS bit Repeat-Single-Channel –Single channel sampled and converted continuously –New sample occurs with each trigger (ADC12SC, TimerA, TimerB) Repeat-Sequence-of-Channels –Sequence of channels sampled and converted repeatedly –Sequence re-starts when reaching ADC12MCTLx with EOS bit

2008EECS Software Configuration How it looks in code: Configuration ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP; ADC12MCTL0 = EOS | SREF_1 | INCH_11; Reading ADC data m_reading = ADC12MEM0;

2008EECS A Software Perspective command void Read.read() { ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP; ADC12MCTL0 = EOS | SREF_1 | INCH_11; call Timer.startOneShot( 17 ); } event void Timer.fired() { ADC12CTL0 |= ENC; ADC12IE = 1; ADC12CTL0 |= ADC12SC; } task void signalReadDone() { signal Read.readDone( SUCCESS, m_reading ); } async event void HplSignalAdc12.fired() { ADC12CTL0 &= ~ENC; ADC12CTL0 = 0; ADC12IE = 0; ADC12IFG = 0; m_reading = ADC12MEM0; post signalReadDone(); }

2008EECS A Software Perspective command void Read.read() { ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP; ADC12MCTL0 = EOS | SREF_1 | INCH_11; call Timer.startOneShot( 17 ); } event void Timer.fired() { ADC12CTL0 |= ENC; ADC12IE = 1; ADC12CTL0 |= ADC12SC; } task void signalReadDone() { signal Read.readDone( SUCCESS, m_reading ); } async event void HplSignalAdc12.fired() { ADC12CTL0 &= ~ENC; ADC12CTL0 = 0; ADC12IE = 0; ADC12IFG = 0; m_reading = ADC12MEM0; post signalReadDone(); }

2008EECS A Software Perspective command void Read.read() { ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP; ADC12MCTL0 = EOS | SREF_1 | INCH_11; call Timer.startOneShot( 17 ); } event void Timer.fired() { ADC12CTL0 |= ENC; ADC12IE = 1; ADC12CTL0 |= ADC12SC; } task void signalReadDone() { signal Read.readDone( SUCCESS, m_reading ); } async event void HplSignalAdc12.fired() { ADC12CTL0 &= ~ENC; ADC12CTL0 = 0; ADC12IE = 0; ADC12IFG = 0; m_reading = ADC12MEM0; post signalReadDone(); }

2008EECS A Software Perspective command void Read.read() { ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP; ADC12MCTL0 = EOS | SREF_1 | INCH_11; call Timer.startOneShot( 17 ); } event void Timer.fired() { ADC12CTL0 |= ENC; ADC12IE = 1; ADC12CTL0 |= ADC12SC; } task void signalReadDone() { signal Read.readDone( SUCCESS, m_reading ); } async event void HplSignalAdc12.fired() { ADC12CTL0 &= ~ENC; ADC12CTL0 = 0; ADC12IE = 0; ADC12IFG = 0; m_reading = ADC12MEM0; post signalReadDone(); }

2008EECS A Software Perspective command void Read.read() { ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP; ADC12MCTL0 = EOS | SREF_1 | INCH_11; call Timer.startOneShot( 17 ); } event void Timer.fired() { ADC12CTL0 |= ENC; ADC12IE = 1; ADC12CTL0 |= ADC12SC; } task void signalReadDone() { signal Read.readDone( SUCCESS, m_reading ); } async event void HplSignalAdc12.fired() { ADC12CTL0 &= ~ENC; ADC12CTL0 = 0; ADC12IE = 0; ADC12IFG = 0; m_reading = ADC12MEM0; post signalReadDone(); }

2008EECS MCU Kernel Driver Interrupts and Tasks ADC Application command void Read.read() { ADC12CTL0 = SHT0_2 | REF1_5V | REFON | ADC12ON; ADC12CTL1 = SHP; ADC12MCTL0 = EOS | SREF_1 | INCH_11; call Timer.startOneShot( 17 ); } event void Timer.fired() { ADC12CTL0 |= ENC; ADC12IE = 1; ADC12CTL0 |= ADC12SC; } task void signalReadDone() { signal Read.readDone( SUCCESS, m_reading ); } async event void HplSignalAdc12.fired() { ADC12CTL0 &= ~ENC; ADC12CTL0 = 0; ADC12IE = 0; ADC12IFG = 0; m_reading = ADC12MEM0; post signalReadDone(); }

2008EECS Interrupts and Tasks Tasks are run-to-completion –Used to signal application events –Break up computation in the application Interrupts –Generated by the hardware –Preempt execution of tasks Interrupts and tasks can schedule new tasks Hardware Interrupt Task Handler