Electronics > Beginners

Generating precise outputs from a comparator

<< < (4/4)

guymo:

--- Quote from: romons on July 05, 2018, 10:51:14 pm ---rstofer, yes, this works. I spent a few minutes simulating it, and it really does work. You need to use an increasing sawtooth, ie, 0 up to 5 then immediately back to 0 for both of the sawtooths.

The way to think about it is the sawtooths are a line that is restarted when it hits 5, repeating again and again, similar to modulo arithmetic. Adding two lines adds the slope modulo 5, and since the slope defines the frequency, adds the frequency.

Very clever.

--- End quote ---

Exactly -- arithmetic mod 5 is the best way to convince yourself that it works, and it also doesn't matter about phase alignment, though of course the phase of the resulting wave does depend on the phases of the waves you start with.

I think rstofer misunderstood what I meant by a 0-5V sawtooth. I mean a wave that starts at 0V and rises to 5V before resetting, while I think rstofer thought I meant a sawtooth of any amplitude between 0 and 5V, which of course won't work.

rstofer:

--- Quote from: guymo on July 06, 2018, 10:52:02 am ---Exactly -- arithmetic mod 5 is the best way to convince yourself that it works, and it also doesn't matter about phase alignment, though of course the phase of the resulting wave does depend on the phases of the waves you start with.

I think rstofer misunderstood what I meant by a 0-5V sawtooth. I mean a wave that starts at 0V and rises to 5V before resetting, while I think rstofer thought I meant a sawtooth of any amplitude between 0 and 5V, which of course won't work.

--- End quote ---

I did indeed misunderstand.  Old age...
I ran an example on Excel and it didn't work but the example had the same misunderstanding.

Zero999:

--- Quote from: guymo on July 05, 2018, 03:17:01 pm ---
--- Quote from: Hero999 on July 05, 2018, 08:16:23 am ---What issues did you have with the TL431?

--- End quote ---

I was using two of them, one for a 2.5V reference and one for the 5V clamp. The 5V clamp seemed to work ok though it was more like 5.1V; the 2.5V reference I couldn't get close to 2.5V, I think because the cathode voltage was 12V or so, so the reference strays from its nominal 2.5V. I don't really understand the data sheet! And I seemed to need to feed both of them quite a lot of current.

--- End quote ---
5.1V isn't that bad. It would be on the upper band of the tolerance, for the standard grade TL431, so it's not unexpected, especially if you have 5% tolerance resistors and your meter is slightly out. Use the B grade TL431 and 0.5% resistors, if you want more precision.

Another reason for the voltage being wrong is the current through the TL431 being too low. It should be at least 1mA, for it to work properly.

T3sl4co1l:
This won't add the frequencies in the way you're probably expecting.

A comparator is a nonlinear element.  This is a special case of a more general truth: when waveforms are added together in a linear circuit, they obey superposition: it's just that, the result is the simple sum of the inputs.  When the sum is passed through a nonlinear circuit, however, superposition is broken, and the result is not the simple sum, but contains product terms (which contain sum and difference frequencies, harmonics, and harmonics of the sums and differences, and so on).

The simplest (textbook) case is a product of two sines (y = (sin wt)(sin vt)), or the square of the sum of two sines (y = (sin wt + sin vt)^2).  In either case, we can use trig identities to simplify the result, and observe that the frequencies w and v add and subtract.

A triangle wave is a bunch of sine waves stacked up in a particular manner.  That is, we can take the Fourier series of the triangle wave, and look at the superposition of sines (harmonics).  When this wave is sent through a nonlinear circuit (the comparator), the harmonics are mixed in this way, and a different result is obtained (namely, a square wave of some duty cycle; the harmonics of which, generally go as 1/n when n = odd and zero otherwise; but a variable duty cycle promotes even harmonics and puts a sinc(f) envelope on them corresponding to pulse width; okay so this is technically correct, but for simplicity's sake, suffice it to say, it's just some kind of square wave).

The sum of two (orthogonal*) triangle waves, will indeed cross zero (or for two biased (0-5V) triangle waves, cross 5V -- it's just an arbitrary threshold, might as well center things around zero for argument's sake here), (sum of frequencies) times per second.  So the comparator output will be a square wave with those zero crossings.

But notice what the one triangle is doing to the other.  Think about one triangle varying very slowly.  It's varying the threshold the other one is being compared at: it's making PWM.  You will indeed get one extra pair of edges, every cycle of the slow wave; but the edges aren't evenly distributed.  The one frequency remains, as does the slow frequency (we've made a PWM modulator -- it could just as well be used for, say, audio reproduction!), and the sum and difference, and their harmonics.  It's a very messy process, if all you wanted was the sum and difference!

*Meaning, the frequencies don't match up in some relevant way.  They aren't harmonically related, say.  Or, at least, the ratio is an odd enough number that we can't measure it very easily.

Tim

guymo:

--- Quote from: T3sl4co1l on July 06, 2018, 09:58:10 pm ---This won't add the frequencies in the way you're probably expecting.

--- End quote ---

I don't see why not. I do appreciate your detailed post but I still think that this circuit performs frequency addition for fixed amplitude sawtooth waves.

To (perhaps) simplify, consider a sawtooth wave that rises from 0V to 1V with frequency f, and suppose that the voltage of this wave at time t=0 is k.
Then the voltage at time t is the fractional part of ft+k. (I'm doing "arithmetic mod 1" i.e. taking the fractional part).

My "frequency adder" circuit would take two such waves, sum their voltages, and subtract 1V if the result goes over this threshold. That is to say, it just returns the fractional part of the sum.
If the input waves are given by the fractional parts of f_1 t + k_1  and f_2 t + k_2 then the result is the fractional part of

f_1 t + k_1 + f_2 t + k_2 = (f_1 + f_2) t + (k_1 + k_2)

So it is a sawtooth of frequency f_1 + f_2 as claimed.

I do not make any claims for what this circuit would produce if fed with triangles, sines or other arbitrary waveforms. It's a sawtooth frequency adder. I am surprised that it seems surprising to people!

Navigation

[0] Message Index

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod