In fact, the simplest way to convert sine wave, triangular wave and sawtooth wave into rectangular wave is to use inverters in logic devices, such as CD4069, MC 14069, 74HC04, 74HC 14 and so on. As long as the AC signal is connected to the input end of the inverter through capacitive coupling and then the signal is taken from the output end of the inverter, usually a rectangular wave can be obtained by one inverter. See the picture below-