Electronic – Sine to square on complex wave

convertersinesquare

What are the required parts on a circuit to get a square wave out of a sine one following the constraint shown in the image?

Schmitt triggers seem to work on continuous sine wave but as you can see, I need to keep the variable volume information as is.

Do you know any part(s) that could do it?

Edit:

Oldfart corrected my graph. This is what I want to achieve. To me, the net result is the same but I understand how wrong I was with my waves looking into the future. My mistake.

I currently solve that situation in C++ but I was curious if HW could do it.

Sine to wave constraint

Best Answer

This is doable, but could be prone to noise. What you appear to be after is an output squarewave, which transitions on the defection point of the incoming signal AND whose amplitude is that of the transition point.

The point of inflection can be determined by differentiating the signal and testing for a sign change (+ve to -ve or -ve to +ve).

A Sample&Hold can then be used to influence the amplitude of the resultant signal.

The concept is demonstrated below (crudely, for a 2min model...). How this is realised in practice is a different problem. The main concern will be the differentiator and the susceptibility to noise.

The incoming signal will need to be filtered and potentially a deglitch/retrigger function on the sample & hold. This will impact your bandwidth. If the signal of interest is "slow changing" with regards to the processing you should be fine. You can see the impact of a fast-changing signal on the differentiator below as techically there was a very quick +ve change and a -ve change, but the fix-step sim triggered once. A 1kHz filter before resolves aspects of that

enter image description here

enter image description here


WIth a 1kHz pre-filter (to manage the fast transition) enter image description here

enter image description here

Now you can see there is an additional level change as the signal is slow enough for the fix-step

Do you know any part(s) that could do it?

To sample, to differentiate, to sample & hold, to output... I doubt any dedicated analogue chip exists that does this. It could be built out of some OPAMPS, FETS, R,C ... A better solution would be to use a small uP and this would not need that much processing.