Phase/Capacitance calculation question. - Page 1
Forum section: electronics / projects

author: kvresto
author_rank: Regular Contributor
timestamp: May 20, 2016, 01:28:11 am
content: Hi Everyone.I’m stuck interpreting some results from my experiments, and I think I’ve confused myself and hope someone can help clear it up. I’m playing around with the circuit pictures below, and I’m trying to use the voltage and current method to extract the phase and value of a capacitor. In the form pic is what I’m trying to do.My DSO measures the phase shift of the resistor voltage to the capacitor voltage as ~ 33 degrees, which is about right as the calculated phase is 36.37 degrees.The LT spice simulation shows V1, V2, and V3. V1, and V2 shows the R_current leading the C_voltage by about 33 degrees.V3 is, V1-V2, the output from the diff-amp, and its phase difference from the sig_gen, is ~55 degrees. So the total phase shift is 33+52=85 degrees which agrees with my DSO value of ~84 degrees.With the formulas above I can connect to my hardware to both channels of my function generator, dial up a frequency, and scan through 90 degrees of phase shift, and when I sample and run it through the algorithm, I can reliably measure the phase shift almost exactly as to what is displayed on my DSO.Great!, but my capacitor value seems to be always out by a factor of 100. I connect V3 and V4 to my sampling circuit, with a 1uF cap in series with 100R, and I measure 100uF? Ive previously connected a 4.7uF and I measured about 470uF. The vales are not exact ie my MM measures the capacitor as 0.98uF, and my algorithm comes back as 93uF, and of course it changes with other caps as well.Sure, it seems to me a scaling issue, but where?Also does anyone know how to insert these mathtype formulas straight into the post?

author: StillTrying
author_rank: Super Contributor
timestamp: May 20, 2016, 01:46:46 am
content: Well R1 is 100R.

author: Zeranin
author_rank: Regular Contributor
timestamp: May 20, 2016, 04:32:09 am
content: The correct answers for the calculated voltages are, for 1.0V at output of signal generator :-Vresistor = 0.59296 at 53.632 degreesVcapacitor = 0.80523 at 36.367 degreesThis seems to be the same as your calculations, and close to what you measure. Your phasor diagram does not look quite right, because if you add the Vresistor vector to the Vcapacitor vector then this should equal the Vgenerator vector, but on your phasor diagram it does not. Maybe you did not draw it to scale.We know that the capacitor is actually 1uF, because (presumably) it says so on the capacitor, and the circuit also behaves as for a 1 uF capacitor.The only remaining question is why you don't 'measure' the capacitor as 1 uF, but apparently as 100 uF. I can't answer that, as you don't say how you 'measure' the capacitance, but however you are doing it, there is a x100 error either due to the instrument, your interpretation of what the instrument reads, or some other measurment error on your part.Don't know what else there is to be said. Hope I understood what you were doing and asking.Edit. Reading your post again, it's not clearwhatvoltages you measure at V3 and V4. Never mind about phase for now. Can you tell us the magnitude of your measured V3 and V4? I would also get out your humble DVM, set on ACV, and measure V3, V4, and also directly measure the voltages across the 100 ohm resistor and 1uF capacitor, which of course should be the same as V3 and V4. Tell us the results of these measurements, and then explain exactly what puzzles you.

author: kvresto
author_rank: Regular Contributor
timestamp: May 20, 2016, 06:37:27 am
content: Quotezeranin, going over my work, V3 is incorrect. Can you show me your calculations on how you got the resistor vector? (Vresistor = 0.59296 at 53.632 degrees)thanks, I think you have understood my question very well.EDIT: No worries, I'll make those measurements as soon as I get back to my bench this evening, I'll post my results.

