Lab 3: ADC.

Slides:



Advertisements
Similar presentations
Jordan Barry Victor Brzeski
Advertisements

Chung-Ta King National Tsing Hua University
Analog-to-Digital Converter (ADC) And
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
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.
555 Timer ©Paul Godin Updated February Oscillators ◊We have looked at simple oscillator designs using an inverter, and had a brief look at crystal.
Analog/Digital Subsystem
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.
2008EECS Dealing with Analog Signals A Microcontroller View Jonathan Hui University of California, Berkeley.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 11: Sampling, ADCs, and DACs Oct 12, 2010 Slides adapted.
Analogue to Digital Conversion
Slides created by: Professor Ian G. Harris Inputs and Outputs PIC Vcc RA3 RA4 RA5  Make an LED toggle state when button is pressed  Need to read RA3,
Introduction of Holtek HT-46 series MCU
1 Analog-to-Digital Converter (ADC). 2 ADC Features (1/3) ADC conversion rate 1 MHz and 12-bit resolution – 1µs conversion time at 56 MHz – 1.17µs conversion.
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.
M.S.P.V.L. Polytechnic College, Pavoorchatram
TIMERS.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
Colorado Space Grant Consortium Gateway To Space ASEN 1400 / ASTR 2500 Class #12 Gateway To Space ASEN 1400 / ASTR 2500 Class #12 T-58.
T IMERS - 2. O UTPUT U NIT Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals.
Peripherals and their Control An overview of industrially available “peripheral devices” that use “pulse-width modulation” for information passing. Review.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
Chapter 13 Linear-Digital ICs. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. Electronic Devices.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Digital to Analogue Converter
CS4101 嵌入式系統概論 Analog-to-Digital Converter 金仲達教授 國立清華大學資訊工程學系 ( Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008 )
Lecture 13 A/D Converter & D/A Converter. Outline Basic Operation Single Scan Mode Continuous Scan Mode Group Scan Mode Interrupt Sources Registers D/A.
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.
SIGMA-DELTA ADC SD16_A Sigma-Delta ADC Shruthi Sujendra.
3/2/2015IoET - L05 sense1 Wireless Embedded InterNet working Foundations of Ubiquitous Sensor Networks Triggers and Sensing David E. Culler University.
Ultra-low Power Motion Detection using the MSP430F2013.
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.
UBI >> Contents Lecture 8 SAR ADC MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior (PT) Pedro Dinis Gaspar, António.
Project: security lock system Idea: –Create a 4bit password using switches –Send data serially (one bit at a time) using an LED –Receive the code serially.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
ECE 2799 Electrical and Computer Engineering Design ANALOG to DIGITAL CONVERSION Prof. Bitar Last Update:
Analog to Digital Converter (ADC)
Chapter Microcontroller
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.
Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics 기 정 두 원.
TITLE: 555 Timer OM INSTITUTE OF TECHNOLOGY Subject: Analog Electronics ( ) Semester: 03 Prepared By:
Renesas Electronics Europe GmbH A © 2010 Renesas Electronics Corporation. All rights reserved. RL78 AD converter.
Electronic Devices and Circuit Theory
Chapter 7 ADC, DAC, and Sensor Interfacing 1. Microcontroller Connection to Sensor via ADC 2.
Recall the Container Thermometer
Introduction to MSP430G2553 and MPU6050
Application Case Study Security Camera Controller
Environment Temperature Monitor
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
68HC11 Interrupts & Resets.
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
555 Timer EEE DEPARTMENT KUMPAVAT HARPAL( )
UNIT – Microcontroller.
Chapter 13 Linear-Digital ICs
Prof. Chung-Ta King Department of Computer Science
Created by Luis Chioye Presented by Cynthia Sosa
ECE 354 Computer Systems Lab II
MSP430 Teaching Materials
Digital Control Systems Waseem Gulsher
PIC18F458 Analog-to-Digital
Lecture 13 A/D Converter & D/A Converter
MSP432™ MCUs Training Part 6: Analog Peripherals
Prof. Chung-Ta King Department of Computer Science
ADC and DAC Data Converter
ECE 3567 Microcontroller Lab
Presentation transcript:

Lab 3: ADC

Signal Path Produce a proper output voltage level Signal Conditioning (if necessary) Sensors Amplification Filtering Analog to Digital Conversion (ADC) Light Temperature Acceleration Humidity Pressure etc. Resistance Capacitance Current Voltage etc. 10011101 Convert to voltage Converts voltage to digital number Today’s labs

General View Each storage register associated with a control register Positive/Negative voltage reference: define the upper and lower limits of the conversion 16 conversion result storage registers 4 clock sources available for ADC12 clock Software configurable sample-and-hold period 12 input channels available

