Hello all, I tried to make an ideal opamp in xsche...

# analog-designe

Eslam Morsie

07/10/2021, 10:24 PMHello 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 AMSounds like a case for B source magic. See chapter 5.5.1 in the ngspice manual.

π 1

v

Vern

07/11/2021, 2:47 AMThat'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π 2

π 1

e

Eslam Morsie

07/14/2021, 10:59 AMThanks 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?

Eslam Morsie

07/14/2021, 12:39 PMs

Stefan Schippers

07/14/2021, 8:55 PM`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 AMt

Tom

08/07/2021, 4:36 PM`opamp`

, and one dominant pole compensated model `opamp2`

2 Views