Main Content

Troubleshoot a SPICE Conversion of an IGBT Subcircuit

This example shows how to troubleshoot the conversion of a SPICE insulated gate bipolar transistor (IGBT) subcircuit and convert it into an equivalent Simscape™ component. The subcircuit2ssc function converts all the subcircuit components inside a SPICE netlist file into one or more equivalent Simscape files. However, in some cases, you must manually edit the original SPICE netlist.

Open the IGBT Subcircuit

In this example, you will convert this IGBT to a Simscape component, add it to a model, and simulate the model. The IGBT subcircuit combines the bipolar junction transistor (BJT) and SPICE Level 1 metal-oxide-semiconductor field-effect transistor (MOSFET) models and equations with a drain-gate capacitance model. To open the SPICE netlist, in the MATLAB command window, enter edit IGBTCharacteristicsSubcircuitOriginal.cir.

* Fast and accurate SPICE IGBT model

.SUBCKT IGBTMODEL C G 0
.FUNC WDSJ(X1,X2) {SQRT(12.422*{ESI}*VDS(X1)/(X2))}
.FUNC VDS(X) {SQRT(X^2+0.01^2)/2}
M1 N1 N2 0 0 MOSN
RG G N2 {5.7-7M*(125-TEMP)} 
Q1 0 N1 C BJTP
CGDOX N3 N2 0.1N
VICGDOX N1 N3 0
GCGD N1 N2
+VALUE = {(COXD*AGD*ESI/(WDSJ(V(N1,N2),{NB})*COXD+AGD*ESI))*I(VICGDOX)}

.PARAM TEMP=25
.PARAM AGD=50 ESI=1.0359 NB=2 COXD=175 VTO={4+7M*(125-TEMP)}
.MODEL MOSN NMOS (IS=20N KP=20 VTO={VTO} RD=0.5M CGSO=160U)
.MODEL BJTP PNP (BF=0.26 TF=1.5U CJC=0.6N RE=1M BR=0.44 IS=2E-15 NF=2 XTI=6 XTB=5)

.ENDS IGBTMODEL

Modify the IGBT SPICE Subcircuit

Not all SPICE subcircuits can be directly converted with the subcircuit2ssc function. If you run the subcircuit2ssc conversion directly on this file you will receive the following error:

"Error using spiceSubckt/extractSubcktDefinitionStrings (line 1182)"
"Connecting public nodes to ground is illegal."
"Error in spiceSubckt/loadSubckt (line 379)"
                "this.extractSubcktDefinitionStrings; % parse the subckt line"
"Error in spiceSubckt (line 69)"
                "this.loadSubckt(fullNetlist); % populate the object properties"
"Error in subcircuit2ssc (line 55)"
    "subcircuitArray(ii) = spiceSubckt(file,subcctName(ii));"
"Error in subcircuit2ssc (line 31)"
        "subcircuit2ssc(netlist,target);"

The conversion generates an error because the SPICE subcircuit connected a public node directly to node 0. In SPICE, node 0 is ground. To resolve the error, update the SPICE netlist file by renaming node 0 to node E.

If you now run subcircuit2ssc and then ssc_build you will receive the following error:

"Failed to generate 'myIGBT_lib'"
"Caused by:"
    "Error using ne_parselibrarypackage (line 66)"
    "Error: Class member redefinition has been found:"
        "Error using myIGBT.igbtmodel> (line 22)"
        "Class member 'temp' is defined."
        "Error using myIGBT.igbtmodel> (line 31)"
        "Class member 'temp' is defined."

The build generates an error because the SPICE subcircuit includes the definition of a local parameter named TEMP which is a reserved SPICE variable name for global temperature. To resolve the error and use the global temperature, remove the local parameter definition of TEMP from the SPICE library file. Alternatively, if you want to specify a local temperature, choose a name other than TEMP for the local parameter.

Save the changes into a new file named TroubleshootSPICEImportModified.cir.

* Fast and accurate SPICE IGBT model

.SUBCKT IGBTMODEL C G E
.FUNC WDSJ(X1,X2) {SQRT(12.422*{ESI}*VDS(X1)/(X2))}
.FUNC VDS(X) {SQRT(X^2+0.01^2)/2}
M1 N1 N2 E E MOSN
RG G N2 {5.7-7M*(125-TEMP)}
Q1 E N1 C BJTP
CGDOX N3 N2 0.1N
VICGDOX N1 N3 0
GCGD N1 N2
+VALUE = {(COXD*AGD*ESI/(WDSJ(V(N1,N2),{NB})*COXD+AGD*ESI))*I(VICGDOX)}

.PARAM AGD=50 ESI=1.0359 NB=2 COXD=175 VTO={4+7M*(125-TEMP)}
.MODEL MOSN NMOS (IS=20N KP=20 VTO={VTO} RD=0.5M CGSO=160U)
.MODEL BJTP PNP (BF=0.26 TF=1.5U CJC=0.6N RE=1M BR=0.44 IS=2E-15 NF=2 XTI=6 XTB=5)

.ENDS IGBTMODEL

To see the differences between the two files, in the MATLAB command window, enter visdiff('IGBTCharacteristicsSubcircuitOriginal.cir','TroubleshootSPICEImportModified.cir').

Run this command to convert the SPICE subcircuit of the TroubleshootSPICEImportModified.cir model to a Simscape component and place the generated files in the newly created directory called +myIGBT:

Netlist converted. Review Simscape component files and make
manual edits for any unsupported items before building the
Simscape library located at:
+myIGBT.

Generate the Simscape library using the ssc_build function.

Generating Simulink library 'myIGBT_lib' in the current directory '/tmp/Bdoc24a_2528353_1020267/tp4001e0e8/simscapeelectrical-ex00700102' ...

Open the Converted IGBT Model

The igbtmodel.ssc file stored in the +myIGBT directory is the converted Simscape component obtained by running the subcircuit2ssc function on the modified SPICE netlist. The subcircuit2ssc function also converted all the functions implemented in the SPICE subcircuit and stored them in a subdirectory named +igbtmodel_simscape_functions. To edit the generated simscape component, in the MATLAB command window, enter edit +myIGBT/igbtmodel.ssc.

To adjust the Simscape global temperature, in the Environment Parameters block, modify the Temperature parameter.

Verify Simulation Results

The IGBTCharacteristicsSubcircuitVerification script compares collector current versus collector-emitter voltage curves for a range of gate-emitter voltages with the SPICE netlist simulation results, which are stored in the IGBTCharacteristicsSubcircuitData.mat MAT-file. The gate-emitter voltages, Vge, are 8 V, 10 V, 12 V, 15 V, and 20 V. The Vce voltage sweeps from 0 V to 10 V.

To plot these characteristics with different settings, double-click the block labeled Define Conditions (Vge and Vce) and define the vector of Vge and the minimum and maximum Vce voltages. In the model, to run the simulations and plot the results, click plot curves.

Results from Real-Time Simulation

This example has been tested on a Speedgoat Performance real-time target machine with an Intel® 3.5 GHz i7 multi-core CPU. This model can run in real time with a step size of 50 microseconds.