Top Banner
Dr M. Abd El Ghany Eng. Yasmin Adel Microelectronics Lab ELCT 708 Session 5 ADC
32

Microelectronics Lab ELCT 708 - German University in Cairo

Apr 24, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Microelectronics LabELCT 708

Session 5

ADC

Page 2: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Analog signal vs Digital signal

• Analog signal is a continuous wave that keeps on changing over a time period.

• Examples : temperature, pressure, voltage,

• Digital signal is discrete in nature.

• The fundamental difference between analog and digital signal is that analog signal is represented by the sine waves whereas, the digital signal is represented by square waves.

Page 3: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Why do we convert Analog signal to Digital Signal?

• Analog signal processing is quite inefficient in terms of accuracy, speed and desired output.

• Hence, we convert them to digital form using an Analog to Digital Converter (ADC).

Page 4: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Signal Acquisition Process

• In the Real World, a sensor senses any physical parameter and converts into an equivalent analog electrical signal.

• For efficient and ease of signal processing, this analog signal is converted into a digital signal using an Analog to Digital Converter (ADC).

• This digital signal is then fed to the Microcontroller (MCU) and is processed accordingly.

Page 5: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Signal Acquisition Process

Microcontrollers are meant to deal with digital information. They only understand ‘0’ and ‘1’ values. So what if we need to get some non-digital data in to microcontroller. The only way is to digitize or simply speaking to convert analog in to digital. This why almost all microcontrollers are featured with ADC module.

Page 6: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADC

• ADC is one such hardware which measures analog signals and produces a digital equivalent of the same signal.

• AVR microcontrollers has inbuilt ADC facility to convert analog voltage into an integer.

• AVR convert it into 10-bit number of range 0 to 1023.

Page 7: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADC Parameters

1. Resolution: How many bits are used to represent one analog value.

For N bits, Resolution = 1 / ( 2^N ) .

Resolution is better for higher N.

2. Digital codes numbering: The number of digital codes that can exist: The number of a code ( 0 to2^N - 1 ) .

3. Full Scale ( FS ): The full range of output ( 0 to Vref ) or

( –Vref to Vref ) according to the design.

4. Step Size (Δ): The size of the analog value of the least significant bit. As the number of bits increase, the step size decreases. ▪ FS/ 2^N

Page 8: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Successive Approximation ADC

3 bits ADC

Step Size=2

23= 0.25 𝑉

Page 9: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Sampling Frequency

• The sampling frequency stand outs the speed to convert the analog signal to digital result.

• Therefore, the ADC sampling frequency must be at least twice the analog signal frequency.

• Sampling the signal at twice the analog signal frequency will not result in a loss of information.

• If sampling frequency is less, then the information will be lost.

• For example, an ADC with a conversion time of 10 μs can be used to sample an analog signal with a time period of 20μs, i.e., 50 kHz.

Page 10: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

AVR ADC

• 8 Channels implies that there are 8 ADC pins are multiplexed together. You can easily see that these pins are located across PORTA.

• AVR ADC is 10 bit Resolution.

Page 11: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

AVR ADC

• AVCC: is the supply voltage pin for Port A and the A/D Converter.

• It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.

• AREF: is the analog reference pin for the A/D Converter.

Page 12: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

AVR Connection

Page 13: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADC Prescaler

• The ADC operates within a frequency range of 50kHz to 200kHz. But the CPU clock frequency is much higher (in the order of MHz).

• Frequency division must take place.

• The prescaler acts as this division factor. It produces desired frequency from the external higher frequency.

• There are some predefined division factors 2, 4, 8, 16, 32, 64, and 128. For example, a prescaler of 64 implies F_ADC = F_CPU/64. For F_CPU = 16MHz, F_ADC = 16M/64 = 250kHz.

Page 14: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

AVR ADC

• The Type of ADC implemented inside the AVR MCU is Successive Approximation (SAR) type.

Page 15: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

SAR ADC

• The SAR ADC basically implements a binary search algorithm.

Page 16: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Binary Search Algorithm

Page 17: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

SARDesign Approach, Zoom in