author: Zeranin
author_rank: Regular Contributor
timestamp: May 20, 2016, 08:06:14 am
content: Quote from: kvresto on May 20, 2016, 06:37:27 amI hurriedly scratched out the answer on the back of an envelope. There are many ways to skin a cat, but here’s how I did it.Xc=1/(wC)=135.79 ohmsZ = SQRT(R^2 + Xc^2) = 168.64 ohmsFor simplicity, set generator to 1.0 voltsI = V/Z = 1.0/Z = 5.93mAVresistor = IR = 0.59296 volts (at angle theta wrt the generator)Vcapacitor = IXc = 0.80523 volts (at angle beta wrt the generator)Then draw your right-angled voltage vector triangle, with a hypotenuse of 1.0, lying along the Real x-axis.Let theta be the angle between this horizontal hypotenuse, and VresistorCos(theta) = 0.5926/1.0, theta=53.632 degreesFrom the triangle, beta=90-theta = 36.367 degrees(or if you prefer, from Cos(beta)=0.80523/1.0)No complex arithmetic required.Cheers.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 20, 2016, 08:25:48 am
content: Quote from: kvresto on May 20, 2016, 01:28:11 amLook for a LaTeX translation/export function, and put it in math mode in your post. Quote this to see what I mean...\$ Z = \sqrt{R^2 + X^2} \$Tim

author: kvresto
author_rank: Regular Contributor
timestamp: May 20, 2016, 09:47:05 am
content: zeranin,Vsig=3VppV3=1.6Vpp, 0.57VrmsV4=2.44Vpp, 0.872VrmsVR=0.568VrmsVC=0.872Vrms.Using the complex arithmetic method, it appears only phase angle is correct, ie phi = 84.5 degrees, and phi = atan(Xs/Rs).The calculated value for the cap (1uF) is not correct, ie C = 81.60uF, and C = 1 / (2*pi*f*Xs), f=1172Hz.The ratio of Rs and Xs must be correct, because these phase calculations are confirmed by my DSO.I want to keep working on this to get to the heart of my issue but I'm not sure how to proceed.below are my calcs as per my matlab script:Rs = ((Vp*Ip) + (Vq*Iq)) / ((Ip*Ip) + (Iq*Iq))Xs = ((Vq*Ip) - (Vp*Iq)) / ((Ip*Ip) + (Iq*Iq))Q = abs(abs(Xs)/Rs)Z = sqrt((Rs*Rs) + (Xs*Xs))phi = atan(Xs/Rs)C = 1 / (2*pi*f*Xs)Quotezeranin, also sin(53.6) doesn't equal 0.5926, did I miss something. I admit I'm not picturing your description, can you draw it out, yep I always do better with pictures,,,, and really, really big lettersThanks Tim

author: Zeranin
author_rank: Regular Contributor
timestamp: May 20, 2016, 10:16:05 am
content: Quote from: kvresto on May 20, 2016, 09:47:05 amOoops, sorry! I carelessly wrote SIN instead of COS, and have edited my previous posting accordingly. Well spotted. My result is correct though, the error being typographical only.I'll take a look at the rest of your posting. Keep in mind that I solved the problem for Vsig=1.0, so you will need to scale all of my voltages by whatever your actual signal generator voltage is. It makes no difference whether we talk RMS, P-P or whatever, just as long as we are consistent throughout.I presume that you followed my working up to :-Then draw your right-angled voltage vector triangle ....,is that correct?

author: Zeranin
author_rank: Regular Contributor
timestamp: May 20, 2016, 10:37:14 am
content: It just occurred to me that we may be at cross purposes. What I did, was to calculate Vresistor and Vcapacitor, given that Vgenerator=1.0, f=1172Hz, R=100 ohms, and C=1.0 uF.However, maybe what you want is the 'opposite'. You have experimentally measured Vresistor and Vcapacitor, and from this want to calculate C. Is that right? In that case, you don't need to measure phase angles at all just to determine C, though you can do so if you wish.Tell me exactly what you want me to calculate.