Conversion Formula This is a conversion formula of ADC For MSP430 ADC12 module It is 12-bit ADC If Vin > Vref+ => output 4095 (max) If Vin < Vref- => output 0 (min)

Input Channels 12 input channels available Multiplexed with P6 GPIO 8 external input pins: A0 ~ A7 2 external voltage reference pins: VeREF+, VeREF- 1 internal temperature sensor 1 supply voltage monitor Multiplexed with P6 GPIO Setting P6SEL to choose the function you want

Internal Voltage Reference Generator Voltage references are used as a base of the conversion Input voltage compares to the voltage reference to generate the conversion result A stable voltage reference is crucial to an accurate conversion Usually we use a special circuit to generate stable voltage reference MSP430 has a built-in voltage reference generator It has two selectable voltage levels 1.5V and 2.5V

Voltage References Options 3 positive reference sources AVcc – Positive supply voltage VREF – internal voltage reference Can be 1.5V or 2.5V, depends on your selection VeREF+ – external positive voltage reference 2 negative reference sources AVss – Negative supply voltage (GND) VeREF- -- external negative voltage reference 6 combinations in total

ADC12 Conversion Modes Single channel single-conversion A single channel is converted once Sequence-of-channels A sequence of channels is converted once Repeat-single-channel A single channel is converted repeatedly Repeat-sequence-of-channels A sequence of channels is converted repeatedly

Conversion Memory 16 ADC12MEMx memory registers to store conversion results Each ADC12MEMx is configured with an associated ADC12MCTLx control register. EOS: End of sequence, indicates last conversion SREFx: Select voltage reference INCHx: Select Input Channel CSTARTADDx bits define the first memory used for conversion This bit is in ADC12CTL1 control register

Use in sequence of channels mode ADC12MCTLx Use in sequence of channels mode

Example Depends on the setting of conversion mode, ADC12MCTLx and CSTARTADDx, the ADC will have different behavior Sequence of Channels CSTARTADDx = 0000 CSTARTADDx = 0100 Single-channel If you need 5 input channels If you need 7 input channels CSTARTADDx = 0000 CSTARTADDx = 0100 You need to set ADC12MCTL0 to ADC12MCTL4 (choose the input channel and voltage reference for each ADC12MEM). You need to set the EOS bit in ADC12MCTL4 to 1, indicates the sequence of conversion end here. And the conversion results will store in corresponding ADC12 memory registers You need to set ADC12MCTL8 to ADC12MCTL14 (choose the input channel and voltage reference for each ADC12MEM). You need to set the EOS bit in ADC12MCTL14 to 1, indicates the sequence of conversion end here. And the conversion results will store in corresponding ADC12 memory registers You need to set ADC12MCTL0 (choose the input channel and voltage reference). And the conversion result will store in ADC12MEM0 You need to set ADC12MCTL8 (choose the input channel and voltage reference). And the conversion result will store in ADC12MEM8

Conversion Clock 4 clock sources available ADC12OSC: ADC12 internal oscillator MCLK SMCLK ACLK For simplicity, we use ADC12OSC in our lab Independent of the system clock

ADC12 Core Two phases for a conversion Conversions in MSP430 ADC12 Sample-and-hold A/D conversion Conversions in MSP430 ADC12 Triggered by a SHI signal Two sample modes Extended Sample Mode Pulse Sample Mode SHI signal triggers a conversion and controls the length of sample-and-hold period SHI signal triggers a conversion, the length of the sample-and-hold period is controlled by other register

The SHI Signal Four selectable sources for SHI ADC12SC bit A single bit in ADC12 control register, set this bit to high will trigger a conversion Timer_A output unit 1 (TA1) Timer_B output unit 0 (TB0) Timer_B output unit 1 (TB1) Lab_2 slide

Sample And Hold Revisit There is a sample and hold circuit before A/D conversion Mostly integrated with the ADC chip When no conversion, switch S1 is open When a conversion start S1 closed Input signal charge C1 S1 open, C1 holds the value of input signal A/D conversion Sample and hold time Time between S1 close and re open If it is too short C1 will not fully charged (error)

Sample Timing Considerations For an accurate conversion, the sample-and-hold time must be long enough to charge up CI to Vs Rs will affect the sample-and-hold time (tsample) For MSP430F1611, RI = 2K ohm (max); CI = 40 pF (max) Minimum tsample for 12-bit conversion =>

Setting tsample If we use ADC internal oscillator (ADC12OSC) as ADC12 clock source. Frequency of ADC12OSC is about 5MHz, if you set SHT0x to 0100, then the sample-and-hold time is 64*(1/5000000) second = 12.8 μs

Rs: Source Resistance Many devices didn’t specify their source resistance (source impedance/output impedance) Measuring source impedance is not an easy task For most of the case, set the SHTx bit to 0001 or 0010 should work My suggestion is it’s only 16 possible setting, just try it out!

