Presentation is loading. Please wait.

Presentation is loading. Please wait.

H. Huang Transparency No.11-1 The 68HC11 Microcontroller Chapter 11: 68HC11 Analog to Digital Converter The 68HC11 Microcontroller Han-Way Huang Minnesota.

Similar presentations


Presentation on theme: "H. Huang Transparency No.11-1 The 68HC11 Microcontroller Chapter 11: 68HC11 Analog to Digital Converter The 68HC11 Microcontroller Han-Way Huang Minnesota."— Presentation transcript:

1 H. Huang Transparency No.11-1 The 68HC11 Microcontroller Chapter 11: 68HC11 Analog to Digital Converter The 68HC11 Microcontroller Han-Way Huang Minnesota State University, Mankato

2 H. Huang Transparency No.11-2 The 68HC11 Microcontroller Basics on A/D Conversion -Almost any measurable quantity, for example, current, voltage, temperature, speed, and time, is analog in nature. -Analog signals must be represented in digital format in order to be processed by the digital computer. -An analog to digital (A/D) converter can convert a electrical voltage to a digital value. -A non-electrical quantity must be converted into electrical voltage before it can be converted into digital value. -A transducer is normally used to convert a non-electrical quantity into a electrical voltage so that it can be further processed by a computer. -The accuracy of an A/D converter is dictated by the number of bits it used to represent the digital value. -An A/D conversion system is illustrated in Figure 11.1

3 H. Huang Transparency No.11-3 The 68HC11 Microcontroller

4 H. Huang Transparency No.11-4 The 68HC11 Microcontroller Optimal Voltage Range for the A/D Converter - A/D converter needs a low reference voltage and a high reference voltage to operate. - The low reference voltage (V LREF ) is often set to 0 and the high reference voltage (V HREF ) is often set to V CC. - Most A/D converters are ratiometric. - To take advantage the whole dynamic range of the A/D converter, we should set scale and shift the sensor output to V LREF ~ V HREF. - The A/D conversion result x corresponds to an analog voltage given by Vx = V LREF + (range  x)  (2 n – 1) where, range = V HREF – V LREF

5 H. Huang Transparency No.11-5 The 68HC11 Microcontroller Example 11.1 Assume there is a 12-bit A/D converter with V LREF = 0V and V HREF = 5V. Find out the corresponding voltage values for A/D conversion results of 100, 400, 800, 1200, and 2400. Solution: range = V HREF – V LREF = 5 V. V(100) = 0V + (100  5)  (2 12 – 1) = 0.12 V V(400) = 0V + (400  5)  (2 12 – 1) = 0.49 V V(800) = 0V + (800  5)  (2 12 – 1) = 0.98 V V(1200) = 0V + (1200  5)  (2 12 – 1) = 1.46 V V(2400) = 0V + (2400  5)  (2 12 – 1) = 2.93 V

6 H. Huang Transparency No.11-6 The 68HC11 Microcontroller An Overview of the 68HC11 A/D Converter -Eight-channel, 8-bit, multiplexed input, successive-approximation conversion method. -A weighted array of capacitors are used to implement the successive-approximation method. -A clock signal is required to control the A/D conversion that must have a frequency no lower than 750 KHz. -Reference voltages are required for the conversion: one is high reference (V RH ) voltage, the other is low reference (V RL ) voltage. The difference between V RH and V RL cannot be lower than 2.5 V. -Accuracy is only guaranteed for V RL = 0 V and V RH = 5 V. -The conversion is ratiometric. The input voltage V RL converts to $00 and the input voltage V RH converts to $FF.

7 H. Huang Transparency No.11-7 The 68HC11 Microcontroller The Clock Frequency Issue -The A/D converter requires a clock to operate. -Either the E clock or the on-chip RC clock signal can be used. -The RC clock runs at 1.5 MHz. -To choose the E clock signal, clear the bit 6 of the OPTION register to 0. -To select RC clock signal, set the bit 6 of the OPTION register to 1. This circuit requires 10 ms to start and settle. -The 68HC11 completes the conversion of one sample in 32 clock cycles. Registers Related to the A/D Operation -ADCTL:A/D control/status register -OPTION: bits 7 and 6 -ADR1-4:A/D result registers 1 to 4

8 H. Huang Transparency No.11-8 The 68HC11 Microcontroller A/D Control Register (ADCTL)

9 H. Huang Transparency No.11-9 The 68HC11 Microcontroller

10 H. Huang Transparency No.11-10 The 68HC11 Microcontroller The OPTION Register ADPU:A/D power up. When set to 1, it enables the A/D converter. After setting this bit, the user must wait at least 100  s before using the A/D converter. CSEL:clock select. When set to 1, the RC clock signal is selected. Otherwise, the E clock is selected. It takes 10 ms for RC clock to stabilize.

11 H. Huang Transparency No.11-11 The 68HC11 Microcontroller The Procedure for Using the A/D Converter Step 1. Connect the hardware properly. Scale and shift the analog inputs, when necessary, so that they fall between V RH and V RL. Step 2.Set the ADPU bit of OPTION register to enable the A/D converter. Step 3.Select the appropriate clock signal by setting or clearing the CSEL bit of the OPTION register. Step 4.Wait for the A/D converter to stabilize. Step 5.Select the appropriate channel(s) and operation modes by programming the ADCTL register. Step 6.Wait until the CCF flag of the ADCTL register becomes 1 and collect the conversion results.

12 H. Huang Transparency No.11-12 The 68HC11 Microcontroller Example 11.5 Write an instruction sequence to set up the following A/D conversion parameters: Nonscan mode Single-channel mode Select channel AN0 Choose the E clock as the clock source for the A/D converter Enable A/D converter Solution: Set bit 5 of ADCTL to 0 to select nonscan mode. Set bit 4 of ADCTL to 0 to select single-channel mode. Set bits 3-0 of ADCTL to 0000 to select channel AN0. Write the value $00 into the ADCTL register. Set the bit 7 of the OPTION register to enable A/D charge pump. Clear the bit 6 of the OPTION register to select E clock as the A/D control clock signal. Wait for 100  s for the converter to stabilize.


Download ppt "H. Huang Transparency No.11-1 The 68HC11 Microcontroller Chapter 11: 68HC11 Analog to Digital Converter The 68HC11 Microcontroller Han-Way Huang Minnesota."

Similar presentations


Ads by Google