phase extractor question - Page 1
Forum section: electronics / beginners

author: Achu
author_rank: Contributor
timestamp: June 22, 2019, 06:06:20 pm
content: Hi,How can you convert a signal into in phase and quadrature components?

author: pwlps
author_rank: Frequent Contributor
timestamp: June 22, 2019, 07:36:33 pm
content: two mixers in quadrature with IF outputs (low-passed) driving two modulators ?

author: Achu
author_rank: Contributor
timestamp: June 23, 2019, 02:10:25 am
content: Yeah but how does one implement it physically?

author: bob91343
author_rank: Super Contributor
timestamp: June 23, 2019, 05:40:31 am
content: I presume you have a reference signal?Use a balanced modulator to get the two outputs.

author: Achu
author_rank: Contributor
timestamp: June 23, 2019, 07:50:14 am
content: Quote from: coppercone2 on June 23, 2019, 04:55:20 amHey!I'm a total noob. So why not show some cooperation man.

author: hamster_nz
author_rank: Super Contributor
timestamp: June 23, 2019, 09:10:16 am
content: What signal are you trying to seperate? And what is your reference signal? Digital or Analog?

author: pwlps
author_rank: Frequent Contributor
timestamp: June 23, 2019, 09:25:56 am
content: Quote from: Achu on June 23, 2019, 02:10:25 amYou buy mixers and implement them physically on a PCBMore seriously (and more friendly) we would need more information about the signals (frequency range, analog vs digital etc.). Also knowing the purpose of the whole circuit might help: it may happen that you actually don't need what you want because there is a better/simpler solution to your problem.

author: Achu
author_rank: Contributor
timestamp: June 23, 2019, 03:48:23 pm
content: I am trying to find a way to find the resistive and reactive part of an impedence.Also I would like to know how such setup woks.So the signal is analog and of frequency range less than few KiloHertz.

author: bob91343
author_rank: Super Contributor
timestamp: June 23, 2019, 05:09:20 pm
content: With such a low frequency you can simply display the impedance on an oscilloscope and measure the trace. Apply a voltage to the impedance and to one axis; display the current on the other axis.A resistor will show a diagonal line. A pure capacitance or inductance will display a diagonal line in the other direction. A complex impedance will display an ellipse.You display the current with a shunt, a small sampling resistor.And of course you drive the whole thing with an audio oscillator.

author: Achu
author_rank: Contributor
timestamp: June 24, 2019, 03:31:52 am
content: Yeah I have given that a thought, in fact I have done that in my college lab.But I was thinking one day I could use the idea to make an RLC meter.

author: bob91343
author_rank: Super Contributor
timestamp: June 24, 2019, 04:04:42 am
content: There are almost as many ways to make an LRC meter as there are people trying to make them. A couple of innovative ways are implemented in two instruments I have.One is the very cheap Chinese 'magic' Mega 328 box that identifies components and measures them. Very clever and a genuine bargain. I use mine frequently.Another, at the other end of the scale, is my GR 1658 Digibridge. This thing measures R L and C at two frequencies very accurately. It only uses one standard, I believe a 20 Ohm resistor or similar. It does the job with a sophisticated system of signals all spaced 45 degrees in phase. I can't explain it too well, partly because it's a bit over my head. But download the manual and read how they do it.

author: ejeffrey
author_rank: Super Contributor
timestamp: June 24, 2019, 04:22:01 am
content: Quote from: Achu on June 23, 2019, 03:48:23 pmIn that case, digitize the signal with an ADC and then do it digitally. Multiplying and sum the digitized waveform by the (DAC generated) output waveform and a 90 degree shifted version of the output. That gives you the in-phase and quadrature signal.

