adc conversion lecture - texas instruments · 2018. 2. 8. · pdiv shsx shp issh divx sselx consx...
TRANSCRIPT
-
TI-RSLK Texas Instruments Robotics System Learning Kit
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Module 15 Lecture: Data Acquisition Systems - Theory
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Data Acquisition Systems
2
You will learn in this module Signals & Sampling
• ADC, DAC
• Range, resolution, precision
• Successive approximation
MSP432
• Software driver
• Spectrum Analyzer
• Central Limit Theorem
IR Sensor
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Data Acquisition Systems
3
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
A Control System includes a Data Acquisition System
4
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Sampling: conversion from analog to digital
5
Amplitude Range Resolution Precision
Time domain Sampling rate, fs
• 0 to ½ fs Number of samples
• Buffer size N Frequency resolution
• fs/N
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
DAC versus ADC
6
DAC Digital to Analog uC output Signal generation ADC Analog to Digital uC input Measurements
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
MSP432 ADC14
7
• 14 bits • 24 channels • 1 Msps
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Successive Approximation
8
8-bit Successive Approximation Game • I pick a number from 0 to 255 • You can guess • I will respond high or low (same) • How many guesses will it take you?
What is your first guess?
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Successive Approximation – How it works
9
8-bit Successive Approximation Game • You asked, “what is bit 7?” • You asked, “what is bit 6?” … • You asked, “what is bit 0?”
• Uses a DAC • Uses a comparator • 1 bit/clock
Good information https://e2e.ti.com/blogs_/b/msp430blog/archive/2016/05/10/how-to-leverage-the-flexibility-of-an-integrated-adc-in-an-mcu-for-your-design-to-outshine-your-competitor-part-1
https://e2e.ti.com/blogs_/b/msp430blog/archive/2016/05/10/how-to-leverage-the-flexibility-of-an-integrated-adc-in-an-mcu-for-your-design-to-outshine-your-competitor-part-1https://e2e.ti.com/blogs_/b/msp430blog/archive/2016/05/10/how-to-leverage-the-flexibility-of-an-integrated-adc-in-an-mcu-for-your-design-to-outshine-your-competitor-part-1
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
ADC14 Software Initialization
10
ADC14->CTL0
Clock (speed/power) Sample and hold (noise) Sequence or single channel Reference (range) Enable Start sample
31-30 29-27 26 25 24-22 21-19 18-17 16 PDIV SHSx SHP ISSH DIVx SSELx CONSx BUSY 15-12 11-8 7 6-5 4 3-2 1 0
SHT1x SHT0x MSC ON ENC SC
31-30
29-27
26
25
24-22
21-19
18-17
16
PDIV
SHSx
SHP
ISSH
DIVx
SSELx
CONSx
BUSY
15-12
11-8
7
6-5
4
3-2
1
0
SHT1x
SHT0x
MSC
ON
ENC
SC
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
ADC14->IFGR0
ADC14 Software Initialization
11
ADC14->CTL1
Address Resolution Format Power
Conversion complete
31-28 27 – 24 22 21 20-16 CH3MAP – CH0MAP BATmap CStartAdr
15-6 5 – 4 3 2 1-0 RES DF REFBURST PWRMD
31 5 4 3 2 1 0 IFG31 … IFG5 IFG4 IFG3 IFG2 IFG1 IFG0
31-28
27 – 24
22
21
20-16
CH3MAP – CH0MAP
BATmap
CStartAdr
15-6
5 – 4
3
2
1-0
RES
DF
REFBURST
PWRMD
31
5
4
3
2
1
0
IFG31
…
IFG5
IFG4
IFG3
IFG2
IFG1
IFG0
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
ADC14 Software Initialization
12
ADC->MCTL[n]
Comparator Differential/single Reference Channel
31-16 15 14 13 12 11-8 WINCTH WINC DIF VRSEL
7 6 5 4 – 0 EOS ADC14INCHx
31-16
15
14
13
12
11-8
WINCTH
WINC
DIF
VRSEL
7
6
5
4 – 0
EOS
ADC14INCHx
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
ADC14 Software Conversion
13
1. Wait for BUSY to be zero 2. Start conversion 3. Wait for completion 4. Read result
uint32_t ADC_In6(void){ while(ADC14->CTL0&0x00010000){}; ADC14->CTL0 |= 0x00000001; while((ADC14->IFGR0&0x01) == 0){}; return ADC14->MEM[0]; }
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Periodic Interrupt and Mailbox
14
1. Sample ADC 2. Run digital filter 3. Save in global 4. Set semaphore
void SysTick_Handler(void){ uint32_t RawADC; P1OUT ^= 0x01; P1OUT ^= 0x01; RawADC = ADC_In6(); ADCvalue = LPF_Calc(RawADC); ADCflag = 1; // semaphore P1OUT ^= 0x01; }
9us
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems - Theory
Summary
15
Analog to Digital Converter Successive Approximation Range Resolution Precision
Software Initialization Mailbox
∑=
−n
i t
miti
x
xx
n 0 max
100
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Module 15 Lecture: Data Acquisition Systems – Performance Measurements
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Data Acquisition Systems
2
You will learn in this module Analog to Digital Converter
• Sampling, Nyquist Theorem • Digital filtering
Noise and statistics
• Probability Mass Function • Spectrum Analyzer • Central Limit Theorem
Data Acquisition Systems
• Range, resolution, precision • Calibration • Accuracy
IR Sensor
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Nyquist Theorem
3
The Nyquist Theorem states that if the signal is sampled with a frequency of fs, then the digital samples only contain frequency components from 0 to ½ fs.
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Statistics
4
Probability Mass Function (PMF) Average (µ = mean) Standard deviation (σ = sigma) Range (max-min) Coefficient of variation, CV = σ/μ Precision log2(μ/σ) Resolution, Δ
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Transducer
5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
0 100 200 300 400 500 600 700 800
Sens
or O
utpu
t (V)
Distance from sensor to wall (mm)
GP2Y0A21YK0F IR Distance sensor • Nonmontonic
• Hyperbolic
• Noisy
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
GP2Y0A21YK0F IR distance sensors are noisy
6
dBFS = 20 log10(V/3.3)
90 mV • Generation/recombination
• Periodic
• White
• Flicker, 1/f
• EM field pickup
3.3V/90mV = 37
50 Hz analog LPF
16 Hz digital LPF
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Probability Mass Function (PMF)
7
0
100
200
300
400
500
600
700
13400 13405 13410 13415
Cou
nt
ADC value
Probability Mass Function (PMF)
N=1
N=2
N=4
N=8
N=16
N=32
• Constant input • Average of last N samples • fs = 1000 Hz
CLT states that as independent random variables are added, their sum tends toward a Normal distribution.
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Analog Low Pass Filter to remove Aliasing
8
Two-pole Butterworth LPF
V in V
C 1 R R
C 2
10 k
141.4 uF
70.7 uF out
10 k
( )4/11
cffinVoutV
+=1) Select the cutoff frequency, fc (50 Hz)
2) Divide the two capacitors by 2πfc (let C1A, C2A be the new values) C1A = 141.4µF/2πfc (0.45µF) C2A = 70.7µF/2πfc (0.225µF) 3) Locate two standard value capacitors (with the 2/1 ratio) C1B = C1A/x (0.44µF, two 0.22 µF in parallel) C2B = C2A/x (0.22µF) 4) Adjust the resistors to maintain the cutoff frequency R = 10kΩ•x (10k, fc = 51 Hz)
See https://www.ti.com/design-tools/signal-chain-design/webench-filters.html
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Digital Filtering
9
x[3] = x[2]; x[2] = x[1]; x[1] = x[0]; x[0] = ADC_In6(); y = (x[0]+x[1]+x[2]+x[3])/4;
y(n) = (x(n)+x(n-1)+x(n-2)+x(n-3)/4
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Averaging Low Pass Filters
10
0.0
0.2
0.4
0.6
0.8
1.0
1.2
0 50 100 150 200
Gai
n
Frequency (Hz)
y(n) = (x(n) + x(n-1) +...+ x(n-N-1))/N N=64 fs = 2000 Hz
fc = 16 Hz
0.707
Linear Filter Finite Impulse Response Low pass
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Averaging Low Pass Filters
11
0.0
0.2
0.4
0.6
0.8
1.0
1.2
0.000 0.020 0.040 0.060 0.080 0.100
Out
put R
espo
nse
Time (sec)
Step response t = 20ms
0.63
y(n) = (x(n) + x(n-1) +...+ x(n-N-1))/N N=64 fs = 2000 Hz
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Distance to wall
12
Wall
X(mm)
Dc Dr Dl
C(mm)
Dr = Ar/(nr + Br) + Cr Dc = Ac/(nc + Bc) + Cc Dl = Al/(nl + Bl) + Cl
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Calibration
13
Distance, X, from the sensor to wall, 80 to 400mm ADC value, n Linear fit 1/X versus n Solve for X = A/(n+B) Add distance to central point, D = A/(n+B)+C
1/X = 8.6067E-07*n- 7.5230E-04 R² 0.998
0.000
0.002
0.004
0.006
0.008
0.010
0.012
0.014
0 2000 4000 6000 8000 10000 12000 14000 16000
1/X
(1/m
m)
ADC Sample, n
-
Texas Instruments Robotics System Learning Kit: The Maze Edition SWRP201 | Data Acquisition Systems – Performance Measurements
Summary
14
Analog to Digital Converter Noise
Sampling Nyquist Theorem, Aliasing Central Limit Theorem Filters Analog LPF Digital LPF
Data Acquisition Systems Calibration Accuracy
∑=
−n
i t
miti
x
xx
n 0 max
100
-
IMPORTANT NOTICE FOR TI DESIGN INFORMATION AND RESOURCES
Texas Instruments Incorporated (‘TI”) technical, application or other design advice, services or information, including, but not limited to,reference designs and materials relating to evaluation modules, (collectively, “TI Resources”) are intended to assist designers who aredeveloping applications that incorporate TI products; by downloading, accessing or using any particular TI Resource in any way, you(individually or, if you are acting on behalf of a company, your company) agree to use it solely for this purpose and subject to the terms ofthis Notice.TI’s provision of TI Resources does not expand or otherwise alter TI’s applicable published warranties or warranty disclaimers for TIproducts, and no additional obligations or liabilities arise from TI providing such TI Resources. TI reserves the right to make corrections,enhancements, improvements and other changes to its TI Resources.You understand and agree that you remain responsible for using your independent analysis, evaluation and judgment in designing yourapplications and that you have full and exclusive responsibility to assure the safety of your applications and compliance of your applications(and of all TI products used in or for your applications) with all applicable regulations, laws and other applicable requirements. Yourepresent that, with respect to your applications, you have all the necessary expertise to create and implement safeguards that (1)anticipate dangerous consequences of failures, (2) monitor failures and their consequences, and (3) lessen the likelihood of failures thatmight cause harm and take appropriate actions. You agree that prior to using or distributing any applications that include TI products, youwill thoroughly test such applications and the functionality of such TI products as used in such applications. TI has not conducted anytesting other than that specifically described in the published documentation for a particular TI Resource.You are authorized to use, copy and modify any individual TI Resource only in connection with the development of applications that includethe TI product(s) identified in such TI Resource. NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE TOANY OTHER TI INTELLECTUAL PROPERTY RIGHT, AND NO LICENSE TO ANY TECHNOLOGY OR INTELLECTUAL PROPERTYRIGHT OF TI OR ANY THIRD PARTY IS GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, orother intellectual property right relating to any combination, machine, or process in which TI products or services are used. Informationregarding or referencing third-party products or services does not constitute a license to use such products or services, or a warranty orendorsement thereof. Use of TI Resources may require a license from a third party under the patents or other intellectual property of thethird party, or a license from TI under the patents or other intellectual property of TI.TI RESOURCES ARE PROVIDED “AS IS” AND WITH ALL FAULTS. TI DISCLAIMS ALL OTHER WARRANTIES ORREPRESENTATIONS, EXPRESS OR IMPLIED, REGARDING TI RESOURCES OR USE THEREOF, INCLUDING BUT NOT LIMITED TOACCURACY OR COMPLETENESS, TITLE, ANY EPIDEMIC FAILURE WARRANTY AND ANY IMPLIED WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUALPROPERTY RIGHTS.TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY CLAIM, INCLUDING BUT NOTLIMITED TO ANY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON ANY COMBINATION OF PRODUCTS EVEN IFDESCRIBED IN TI RESOURCES OR OTHERWISE. IN NO EVENT SHALL TI BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL,COLLATERAL, INDIRECT, PUNITIVE, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES IN CONNECTION WITH ORARISING OUT OF TI RESOURCES OR USE THEREOF, AND REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THEPOSSIBILITY OF SUCH DAMAGES.You agree to fully indemnify TI and its representatives against any damages, costs, losses, and/or liabilities arising out of your non-compliance with the terms and provisions of this Notice.This Notice applies to TI Resources. Additional terms apply to the use and purchase of certain types of materials, TI products and services.These include; without limitation, TI’s standard terms for semiconductor products http://www.ti.com/sc/docs/stdterms.htm), evaluationmodules, and samples (http://www.ti.com/sc/docs/sampterms.htm).
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265Copyright © 2018, Texas Instruments Incorporated
http://www.ti.com/sc/docs/stdterms.htmhttp://www.ti.com/lit/pdf/SSZZ027http://www.ti.com/lit/pdf/SSZZ027http://www.ti.com/sc/docs/sampterms.htm
15_ADC_Lecture_Data Acquisition Systems Theory_1Module 15Data Acquisition SystemsData Acquisition SystemsA Control System includes a Data Acquisition SystemSampling: conversion from analog to digitalDAC versus ADCMSP432 ADC14Successive ApproximationSuccessive Approximation – How it works ADC14 Software InitializationADC14 Software InitializationADC14 Software InitializationADC14 Software ConversionPeriodic Interrupt and MailboxSummary
15_ADC_Lecture_Data Aquisition Systems PerformanceMeasurements_2.pdfModule 15Data Acquisition SystemsNyquist TheoremStatisticsTransducerGP2Y0A21YK0F IR distance sensors are noisyProbability Mass Function (PMF)Analog Low Pass Filter to remove AliasingDigital FilteringAveraging Low Pass FiltersAveraging Low Pass FiltersDistance to wallCalibrationSummary