author: Zeranin
author_rank: Regular Contributor
timestamp: May 20, 2016, 11:31:37 am
content: Quote from: Zeranin on May 20, 2016, 10:37:14 amIf all you want to do is determine C from your experimentally measured Vresistor and Vcapacitor, then that's almost trivially easy. From measurement :-Vresistor=Vr=1.60Vcapacitor=Vc=2.44f = 1172 HzI = Vr/R = Vc/XcXc = R (Vc /Vr) = 100 x 2.44 / 1.60 = 152.5 ohmsC = 1/(2pi f Xc)C = 0.89 uFWhat's more, the value is not out by x100!Let me make a general observation that might be helpful. Your data is not self-consistent.As far a I can see, any calculation has to assume that your capacitor really does behave like a capacitor, with voltage and current shifted by 90 degrees. Likewise, we need to assume that your op-amps are not introducing additional phase shift. That being so, your data must 'add up' according to :-Vsig^2 = Vr^2 + Vc^23^2 = 1.6^2 + 2.44^29 = 2.56 + 5.959 = 8.51Unfortunately, as just demonstrated, your data does not 'add up' meaning it is not self consistent, meaning at least one of the measurements is wrong, or that there are additional phase shift(s) that we can't model, because we don't know if or where they occur. My calculation above for determining 'C' assumes that Vsig is wrong, and the measurements of Vr and Vc are correct, or at least in correct proportion. It seems to me that is the best you can do, and any calculation that purports to use all the data is fundamentally flawed right from the outset, given that the data is not self consistent.

author: Zeranin
author_rank: Regular Contributor
timestamp: May 20, 2016, 12:21:24 pm
content: Finally, you can also calculate 'C' from your phase shift measurements.Let A be the phase angle between Vsig and VrLet B be the phase angle between Vsig and VcA=55 DegreesB=33 DegreesFrom the right-angle triangle phasor diagram that I referred to previously :-COS(A)=Vr=IRCOS(B)=Vc=IXcI Xc / Ir = Cos(B)/COS(A)Xc=RCOS(B)/COS(A)Xc=100 x 0.8387 / 0.6157Xc = 136 OhmsC = 1/(2pi x f x Xc)C = 1/(2pi x 1172 x 136)C = 0.998 uFNot a bad match at all to 1uF

author: kvresto
author_rank: Regular Contributor
timestamp: May 20, 2016, 12:52:57 pm
content: ok, let me re- read and digest, I''ll re post.EDIT:Quoteyes,,, er I hope I did it correctly. But it was the only way I could get adj/hyp to work. Excuse my trig, its been too long.QuoteI see your point Zeranin, and the numbers makes it clear.QuoteInteresting, I can look into this later by playing with the numbers and looking at what this algorithm spits out. So far I have only put in what I've measured.The figures I posted are the correct values. My sig gen is also correct at 3Vpp, so then, additional phase shift, or other, I'll start to look into it.Quotepretty much nails it.Quoteyep, I want C, but I also want all the other values as well, ie phase, Z, Q, Xc, Rs, just experimenting at the moment, and I want to use this algorithm to do so.Zeranin I think your calculation using first principles also shows Vc, and Vr measurements are correct, given that my DVM measures the capacitor I'm using at 0.93uF.Quotegreat result, and something even a small micro can handle.

author: kvresto
author_rank: Regular Contributor
timestamp: May 20, 2016, 02:26:38 pm
content: So just to re-cap, it seems to me that I've now got my phase measurements correct via my hardware and algorithm, as this was a problem earlier, but I still cant get any meaningful results out of the algorithm for the other parameters ie C, Z, Q, Xc, Rs, although as stated, the ratio of Xc and Rs is ok.I would say good progress so far, very happy with that given this is a part time research project.

author: kvresto
author_rank: Regular Contributor
timestamp: May 21, 2016, 01:30:35 am
content: Zeranin, , just for the exercise I’m trying to scale my results to the generator voltage I’m using, and my calculation dont work out.From your post reply #4, and your calculations, if I scale up to my generator voltage of 3Vpp, or 1.5Vp, or what ever, other than 1.0V, the current will change and so will the final angle.Ie:I = V/Z = 1.5/Z = 8.9mA1/cos(0.89), theta=27.12 degrees, no correct.Anyway for completeness, below are LTSpice cursor delay calculations, along with the pics, just refer to the spice schematic above..phi = 360*f*delta_tV1_V2_phase = 360*f*86.2E-6 = 36.39V1_V3_phase = 360*f*126E-6 = 53.2V3_V4_phase = 360*f*212.3E-6 = 89.62Cheers

author: kvresto
author_rank: Regular Contributor
timestamp: May 21, 2016, 01:56:50 am
content: Also as,R=100RC=1uFf=1172From the transfer function of the series RC circuit(LPF), we know, the magnitude and argument of Vcap = [0.806< -36.37]then:Vcapacitor = (0.806)*cos(-36.37) + (0.806)*sin(-36.37)= 0.6489 - j0.4781and:1 +j0 = generator voltagethen Vresistor must be:(1 +j0) - (0.6489 - j0.4781) = 0.3511 + j0.4781sqrt( 0.3511 ^2 + j0.4781^2) = 0.6244atan(j0.4781/0.3511 ) = 53.7068 degreesSo then Vresistor is:0.6244 < 53.71 degrees, which is not too far off what you previously calculated as, ( Cos(theta) = 0.5926/1.0, theta=53.632 degrees )How does that look?EDIT: this is turning out to be a lesson in mathsmore EDITS:I forgot to multiply sin() and cos()with (0.806), I've made all the changes.

author: Zeranin
author_rank: Regular Contributor
timestamp: May 21, 2016, 07:35:11 am
content: Quote from: kvresto on May 21, 2016, 01:30:35 amNo correct, because you did not follow my example properly!Here is my example done properly for Vsig=1.5 voltsXc=1/(wC)=135.79 ohmsZ = SQRT(R^2 + Xc^2) = 168.64 ohmsSet generator to 1.5 voltsI = V/Z = 1.5/Z = 8.895mAVresistor = IR = 0.8895 volts (at angle theta wrt the generator)Vcapacitor = IXc = 1.2078 volts (at angle beta wrt the generator)Then draw your right-angled voltage vector triangle, with a hypotenuse of 1.5, lying along the Real x-axis.Let theta be the angle between this horizontal hypotenuse, and VresistorCos(theta) = 0.8895/1.5, theta=53.63 degreesFrom the triangle, beta=90-theta = 36.37 degrees(or if you prefer, from Cos(beta)=1.2078/1.5)So of course the angles are the same as before, and rot my socks, I do believe that my results match LTspice simulations.I'll go further, and say that if you use LT spice to report the voltages directly across R and C, you will get anexactmatch with my results, and any tiny difference will be due to LTspice, not the calculations.My advice is to look very carefully at and try to understand all my calculations, because they are correct, and the method is easier than the method you are trying to use. If need be, I'll attach a sketch of the voltage vector diagram that I used, but you should be able to figure that out.Then, try to duplicate these results using complex arithmetic.

author: kvresto
author_rank: Regular Contributor
timestamp: May 21, 2016, 09:48:54 am
content: Yeh, I see where I went wrong, always looks obvious when looking back, and sure your method is far less computational, but for the exercise, for me, its been fun exploring these.

author: Zeranin
author_rank: Regular Contributor
timestamp: May 21, 2016, 10:20:32 am
content: Looks like you are up and running, and now able to get the same correct results using a variety of methods, a good place to be.

author: kvresto
author_rank: Regular Contributor
timestamp: May 21, 2016, 11:35:33 am
content: Exactly, its all there. One more thing I need to investigate.1) the quickest way to do the phase measurements.a) what I have already put together.b) or something like, phi = arcos(U.I / |U||I|)

author: kvresto
author_rank: Regular Contributor
timestamp: May 21, 2016, 01:10:55 pm
content: Thanks Zeranin for your patience and generosity.