LTspice - .meas ac - extracting phase - Page 1
Forum section: electronics / projects

author: tree
author_rank: Regular Contributor
timestamp: June 03, 2014, 07:39:48 pm
content: Hello folks,I'm trying to perform some stability analysis in LTspice of an op amp.I am trying to meas the exact phase margin using a .meas statement.meas ac res4 FIND ph(V(out)/V(in,out)) when mag(V(out)/V(in,out))=1This tells LTspice to create a variable called 'res4' whose result is the phase of the open loop gain when the magnitude of the open loop gain is 0dB.The result is the following:res4: ph(v(out)/v(in,out))=(44.9831dB,180°) at 22938.9This says that at 22.9389kHz the phase has an angle of -177.48 deg but it doesn't display the angle, instead it is shown as as magnitude and phase which is a ridiculous way to express an angle.44.9831dB = 177.48 and the 180 phase shift gives it a negative sign.Is there any way to properly display the angle?Thanks.

author: LvW
author_rank: Frequent Contributor
timestamp: June 03, 2014, 07:55:28 pm
content: I cannot imagine that LTSpice gives the phase in log units.Anyway - why don´t you use the clear and logical way to display both magnitude and phase of the loop gain?This gives you a clear picture about the loop gain response - and you can see if everything is OK. Remember: You should not blindly trust such simulation results and it is always good to know approximately what you can expect. This holds, in particular, for loop gain simulations which often are a bit tricky becaus opening the loop must not (a) disturb the dc opearatig point and (b) must not change the loading conditions at the opening.

author: tree
author_rank: Regular Contributor
timestamp: June 03, 2014, 07:56:58 pm
content: What is the clear and logical way?EDIT: got it! I got rid of the mag() function and it displays the magnitude and phase.AND I didn't disturb the DC operating point. The feedback loop is still there.For those who want to follow along I've attached a picture of the schematic

author: f5r5e5d
author_rank: Frequent Contributor
timestamp: June 04, 2014, 03:11:58 am
content: stability tests in sim or the real world can be complicated - and some differing conventions for phase too - you may have open loop phase shift, or return ratio, may want phase margin...the example/Educational folder in your LTspice install has several loopgain probe examples and the FRA filethe Yahoo LTspice group is a good place to look up discussions - if Yahoo hadn't ruined all groups with the stupid infinite scroll UIdo search the group - it isn't a spice beginners tutoring group or chat roomthe basics are - get the circuit working in .TRAN 1st - see if its stable for tmax step size << 1/GBW of the fastest part in the loopthen you don't have to worry about the .AC tool's conventions for phase - you already know its stable and can work from that assumptionyou need to understand the tool - the software can't give a priori formal answers in your particular textbook's or personal preference convention system

author: ejeffrey
author_rank: Super Contributor
timestamp: June 04, 2014, 04:21:42 am
content: You can also add the text statement ".opt meascplxfmt=cartesian" which will cause measurements to be returned in linear (a+bi) units, or '.opt meascplxfmt=polar' to get linear magnitude and phase. It affects all measurements, so only use it if that is what you want.

author: LvW
author_rank: Frequent Contributor
timestamp: June 04, 2014, 08:32:20 am
content: Quote from: tree on June 03, 2014, 07:56:58 pmThe most logical way to measure or to simulate a certain property of a device is to follow the DEFINITION.And the stability margin is defined based on the LOOP GAIN of a circuit with feedback.Hence, as I have mentioned before, you should simulate the LOOP GAIN.Do you know what "loop gain" means and how it is defined - in contrast to closed-loop gain and open-loop gain? (The wording is a bit misleading, I know).Quote from: tree on June 03, 2014, 07:56:58 pmI am afraid, you didn´t get it. I cannot see how you are simulating the loop gain.Question: What is the original circuit to be analyzed and how do you open the loop (youmustopen the loop for ac signals!)-

author: tree
author_rank: Regular Contributor
timestamp: June 04, 2014, 01:41:05 pm
content: If I remember correctly, A = open loop gain, Beta = feedback, A* beta = loop gain.What I'm doing is exactly what open loop gain is. The output divided by the difference between the input terminals.EDIT: There's an LTspice video from Linear's website that deals with op amp stability by analyzing OPEN loop gain, not loop gain.I followed this tutorial:http://www.simonbramble.co.uk/techarticles/advanced_op_amps/advanced_op_amps.htm

author: LvW
author_rank: Frequent Contributor
timestamp: June 04, 2014, 07:05:08 pm
content: Quote from: tree on June 04, 2014, 01:41:05 pmYes - everything correct.However, in your first post you spoke aboutstability analysis, didn´t you?And for this purpose, you need the loop gain - not the gain of the opamp without feedback (open-loop gain).The most simple method is to place an ac source (Vac=1V) BETWEEN opamp output and input of the feedback network.Then, the loop gain is the ratio between the two nodes of the ac source.For higher frequencies - beyond the region which determines stability - this method has some errors, however, it is sufficiently exact.

author: atferrari
author_rank: Frequent Contributor
timestamp: June 06, 2014, 12:48:40 pm
content: Quote from: tree on June 03, 2014, 07:39:48 pmHiMy first post in this forum.Maybe this could help you:http://www.linear.com/solutions/4449

author: tree
author_rank: Regular Contributor
timestamp: June 06, 2014, 01:55:05 pm
content: Quote from: atferrari on June 06, 2014, 12:48:40 pmHi, welcome.I watched that video at least 10 times and I think that applies only to an inverting configuration.

author: LvW
author_rank: Frequent Contributor
timestamp: June 06, 2014, 02:57:36 pm
content: Quote from: tree on June 06, 2014, 01:55:05 pmTree - as you have to analyze the loop gain it does not matter if the closed-loop circuit is operated in inverting or non-inverting configuration.In both cases the loop gain definition/simulation is identical.In my former contribution I have recommended to place the ac source at the output of the opamp.In the video it is placed at the input. The result will be the same. The only thing which matters is the following:The breaking must not drastically change the loading conditions under normal closed-loop operation . This can be sufficiently fulfilled at the output (small output resistance) as well as at the input (large input resistance)