Problem with SUBCKT code

Discussion in 'General Electronics Chat' started by Manolis Grifoman, Mar 6, 2015.

  1. Manolis Grifoman

    Thread Starter New Member

    Mar 6, 2015
    Good evening to all. I have to design a rather complex circuit made by subcircuits which I have only their code. For example the code of the subcircuit I have to implement on PSpice can be seen at the end of this thread. The problem is that I don't know how to create a part through that code. I tried opening model editor and then:

    file -> new

    and after that:

    file -> Create Capture Parts

    and in the window that opens I choose for "Input Model Library" the text file that I renamed to .lib with the code of the subsircuit inside.

    The problem is that when I import the library that is created by this process, to a schematic and after I place the part of this new library I created, the simulation generates the error:
    ERROR(ORPSIM-15108): Subcircuit SET used by X_U1 is undefined

    Why is that? How Can I make it work? I would very much appreciate any help. Thank you in advance!

    The code of the subcircuit is:

    *single electron transistor
    *connections: source
    * | drain
    * | | gate1
    * | | | gate2
    * | | | |
    .SUBCKT SET 1 2 3 4 PARAMS:
    +C1=1E-18 ; Capacitance of junction 1
    +C2=1E-18 ; Capacitance of junction 2
    +R1=1E5 ; Resistance of junction 1
    +R2=1E5 ; Resistance of junction 2
    +Cg1=1E-18 ; Capacitance of gate 1
    +Cg2=0 ; Capacitance of gate 2
    +C0=0 ; Self Capacitance of the island
    +Q0=0 ; Offset charge in units of e
    +TEMP=4.2 ; Temperature

    .PARAM PI=3.1415926535897932 ; Pi constant
    .PARAM E=1.60217733E-19 ; Electronic charge
    .PARAM KB=1.380658E-23 ; Boltzmann's constant
    .PARAM CSUM={C1+C2+Cg1+Cg2+C0} ; The total capacitance of the SET
    .PARAM T={TEMP*CSUM*5.3785467E14} ; Normalized temperature, 5.3785467E14 = kB/e^2
    .PARAM RN1={R1/(R1+R2)} ; Normalized resistance of junction 1
    .PARAM RN2={R2/(R1+R2)} ; Normalized resistance of junction 2

    .FUNC Q(v1,v2,v3,v4) { (Cg1*v3+Cg2*v4+C1*v1+C2*v2)/E+Q0 } ; Definition of a charge term in units of e
    .FUNC VN(v) { CSUM*v/E } ; The normalized voltage
    .FUNC GAMMA(u) { IF(T==0,IF(u<0,-u,0),IF(u==0,T,u/(EXP(u/T)-1)))} ; The rate function
    .FUNC ROUND(x) { x-IF(cos(PI*x)>0,arcsin(sin(PI*x))/PI,-arcsin(sin(PI*x))/PI) } ; The round() function
    .FUNC N_OPT(v1,v2,v3,v4) { ROUND(-Q(v1,v2,v3,v4)+(CSUM/E)*(v1*RN2+v2*RN1)) } ; The most probable charge on the island in units of e

    *************************** the rates for the four tunnel events*****************************

    .FUNC R1L(n,v1,v2,v3,v4) {GAMMA(0.5 - n - Q(v1,v2,v3,v4) + VN(v1))/RN1}
    .FUNC R1R(n,v1,v2,v3,v4) {GAMMA(0.5 + n + Q(v1,v2,v3,v4) - VN(v1))/RN1}
    .FUNC R2L(n,v1,v2,v3,v4) {GAMMA(0.5 + n + Q(v1,v2,v3,v4) - VN(v2))/RN2}
    .FUNC R2R(n,v1,v2,v3,v4) {GAMMA(0.5 - n - Q(v1,v2,v3,v4) + VN(v2))/RN2}

    * determine the relative probabilities; charge state N_OPT is initially assumed to have a relative probability equal to one

    .FUNC PN_1(n,v1,v2,v3,v4) {(R1L(n,v1,v2,v3,v4)+R2R(n,v1,v2,v3,v4))/(R1R(n-1,v1,v2,v3,v4)+R2L(n-1,v1,v2,v3,v4))}
    .FUNC PN_2(n,v1,v2,v3,v4) { PN_1(n,v1,v2,v3,v4)*
    .FUNC PN_3(n,v1,v2,v3,v4) { PN_2(n,v1,v2,v3,v4)*
    .FUNC PN_4(n,v1,v2,v3,v4) { PN_3(n,v1,v2,v3,v4)*
    .FUNC PN_5(n,v1,v2,v3,v4) { PN_4(n,v1,v2,v3,v4)*
    .FUNC PN1(n,v1,v2,v3,v4) {(R2L(n,v1,v2,v3,v4)+R1R(n,v1,v2,v3,v4))/(R2R(n+1,v1,v2,v3,v4)+R1L(n+1,v1,v2,v3,v4))}
    .FUNC PN2(n,v1,v2,v3,v4) { PN1(n,v1,v2,v3,v4)*
    .FUNC PN3(n,v1,v2,v3,v4) { PN2(n,v1,v2,v3,v4)*
    .FUNC PN4(n,v1,v2,v3,v4) { PN3(n,v1,v2,v3,v4)*
    .FUNC PN5(n,v1,v2,v3,v4) { PN4(n,v1,v2,v3,v4)*

    .FUNC PSUM(n,v1,v2,v3,v4) { PN_5(n,v1,v2,v3,v4)+PN_4(n,v1,v2,v3,v4)+PN_3(n,v1,v2,v3,v4)+PN_2(n,v1,v2,v3,v4)
    ++PN4(n,v1,v2,v3,v4)+PN5(n,v1,v2,v3,v4) }

    **************** calculate the current from source to drain ****************

    .FUNC CUR(n,v1,v2,v3,v4) { PN_5(n,v1,v2,v3,v4)*(R1R(n-5,v1,v2,v3,v4)-R1L(n-5,v1,v2,v3,v4))
    ++PN5(n,v1,v2,v3,v4)*(R1R(n+5,v1,v2,v3,v4)-R1L(n+5,v1,v2,v3,v4)) }

    .FUNC CURRENT(n,v1,v2,v3,v4) { E*CUR(n,v1,v2,v3,v4)/(CSUM*PSUM(n,v1,v2,v3,v4)*(R1+R2)) }

    ********************** calculate the island voltage ************************

    .FUNC VOLT(n,v1,v2,v3,v4) { PN_5(n,v1,v2,v3,v4)*(n-5+Q(v1,v2,v3,v4))
    ++PN5(n,v1,v2,v3,v4)*(n+5+Q(v1,v2,v3,v4)) }

    .FUNC VOLTAGE(n,v1,v2,v3,v4) { (E/CSUM)*VOLT(n,v1,v2,v3,v4)/PSUM(n,v1,v2,v3,v4) }

    E1 5 0 VALUE={VOLTAGE(N_OPT(V(1),V(2),V(3),V(4)),V(1),V(2),V(3),V(4))} ; Voltage of the island
    G1 1 2 VALUE={CURRENT(N_OPT(V(1),V(2),V(3),V(4)),V(1),V(2),V(3),V(4))} ; Current from source to drain
    CT1 1 5 {C1}
    CT2 2 5 {C2}
    CGATE1 3 5 {CG1}
    CGATE2 4 5 {CG2}
  2. mvaseem


    Jan 31, 2014
    You need to add this model library (.lib) file into simulation settings.
    On your capture schematic, Go to Pspice -> Edit Simulation profile -> Configuration Files (Tab) -> Library (Category) -> Browse for the file -> Click "Add to Design".
    This would add the model file to your simulation profile. Pspice would pick this library while simulating.
  3. Manolis Grifoman

    Thread Starter New Member

    Mar 6, 2015
    Indeed it worked! Thank you very much!