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.
<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
Answers:
Can you please give the content of .cir.out file
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.
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?
How should the .cir.out file look like if I had selected the component from spice library?
Login to add comment
You can only simulate the component which are available under analog_spice, digital_spice ...etc.
Name end with _spice.
Name end with _spice.
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.
The error seems to be in using the ngspice special variable 'time' which it says is undefined.
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 ?
Are you just trying to simulate simple RC circuit ?
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.
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.
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.
Thanks. If you are able to create the component subcircuit and simulate it, then please consider contributing it to Oscad library.
It works in ngspice-26 (latest version of ngspice)
good! Please share with us how you got it working. Thanks.
I installed ngspice-26 on my system.
Did you use the component B or you just typed r = time*1e6, in ngspice 26 ?
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.
***************************************
<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.
Thanks for the info!
Login to add comment
<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>
Login to add comment