📥 RESOURCES & DOWNLOADS
• ATmega328P Datasheet (ADC sections): https://ww1.microchip.com/downloads/e...
• AVR122 Calibration of the AVR's Internal Temperature Reference (Application Notes): https://drive.google.com/file/d/1yfWB...
• DS3231 Datasheet: https://drive.google.com/file/d/1aR95...
✏️ EXERCISES
• The ATmega Digital Oscilloscope: https://drive.google.com/drive/folder...
• The ATmega Analogue Oscilloscope: https://drive.google.com/drive/folder...
🧠 QUIZ
https://forms.gle/pFRzzkzDHkjvXTtB8
Have you ever wondered how a microcontroller reads real-world analog signals like temperature, light, or voltage levels? In this comprehensive section, we explore the Analog-to-Digital Converter (ADC) built into the ATmega328P - a 10-bit converter capable of sampling rates up to 76.9kSPS that transforms continuous analog voltages into discrete digital values your program can use.
We begin with fundamental concepts: why digital inputs (HIGH/LOW) are insufficient for measuring continuous values, how 10-bit resolution provides 1024 distinct values, and the successive approximation algorithm that converts voltage to a digital integer by comparing against a DAC output bit-by-bit from MSB to LSB.
Reference voltage selection is covered in depth: AVCC (typically 5V, must be within 0.3V of VCC), the internal 1.1V reference for increased accuracy with low-voltage sensors, and external AREF for custom references. You will learn why lower reference voltages increase accuracy (1.07mV steps at 1.1V vs 4.88mV at 5V) and how to calculate voltage divider resistors for custom AREF while limiting current to safe levels (under 1mA).
The ADMUX register is explained: REFS bits for reference selection, the warning against selecting internal reference when external AREF is connected (risk of current flow!), the ADLAR bit for left-adjusted results, and MUX bits for selecting among 8 analog channels plus internal sources. A critical note: after switching channels, discard the first reading to allow charge dissipation.
The ADCSRA control register reveals ADC operation: ADEN enables the hardware, ADSC starts conversion, ADIF flags completion, and ADPS prescaler bits set the ADC clock. For full 10-bit accuracy, the ADC clock should be 50-200kHz; Arduino uses 125kHz (16MHz/128). Higher clocks sacrifice LSB accuracy but enable faster sampling.
Conversion timing is detailed: 13 clock cycles per conversion (25 for the first after enabling), yielding about 9600 SPS at 125kHz. By accepting 8-bit accuracy and using ADLAR=1, you can clock at 1MHz and achieve 76.9kSPS - perfect for building an oscilloscope.
Auto-triggering modes enable hands-off operation: Free Running Mode (ADIF triggers next conversion automatically), timer compare match for fixed-interval sampling, and external interrupt for event-driven acquisition. The timing diagrams show exactly when ADSC, ADIF, and the data registers update.
The DIDR register reduces noise and power: disabling the digital input buffer on ADC pins prevents rapid state changes when analog signals hover near threshold voltages, reducing both power consumption and electrical noise that affects accuracy.
Special internal channels provide unique capabilities: the bandgap reference (stable ~1.1V) enables measuring supply voltage (VCC) by reversing the usual formula - essential for battery-powered projects to detect low charge. The internal temperature sensor, while not factory-calibrated, can be useful after manual calibration using offset (Toff) and gain factor (k) computed from one or two known temperature points.
#Arduino #ATmega #ADC #AnalogToDigital #10Bit #SuccessiveApproximation #ReferenceVoltage #SamplingRate #ADMUX #ADCSRA #TemperatureSensor #BandgapReference #BatteryMonitoring #EmbeddedSystems #Calibration
📖 CHAPTERS
0:00 Introduction
1:19 The World is analog
10:54 The Analog-to-Digital Converter (ADC)
12:02 ADC Pins
14:54 AVCC, AREF, Internal 1.1V Reference
19:16 The internal Temperature Sensor
22:53 Calibration of the internal Temperature Sensor
39:25 The Bandgap Reference
46:38 The ADC in AVR (Register Configurations)
50:18 The AREF Pin
1:01:24 The ADMUX Register
1:04:45 The Configuration Registers (ADCSRA)
1:05:41 Start the Conversion (ADSC) and the Conversion Time
1:10:03 The Prescaler and Frequencies beyond 200kHz
1:17:58 The ADC Interrupt Flag
1:19:54 Auto Triggering the ADC
1:28:29 Reducing Noise: The DIDR
1:31:48 Noise can be good for Randomness
1:33:38 Summary and What's next?