Page 18: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Design Approach, Detailed Steps

Page 19: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADC Registers

1. ADMUX – ADC Multiplexer selection Register

2. ADCSRA – ADC Control and Status Register A

3. ADCH & ADCL – ADC Data Registers

Page 20: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADMUX

Page 21: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADMUX

• Bit 5 – ADLAR – ADC Left Adjust

• Make it ‘1’ to Left Adjust the ADC Result.

Page 22: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADCL and ADCH – ADC Data Registers

• The result of the ADC conversion is stored here.

• The ADC has a resolution of 10 bits hence, it requires 10 bits to store the result.

• One single 8 bit register is not sufficient.

• two registers are used in AVR – ADCL and ADCH

• (ADC Low byte and ADC High byte)

Page 23: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADCL and ADCH – ADC Data Registers

Page 24: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

ADMUXBits 4:0 – MUX4:0 – Analog Channel and Gain Selection Bits

Page 25: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

2. ADCSRA – ADC Control and Status Register A

• Bit 7 – ADEN – ADC Enable – it enables the ADC feature. Unless this is enabled, ADC operations cannot take place across PORTA

i.e. PORTA will behave as GPIO pins.

• Bit 6 – ADSC – ADC Start Conversion – Write this to ‘1’ before starting any conversion. This 1 is written as long as the conversion is in progress, after which it returns to zero. Normally it takes 13 ADC clock pulses for this operation. But when you call it for the first time, it takes 25 as it performs the initializationtogether with it.

• Bit 5 – ADATE – ADC Auto Trigger Enable – Setting it to ‘1’ enables auto-triggering of ADC. ADC is triggered automatically at every rising edge of clock pulse.

Page 26: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

2. ADCSRA – ADC Control and Status Register A

• Bit 4 – ADIF – ADC Interrupt Flag – Whenever a conversion is finished and the registers are updated, this bit is set to ‘1’ automatically. Thus, this is used to check whether the conversion is complete or not.

• Bit 3 – ADIE – ADC Interrupt Enable – When this bit is set to ‘1’, the ADC interrupt is enabled. This is used in the case of interrupt-driven ADC.

Page 27: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

2. ADCSRA – ADC Control and Status Register A

• Bits 2:0 – ADPS2:0 – ADC Prescaler Select Bits – The prescaler(division factor between CPU frequency and the ADC clock frequency) is determined by selecting the proper combination from the following.

Page 28: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Data Sheet

• For more reference Page 207 in Data Sheet

Page 29: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Potentiometers

• They have three terminals (or connection points).

• They have a knob, screw, or slider that can be moved to vary the resistance between the middle terminal and either one of the outer terminals.

• The resistance between the two outer terminals is a fixed (constant) resistance, and it is the maximum resistance of the pot. This resistance doesn’t vary even when the knob, screw, or slider is moved.

• The resistance between the middle terminal and either one of the outer terminals varies from 0 Ω to the maximum resistance of the pot as the knob, screw, or slider is moved.

Page 30: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Potentiometers

• The maximum resistance (between terminals 1 and 3) of the pot —50 kΩ — is stamped on the back of its case.

• If the control knob is positioned at the midpoint of its full range, the resistance between terminals 1 and 2 will be 25 kΩ and the resistance between terminals 2 and 3 will be 25 kΩ.

• As you turn the knob, the two variable resistances — that is, the resistance between terminals 1 and 2 and the resistance between terminals 2 and 3 — change, but their sum is always the maximum resistance of the pot.

Page 31: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Potentiometer as Voltage Divider

• If the outside pins connect to a voltage source (one to

ground, the other to Vin).

• The output (Vout at the middle pin will mimic a voltage

divider.

• Turn the pot all the way in one direction, and the

voltage may be zero.

• Turned to the other side the output voltage approaches

the input.

• A wiper in the middle position means the output voltage

will be half of the input.

Page 32: Microelectronics Lab ELCT 708 - German University in Cairo

Dr M. Abd El GhanyEng. Yasmin Adel

Task 1

• Use a potentiometer as an analog signal and set the digital output for

• 10 leds to represent the number of bits.