A square wave signal can be expressed as the superposition of sinusoidal signals with multiple frequencies, and its expression can be written as follows
s(t)= A0+a 1 * sin(2 * pi * f * t+θ 1)+a2 * sin(2 * pi * 2 * f * t+θ2)+a3 * sin(2 * pi * 3 * f * t+θ3)+ ......
F is the frequency A0 of the square wave signal, A 1, A2 ... is the amplitude, which can be calculated by Fourier expansion formula.
And θ2 ... are written for the phase of the corresponding carrier, and are mainly expressed by combining sine and cosine.
If you want to get a sinusoidal signal through a square wave, you only need to pass through a filter.
The center frequency of the filter is that the frequency bandwidth of the required sine wave signal is less than 2 * f.