ADC12 Interrupts ADC12 has 18 interrupt sources: ADC12IFG0-ADC12IFG15 flag Associated with each ADC12MEMx, indicates a conversion of this memory is complete ADC12OV: ADC12MEMx overflow A conversion result is written to any ADC12MEMx before its previous conversion result was read ADC12TOV: conversion time overflow Another conversion is requested before the current conversion is completed

ADC12IV, Interrupt Vector Generator All ADC12 interrupts are source to a single interrupt vector Similar to Timer_A3 The highest priority enabled ADC12 interrupt generates a number in the ADC12IV register Highest priority interrupt generates a number Branch to the ADC ISR, read ADC12IV, process the associate sub-routine, leave the ADC ISR And then, second highest priority interrupt generates another number Branch to the ADC ISR again, ……….

Reset of Interrupts Overflow interrupts (memory overflow and conversion time overflow) will reset automatically when Any access, read or write, of the ADC12IV register ADC12IFG0-ADC12IFG15 flag will reset when Accessing their associated ADC12MEMx register

Interrupt Enable Register Enable the interrupt of corresponding ADC12 memory (ADC12MEM). Usually, you only need to enable one of the source.

ADC12 Configuration

Enable/disable overflow interrupt ADC12 Configuration Enable/disable internal voltage reference generator, set the voltage reference to 1.5/2.5 V Enable/disable overflow interrupt

ADC12 Configuration We use this bit in ADC12CTL0 register to trigger a conversion. You can try out the other source of trigger. The benefit of using Timer_A or Timer_B trigger sources is you don’t need CPU to handle the trigger

We use ADC12 internal oscillator as clock source ADC12 Configuration Use Pulse Sample Mode We use ADC12 internal oscillator as clock source Depends on your requirement, choose the proper conversion sequence mode

Example: Single Channel, single conversion Only one input channel, one conversion at a time Initialization Configure the ADC: ADC12CTL0 1. setting SHTx 2. setting voltage reference ADC12CTL1 1. setting CSTARTADDx (pointed to one memory) 2. setting SHSx 3. SHP = 1 4. setting ADC12 clock source 5. select single channel, single conversion mode ADC12MCTLx 1. depends on the conversion mode you choose, and the input channel and voltage reference you want, set proper ADC12MCTLx register Turn-on ADC12 Set ADC12ON to 1 Enable Conversion Trigger a Conversion Set ENC to 1 An ADC interrupt generated when the conversion complete. The conversion result is available at the memory register you choose You can use a timer to trigger a conversion, in the timer ISR, set the ADC12SC bit to 1 You need to enable the corresponding interrupt. The one selected by CSTARTADDx

Example: Sequence of Channels Multiple input channels, a sequence of conversions Configure the ADC: ADC12CTL0 1. setting SHTx 2. setting voltage reference 3. set MSC bit to 1 (multiple conversion automatically start) ADC12CTL1 1. setting CSTARTADDx (pointed to one memory) 2. setting SHSx 3. SHP = 1 4. setting ADC12 clock source 5. select Sequence-of-channels mode ADC12MCTLx 1. depends on the conversion mode you choose, and the input channel and voltage reference you want, set proper ADC12MCTLx register 2. depends on the number of channels you want, set the EOS bit to 1 in the proper ADC12MCTLx register Initialization Turn-on ADC12 Set ADC12ON to 1 Enable Conversion Trigger a Conversion Set ENC to 1 An ADC interrupt generated when the last conversion complete. The conversion results are available at the memory registers you choose You can use a timer to trigger a conversion, in the timer ISR, set the ADC12SC bit to 1 You need to enable the interrupt of the last conversion memory.

Today’s Labs Lab 1: Light Sensor use the sample code on website choose a light sensor on Taroko configure the ADC to take samples from the light sensor when the light sensor is covered by hand, turn on a LED; when the hand remove, turn off the LED set a threshold

Lab2: Infrared Proximity Sensor Connect the sensor to Taroko configure the ADC to take samples from the sensor use an obstacle(hand, paper, etc.) to approach the sensor if distance < 10 cm, Red LED on if distance > 20 cm, Green LED on else, Yellow LED on Signal GND Vcc

Lab 3: Accelerometer Connect the accelerometer module to Taroko Configure a GPIO pin as a supply voltage source for the accelerometer module configure the ADC to take samples from multiple input channels Configure the LEDs when accelerate in +X direction, turn on Red LED; accelerate in -X direction, turn off Red LED when accelerate in +Y direction, turn on Green LED; accelerate in -Y direction, turn off Green LED when accelerate in +Z direction, turn on Yellow LED; accelerate in -Z direction, turn off Yellow LED