The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 4:30pm
Pages: 1
Send Topic Print
Very slow simulation in using current limiting voltage source (Read 5007 times)
wanyancan
New Member
*
Offline



Posts: 2

Very slow simulation in using current limiting voltage source
Jun 07th, 2011, 5:41pm
 
Hi all,

Following the example in Current limited voltage regulator (model, test) from http://www.designers-guide.org/VerilogAMS/, I designed another voltage follower with limited current 'imax' and 'imin' parameters. However, when simulating with a simple circuit, it becomes very slow. The steps seem to be incorrectly set. Would any one give me some advice? I suspect that 'cross' event detection is wrongly configured. How do I use 'expr_tol' parameter only while leave 'time_tol' as null (as default) ?

Code:
`include "constants.vams"
`include "disciplines.vams"

module CurrentLimiterVsource(in,out);
	input in;
	output out;
	electrical in;
	electrical out;
	real v, i, vin, sum1, sum2;
	parameter real imax = 1;
	parameter real imin = -1;

	analog begin
		vin = V(in);
		v = V(out);
		i = -I(<out>);
		sum1 = v-vin - (i-imax)*(out.potential.abstol/out.flow.abstol);
		sum2 = v-vin - (i-imin)*(out.potential.abstol/out.flow.abstol);
		@(cross(sum1,0,1p,out.potential.abstol))
			$strobe("imax reached at time:%r, sum1:%r, sum2:%r",$abstime,sum1,sum2);
		@(cross(sum2,0,1p,out.potential.abstol))
			$strobe("imin reached at time:%r, sum1:%r, sum2:%r",$abstime,sum1,sum2);

		if (sum1*sum2<0)
			V(out) <+ vin;
		else
			if (sum1<=0)
				I(out) <+ -imax;
			else
				I(out) <+ -imin;
	end
endmodule 



The test circuit is as below:
Code:
I41 (Vin Vout) CurrentLimiterVsource imax=2500u imin=-2m
V3 (Vin 0) vsource dc=0 type=sine delay=1u freq=5M ampl=1 mag=1
C1 (net1 0) capacitor c=1u
C0 (Vout net1) capacitor c=1p
R0 (Vout net1) resistor r=1K
simulatorOptions options reltol=1e-3 vabstol=1e-6 iabstol=1e-12 temp=27 \
    tnom=27 scalem=1.0 scale=1.0 gmin=1e-12 rforce=1 maxnotes=5 maxwarns=5 \
    digits=5 cols=80 pivrel=1e-3 sensfile="../psf/sens.output" \
    checklimitdest=psf
tran tran stop=2u errpreset=conservative write="spectre.ic" \
    writefinal="spectre.fc" annotate=status maxiters=5
finalTimeOP info what=oppoint where=rawfile
dcOp dc write="spectre.dc" maxiters=150 maxsteps=10000 annotate=status
capInfo_dc info what=captab where=rawfile threshold=0.0 detail=nodetonode \
    sort=name
dcOpInfo info what=oppoint where=rawfile
dc dc hysteresis=yes param=VH start=0 stop=3.3 oppoint=rawfile \
    maxiters=150 maxsteps=10000 annotate=status
ac ac start=10k stop=10M annotate=status 

Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: Very slow simulation in using current limiting voltage source
Reply #1 - Jun 8th, 2011, 12:14am
 
I see no obvious issue with your model, and when I ran it the speed seemed fine (I used Spectre version 7.1.1).

I have noticed that I normalizing with abstols can be problematic. Indeed you are adding voltage, which is scaled to near unity, to current times vabstol/iabstol, which is scaled to near 1000. That makes it difficult for the cross function. I found it better to scale by the estimated ratio of Vlimit to Ilimit.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
wanyancan
New Member
*
Offline



Posts: 2

Re: Very slow simulation in using current limiting voltage source
Reply #2 - Jun 9th, 2011, 6:11pm
 
Hi Ken,

I tried to print abstol values for both voltage and current, and the ratio is 10e6 (1uV and 1pA) which are indeed not suitable as scale factor. Besides this, I changed the if-clause to
Code:
if (sum1*sum2<0)
    V(outP,outN) <+ vin;
else
    if(sum1<0)
        I(outP,outN) <+ -imax;
    else if (sum2>0)
        I(outP,outN) <+ -imin; 


which leaves the case when sum1==0 or sum2==0 to be unchanged. It seems helping to eliminate the saw waveform as attached image and give a better simulation time.

There's another question on @cross's parameters "time_tol" and "expr_tol". How does it affect the solving resolution? Do they need to be satisfied if they are both  given explicitly ? What if none of them are given? What if only "time_tol" is given to be a tiny value such as "10a" (Does it restrict the solving steps to be always less than "10a" secs)?
Back to top
 

CurrentLimiter.png
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: Very slow simulation in using current limiting voltage source
Reply #3 - Jun 10th, 2011, 1:21am
 
Default behavior of the cross tolerances is not really defined by the standard. You have to ask your simulator vendor what they do when you leave them off.

Many years ago I used to feel very comfortable not specifying the tolerances on the cross function, but in my experience the simulator vendors are loosening the tolerances to a degree that it is becoming problematic, particularly on signals not scaled near unity, such as currents.

I am not sure what the waveforms you showed are for, but the second seems like it is experiencing severe trapezoidal rule ringing. You might want to try the transient option method=gear2only.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: Very slow simulation in using current limiting voltage source
Reply #4 - Jun 18th, 2011, 11:05pm
 
Hi Wanyancan,

Of course timeTol and exprTol should be satisfied if they were specified explicitly. But it does not restrict the analog solver steps always less than "10a" seconds in your case. It has effect on the step only if the event condition is met, i.e. the condition in the parentheses after cross is met.

I think that timeTol and exprTol in cross is used to reduce the error at the event occurs. Based on Ken's book, it is a time point that is just after the expression crosses the threshold.

Best Regards,
Yawei
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.