The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 24th, 2024, 2:31am
Pages: 1
Send Topic Print
VerilogA Non Ideal OpAmp Model Voltage Limiting (Read 9573 times)
aintk
New Member
*
Offline



Posts: 2

VerilogA Non Ideal OpAmp Model Voltage Limiting
Jun 25th, 2013, 5:16pm
 
I am trying to build up a basic non-ideal opamp model in Verilog A and am having trouble understanding why my implementation of the voltage limiting doesn't function as I would expect it to(credit given to a model I saw somewhere that use an identical idea).

Specifically, when I run a DC sweep from -20 to 20(where vss=-15 and vdd=15), I observe ideal behavior. Any explanations/help would be very appreciated.

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

module ideal_opamp_va (vp, vn, vdd, vss, vout);
input vdd, vss, vn, vp;
output vout;
electrical vdd, vss, vn, vp, vout;

parameter real rin = 1M from (0:inf), //Input Resistance
	       g = 50000 from (0:inf),     //Large Signal Voltage Gain
	       threedb=1M from (0:inf),    //3dB Frequency
	       imax = 10m from (0:inf),     //Maximum Ouput Current
	       ro = 50 from (0:inf);       //Output Resistance
	  
real vo_freq, io, vo, vomax, vomin; 

analog begin
//definitions
vo = V(vout);
vomax = V(vdd);
vomin = V(vss);

//input current
I(vp,vn) <+ V(vp,vn)/rin + white_noise(4 * `P_K * $temperature/rin, "thermal") + flicker_noise(4 * `P_K * $temperature/rin, 1, "pink");

//frequency response
vo_freq = laplace_nd(V(vp,vn)*g, {1}, {1, 1/(`M_TWO_PI*threedb)});


//output current
io = (vo_freq-V(vout))/ro;

// limit output voltage
if (V(vout) >= 0)
      io = io*tanh((vomax-V(vout)));
else
      io = io*tanh(abs(vomin-V(vout)));


//output current limit
if (I(vout) > imax)
	io = imax;

if (I(vout) < -imax)
	io = -imax;



I(vout) <+ slew(io,threedb*imax);

end
endmodule 

Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: VerilogA Non Ideal OpAmp Model Voltage Limiting
Reply #1 - Jun 26th, 2013, 1:16am
 
aintk wrote on Jun 25th, 2013, 5:16pm:
... my implementation of the voltage limiting doesn't function as I would expect it to...
Specifically, when I run a DC sweep from -20 to 20(where vss=-15 and vdd=15), I observe ideal behavior.
So, what does it (not) do?

The code works by limiting the output current near vout_max/min.

- B O E
Back to top
 
 
View Profile   IP Logged
aintk
New Member
*
Offline



Posts: 2

Re: VerilogA Non Ideal OpAmp Model Voltage Limiting
Reply #2 - Jun 26th, 2013, 2:24pm
 
I first ran a simulation that did a dc sweep between -20 and 20V while the amplifier was in unity gain feedback. The output still saw a normal -20 to 20V ramp without the clipping I would expect.

I figured there might be an issue with starting in an invalid range so i also did a test for 0 to 20V where I saw the same behavior(no clipping at 15V just a ramp).

Thanks for the help.
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: VerilogA Non Ideal OpAmp Model Voltage Limiting
Reply #3 - Jun 27th, 2013, 3:23am
 
aintk,
oh, ideal = not clipping.

- B O E
Back to top
 
 
View Profile   IP Logged
weber8722
Community Member
***
Offline



Posts: 95

Re: VerilogA Non Ideal OpAmp Model Voltage Limiting
Reply #4 - Mar 1st, 2015, 11:04am
 
Hi,

best test the model 1st without feedback, this makes life much easier!
Instead of the horrible 2 if-statements better use the min and max functions (or make little macros).

ylimited=max(ymin,min(y,ymax)); // Smiley

Bye Stephan
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.