Alter parameter in simulation to measure CMRR

Hi all.

I want to measure the CMRR in a amplifier. In order to automatize the measurement, I would like to use two AC analysis and alter statemets to change the AC values in the sources, and then collect the measurements to calculate Adiff/Acm.

How can I do it?

Thanks

Here is a tutorial on CMRR measurements https://www.analog.com/media/en/training-seminars/tutorials/MT-042.pdf.

You should give more information. What is your circuit? What is your manual procedure to achieve the measurements?

1 Like

Hi Holger!

Thanks for the document.
Actually my ā€œamplifierā€ is a multi-stage opamp amplifier with one or more internal feedback. So I have decided to follow the most generic way to measure CMRR. Iā€™m using the setup in the Figure, first I measure differential gain adding +0.5/-0.5 AC Voltage in the voltage sources VINP and VINM. Then I zeroed those voltage sources and add 1 AC Voltage in VCM voltage source. The last setup gives me the CM gain. Finally, my CMRR will be Adiff/Acm. Iā€™m thinking in use alter parameter to execute two secuencial AC analysis.

I guess that your procedure cannot be done with the ngspice embedded into Eeschema. The Eeschema/ngspice interface is too limited. The main point is that you can run only one simulation at a time. Altering something, running it in addition and watching and comparing the results is not possible.

You may create the ngspice netlist by Eeschema. If your circuit in Eeschema is ready for simulation, run the first ac simulation and create a netlist. Then do the changes (to your voltage sources ?), run again Eeschema and create a second netlist. And now you may compare what has to be changed from first to second netlist and find a way to do it automatically by adding a .control script. Depending on what you want to change, commands ā€˜alterā€™ or ā€˜alterparamā€™ may be chosen. In the script you also may do calculations using both results, or plotting. Finally you may add the script to Eeschema for running your sequence automatically by the Tools->Generate Netlist Fileā€¦->Spice->Run Simulator procedure.

You may start with the KiCad\share\kicad\demos\simulation\sallen_key\sallen_key.sch example on how to run an ac simulation, and then move on. An example how to use external ngspice is given here: http://ngspice.sourceforge.net/ngspice-eeschema.html#external. And of course you may publish your intermediate results here, if there are more questions.

2 Likes

What if you made two copies of the circuit, one for Diff and one for CM, and then divide each of the two unique OUT nodes? Two separate instances of the same opamp subckt in SPICE behave exactly the same. Or does this not work out for what you want to do?

Basically it is a good idea to run both circuits at the same time! However we have been talking about ac simulation so far. I am not aware of a means which allows to do a division (by a circuit), when running ac. In ac simulation the whole circuit is linearized, division is non-linear. I even do not know what will happen to a divide-by circuit made with a B-Source if it is linearized during the ac simulation. One also should check what happens if you run an ac simulation with multiple voltage sources having the ac flag, maybe by some well-known test circuits.

So your idea might be good if one adds a small script inside of Eeschema/ngspice that deals (divides etc.) with Vout and Vout1. But how to plot its results?

Oh, whups. In another thread he was asking about the .meas command so I thought he was just using that in some form. Yeah, I guess we have no idea what his intended way of viewing the data/result is. I shouldnā€™t have assumed that.

Hi .How can I obtain and understand the CMRR of 180nm CMOS and 14nm FinFet .i want to compare and know which has better

This is a forum about KiCad and its usage. Please look for an electronics forum to post your question.