The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Design Languages >> Verilog-AMS >> variable resistor(current across resistor constant, voltage varying) https://designers-guide.org/forum/YaBB.pl?num=1551177912 Message started by Paritosh Sahu on Feb 26th, 2019, 2:45am |
Title: variable resistor(current across resistor constant, voltage varying) Post by Paritosh Sahu on Feb 26th, 2019, 2:45am Hello everyone, I am trying to model a variable resistor where the current across the resistor stays the same and acts as the input, and the voltage drop is dependent on the resistance change. So, will V(t,b)<+I(t,b)*transition(rout,1n,1n); work in this case? The rout transitions between two values at different times which is defined by the timer function. I am getting convergence errors in SPICE when I do it this way. Is it because the resistance value is becoming negative in some case? or some other reason? I have to put this device as feedback in an inverting amplifier op-amp configuration. When I had modeled the device as a voltage-dependent resistor as, I(t,b)<+ V(t,b)/transition(rout,1n,1n), it was working fine. Thanks for the help. -Paritosh |
Title: Re: variable resistor(current across resistor constant, voltage varying) Post by Geoffrey_Coram on Feb 27th, 2019, 5:37am I'm not a big fan of the transition() function; it makes sense when you're modeling logic gates and want the output to "transition" from high to low. But for a resistor or anything "analog", I stay away from it. Is rout set to fixed values at different times by the timer? Or does the timer trigger an evaluation that then depends on voltages or currents? Is the resistance value becoming negative, do you know this is actually happening? In that case, yes, this is very likely to be the cause of convergence problems. Does a negative resistance make any sense in your circuit? |
Title: Re: variable resistor(current across resistor constant, voltage varying) Post by Ken Kundert on Feb 27th, 2019, 1:59pm I know of no reason why Code:
should cause convergence errors, and I do not share Geoffrey's dislike of the transition function in the case. Presumably you are trying to model some combination of switches and resistors. Including the transition function prevents a discontinuous jump in the resistance, which could cause convergence issues. The resistance will not go negative as long as rout is always non-negative. I see a lot of people use short delays and short transition times without thinking. You should be aware that they slow the simulation. You should avoid using the delay at all unless it is important, and the transition time should be as large as you are comfortable with. So something like: Code:
would be better. It is hard to help you with so little information. You would be better served by giving the whole model, and perhaps even enough information so that we could duplicate your situation. For example, one thing that could be causing problems if rout were varying continuously or if it was a function of I or V. -Ken |
Title: Re: variable resistor(current across resistor constant, voltage varying) Post by Paritosh Sahu on Feb 28th, 2019, 4:59am Thank you, Geoffrey and Ken, for the feedback. I apologize for the insufficient information. I will write my detailed model code here. So, the basic conditions of my device are: 1. The device is current dependent, means the input is current. 2. The current across the device remains the same, but the resistance of the device transitions between two specific values. So, basically, the voltage drop across the device follows the resistance change. 3. The values of the resistance are a function of the input current. 4. The transition between the resistance values happens at random time instances within the simulation time. How many of these transitions occur within a particular time interval is again a function of the input current. As I intend to use this device in the feedback loop of an inverting op-amp configuration, I thought to model it as a variable resistor. Any other suggestions are welcome. The code is as follows: Code:
I would really appreciate some feedback on the code. Kindly please let me know if I am doing any mistake anywhere. And what exactly is causing the convergence error here? As far as I have checked in the values, there are no negative values of rout. The value of rout is dependent on I, but it stays constant throughout the simulation. Thanks a lot. -Paritosh Sahu |
Title: Re: variable resistor(current across resistor constant, voltage varying) Post by Ken Kundert on Feb 28th, 2019, 7:12am Wow. You kind of buried the lead with your original question. Your model seems very complicated, and there is a lot of it where I cannot tell whether it makes sense or not. But I can see two obvious issues: You should not use 0 for transition times on transition function in this statement: Code:
This statement is problematic given the rest of your model: Code:
When f is greater than spike(cur) then rout varies continuously in time, making it unsuitable as an argument to the transition function. The argument of the transition function must be piecewise constant. Using a continuously varying expression as an argument to a transtion function results in erratic behavior as the transition function wants to generate a continuous stream of transitions, so it keeps interrupting itself. Also, making rout a function of cur makes the resistor nonlinear, which is likely the ultimate cause of your convergence issues. Finally, I am always a bit suspicious of the use of the abs() function in device models. They have a tendency of creating non-physical kinks in the IV characteristics. -Ken |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |