Chapter 11 Analog I/O Interfacing From Introduction to Embedded Systems by Valvano.

Slides:



Advertisements
Similar presentations
Analog-to-Digital Converter (ADC) And
Advertisements

12-1 EE 319K Introduction to Microcontrollers Lecture 12: A/D Conversion and Lab 8 Read Book Sections 10.2 and 11.4.
ECE 265 – LECTURE 14 Analog Signal Acquisition The A/D converters 5/14/ ECE265.
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.
5/4/2006BAE Analog to Digital (A/D) Conversion An overview of A/D techniques.
Shuvra Das University of Detroit Mercy
Lecture 9: D/A and A/D Converters
Analogue to Digital Conversion
Interfacing Analog and Digital Circuits
Unit 4 Sensors and Actuators
Data acquisition and manipulation
ECE 371 – Unit 15 Data Acquisition Systems A/Ds in MC9S12DPS56B Microcontroller.
Storey: Electrical & Electronic Systems © Pearson Education Limited 2004 OHT 26.1 Data Acquisition and Conversion  Introduction  Sampling  Signal Reconstruction.
Analog-to-Digital Converter (ADC)
Analogue to Digital Conversion
Introduction to Data Conversion
Discussion #25 – ADCECEN 3011 Conversion Mosiah 5:2 2 And they all cried with one voice, saying: Yea, we believe all the words which though has spoken.
ADC STUDENT LECTURE Andrew Brown Jonathan Warner Laura Strickland.
EET260: A/D and D/A converters
H. Huang Transparency No.11-1 The 68HC11 Microcontroller Chapter 11: 68HC11 Analog to Digital Converter The 68HC11 Microcontroller Han-Way Huang Minnesota.
Week #7 Data Acquisition System, Part (A)
Digital to Analog Converters
Computer Based Data Acquisition Basics. Outline Basics of data acquisition Analog to Digital Conversion –Quantization –Aliasing.
Fall 2004EE 3563 Digital Systems Design Audio Basics  Analog to Digital Conversion  Sampling Rate  Quantization  Aliasing  Digital to Analog Conversion.
Digital to Analog Converters (DAC) 1
1 Sensors and Measurements Penderia & Pengukuran ENT 164 Signal Processing Elements Hema C.R. School of Mechatronics Engineering Northern Malaysia University.
1 ATD10B8CV2 on MC9SI2C By: Yuchun Huang. 2 ADC ADC Power Supply.
ACOE2551 Microprocessors Data Converters Analog to Digital Converters (ADC) –Convert an analog quantity (voltage, current) into a digital code Digital.
1 4-Integrating Peripherals in Embedded Systems (cont.)
Digital to Analogue Converter
INTERFACE WITH ANALOG WORLD
ELN5622 Embedded Systems Class 7 Spring, 2003 Aaron Itskovich
Chapter 8 Serial and Parallel Port Interfacing Valvano’s Intro. To Embedded Systems.
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.
Other Chapters From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
Digital to Analog Converters (DAC) 1 Technician Series ©Paul Godin March 2015.
Analog Capture- Port E. Digital to Analog and Analog to Digital Conversion D/A or DAC and A/D or ADC.
Digital Control CSE 421.
Data Acquisition System
Embedded Control Systems Dr. Bonnie Heck School of ECE Georgia Tech.
Embedded Systems Design 1 Lecture Set C Interfacing the MCS-51 to: –D/A Converter –A/D Converter.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
H. Huang Transparency No.10-1 The 68HC12 Microcontroller Chapter 10 68HC12 Analog to Digital Converter.
ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ (22Δ802) Β΄ ΕΞΑΜΗΝΟ Καθηγητής Πέτρος Π. Γρουμπός  Ώρες Γραφείου: Τετάρτη Πέμπτη Παρασκευή 11:00- 12:00 Γραφείο: 1.
Lecture Notes / PPT UNIT III
EE 319K Introduction to Embedded Systems
Analog-Digital Conversion. Analog outputs from sensors and analog front- ends (analog signal conditioning) have to be converted into digital signals.
FOR MORE CLASSES VISIT   ECET 340 Week 1 HomeWork 1  ECET 340 Week 1 iLab 1  ECET 340 Week 2 HomeWork 2  ECET 340 Week 2 iLab.
MECH 373 Instrumentation and Measurements
Microprocessors Data Converters Analog to Digital Converters (ADC)
Digital Control CSE 421.
Chapter 12: Analog-to-Digital Converter
EI205 Lecture 13 Dianguang Ma Fall 2008.
Analog-to-Digital Converter
ECET 340 Competitive Success/snaptutorial.com
ECET 340 Education for Service-- snaptutorial.com.
ECET 340 Teaching Effectively-- snaptutorial.com.
Digital Acquisition of Analog Signals – A Practical Guide
Soutenance de thèse vendredi 24 novembre 2006, Lorient
Lesson 8: Analog Signal Conversion
CSCI1600: Embedded and Real Time Software
Conversation between Analogue and Digital System
ADC and DAC Data Converter
ANALOG TO DIGITAL CONVERTER (ATD).
CSCI1600: Embedded and Real Time Software
ADC and DAC Data Converter
Presentation transcript:

Chapter 11 Analog I/O Interfacing From Introduction to Embedded Systems by Valvano

11.1 Approximating Continuout Signals in the Digital Domain Analog Signal —one that is continuous in both amplitude and time. To “digitize” the signal, it is quantized in amplitude and time. –Limits are placed in the amplitude (0 to 5 volts) –The amplitude may be divided into a finite set of discrete values.

11.1 (cont.) Range of system —maximum minus minimum. Precision of system– defines the number of values from which the value is selected. Resolution – is the smallest change in value that is significant.

Figure 11.1 Fig is a temperature waveform Fig is a temperature waveform. –0-32 degrees (C) –5 bits used for the amplitude. –1 Hz sampling speed (periodic interrupt).

Figure 11.1 (cont.) Nyquist Rate—sample at twice the highest frequency or aliasing will occur.

Checkpoint 11.1 Why can’t the digital samples represent the little wiggles in the analog signal? ANSWER—because the frequency components of the wiggles are higher than half the sample rate. Thus, the Nyquist Theorem is violated.

Checkpoint 11.2 Why can’t the digital samples represent terperatures above 31 degrees? Answer: Because temperatures above 31 degrees are beyond the range, which is defined in this example as (0-31).

Figure 11.2 Shows DAC and ADC. For the 9S12, the SPI can be used for interfacing. Assume we have an m-bit DAC. Assume N is an m-bit digital output of the microcomputer. Vout = (Vmax-Vmin)* N/2 m + Vmin.

Designing a DAC Example 11.1 –design a 2 bit DAC –Table 11.1 show the specifications. –Figure 11.3 illustrates a 2 bit DAC. –Checkpoint 11.3—How would you design a 3- bit DAC, using this method? (use resistors with a 1/2/4 ratio.)

11.3 Music Generation Figure 11.4—illustrates interface to headphones, and an audio amplifier connected to a speaker. Figure 11.5—loudness (amplitude) and pitch (1/period). Table 11.2—frequencies of musical notes. Page 402 has more information.

11.4 Analog to Digital Conversion Most of the 9S12 microcontrollers have a built-in ADC Table 11.3, page S12C32—1 8 channel 10-bit ADC –Port AD bit S12DP512—two 8-channel 10 bit ADC.

S12 ADC Details 9S12C32 –Port AD can be individually defined as analog input, digital output, or digital input. –Set the corresponding bit in the DDRAD register to 1, then that bit can be used as a digital output.

ADC When triggered, the ADC performs a sequence of conversions, with the sequence length being any number from 1 to 8 conversions. Table 11.3 lists the registers used for ADCs.

Table 11.3 ATDCTL2—control register 2—bits that activate the ADC module. –ADPU—bit 7 --enables when 1 –AFFC—bit 6 –AWAI – bit 5 –ETRIGLE—bit 4 –External Trigger Mode bit –ETRIGP—bit 3—used with ext. trigger mode –ETRIG—bit 2—used with ext. trig.mode (T11.4) –ASCIE –bit 1—will request interrupt on completion –ASCIF—bit 0—ATD Sequence Complete Interrupt Flag.

