https://open-source-silicon.dev logo
#analog-design
Title
# analog-design
e

Eslam Morsie

07/10/2021, 10:24 PM
Hello all, I tried to make an ideal opamp in xschem using VCVS with high gain but there was a problem its output is infinite as it has no rails. Is there a way to make a limiter in xschem or is there an Ideal opamp ready to be used?
c

Christoph Maier

07/11/2021, 12:46 AM
Sounds like a case for B source magic. See chapter 5.5.1 in the ngspice manual.
👍 1
v

Vern

07/11/2021, 2:47 AM
That's a classic macro modelling issue. The classic way to model supply clipping is by using a subcircuit with some diodes to the rails inside. I think The Spice Book by Andrei Vladimirescu had an example of that.
👍 2
s

Stefan Schippers

07/13/2021, 5:03 PM
@Eslam Morsie A good candidate for this is the tanh function applied to a 'B' voltage source, see picture. The advantage is the transfer function is continous with continus derivative. so it will not cause convergence issues. In the example, VCC is a .param set to 3
👍 2
🙌 1
e

Eslam Morsie

07/14/2021, 10:59 AM
Thanks sir @Stefan Schippers but I have a question: what is "100" in the bsource is that the opamp gain? and the output swept vs what?
@Stefan Schippers Could you please provide the spice netlist used to test the circuit "stimuli"?
s

Stefan Schippers

07/14/2021, 8:55 PM
@Eslam Morsie yes, 100 is a parameter controlling the gain. The actual gain around the middle point is
VCC/2 * 100
(the derivative of
tanh(x)
is
1-[tanh(x)]^2
, so the derivative of tanh(0) is 1). you can replace '100' with a GAIN parameter and set .param GAIN={100/VCC*2} Simulation sweeps the PLUS voltage around 1.5V and keeping MINUS to 1.5V Here the netlist for the example:
Copy code
**.subckt test_bsource PLUS MINUS OUT
*.ipin PLUS
*.ipin MINUS
*.opin OUT
B2 OUT 0 V = 'VCC/2*(1+tanh(GAIN*(V(PLUS_I)-V(MINUS_I))))' 
V1 PLUS PLUS_I 0
V2 MINUS MINUS_I 0
.param VCC=3
** set gain to 100. Divide by VCC/2 to cancel out the VCC/2 multiplier in Bsource expression
.param GAIN={100/VCC*2}

vminus minus 0 {VCC/2}
vplus plus 0 {VCC/2}
.control
save all
dc vplus 0 3 0.001
write test_bsource.raw
.endc

.end
e

Eslam Morsie

07/15/2021, 8:43 AM
@Stefan Schippers Many thanks for the explanation
t

Tom

08/07/2021, 4:36 PM
@Eslam Morsie I didn't see this post until now but I already have exactly what you're looking for in my analoglib https://gitlab.com/edalibs/analoglib/-/blob/master/spice/util.sp there are two versions of the opamp, one ideal infinite BW one
opamp
, and one dominant pole compensated model
opamp2
2 Views