author: pwlps
author_rank: Frequent Contributor
timestamp: June 24, 2019, 11:28:09 am
content: Quote from: Achu on June 23, 2019, 03:48:23 pmOk, so let's first recall the principle of extracting the phase shift by frequency mixing. Say you apply a voltage current I=I0 cos(wt) to your impedance Z=X+iY, the voltage on Z will be V=I0*|Z|*cos(wt+phi). (you also have tan(phi)=Y/X)If you multiply the V signal by a reference signal cos(wt) you get cos(wt+phi)*cos(wt)=1/2(cos(2wt)+cos(phi)) and after a lowpass filtering you get a DC voltage proportional to cos(phi) (principle of "synchronous detection"). So basically you multiply the current by the voltage. To measure the current and voltage at the same time just put a shunt resistance in series with the unknown impedance Z you measure, the voltage on the resistance is proportional to the current.For practical implementation you can feed the R-Z series impedance via a transformer and set the ground in the middle point between R and Z. If you don't have a transformer use two opamps configured as voltage subtractors (differential amps).In RF we use double balanced mixers for multiplication but you won't find DBMs for such low frequencies.For frequencies below a few MHz you can find active analog multipliers like the AD633 (it has differential inputs so you won't need any additional voltage subtracting circuit). Note also that your reference signal does not need to be sinusoidal, it can be (and in fact is the most often) a square wave, as you can easily show applying the calculations above to the Fourier series expansion of a square wave. Multiplication by a square wave is much easier: just periodically changing the sign of the input signal, if you want a purely analog circuit (no microcontroller) it is easy to assemble such a "DBM" with a comparator, inverter and a DPST analog switch (I did it once in a similar low-frequency application, the "home made" mixer circuit was chosen mainly for pedagogical reasons but it worked very well). This also has the big advantage that the output is independent of the amplitude of the reference signal.Now there is a little problem with measuring small phase shifts because cos(phi) will be very close to 1 and not varying much. This is why we usually use two mixing circuits with two reference signals in quadrature, so that you get cos(phi) and sin(phi) at the same time*. Another benefit of quadrature detection is that the determination of the phase angle will not depend anymore on any signal/reference amplitudes nor on the value of the shunt resistance. For low frequencies it can be done easily with a microcontroller and is maybe a bit more difficult with a purely analog circuit, I have seen two types of circuits: 1) a two D flip-flop circuit to generate two square-wave reference from a 2f input, then a lowpass to get the sinusoidal excitation signal; 2) using an R-C network and two comparators to detect zero-crossing of the R and C voltages (then no need for a lowpass).* This also allows to determine the sign of phi, not possible with cos(phi) alone.

author: pwlps
author_rank: Frequent Contributor
timestamp: June 25, 2019, 03:36:43 pm
content: Here is a quick and dirty trial of a "beginner grade" analog circuit to measure Z by the method I explained in the previous post. (Of course professionals are welcome to criticize it). For the values in the schematic the theory gives tan(phi)=2*pi*1000*0.1/5000=0.1256 and the simulation gives tan(phi)=Vsin/Vcos=63/506=0.1245.Edit: I started with a transformer but I think a version measuring current by a transimpedance would be more practical (I will make one if I have time). Anyway it was to show the principle, there are many possible variations.

author: Achu
author_rank: Contributor
timestamp: December 31, 2019, 01:43:52 pm
content: Could you explain how the op amp section work?Thank you

author: pwlps
author_rank: Frequent Contributor
timestamp: December 31, 2019, 06:02:58 pm
content: Quote from: Achu on December 31, 2019, 01:43:52 pmThere is nothing special about the opamp section: U7 is a high impedance buffer and U1 an inverter. U3 and U6 select either a direct or inverted voltage depending on the sign of reference signals (square waves) Vrefc and Vrefs (see my explanations posted on June 24).If you were asking about U2 and U8 these are comparators, not opamps. U2 generates a square signal following the voltage across C1 and U8 generates a square signal following the voltage across R1. Since R1 and C1 are in series the voltage across R1 is proportional to the current through C1, therefore the two generated square signals are in quadrature. The U8 signal Vrefc is in phase with the current through Z (because Z is in series with R1) and the U2 signal Vrefs is in quadrature with it. R8 and R11 are just to provide a DC polarisation of the comparator inputs.

author: Achu
author_rank: Contributor
timestamp: January 01, 2020, 01:15:07 pm
content: Ok thanks for explaining.Now, if I were to use it as an LCR meter, when measuring a capacitor one of the output voltage will be negative and could you tell me how would I measure it using a standard Microcontroller ADC say,Arduino or PIC.?I know I'm going off topic but I could really use the knowledge.Thank You

author: pwlps
author_rank: Frequent Contributor
timestamp: January 01, 2020, 04:05:10 pm
content: Quote from: Achu on January 01, 2020, 01:15:07 pmHappy New Year!You can map any voltage range to the 0-5V range, e.g.https://electronics.stackexchange.com/questions/378301/circuit-for-mesure-positive-negative-voltage-vref-resolutionhttps://krakkus.com/measuring-negative-voltage-arduino/"This needs a careful and stable calibration, therefore to correctly measure very small phase shifts (signal close to zero) I would add here an auto-zero feature using a micro reed relay like D31A3100 or equivalent.

author: Achu
author_rank: Contributor
timestamp: January 02, 2020, 04:22:14 am
content: Happy new year to you too!!So it is possible to use the same circuit??I used an SPST switch ti mix non shifted input and shifted reference and sampling gave same results I think, is that wrong?Also if I were to remove the coupling transformer, how should I modify it?And could I use an op amp current source to drive the impedance?One more question, don't we need two readings for current and voltage?Thanks

