How can I do my own sub ckt for SPICE. I want to design a potentiometer(for eg). Assuming it in the form of a block model - it will have 3 pins - 2 pins for the resistor and 1 pin for the centre tap that can vary the resistor value. If I warite a subckt, how do I proceed with it please ? Is there any suitable tutorial ? Also, for eg - I would like to design a subckt for a variable resistor.This is time based(at time t0 it has a specific value,t1 it has specific value and so on and so forth). I have a formula for it. How can I implement this formula sub-ckt ? I am look at the syntax for this please.
-
Related: http://electronics.stackexchange.com/questions/195102/spice-modelling-of-variable-resistance – the gods from engineering Oct 13 '15 at 14:52
-
Like with your other question, you need to clarify what version of spice you want this for. Chances are something exists already. – the gods from engineering Oct 13 '15 at 14:53
-
How is it related? In this I am asking for a tutorial on how to make a subckt. The link u posted is for a specific querry. – Board-Man Oct 13 '15 at 14:54
-
It surely is related (both your questions ask for a variable resistor). I didn't say it was exactly the same thing. For a tutorial on this approach (subckt) see http://powerelectronics.com/site-files/powerelectronics.com/files/archive/powerelectronics.com/mag/503PET07.pdf – the gods from engineering Oct 13 '15 at 14:56
-
http://www.seas.upenn.edu/~jan/spice/PSpice_ReferenceguideOrCAD.pdf and http://igdrassil.narod.ru/audio/spice/pspice_tutorial.pdf – Andy aka Oct 13 '15 at 15:16
1 Answers
Since you're apparently asking about PSpice (based on your other question):
.subckt VARIRES 1 2 CTRL
R1 1 2 1E10
G1 1 2 Value = {V(1,2)/(V(CTRL)+1µ)}
.ENDS
This is from http://powerelectronics.com/site-files/powerelectronics.com/files/archive/powerelectronics.com/mag/503PET07.pdf
The above a 1 ohm (variable) resistor. G1 is a (controlled) current source. The (current) value it returns is based on dividing the voltage between the nodes 1 and 2 (the ends of the pot) by the value of the controlling voltage applied at node CTRL (the pot cursor/wiper). R1 (which has a huge value) is simply there to measure the voltage from 1 to 2. To actually change the current (resistor value), you need go change G1.
That frankly struck me as not the most obvious approach. The more obvious way is using two resistors:
.subckt SCHEMATIC1_R1 1 2 t
RT_R1 1 t {(1K*(1-X))+.001}
RB_R1 t 2 {(1K*X)+.001}
.ends SCHEMATIC1_R2
From https://www.ece.vt.edu/tutorials/download/Sweeping_POT.pdf
This is a 1K variable resistor and uses the X parameter (between 0 and 1) to set the position of the pot.
- 14,475
- 2
- 45
- 98
-
But how did they get the G1 comment ? What is G1? It is a formula no? How can we model a formula in subckt ? – Board-Man Oct 13 '15 at 15:03
-
Also, if V(CTRL) is 1V (according to the fig), what would the resistor be ? We dont thave the V(1,2) and neither do we have I. – Board-Man Oct 13 '15 at 15:07
-
This is a 1 ohm (variable) resistor. G1 is a (controlled) current source. The (current) value it returns is based on dividing the voltage between the nodes 1 and 2 (the ends of the pot) by the value of the controlling voltage applied at node CTRL (the pot cursor/wiper). – the gods from engineering Oct 13 '15 at 15:12
-
And in case you wonder: R1 (which has a huge value) is simply there to measure the voltage from 1 to 2. To actually change the current (resistor value), you need go change G1. – the gods from engineering Oct 13 '15 at 15:24
-
-
Gotcha !!! Voltage controlled current source !!!!!!!!!!!!!!!!!!!!!!!!!! – Board-Man Oct 13 '15 at 15:27
-
But,
Linear Voltage-Controlled Current Sources
General form: GXXXXXXX N+ N- NC+ NC- VALUE Examples:
G1 2 0 5 0 0.1MMHO N+ and N- are the positive and negative nodes, respectively. Current flow is from the positive node, through the source, to the negative node. NC+ and NC- are the positive and negative controlling nodes, respectively. VALUE is the transconductance (in mhos).
The above is the syntax of the VCCS in SPICE. The units is mhos. But this formula (V(1,2)/(V(CTRL)....) is a unitless value !!!
– Board-Man Oct 13 '15 at 15:32