Op amps and trigonometrie

Discussion in 'General Electronics Chat' started by markbauerd, Oct 21, 2013.

  1. markbauerd

    Thread Starter New Member

    Oct 21, 2013
    Hi everyone,

    I am suggesting your help for a problem that I have a hard time figuring out. I have two signal sin(2x) and cos(2x). I am trying to figure it out a circuit that could extract x from these two signals.
    Any ideas ?

    Thank you in advance for taking the time to look at this.

  2. KL7AJ

    Senior Member

    Nov 4, 2008
    Yes....this is a snap! (It's how you get the MAGNITUDE output from a standard Lock-In amplifier, as well)

    You can use two balanced modulators (or gilbert cells) driven in quadrature. Take the product generated by each (reference signal and "unknown" and add them together.

    I'll see if I can create a diagram for you in a day or so with my cad program...but it's very late tonight!
  3. WBahn


    Mar 31, 2012
    The big problem in coming up with a "traditional" (can't think of a better term) opamp circuit is that you are trying to extract a parameter that is a measure of something over time as opposed to something that is instantaneous.

    Some possible approaches:

    1) Take the derivative of one of the signals, call it y. The magnitude of y will be proportional to x. But y itself won't be proportional to x since it will be a sinusoidal. So you will need a circuit to produce a voltage proportional to the magnitude of y, which is pretty easy to do.

    2) Count zero crossings. With quadradure signals available, this is pretty easy to do, depending on the frequencies we are talking about. But if you are looking for opamp-based solutions, I have to assume that we are talking about pretty tame frequencies.

    3) Generate a reference signal with a VCO (voltage controlled oscillator) and servo it to match your signals. The programming voltage of the VCO will tell you what x is. This is known as a PLL (phase-locked loop). It's a more sophosticated technique, but depending on how much noise your signals have will probably produce the "best" results (depending on what is important to you).
  4. markbauerd

    Thread Starter New Member

    Oct 21, 2013
    Hi everyone,

    Thank you for your kind help.

    KL7AJ, I was thinking of something with modulators but I have a hard time figuring out how just with multiplication I can extract the phase from a trigonometric function. I appreciate that you take some time of yours to help me out. thanks.


    For option 1 I am a little confused. Is the magnitude of the derivative of a sin(x) function proportional to x ?
    Say Va=sin(2*x) -> y=dVa/dt=2*cos(2*x)
    |y| proportional to x ?
    But I was also maybe thinking of a technique with derivatives.

    For option 2, yeah the frequency is something classic 1 to 10000Hz.
    Do you mind explaining a little more this. I am not familiar with the method.

    Option 3, I will study a little more PLL and post again.

    Thanks again for your replies. I am happy to see that there are some ideas and this is not impossible to do with op amps. I was thinking of using a microcontroller to scan with an ADC the 2 signals and do the numeric calculation and then output this with a DAC.
    But this means programming the microcontroller and latency issues.

    I forgot to say that x is a function of time (x(t)), I hope this doesn't change everything.

  5. WBahn


    Mar 31, 2012
    I may well have been misreading your original question. I was assuming that you were looking for the frequency of something, so I was assuming the x(t) was something like ωt.

    For the general case, you have

    y1 = sin(2x(t))
    y2 = cos(2x(t))

    dy1/dt = 2cos(2x(t))*dx/dt
    dy2/dt = -2sin(2x(t))*dx/dt

    If you then divide dy1/dt by y2 (may be easier said than done), you get 2dx/dt.

    If x(t) is not mostly linear with time (making it roughly a sinusoid), then I don't know how well a PLL will be able to track it.
  6. Tesla23

    Active Member

    May 10, 2009
    You give no idea of the performance you require (accuracy / speed / technology), but if you want analogue processing one possibility may be to use something like:

    x ≈ sin(x) + 0.2673 * (1 - cos(x))
    with an accuracy of better than 0.7° for 0 <= x <= pi/4

    the x=pi/4 boundaries are easy to find as these are where
    |sin(x)| = |cos(x)|

    and over the 2*pi range you would have to switch between sin and cos.