Differentiating between a square wave or sawtooth wave with a circuit...?

If the frequency for both waves is going to be 100 kHz with the same amplitude, you could construct a narrow bandpass filter at 200 kHz to put the signal through. In theory a pure squarewave should only have odd harmonics, so there should not be much output at the second harmonic frequency. On the other hand, a sawtooth wave has booth even and odd harmonics, so you will get a greater output. The peak amplitude for the second harmonic of a sawtooth wave will simply be \$ \frac{2A}{\pi} \$, where A is the peak amplitude of the input sawtooth. If wish you can then follow up the output of the bandpass filter with a peak detector and some kind of comparator.


An outline of a solution: Maybe run it through a differentiator. The derivative of a square wave will be alternating positive-going and negative-going spikes, whereas the derivative of a sawtooth should be more or less constant at a low value in one polarity during the rampy bits, with periodic larger valued spikes in the opposite polarity when the sawtooth resets. So then HPF that to get rid of the constant low-values you get from the sawtooth ramps, and look to see whether you're getting spikes of both polarities, or just a single polarity.


You can easily detect some simple waveforms by detecting the flanks of the signal. A square has quick rising and falling flanks, a sawtooth has only quick rising or quick falling flanks, depending on the signal.

So you check for rising and falling flanks: if you detect both, it is square. If you detect only one type, it is triangle, as long as you are sure only these signals will be input.

Try with a differentiator circuit, which is easily done with an opamp. See here: http://www.physics.iitm.ac.in/courses_files/courses/eleclab03_odd/mathematical_operations.htm

The steepness of the flank is represented in the output of the differentiator.

Feed this signal and its inversion into Schmitt-Triggers and / or retriggerable monoflops, and you have logic level representation of RisingFlank and FallingFlank, which in turn you can use for further computation or display.