# Parametric simulation and double sweep

hello all there!, does any body know if is possible to plot 1.Ic vs Vce for differents Ib for a single stage BJT common emmiter amplifier ? 2. Regarding to Maximum Power Transfer Theorem, how to plot Power(Rload) for a simple resistive circuit .
Both using ngsSpice? but, any suggestion? thanks in advance.

Unfortunately the Eeschema interface to the embedded ngspice is still very limited. It does not allow plotting functions of node and branch variables. The independent x axis is time for .tran and sweep voltage for .dc simulation, y is node voltage or branch current. So power is not available, and if VCE is not the externally supplied sweep voltage, but is resulting from your circuit, it cannot be made the x axis.

It is however possible, to use Eeschama in conjunction with external stand-alone ngspice. See for example http://ngspice.sourceforge.net/ngspice-eeschema.html#external. This approach opens up all the capability of ngspice, and still will have Eeschema as the circuit source. It will however require a little more digging into the ngspice controls.

If you are interested in pursuing this route, you may publish your circuit here, together with your measurement needs, and we may together find a sloution.

Hi Holger, the plot I want to obtain from the circuit shown in :
maximum power transfer is the one of Pload with Rload in the 0-2.8 ohms range, any suggestion? Best regards.

Your link requires me to set up a google account. I will not do that. My suggestion is that you provide here a KiCad version of the circuit. This could be the basis of further discussions.

1 Like

Not only that, link doesnâ€™t even work at all.

Hi! I hope you can see now the circuit and the plot I am trying to simulate in Kicad, thanks!

Oh dear, does nobody do algebra any more? If you plug in the values into Pload = I**2 * Rload you get the equation:

`Pload = (400*Rload)/(4+4*Rload+Rload**2)`

which you can plot with a graphing program. No simulation required.

``````gnuplot> f(x) = (400*x)/(4+4*x+x**2)
gnuplot> plot [1.4:2.8] f(x)
``````

1 Like

I believe youâ€™re missing the point of the question, which is to learn how to do trivial examples in ngspice such that the process can be applied to more complex circuits. Heâ€™s not asking how to plot a curve, heâ€™s asking how to use a tool.

@holger, I attached at least a simple starting point. Iâ€™m curious to see your workaround, if possible. I remember you did something similar in this forum post. Would your workaround be that much different than this? Spice Resistor Sweep

resistor_power.zip (3.0 KB)

1 Like

thanks for your input kenyapcomau, but the point is, as Ste says, to analyze how ngspice can be used to solve the question posed.

Thanks a lot! Iâ€™ll consider your idea.

I tried to take a stab at it and this is what I came up with. I used @holger 's voltage controlled resistor subcircuit from the linked post. I used a MOSFET symbol for it because it has three terminals and I didnâ€™t want to make a custom symbol. The â€śvoltageâ€ť at the â€śgateâ€ť is swept through the resistance range you want. Then, a B-source off to the side calculates the wattage for your â€śresistorâ€ť and allows you to plot it as a voltage in the Simulator app.

resistor_power_v2.zip (10.0 KB)

Iâ€™ll try some things and see if I can do the transistor plots you requested too.

Hereâ€™s my attempt at the transistor curves. Using parameter sweep with external ngspice is going to be a lot more elegant, but this works fully within KiCad. I basically just copied the circuit 4 times, but kept the same sweeping voltage source across all 4 copies. Please note that ISOURCE symbol within KiCad is backwards, so you need negative current value for them (or flip them around).

common_emitter.zip (10.3 KB)