Skip to content
Maurício Gedrat
← All work

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

Oscilloscope showing a 68.2 kHz sine wave
Part 1, first bench test: sine at 68.2 kHz.
Oscilloscope showing a 2.92 kHz square wave
Part 1: square wave at 2.92 kHz, 12.1 V peak to peak.
Oscilloscope showing a 2.93 kHz triangle wave
Part 1: triangle wave at the same frequency.
Oscilloscope showing a sawtooth wave
Part 2: with P2 at one end, the triangle becomes a sawtooth (11.46 kHz).
Oscilloscope FFT with the fundamental peak
Sine FFT: fundamental at 2.40 kHz, 1.67 V.
Zoomed FFT with cursors on the 2nd and 3rd harmonics
Zoomed FFT: 2nd harmonic at 49.6 mV, 3rd at 32.0 mV.
Block diagram of the function generator
How the five blocks connect.
Schematic of the symmetry and integrator block
Block 2: symmetry, frequency adjustment and integrator.

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

  1. 01Relaxation oscillator: an LM311 hysteresis comparator and an LM324 integrator; the sine comes from a diode shaper.
  2. 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.
  3. 03Symmetry with two diodes and pot P2: each half-cycle charges the capacitor through one side of P2, giving pulse and sawtooth waves.
  4. 04Output stage with an inverting amplifier (amplitude) and an inverting summer (DC level), plus a VCO using a 2N3904 transistor as a switch.
  5. 05FFT on a Tektronix MSO2014B oscilloscope, reading each harmonic with the cursors to compute THD.

How the system works

  1. 01

    Comparator

    LM311 · square

  2. 02

    Integrator

    LM324 · triangle

  3. 03

    Shaper

    diodes · sine

  4. 04

    Output

    amplitude · offset

  5. 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