Download presentation
Presentation is loading. Please wait.
Published byStephen Gibbs Modified over 9 years ago
1
Analog Capture- Port E
2
Digital to Analog and Analog to Digital Conversion D/A or DAC and A/D or ADC
3
Real world (lab) is analog V tt Computer (binary) is digital D/A Conversion ComputerDAC Computer DAC A/D Conversion V
4
Digital to Analog Conversion (DAC or D/A) 8 bits Computer A/D
5
Digital to Analog conversion involves transforming the computer’s binary output in 0’s and 1’s (1’s typically = 5.0 volts) into an analog representation of the binary data
6
D/A conversion can be as simple as a weighted resistor network 4 - bit DAC Converter Resistor values correspond to binary weights of the number D 3 D 2 D 1 D 0, i.e. 1/8, 1/4, 1/2, and 1 Using EWB we can model this device
7
Analog-to Digital Conversion (ADC or A/D) A/D 8 bits Computer
8
An ideal A/D converter takes an input analog voltage and converts it to a perfectly linear digital representation of the analog signal If you are using an 8-bit converter, the binary representation is 8-bit binary number which can take on 2 8 or 256 different values. If your voltage range were 0 - 5 volts, then 0 VOLTS0000 0000 5 VOLTS1111 1111
9
00000000 00000001 00000010 00000011111111111111111011111101......... Voltage (Volts) Analog Voltage 11111100 1 LSB
10
Number of Bits (N)Resolution (1/2 N ) Increment (mV) for 5 volts 61/6478.1 81/25619.6 101/1024 4.9 121/4096 1.2 141/16384 0.3 161/65536 0.07
11
Analog signals Analog output is typical of most transducers and sensors. Need to convert these analog signals into a digital representation so the microcontroller can use it. Some characteristics of analog signals. –Maximum and minimum voltages –Precise continuous signals –Rate of voltage change –Frequency if not a steady state signal 12/22/2015 ECE265 11
12
Analog Digital Conversion 2-Step Process: Quantizing - breaking down analog value is a set of finite states Encoding - assigning a digital word or number to each state and matching it to the input signal
13
Step 1: Quantizing Example: You have 0-10V signals. Separate them into a set of discrete states with 1.25V increments. (How did we get 1.25V? See next slide…) Output States Discrete Voltage Ranges (V) 00.00-1.25 11.25-2.50 22.50-3.75 33.75-5.00 45.00-6.25 56.25-7.50 67.50-8.75 78.75-10.0
14
Quantizing The number of possible states that the converter can output is: N=2 n where n is the number of bits in the AD converter Example: For a 3 bit A/D converter, N=2 3 =8. Analog quantization size: Q=(V max -V min )/N = (10V – 0V)/8 = 1.25V
15
Encoding Here we assign the digital value (binary number) to each state for the computer to read. Output States Output Binary Equivalent 0000 1001 2010 3011 4100 5101 6110 7111
16
Accuracy of A/D Conversion There are two ways to best improve accuracy of A/D conversion: increasing the resolution which improves the accuracy in measuring the amplitude of the analog signal. increasing the sampling rate which increases the maximum frequency that can be measured.
17
Resolution Resolution (number of discrete values the converter can produce) = Analog Quantization size (Q) (Q) = Vrange / 2^n, where Vrange is the range of analog voltages which can be represented In our previous example: Q = 1.25V, this is a high resolution. A lower resolution would be if we used a 2-bit converter, then the resolution would be 10/2^2 = 2.50V.
18
Sampling Rate Frequency at which ADC evaluates analog signal. As we see in the second picture, evaluating the signal more often more accurately depicts the ADC signal.
19
Aliasing Occurs when the input signal is changing much faster than the sample rate. For example, a 2 kHz sine wave being sampled at 1.5 kHz would be reconstructed as a 500 Hz (the aliased signal) sine wave. Nyquist Rule: Use a sampling frequency at least twice as high as the maximum frequency in the signal to avoid aliasing.
20
Overall Better Accuracy Increasing both the sampling rate and the resolution you can obtain better accuracy in your AD signals.
22
ADC Flow Diagram in HC11 8 channel/bit input V RL = 0 volts V RH = 5 volts Digital input on PE 01234567 Port E (analog input) Pin: Analog Multiplexer A/D Converter Result Register Interface ADR1 - result 1 ADR2 - result 2 ADR3 - result 3 ADR4 - result 4
23
Port E and ADR addresses When using Port E as a digital port the port is accessed through address $100A The A/D control register, ADCTL, is at address $1030 The ADR registers are at addresses – these are read only registers. –ADR1 - $1031 –ADR2 - $1032 –ADR3 - $1033 –ADR4 - $1034 12/22/2015 ECE265 23
24
PE0 AN0 PE1 AN1 PE2 AN2 PE3 AN3 PE4 AN4 PE5 AN5 PE6 AN6 PE7 AN7 ANALOG MUX 8-bits CAPACITIVE DAC WITH SAMPLE AND HOLD SUCCESSIVE APPROXIMATION REGISTER AND CONTROL V RH V RL RESULT REGISTER INTERFACE ADR1ADR2ADR3ADR4 ADCTL A/D CONTROL CCF SCAN MULT CDCCCBCA INTERNAL DATA BUS P 64 M68HC11 Family Data Sheet Stuctural Diagram of ADC on HC11
25
Output StatesDiscretized Voltage Range Binary Coded Equivalent 00 - 19.5 mV $00 119.6 - 39.0 mV $01 239.1 - 58.5 mV $02 …… … 2554.98 - 5.0 V $FF HC11 => 8 bits => 2 8 = 256 HC11 accepts 0 – 5V range Voltage Range = (V RH – V RL )/255 * State
26
ADCTL register To use the A/D converter on the 68HC11 the users only needs to write to ADCTL for the CPU to read results from the register. There are 8 A/D channels but only 4 results from one of the two groups of 4 can be stored at any one time. –Could also use the 4 registers to save 4 conversions from one input pin ADCTL register – controls how the A/D converter works and how the registers are used. 26
27
00000 Bit:01432675 CCF |No Op| SCAN |MULT | CD | CC | CB | CA CCF: (1) after conversion cycle, (0) when written to. SCAN: Continuous (1) or Not (0) MULT: Multi-Channel (1) or Single Channel (0) 0 = Single Channel is read 4 times CD:CC:CB:CA = 0000 – 0111 Chooses input channel Chooses Channel Group when MULT = 1 0 0 ADCTL Register $1030 0 - Read
28
Control register continued Bit 7 – is set when the A/D conversion is completed. Writing to ADCTL will clear the bit. Bit 6 – unused Bit 5 – SCAN –Value of 0 – single conversion mode – conversion takes place after a write to the register. –Value of 1 – continuous conversion mode Bit 4 – Multiple/Single Channel Control (MULT) –Value of 0 – Single channel – Consecutive conversions results are stored in consecutive ADRx registers ( single channel converted four consecutive times. –The converted value will be copied in 1031-1031 –Value of 1 – each pin in the group is converted and the result stored in the ADR register. The CC control bit determines which group of four channels will be converted. Four sequential channels will be converted one time. 28
29
Control register continued Bit 3- CD is always clear during normal operation. Bit 2– CC When MULT =1 will select the upper or lower group of eight analog input channels; set = upper group (channels 5-8), clear = Lower group (Channel 1-4). When MULT = 0 CC,CB and CA determine which channel will be converted. (Table 11.10) Bit 1, 0- CB and CA will be ignored when MULT =1.
30
More on control register The MULT bit says. 1 channel or all 4 Table lists specific group. and pin(s) 30
31
Example of interface setup What configuration is needed in the ADCTL register for the A/D to convert continuously group 0? Solution: Bits 7 and 6 are don’t cares Bit 5 = 1 convert continuously Bit 4 = 1 group of 4 channels Bits 3 and 2 = 00 group 0, PE0-3 Bits 1 and 0 are not used. Value of xx11 00xx or could store 0011 0000 $30 31
32
Setup example 2 What value needs to be written to the ADCTL register to have continuous conversions of pin PE0? What assembler language instructions would you use to set up this? Set ADCTL as follows: –Bits 7 and 6 – don’t cares –Bit 5 – 1 convert continuously val – 0010 0000 –Bit 4 – 0 single channel –Bit 3,2,1,0 – 0000 the value for PE0 The assembler code (assumes A accumulator is free) – LDAA #$20 – STAA $1030 32
33
Example: Enable A/D, select PE0, continuous mode ORG $0200 LDX #$1000 BSET $39,X $80 ; Enable the A/D LDAA #$20; Continous scan, PE0 is selected STAA $30,X conBRA con If only PE0 is connected you will get the converted data in locations $1031-$1034.
34
Example: Enable A/D, select Group 0 (Channels 1-4), continuous mode ORG $0200 LDX #$1000 BSET $39,X $80 ; Enable the A/D LDAA #$30; continous scan, group 0 is selected STAA $30,X conBRA con If only PE0 is connected you will get the converted data in location $1031.
35
Options Register $1039 100100 Bit:01432675 ADPU |CSEL | IRQE |DLY | CME | NoOp| CR1 | CR0 ADPU: 0 in this bit disable the A/D, 1 will enable the A/D. CSEL: use internal system clock (1), use E-clock (0) -1
36
Analog to Digital Results Register: $1031 - $1034 000010 Bit:01432675 00 ADR2 ($1032) Register $1032 = $02 Options Register ($1039) = $80 ADCTL Register ($1030) = $00 Just read in signal between 19.2 – 39.0 mV on pin E1!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.