Table 11.3 ATDCTL3—control register 3—bits that configure the ADC mode. –Bit 7—0 –Bit 6—S8C (sequence conversions) –Bit 5– S4C –Bit 4– S2C –Bit 3—S1C –Bit 2—FIFO—(not in text—freeze mode) –Bit 1 – FRZ1 –Bit 0– FRZ0

Table 11.3 ATDCTL4—control register 4—more bits that configure the ADC mode. –Bit 7—SRES8—resolution select bit –Bit 6—SMP1—sample time select bit –Bit 5—SMP0– sample time select bit. –Bit 4– PRS4 –Bit 3—PRS3 –Bit 2—PRS2 –Bit 1– PRS1 –Bit 0—PRS0

Table 11.3 ATDCTL5—writing to this register starts and ADC conversion –Bit 7-- DJM—Result register data justified bit. –Bit 6– DSGN—Data representation bit. –Bit 5– SCAN– related to no. of sequences –Bit 4—MULT—multiple possible input bits. –Bit 3—0 –Bit 2—CC2—sequence counter (with bit 1 & 0) –Bit 1—CC1 –Bit 0—CC0

Table 11.3 Other registers –ATDSTAT0 –ATDSTAT1 –ATDDIEN –PORTAD—(PAD7—PAD0) –ATDDR0-7—Results of the conversions.

ADC Triggers Three ways to trigger the ADC –(1)Use an explicit software trigger—when conversion is complete, the SCF flag is set –(2)continuous mode—software starts, but the sample sequence is repeated continuously. –(3) external trigger on digital input, PAD07. The results are found in ATDDRs.

Number of Conversions Bits S8C, S4C, S2C, S1C control the number of conversions per sequence. –Let n be the four bit number indicated. –For n equals 1-7, n will be the length. –For n=0, or 8 – 15, the length is 8. SRES8—the ADC resolution select bit –8 bits when SRES8 = 1 –10 bit when SRES8 = 0

Timing 8-bit resolution reduces conversion time and may reduce software design. 10 microseconds are needed to convert an analog value to a digital number. ATDCTL4 selects the sample period and PRS- Clock prescaler SMP1,SMP0—sample time select bits. –Select the length of the second phase of the sample time in units of ATD conversion clock periods (Table 11.5)

ATD Clock Frequency Let m be the 5-bit number formed by PRS4-0. Let fe be the frequency of the E clock. The ATD clock frequency is fe/2(m+1). The default value of m is 5 so the default ATD clock frequency is fe/12.

ATD Clock (cont.) Freescale recommends a clock rate from 500 kHz to 2Mhz. Other issues: –For analog signals with white noise, we can add a low pass filter by increasing the ADC sample time, s. –For faster conversions, increase the clock frequency. –For signals with high slopes, dv/dt, a higher conversion time is needed. –Let n be the number of bits, then the time for one conversion is 2(m + 1)(s + n)/fe.

Observation The ADC frequency does not determine the data acquisition sampling rate, rather it determines how fast one ADC conversion occurs. The sampling rate is determined by how often the software starts the ADC conversion.

The ATDCTL5 Register Writing to the ATDCTL5 register will start an ADC conversion. –Continuous conversions—SCAN =1. –Only one sequence occurs—SCAN =0. –CC,CB,CA select the analog input channel –The result registers are 16 bits. –The result is right justified when DJM = 1 and left justified if DJM =0. –When DSGN=1 the result will have a signed format; when DSGN=0 the result will be unsigned. –(See Table 11.6—formats for the 9S12 ADCs.)

Example 11.2 Design a device driver for the internal ADC. Solution –ADC_in will be a function that performs one conversion. –ADC_init will initialize the ADC.

Program 11.1 Assembly and C are shown. –ADC_Init movb #$80, ATD0CTL2 ; power up – movb #$08, ATD0CTL3; 1 sample – movb #$05, ATD0CTL4; 10-bit – rts –Note in the above ADPU =1, S1C =1, and SRES8=0.

Program 11.1 Solution (cont.) With m =5, and 24 Mhz E clock we have a 2 MHz ADCclock. Assuming low noise, use the shortest possible sampling time (s = 4). The conversion time is 7 microseconds.

Program 11.1 Note the lower portion of the program: –ADC_instaa ATD0CTL5 ; START AD, where REGA =$82. –Loop brclr ATD0STAT1, $01, Loop – ldd ATD0DR0 ; 10 bit result – rts –Note: for the 9S12C32 change all ATD0s to ATD.

11.5 Multiple Access Circular Queues (MACQ)—used for performing digital signal processing on a data acquisition system. It is fixed length and order preserving data structure (see Figure 11.12).

MACQ Useful for implementing digital filters and digital controllers (page 408) d = (v[0] + 3v[1] – 3 v[2] –v[3])/6Δt Where d is the derivative, v[i] are the most recent sample times and Δt is the sampling interval. When a new sample is taken, v[1] = v[0], v[2] =v[1], v[3] =v[2] and the new sample becomes the next v[0].

11.6 Real-Time Data Acquisition We need to sample at a fixed rate. Perfect world—(t i – t i-1 ) = 1/fs where fs is the sampling frequency as required by the Nyquist theorem. Imperfect world –Time jitter (δt)—maximum variation in the sample-to-sample time. – 1/fs – δt <(t i –t i-1 ) < 1/fs + δt

11.6 (cont.) Section 9.2—9 cycles needed to process an interrupt (vector fetch, push registers). These 9 cycles and the ISR are equal for every sample. Problems –(1) instruction currently being executed at the time of the interrupt request—at most this is 13 cycles or microseconds on an 8 Mhz 9S12--acceptible –(2) jitter could be much larger-- the main program could disable interrupts, which could cause jitter in the sampling—if interrupts need servicing they could also cause jitter.

Example 11.3 Design a real-time data acquisition system that samples a voltage signal, performs a digital differentiation and displays the slope on a LCD. The range of inputs is 0 to + 5 V with frequency components of 0 to 50 Hz.

Example 11.3 Solution: –Connect the input to PAD2 (any ADC input is ok.) –Sampling should be at 100 Hz or faster. –Output to LCD is about.4ms (see Program 8.7, 10 characters at 40 microseconds each. –Periodic output compare interrupt (Program 9.4) –Main program initializes: PLL, OC6, and AD or faster. –Output to LCD is about.4ms (see Program 8.7, 10 characters at 40 microseconds each. –Periodic output compare interrupt (Program 9.4) –Main program initializes: PLL, OC6, and ADC

Example 11.3 (cont.) See Figure 11.13—Flowchart –Main loop– wait for a sample, calculate the derivative, then output the slope. –Program 11.2—page

Example 11.4 Design an analog interface between a 30kΩ thermistor and the 9S12, so that temperatures between 20° and 45°C can be measured. Solution– the thermistor is a transducer with its resistance proportional to temperature. –30kΩ thermistor has resistance of 30kΩ at room temperature (25°C). –Figure shows a circuit related to the thermistor.

11.7 Control Systems A control system (Figure 11.15) is a collection of mechanical and electrical devices for “controlling” a physical plant, for example a DC motor. The physical plant is described by “real state variables” and these variables are to be controlled. A sensor and state estimator comprise a data acquisition system. A closed loop control system uses the output of the state estimator in a feedback loop to drive the errors to zero. The actuator is a transducer that converts the control system commands (U(t)) into driving forces (V(t)) that are applied to the physical plant.

Example 11.5 Design a control system that controls a DC motor in the range of 1000 to 2000 RPM Solution: –One input will be the desired speed (RPM) stored as a decimal integer in a global variable called Desired. –The second input is the measured speed. –Figure illustrates a flowchart showing the Error =Desired – Measured. –U is either increased or decreased (or remains the same at its max and min).