PSpice and MacSpice

Discussion in 'The Projects Forum' started by Tom O'Leary, Apr 16, 2014.

  1. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    I'm new to PSpice and I'm working on a project for school. My professor sent me a .CIR file that he created in MacSpice so I could get used to the programming style and try to run it on my computer. The problem is I have a PC so I'm using PSpice, not MacSpice. When I try to run his file I get a whole bunch of error notifications.

    Is there any way to run his MacSpice file in PSpice? Or is there a way to download MacSpice without downloading an Apple OS onto my laptop? I have very limited access to Macs so using PSPice would be very beneficial for me. Any advice would be appreciated.

    Thanks,
    Tom
     
  2. crutschow

    Expert

    Mar 14, 2008
    13,022
    3,235
    Doubt there's any way you can run MacSpice on your PC. But you should be able to look at the errors and determine what needs to be changed to run the circuit on Pspice.
     
    Last edited: Apr 18, 2014
  3. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    Yeah that's what I figured. I can see the errors, but since I don't know much about PSpice or programming in general I'm having a hard time figuring out how to fix the problems. Thanks though.
     
  4. crutschow

    Expert

    Mar 14, 2008
    13,022
    3,235
    So what do the errors say?
     
  5. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    Here is an excerpt from the output file after I ran the simulation:

    ERROR -- Missing model
    Xvent 30 par_sin par_Emax par_Ediastole par_vent_Tsys par_HR par_sigma par_sin2 par_harmonic2 Cventricle

    * outlet valve diode
    Dvent_out 30 1


    **** SUBCIRCUIT DEFINITION SECTION

    --------------$
    ERROR -- Missing model
    .SUBCKT Cventricle 4 par_sin par_Emax par_Ediastole par_Tsys par_HR par_sigma par_sin2 par_harmonic2

    * Bx: Non-linear dependent source
    * Calculate f(input voltage) - this voltage is equal to the non-linear compliance which is the reciprocal of elastance
    * - the positive part of a sine wave. u = unit step function
    Bx 1 0 V = v(4)/(v(par_Ediastole) + (v(par_Emax)-v(par_Ediastole))*(v(par_sin) -v(par_sin2)*v(par_harmonic2))*
    0.77*u(v(par_sin))*(1+v(par_sigma)*i(vx)))
    $
    ERROR -- Invalid device in subcircuit


    This is just a small section of the overall code, but you can see where the errors are. I think one of the errors is from the line being too long. I'm not sure about the "missing model" error though. Is it something missing from my library? I'm not sure why the .SUBCKT line caused an error either.

    I feel like maybe I'm not using a full version of PSpice and that's what is causing some of the errors. I downloaded version 16.6 from the Cadence website, but it says Lite version. Do you know of any place way to download a full version or is that the full version?
     
  6. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    My professor just informed me that he believes the location of the error is directly above the $ sign. This is the opposite of how I thought the errors were pointed out. So in light of that here is a smaller section of the code with the error notification:

    * heart
    * inlet valve diode
    Dvent_in 3 30

    * variable elastance heart model
    -------------$
    ERROR(ORPSIM-16407): Missing model
    Xvent 30 par_sin par_Emax par_Ediastole par_vent_Tsys par_HR par_sigma par_sin2 par_harmonic2 Cventricle

    * outlet valve diode
    Dvent_out 30 1


    **** SUBCIRCUIT DEFINITION SECTION

    --------------$
    ERROR(ORPSIM-16407): Missing model

    If my professor is correct then this is saying that the first errors in my code are with the inlet and outlet diodes labelled Dvent_in and Dvent_out. Any idea what those two errors might mean? Thanks in advance.
     
  7. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    Hey Crutschow,
    Just a heads up that I figured that part out. Thanks for all your help. I have cleaned up most of the errors in my program, but new ones came up when I ran it. Here is one of the lines that is causing problems:

    .SUBCKT Cvenous 4 par_N par_C0 par_a par_adif

    The line itself isn't causing problems, but here is the error that pops up:

    **** EXPANSION OF SUBCIRCUIT Xceph ****
    Xceph.Bx Xceph.1 0 Xceph.V Xceph.v 4 *v
    -------------------------------------$
    ERROR(ORPSIM-16147): Invalid parameter

    Is this saying that "4" is an invalid parameter or that "v" is an invalid parameter? I defined Xceph earlier in the program and the subcircuit seems to be fine so I'm not sure why this is coming up?
     
  8. mvaseem

    Member

    Jan 31, 2014
    48
    8
    Can you post the line where you are calling the subckt - Xceph.
    Also if you can post the subckt definition as well , it would be easy to figure out the cause of this error.
     
  9. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    I think that is what is confusing me. I don't actually have a subcircuit called Xceph. Here is the line where I create Xceph:

    Xceph 2 par_ven_N par_ven_Cceph0 par_ven_aceph par_ven_acephdif Cvenous
    Xchest 2 par_ven_N par_ven_Cchest0 par_ven_acent par_ven_acentdif Cvenous
    Xabs 2 par_ven_N par_ven_Cabs0 par_ven_acent par_ven_acentdif Cvenous
    Xthigh 2 par_ven_N par_ven_Cabs0 par_ven_acaud par_ven_acauddif Cvenous
    Xcalf 2 par_ven_N par_ven_Ccalf0 par_ven_acaud par_ven_acauddif Cvenous


    Each one of these lines causes an error that displays below the end of the program when I run it. All of the errors are the same as the Xceph error. I have 2 .SUBCKTs defined in the code, but neither calls for any of the X lines above. Is the problem that I need to define a .SUBCKT for each line? So I should add 5 .SUBCKTs to the code to make it work?
     
  10. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    Here is the code from the Xceph line all the way to where the error is defined.


    Xceph 2 par_ven_N par_ven_Cceph0 par_ven_aceph par_ven_acephdif Cvenous
    Xchest 2 par_ven_N par_ven_Cchest0 par_ven_acent par_ven_acentdif Cvenous
    Xabs 2 par_ven_N par_ven_Cabs0 par_ven_acent par_ven_acentdif Cvenous
    Xthigh 2 par_ven_N par_ven_Cabs0 par_ven_acaud par_ven_acauddif Cvenous
    Xcalf 2 par_ven_N par_ven_Ccalf0 par_ven_acaud par_ven_acauddif Cvenous
    Cperipheral 2 0 0.03

    * heart
    * inlet valve diode
    Dvent_in 3 30 Default
    .model Default D

    * variable elastance heart model
    Xvent 30 par_sin par_Emax par_Ediastole par_vent_Tsys par_HR par_sigma par_sin2 par_harmonic2 Cventricle

    * outlet valve diode
    Dvent_out 30 1 Default1
    .model Default1 D


    **** SUBCIRCUIT DEFINITION SECTION

    .SUBCKT Cventricle 4 par_sin par_Emax par_Ediastole par_Tsys par_HR par_sigma par_sin2 par_harmonic2

    * Bx: Non-linear dependent source
    * Calculate f(input voltage) - this voltage is equal to the non-linear compliance which is the reciprocal of elastance
    * - the positive part of a sine wave. u = unit step function
    Bx 1 0 V = v(4)/(v(par_Ediastole) + (v(par_Emax)-v(par_Ediastole))
    *(v(par_sin) -v(par_sin2)*v(par_harmonic2))* 0.77*u(v(par_sin))*(1+v(par_sigma)*i(vx)))

    * Cx linear capacitance
    Cx 2 0 1
    * Vx: Ammeter to measure current into the capacitor
    Vx 2 1 DC 0
    * Fx: Current controlled current source
    * drives the current through Cx back into the circuit - the same current as the nonlinear compliance would have
    Fx 0 4 Vx 1

    .ENDS Cventricle


    .SUBCKT Cvenous 4 par_N par_C0 par_a par_adif

    * Bx: Non-linear dependent source
    * Calculate f(input voltage)
    Bx 1 0 V = v(4)*v(par_C0) * ( v(par_N) + (1 - v(par_N) ) / cosh( (v(par_a) + v(par_adif) * u(v(4) - 4.000)) * (V(4) - 4.000)))

    * Cx linear capacitance
    Cx 2 0 1
    * Vx: Ammeter to measure current into the capacitor
    Vx 2 1 DC 0
    * Fx: Current controlled current source
    * drives the current through Cx back into the circuit
    Fx 4 0 Vx 1
    .ENDS Cvenous

    **** INITIAL CONDITIONS

    .ic v(1)=80 v(30)=5 v(2)=10

    **** COMMANDS SECTION

    ***Dropped .control command, doesn't work in PSpice
    .options ITL1=1000 ITL4=1000 GMINSTEPS=1 reltol=0.01 method=gear gmin=1e-3 chgtol=1e-9 srcsteps=1


    * Run a .TRAN analysis and print the name of the active plot

    .tran 0.001s 10s 0s 0.01s



    .plot DC v(3) v(30) v(1) v(2)
    *Changed from plot to .plot DC

    ***Removed .endc command, invalid command

    .END


    **** EXPANSION OF SUBCIRCUIT Xceph ****
    Xceph.Bx Xceph.1 0 Xceph.V Xceph.v 4 *v
    -------------------------------------$
    ERROR(ORPSIM-16147): Invalid parameter


    As you can see the error says "Invalid parameter" and appears to be pointing to either the 4 or the *v. But the *v is a comment and the 4 is a node number so I don't know how either one of those could be causing an error.
     
  11. mvaseem

    Member

    Jan 31, 2014
    48
    8
    I haven't looked at this in detail, but a glance shows one obvious problem with the code which explains the reason for error.
    There are B devices in the subckt definitions , normally starting with Bx. These are being used as behavioral devices, which Pspice supports differently (as E,F,G,H devices).
    In your case these seems to be voltage controlled voltage sources (which means E device for Pspice).

    Change all the Bx definitions from B to E. See following example -

    Bx 1 0 V = v(4)/(v(par_Ediastole) + (v(par_Emax)-v(par_Ediastole))

    Change above to following :

    Ex 1 0 Value = {v(4)/(v(par_Ediastole) + (v(par_Emax)-v(par_Ediastole))}

    Do the same for all B devices and simulate again.
     
  12. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    Hey guys,
    Sorry to keep blowing up this thread, but I found the problem. Here is where one of the problems was occuring:

    .SUBCKT Cvenous 4 par_N par_C0 par_a par_adif

    * Bx: Non-linear dependent source
    * Calculate f(input voltage)
    Bx 1 0 V = v(4)*v(par_C0) * ( v(par_N) + (1 - v(par_N) ) / cosh( (v(par_a) + v(par_adif) * u(v(4) - 4.000)) * (V(4) - 4.000))

    The problem occurs right after:
    Bx 1 0 V = v(4)

    Immediatley after the (4) is *v(par_C0). PSpice thought this was a mathematical statement I guess, but it is actually the beginning of a comment which should not be connected to the Bx definition line. The same problem is happening in the subcircuit Cventricle. The problem with that subcircuit is also on the Bx line where the "/" symbol is after v(4).

    The problem I'm having with fixing that is that this actually needs to be a mathematical equation and not a comment. Does anyone know how to do division equations like that one in PSpice? I am also expecting the fact that I defined Bx, Vx, Cx, and Fx in 2 different subcircuits to cause an error. Is that correct? Or is that not a problem since they are in different subcircuits?

    Any knowledge would be helpful. Thanks.
     
  13. Tom O'Leary

    Thread Starter New Member

    Apr 9, 2014
    11
    0
    I see. I thought I read somewhere that B devices could be used in PSpice. I tried changing the B's to E's, but now an error comes up that says "extra text on line" and the $ symbol points to the letter "v" in the Ex lines. Any idea why that is?

    Also, what I really need to know is how to do arithmetic in PSpice. I read a user manual that said PSpice uses * and / for multiplication and division, but when I use * it thinks everything after it is a comment and it doesn't recognize "/". Any thoughts on that?
     
  14. mvaseem

    Member

    Jan 31, 2014
    48
    8
    B device for Pspice means GaAsFET model.
    In your case it is not a FET model, but arithmetic calculation (VCVS). So you would definitely need to use E device instead of B.

    Yes Pspice treats "*" as multiplication and "/" as division. But you need to tell it that you are using them in expression. Enclosing the calculation within curly brackets is the way to tell. Like the example I posted.
    Without curly brackets it is treated as comment.
     
Loading...