1
\$\begingroup\$

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

\$\endgroup\$
  • 3
    \$\begingroup\$ Your red wave violates causality. It needs to predict the future. Look at the second transition when it goes negative. It need to know when the first minimum will occur in advance. The only solution is to store the signal in memory and do the processing afterwards. \$\endgroup\$ – user110971 Aug 4 '19 at 16:38
  • 1
    \$\begingroup\$ @JonRB The differentiator would, indeed, figure out when the 1st derivative transitions between + and - (or the reverse.) But in no possible way would it predict the magnitude of the next transition (which appears to occur in a few places, but not others.) But yes, when the 1st derivative goes through 0 one could sample and hold a nearby magnitude value. (I've done something very much like that in an optical glass sorter for recycling broken bits of glass.) \$\endgroup\$ – jonk Aug 4 '19 at 17:29
  • 1
    \$\begingroup\$ If we look at the second half of the diagram, it can be done with a differentiator, on a zero crossing from the diff, it stores the value of the waveform. For the first part oft he diagram, you need an anticipator circuit (tm). You can get one of those at the expense of latency, store enough of the waveform and look back in software. \$\endgroup\$ – Neil_UK Aug 4 '19 at 17:37
  • 1
    \$\begingroup\$ @Larry: you forgot to add in the why and your application during your edit. \$\endgroup\$ – Transistor Aug 4 '19 at 17:56
  • 1
    \$\begingroup\$ @jonk thats why you would need a differentiator and a "sample and hold". The d/dt to catch the change in direction, which would also be needed to trigger the "sample and hold" which equally would need to cater for +ve and -ve signals. This is doable, just not the nicest of things. Plus a practical differentiator will be noisy \$\endgroup\$ – JonRB Aug 4 '19 at 17:58
6
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks you so much, it sounds like a hassle. I will just keep doing it in software and later maybe in a dedicated uP. Thanks! \$\endgroup\$ – Larry Aug 5 '19 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.