Fork me on GitHub

Project Notes

#163 VariableSawtoothGenerator

Test a variable-geometry, fixed-amplitude sawtooth wave generator circuit


This is an interesting sawtooth wave generator that’s described in an excellent w2aew tutorial.

It uses two independently-controlled BJT current sources to sequentially charge and discharge a capacitor - generating the rising and falling slopes of the wave.

A comparator with hysteresis is used to switch the current sources.

Components and Limitations

I’m using an LM324 op-amp for the comparator and buffer circuits. This is just borderline acceptable, since it is not rail-to-rail and so the resulting votage differential in the hysteresis cycle is only about 1V. It also seems to be contributing some degree of crossover distortion.

1N4148 diodes are recommended, but I did try replacing them all with standard 1N4007 rectifers. While the circuit still functioned, with 1N4007 diodes there was more distortion of the waveform - I think primarily because of the lower switching speed.

Results - LM324

The following trace is with a 5V supply. It’s a bit hard to read because I crammed 4 measurements in one. The inputs are all DC coupled with no offset to the centre 0V line. comparator output swings from ~0.7V to ~3.7V (showing how far from rail-rail the LM324 is!) *

5v trace LM324

Channel Colour Probe Point Measurement
CH1 yellow SAWOUT saw output
CH2 blue SQUAREOUT comparator output / left of diode bridge, swinging from ~0.7V to ~3.7V
CH3 red P3 charging current source
CH4 green P4 comparator voltage threshold


Replacing the LM324 with LF347N, circuit loses dynamic range but still produced a relatively undistorted wave.

5v trace LF347N


Replacing the LM324 with TL074CN, circuit loses some dynamic range and has significant crossover distortion.

5v trace TL074CN



The Schematic

The Build

Credits and References

Project Source on GitHub Project Gallery Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is just my personal collection of projects. Two main themes have emerged in recent years, sometimes combined:

  • electronics - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting
  • scale modelling - I caught the bug after deciding to build a Harrier during covid to demonstrate an electronic jet engine simulation. Let the fun begin..
To be honest, I haven't quite figured out if these two interests belong in the same GitHub repo or not. But for now - they are all here!

Projects are often inspired by things found wild on the net, or ideas from the many great electronics and scale modelling podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know (or send a PR!). See the individual projects for credits where due.