author: pwlps
author_rank: Frequent Contributor
timestamp: January 02, 2020, 01:46:12 pm
content: Quote from: Achu on January 02, 2020, 04:22:14 amI don't use arduino so I'm not aware of its possibilities and constraints but ok if you say you can shift the ADC reference to measure negative voltages.QuoteYes, as I was saying in a previous post using a transimpedance (as a current source) is another possibility and could be simpler to implement.But now I'm on vacations and can't do any schematics, try to do it yourselfQuoteYou wanted to measure the phase shift between the voltage and current, the circuit does it measuring the voltage components in and out of phase with the current (we could do it the opposite way, measuring the current components in and out of phase with the voltage). Make sure you understand well the math I explained and the principle of this measurement.Now, if you want to measure the module |Z| as well you will need another input to separately measure the currentamplitude(here sensed by R1 or, if a current source is used, from the voltage driving the current source).

author: Achu
author_rank: Contributor
timestamp: January 04, 2020, 04:29:07 pm
content: HiI made this design. Is it good?I used a transimpedance amplifier to measure current.

author: unitedatoms
author_rank: Frequent Contributor
timestamp: January 04, 2020, 08:37:58 pm
content: @Achu. There are few improvements you can do.1. Instead of commutating voltage, commutate the current. This way: Follower opamp loaded with R->switch->Transimpedance amplifier. This will maintain switch close to zero volts, where it is most linear.2. Use much higher current to commutate, instead 10k, go to reasonably low R, 350Ohm, if op amp can stay stable and linear with that currents. This will allow to mask switchimperfect conductanceinjected charge better.3. Instead of commutating opposite polarities through same switch/low pass filter, like positive vs inverted signal, commutate zero vs signal. This will make each feeding opamp not trying competitively regulate same filter aggregating results of 2 opamps. I found this being a precision problem. When you let two loop compete instead of precision of single loop you will get may be still fairly accurate value, but it will never settle in deterministic manner. It looks like chaotic wandering value with never disappearing small value. I did modelling last month and it took a lot for me to solve the cause of puzzling low frequency noise even in perfectly noiseless LTSpice.4. Use a dedicated part for positive/inverted pair of signals. The phase will match perfectly. The inverter in your schematic is inevitable lag, making shift slightly more than expected 180 degrees.

author: pwlps
author_rank: Frequent Contributor
timestamp: January 05, 2020, 03:28:22 am
content: Quote from: Achu on January 04, 2020, 04:29:07 pmJust one comment (on your version, I did not study yet the modifications suggested by unitedatoms): in your design Vrefc has some arbitrary additional phase shift with respect to the V signal, depending on C1,R6,R2. If we call this phase shift theta, and with definitions Z=|Z|exp(i*phi), V=V0cos(wt), I=I0cos(wt-phi), I0=V0/|Z| then your measured voltages are (within a factor 2/pi or something like this):Vcosphi=V0 cos(theta)Vsinphi=V0sin(theta)Icosphi=I0 cos(theta-phi)Isinphi=I0sin(theta-phi)You might avoid some redundancy designing the quadrature generator so that Vrefc is in phase with V and theta=0 (e.g. using an active differentiator), then you could get rid of the Vsinphi channel.

author: Achu
author_rank: Contributor
timestamp: January 05, 2020, 01:23:24 pm
content: I actually simply modified the previous design you provided earlier to remove the transformer.So does your earlier design also create an arbitrary phase shift to the voltage?

author: pwlps
author_rank: Frequent Contributor
timestamp: January 05, 2020, 02:13:20 pm
content: Quote from: Achu on January 05, 2020, 01:23:24 pmIn my design the quadrature generating R-C network isin serieswith the tested impedance Z so that thecurrent I is the same: Vrefc is in phase with I (and Vrefs in quadrature), no arbitrary phase shift. This is simple but may introduce quadrature error when Z is very high and the current very small, so it is better to feed Z and the reference/quadrature generator in parallel, with the same voltage (something as you did but taking the reference input from V (after R2) and not from the source). But then if you want to generate a Vrefc in phase with V you need an active device.

author: Achu
author_rank: Contributor
timestamp: January 05, 2020, 03:51:05 pm
content: yeah, an active differentiator. But the problem with a generic op amp is that one cannot use multiple test frequencies due to oscillations at higher frequencies. I intent to use a max test frequency of 100khz.What are some choices for good op-amps? Would TL0XX make the cut.thankz.

author: pwlps
author_rank: Frequent Contributor
timestamp: January 05, 2020, 10:21:37 pm
content: Quote from: Achu on January 05, 2020, 03:51:05 pmI have been using LT6220/LT6221 in a similar application at 1-2MHz, these high speed precision opamps will perform much better than TL0XX. (NB. To be stable they will need a not too big feedback resistance (e.g. R9 rather 1k than 10k, also add a small 5-10pF cap in parallel with R9, see "feedback components" section in the datasheet).Other suggestions:comparator: LT1394switch/multiplexer: above 1MHz I was using LMH6570 which is much faster than ADG1634 (but more expensive per channel) and also features internal input buffers solving problems pointed out by unitedatoms. (cf. an alternative cheaper per channel: AD8182, also buffered)All these components work well with a +/-5V supply.