saving . . . saved Error in using 'RVAR' component has been deleted. Error in using 'RVAR' component has been hidden .
Error in using 'RVAR' component
Title
Question
I have drawn a simple capacitor discharge circuit with a variable resistor. I have used the component name 'RVAR' for the variable resistor. The resistance of the variable resistor depends on simiulation time. The contents of the .ckt file are given below.

<span style="font-style: italic;">* eeschema netlist version 1.1 (spice format) creation date: wednesday 07 may 2014 05:19:01 pm ist</span>

<span style="font-style: italic;">r1  2 0 r='time*1e6'</span>
<span style="font-style: italic;">c1  2 0 1u ic=10</span>

<span style="font-style: italic;">.tran  10e-06 10e-03 0e-00 uic</span>
<span style="font-style: italic;">.end</span>

When I try to simulate this circuit in ngspice, I get the following error.

<span style="font-style: italic;">3: Undefined number [TIME]</span>
<span style="font-style: italic;">3:   Expression err: time*1e6</span>
<span style="font-style: italic;">3: Cannot compute substitute</span>
<span style="font-style: italic;"> Copies=7 Evals=7 Placeholders=1 Symbols=0 Errors=3</span>
<span style="font-style: italic;">Numparam expansion errors: Run Spice anyway? y/n ? </span>

Am I using 'RVAR' correctly?

Thanks.


Oscad General None min None sec 07-05-14, 5:57 p.m. Ravindra Shende

Answers:

Can you please give the content of .cir.out file
07-05-14, 7:18 p.m. fahim
The contents of .cir.out file are:

<span style="font-style: italic;">* eeschema netlist version 1.1 (spice format) creation date: wednesday 07 may 2014 05:19:01 pm ist</span>

<span style="font-style: italic;">r1  2 0 r='time*1e6'</span>
<span style="font-style: italic;">c1  2 0 1u ic=10</span>

<span style="font-style: italic;">.tran  10e-06 10e-03 0e-00 uic</span>

<span style="font-style: italic;">* Control Statements </span>
<span style="font-style: italic;">.control</span>
<span style="font-style: italic;">run</span>
<span style="font-style: italic;">.endc</span>
<span style="font-style: italic;">.end</span>
07-05-14, 7:23 p.m. Ravindra Shende

Login to add comment


You have not selected the component from spice library. Hence it is not simulating. To know more about how to add library please look into oscad spoken tutorial.


07-05-14, 7:43 p.m. fahim
I have selected it from spice library named 'device'. The component name was 'RVAR'. Is there any documentation for the components in your libraries explaining what they are and what parameters they take etc.?

How should the .cir.out file look like if I had selected the component from spice library?
07-05-14, 8 p.m. Ravindra Shende

Login to add comment


You can only simulate the component which are available under analog_spice, digital_spice ...etc.
Name end with _spice.

07-05-14, 8:09 p.m. fahim
I tried using the resistor in the 'analogSpice' library giving it the value "R='TIME*1e6'". I still get the same error.

The error seems to be in using the ngspice special variable 'time' which it says is undefined.
07-05-14, 8:22 p.m. Ravindra Shende

Login to add comment


It is not the correct format to give value of resistance. The value should be like 100,1k,100k like that.

Are you just trying to simulate simple RC circuit ?   
07-05-14, 9:09 p.m. fahim


If I am not mistaken, you are trying to simulate a time dependent resistance. As far as I understand, you cannot directly specify the parameter time in the resistance value expression. You need to model your resistor as a behavioral voltage source, B and then specify the expression there.

Refer ngspice manual page 91-92 for an example of R = 1k/sqrt(HERTZ). http://ngspice.sourceforge.net/docs/ngspice-manual.pdf

But unfortunately we dont have the behavioral source B modelled in Oscad. It would take some time for us to do this. One option is you can create a component called B in the component library using the library editor option in schematic editor and give the desired expression in the value field (say time*1e6), all other components are there in Oscad. Let us know if this helps.
07-05-14, 11:11 p.m. rakhiwarriar
You got it right rakhiwarriar! I <span style="font-style: italic;">am</span> trying to simulate time dependent resistance. Its very unfortunate that its not possible is oscad. Thanks anyway for understanding my problem and for the suggestion.
08-05-14, 11:03 a.m. Ravindra Shende
Thanks. If you are able to create the component subcircuit and simulate it, then please consider contributing it to Oscad library.
08-05-14, 2:43 p.m. rakhiwarriar
It works in ngspice-26 (latest version of ngspice)
09-05-14, 12:42 p.m. Ravindra Shende
good! Please share with us how you got it working. Thanks.
09-05-14, 1:06 p.m. rakhiwarriar
I installed ngspice-26 on my system.
09-05-14, 3 p.m. Ravindra Shende
Did you use the component B or you just typed r = time*1e6, in ngspice 26 ?
09-05-14, 3:02 p.m. rakhiwarriar
Here is the netlist.

***************************************
<span style="font-style: italic;">simple RC circuit</span>

<span style="font-style: italic;">C1 1 0 1u ic=10</span>
<span style="font-style: italic;">R1 1 0 R = {TIME*1E6}</span>

<span style="font-style: italic;">.control</span>
<span style="font-style: italic;">tran 10u 1m uic</span>
<span style="font-style: italic;">plot V(1)</span>
<span style="font-style: italic;">.endc</span>

<span style="font-style: italic;">.end</span>
***************************************

Save this in a text file with '.net' extension (say RC.net). Run this file on a system (with ngspice-26 installed on it) as 'ngspice RC.net'.

I have tested it on my system and it works fine.
09-05-14, 3:36 p.m. Ravindra Shende
Thanks for the info!
09-05-14, 4:15 p.m. rakhiwarriar

Login to add comment


Log-in to answer to this question.