Analog & Circuit Analysis
In the real world, signals are analog—continuous voltages and currents that represent physical phenomena. Understanding how to process, convert, and analyze these signals is essential for bridging the gap between the digital microcontroller and the physical world.
Operational Amplifiers (Op-Amps)
Op-Amps are the building blocks of analog circuits. They can amplify, filter, and condition signals before they reach your microcontroller.
Key Op-Amp Configurations
- Inverting Amplifier: Output is inverted and amplified. Gain = -Rf/Rin
- Non-Inverting Amplifier: Output is in-phase with input. Gain = 1 + Rf/Rin
- Voltage Follower (Buffer): Unity gain, high input impedance. Used for impedance matching.
- Summing Amplifier: Adds multiple input signals together.
- Differential Amplifier: Amplifies the difference between two inputs.
💡 Pro Tip: Always check the op-amp's slew rate and bandwidth (GBW) to ensure it can handle your signal frequency!
Analog-to-Digital Conversion (ADC)
ADCs convert continuous analog voltages into discrete digital values that your microcontroller can process.
Key ADC Parameters
- Resolution: Number of bits (e.g., 10-bit = 1024 levels, 12-bit = 4096 levels)
- Sampling Rate: How fast the ADC can take samples (Samples per second)
- Reference Voltage (Vref): The voltage that corresponds to the maximum digital value
- Quantization Error: Inherent error due to discrete levels = Vref / (2^n)
ADC Types
- Successive Approximation (SAR): Good balance of speed and resolution. Most common in MCUs.
- Flash ADC: Very fast, but expensive and power-hungry.
- Delta-Sigma (ΔΣ): High resolution, slower. Great for precision measurements.
Digital-to-Analog Conversion (DAC)
DACs do the opposite—they convert digital values back to analog voltages for driving speakers, motors, or generating waveforms.
Common DAC Architectures
- R-2R Ladder: Simple resistor network, commonly used
- Weighted Resistor: Different resistor values for each bit
- PWM-based DAC: Using PWM with low-pass filter to approximate analog output
Pulse Width Modulation (PWM)
PWM is a technique to encode analog-like values using digital signals by varying the duty cycle.
PWM Applications
- Motor Speed Control: Vary duty cycle to control average voltage
- LED Dimming: Control brightness without changing voltage
- Audio Generation: Create tones and simple waveforms
- Power Supply Regulation: Switch-mode power supplies
Signal Conditioning
Before feeding analog signals to an ADC, they often need conditioning:
Common Conditioning Techniques
- Amplification: Boost weak signals to ADC input range
- Filtering: Remove noise and unwanted frequencies (Low-pass, High-pass, Band-pass)
- Level Shifting: Shift bipolar signals to unipolar range
- Clamping/Protection: Prevent overvoltage damage to ADC inputs
Practical Example: Temperature Sensor Interface
Reading an analog temperature sensor (like LM35) involves:
🎯 Key Takeaway: Understanding analog electronics allows you to interface with the physical world—sensors, actuators, and audio—effectively bridging the analog-digital divide.