The example below explains and demonstrates the bug.
A working example in ngspice 25_release can be seen here:
http://www.ngspice.com/index.php?public_circuit=0RYEpA
This bug also affects more recent versions as used here:
http://easyeda.com/file_view_limit-test_0qke8qI0U.htm
(sorry but I don't know the exact ngspice version number used in EasyEDA)
The expected behaviour is that the choice of argument names in a .func definition should be completely unaffected by the signal or net names used within any instance of the function so defined.
This problem does not arise in LTspice (nor, I think, in PSpice).
.tran 1u 1m 0
.func LIMIT(x,y,z) {min(max(x, y), z)}
V1 x GND SINE(0 2 1k)
B1 out GND V=LIMIT(V(x),-1,1) ; this instance works OK
V2 y GND SINE(0 2 1k)
B2 out GND V=LIMIT(V(y),0,1) ; this instance gives 0 output.
V3 y GND SINE(0 2 1k)
B3 out GND V=LIMIT(V(y),-1,1) ; this instance throws an error: no such function 'v'
V4 z GND SINE(0 2 1k)
B4 out GND V=LIMIT(V(z),-1,1) ; this instance fails transient solution
.END
I have a fix, needs some testing before upload.
Thanks for the report.
Holger
Holger,
Many thanks. That is an amazing turnaround on a bug report. Especially at
this time of year!!
A very happy new Year to all of the ngspice developers.
:)
Cheers,
signality.co.uk
On 28 December 2013 11:03, Holger Vogt h_vogt@users.sf.net wrote:
Related
Bugs:
#268I have uploaded my fix.
Please check!
My test file was:
bug 268
.tran 1u 1m 0
.func LIMIT(x,y,z) {min(max(x, y), z)}
.func LIMIT2(x,y,v1) {min(max(x, y), v1)}
.func LIMIT3(x,y,zz) {min(max(x, y), zz)}
.func testfcnv(y) {y}
V1 x GND SINE(0 2 1k)
R1 x V1 1
Vdc0 V1 GND dc 0
B1 out1 GND V=LIMIT(V(x),-1,1) ; this instance works OK
V2 y GND SINE(0 2 1k)
B2 out2 GND V=LIMIT(V(y),0,1) ; this instance works OK
B5 out5 GND V=LIMIT(testfcnv(V(y)),0,1) ; this instance works OK
B3 out3 GND V=LIMIT(V(y),-1,1) ; this instance works OK
V4 z GND SINE(0 2 1k)
B4 out4 GND V=LIMIT(V(z),-1,1) ; this instance works OK
B6 out6 GND V=LIMIT(V(0, z),-1,1) ; this instance works OK
B7 out7 GND V=LIMIT2(I(V1),-1,I(V1)) ; this instance works OK
B8 out8 GND V=LIMIT(V(y, 0),-1,1) ; this instance works OK
V3 zz GND SINE(0.1 2 1k)
B9 out9 GND V=LIMIT3(V(y, zz),-1,1) ; this instance works OK
.END
Holger
It will be two or three days before I can test your fix but I will let you
know as soon as I have.
We are using ngspice in an exciting new EDA tool suite:
http://easyeda.combut it is undergoing a major update in the next few
days, part of which
will be to recomplie ngspice from your latest sources so it will be just
after that when I can try the fix out.
Cheers,
signality.co.uk
On 28 December 2013 17:00, Holger Vogt h_vogt@users.sf.net wrote:
Related
Bugs:
#268I will run your example to check. I just need to wait for the developers at
EasyEDA to update to the latest git version of ngspice.
:)
Cheers,
signality.co.uk
On 30 December 2013 13:29, Holger Vogt h_vogt@users.sf.net wrote:
Hi Holger,
Deep joy!
I have just verified your fix here:
http://easyeda.com/file_view_limit-test-2_IibtnFXfx.htm
Many thanks again and a very happy new year to you.
Cheers,
signality.co.uk
On 30 December 2013 17:49, Andy Fierman signality@users.sf.net wrote: