Gerador de funções analógico
Square, triangle and sine waves from an LM311 and an LM324, built on a breadboard
- Electronics
- Year
- 2026
- Context
- Signal Processing course — Fundação Liberato
- Team
- Maurício Gedrat, Leonardo Kohn
Illustrative background photo: Mitchell Y / Unsplash
Overview
A ±12 V function generator that produces three waveforms, measured and analysed on an oscilloscope.
Records








The problem
Build a wide-range generator from just a comparator and op-amps (Part 1), then turn it into an instrument: adjustable symmetry, waveform selection, amplitude, DC level and a VCO (Part 2) — measuring how much the sine distorts.
The approach
- 01Relaxation oscillator: an LM311 hysteresis comparator and an LM324 integrator; the sine comes from a diode shaper.
- 02Changes after the first bench test to widen the range: P1 from 5 k to 10 k and R6 from 62 k to 33 k.
- 03Symmetry with two diodes and pot P2: each half-cycle charges the capacitor through one side of P2, giving pulse and sawtooth waves.
- 04Output stage with an inverting amplifier (amplitude) and an inverting summer (DC level), plus a VCO using a 2N3904 transistor as a switch.
- 05FFT on a Tektronix MSO2014B oscilloscope, reading each harmonic with the cursors to compute THD.
How the system works
- 01
Comparator
LM311 · square
- 02
Integrator
LM324 · triangle
- 03
Shaper
diodes · sine
- 04
Output
amplitude · offset
- 05
Oscilloscope
FFT · THD
Implementation
- Part 1: oscillator and sine shaper on a breadboard, at ±12 V.
- Part 2: symmetry, waveform selection, amplitude, DC level and the VCO as a stretch goal, with every parameter's limits set before design.
- Each waveform measured at the minimum and maximum frequency, and 10 harmonics of the sine read on the FFT.
Result
In Part 2 the output covered 0.91 kHz to ≈ 12 kHz (the target was 1 to 10 kHz), the sawtooth worked in both directions and the sine's THD was between 3.5 % and 5.8 % at 2.38 kHz. Near 12 kHz the waves start to distort: the limit is the LM311's delay and the LM324's 0.5 V/µs slew rate.
- 5.76–121 kHz
- range, Part 1
- 0.91–12 kHz
- output, Part 2
- 3.5–5.8 %
- sine THD
What I learned
Measured values were ≈ 0.52× the calculated ones in Part 2 and ≈ 0.53× in Part 1. A nearly constant factor pointed at fixed terms — capacitor tolerance, breadboard capacitance, IC delay — rather than a wiring mistake.
Technologies
- LM311
- LM324
- 2N3904
- VCO
- Oscilloscope
- FFT