Layer 2 — Circuit & Hardware

AVR Impedance Meter

ATmega16-based impedance meter using an AC bridge at 10 kHz. Peak detector and zero-crossing detector measure magnitude and phase; polar-to-rectangular firmware conversion.

ATmega16Microcontroller
10 kHzTest Signal Frequency
OPA2172DOp-Amps
LM393Comparators
|Z|, θ → R+jXOutput

Overview

An impedance meter measures the complex electrical impedance Z = |Z|·e^(jθ) = R + jX of an unknown component at a specific test frequency. Most bench LCR meters use dedicated ICs; this project implements the same measurement from first principles on an ATmega16 using a bridge circuit, precision analog front-end, and digital signal processing in firmware.

The fundamental approach is the AC bridge: the unknown impedance Z_x is placed in one arm of a balanced Wheatstone-type bridge driven at 10 kHz. At balance, the voltage across the bridge diagonal is zero. In this design, rather than manually balancing the bridge, the bridge is unbalanced intentionally and the imbalance voltage is measured — its amplitude gives |Z_x| and its phase relative to the drive signal gives θ.

Circuit Architecture

AVR Impedance Meter — Signal Chain ATmega16 PWM → 10 kHz sq. LPF + Buffer sq. → ~sine V_drive AC Bridge R_ref ‖ Z_x arms V_bridge OPA2172D Differential Amp Peak Detector ADC ch. → |Z| LM393 ZCD Timer capture → θ |Z| θ ATmega16 — Firmware |Z|, θ → R + jX → 16×2 LCD Generation Measurement Processing
Fig. 1. Signal chain (three stages): Generation — ATmega16 PWM square wave → RC low-pass filter → approximate sine drive; Measurement — AC bridge imbalance amplified by OPA2172D, then split to peak detector (ADC, gives |Z|) and LM393 zero-crossing detector (timer capture, gives θ); Processing — ATmega16 converts polar |Z|∠θ to rectangular R + jX and displays on LCD.

Signal Chain Detail

Test Signal Generation

The ATmega16 generates a 10 kHz square wave using its built-in PWM timer. A first-order RC low-pass filter converts this to an approximate sine wave with sufficient amplitude for the bridge. The 10 kHz frequency is chosen as a compromise: high enough to measure reactive components (capacitors, inductors) over a useful range, low enough for reliable zero-crossing detection with a standard comparator.

Magnitude Measurement — Peak Detector

The bridge imbalance voltage (proportional to Z_x) is amplified by the OPA2172D differential amplifier. A diode-capacitor peak detector then captures the amplitude envelope. The OPA2172D is chosen for its rail-to-rail output and low offset voltage (<25 μV), which is important when the bridge approaches balance (small imbalance signal). The peak detector output is read by the ATmega16 ADC (10-bit, 5V reference).

Phase Measurement — Zero-Crossing Detector

The phase between the bridge imbalance voltage and the reference signal is measured by time-of-flight between their zero crossings. Each zero crossing triggers an edge on an MCU digital input via the LM393 comparator. The ATmega16 input capture timer records the time difference Δt; the phase angle is then:

θ = 2π × Δt × f_test = 2π × Δt × 10,000

The 16-bit input capture timer at F_CPU = 8 MHz gives a time resolution of 125 ns, corresponding to a phase resolution of 0.45° at 10 kHz — adequate for most passive component measurements.

Polar-to-Rectangular Conversion

The firmware converts the measured polar form (|Z|, θ) to rectangular form (R, X) using fixed-point trigonometry (look-up table for sin/cos to avoid floating-point overhead on the AVR):

R = |Z| × cos(θ)     X = |Z| × sin(θ)

Both polar and rectangular forms are displayed on a 16×2 LCD connected via 4-bit parallel interface.

Results and Figures

System overview
Fig. 2. Complete system block diagram showing all signal chain stages from PWM generation to LCD display output.
AC bridge circuit
Fig. 3. AC bridge schematic: reference arm (R_ref) and unknown arm (Z_x). The OPA2172D amplifies the differential bridge imbalance voltage.
Peak detector
Fig. 4. Peak detector circuit with hold capacitor and op-amp buffer. The held voltage is proportional to the bridge imbalance amplitude, giving |Z_x|.
Zero crossing detector
Fig. 5. LM393 zero-crossing detector. Output edges trigger the ATmega16 input capture unit for phase measurement.