how to change the SPICE simulation engine from SIMetrix to LTspice in ee.spice.semiconductorSubcircuit2lookup
19 views (last 30 days)
Show older comments
I want to change the SPICETool to LTspice. I am trying to parameterize a sic mosfet using this function like in ee_SiC_mosfet_tabulated example. here is the code I'm using
%% Set Lookup Table Data From a SPICE subcircuit
%% Description:
%
% Generate lookup table data from a SPICE subcircuit file and set lookup
% table parameters for the N-Channel MOSFET (Lookup Tablez-Based) model.
% Copyright 2022 The MathWorks, Inc.
%% Open model
model = 'ee_SiC_mosfet_tabulated';
if ~bdIsLoaded(model)
open_system(model)
end
blockName = [model, '/N-Channel MOSFET'];
%% Set the SPICE simulation parameter to extract lookup table data
subcircuitFile = fullfile(matlabroot, "toolbox", "physmod", "elec", ...
"eedemos", "applications", "devicecharacteristics", ...
"C2M0025120D.lib"); % File path of the SPICE subcircuit file
subcircuitName = "C2M0025120D"; % The subcircuit name of the device model
outputPath = fullfile(matlabroot, "toolbox", "physmod", "elec", ...
"eedemos", "applications", "devicecharacteristics", ...
"C2M0025120D"); % The path of the generated SPICE netlists and the simulation output files
SPICEPath = "C:\Program Files\LTC\LTspiceXVII\XVIIx64.exe"; % The path of the SPICE simulation engine executable
terminals = [1,2,3,0,5]; % Terminal orders in the subcircuit
% Define the gate-source voltage range, drain-source steps, and temperature
% steps for the transfer characteristics of the SiC MOSFET
flagIdsVgs = 1; % Flag for transfer characteristics
flagIdsVds = 0; % Flag for output characteristics
VgsRangeIdsVgs = [0 20]; % Vgs range
VdsStepsIdsVgs = [0.1:1:20.1,30:10:1200]; % Vds steps
T = [25 100 175]; % Temperature steps
% Define the gate-source voltage steps, drain-source steps, and ac
% simulation parameters for capacitance characteristics
flagCapacitance = 1; % Flag for capacitance characteristics
VgsCapacitance = -5:2:20; % Vgs steps
VdsCapacitance = [0:1:10, 20:10:100]; % Vds steps
frequencyCapacitance = 1e6; % Small signal AC frequency
acVoltageCapacitance = 0.25; % Small signal AC amplitude
% Define the voltage range for diode characteristics
flagDiodeIV = 1; % Flag for diode characteristics
VdsDiodeIV = [0 -30]; % Vds range
%% Generate lookup table data from the SPICE subcircuit
% Uncomment the code below to generate lookup table data if you have
% installed SIMetrix
lookuptable = ee.spice.semiconductorSubcircuit2lookup(subcircuitFile, ...
subcircuitName, SPICEPath, 'outputPath', outputPath, 'terminals', terminals, ...
'flagIdsVgs', flagIdsVgs, 'flagIdsVds', flagIdsVds, 'flagTailTransient', 0,'VgsRangeIdsVgs', ...
VgsRangeIdsVgs, 'VdsStepsIdsVgs', VdsStepsIdsVgs, 'T', T, 'flagCapacitance',...
flagCapacitance, 'VgsCapacitance', VgsCapacitance, 'VdsCapacitance', ...
VdsCapacitance, 'frequencyCapacitance', frequencyCapacitance, ...
'acVoltageCapacitance', acVoltageCapacitance, 'flagDiodeIV', flagDiodeIV, ...
'VdsDiodeIV', VdsDiodeIV);
save('lookuptable.mat','lookuptable') % Save the lookuptable data in a MAT-file.
%% Set lookup table parameters for the N-Channel MOSFET
% Load the lookuptable MAT-file
load("lookuptable.mat")
% Setup channel parameters
set_param(blockName, 'Vgs_vec', mat2str(lookuptable.channel.VgsVec'));
set_param(blockName, 'Vds_vec', mat2str(lookuptable.channel.VdsVec'));
set_param(blockName, 'T_vec', mat2str(lookuptable.channel.TVec));
mdlWks = get_param(model,'ModelWorkspace');
assignin(mdlWks, 'Ids_3D', lookuptable.channel.IdsMat);
% Configure capacitance parameters
set_param(blockName, 'C_GS_vec',mat2str(lookuptable.capacitance.CgsMat));
set_param(blockName, 'C_GD_vec',mat2str(lookuptable.capacitance.CgdMat));
set_param(blockName, 'C_DS_vec',mat2str(lookuptable.capacitance.CdsVec'));
set_param(blockName, 'C_Vgs_vec',mat2str(lookuptable.capacitance.VgsVec'));
set_param(blockName, 'C_Vds_vec',mat2str(lookuptable.capacitance.VdsVec'));
% Configure diode parameters
set_param(blockName, 'VfVec',mat2str(lookuptable.diode.VVec'));
set_param(blockName, 'TjVec',mat2str(lookuptable.diode.TVec'));
set_param(blockName, 'IfMat',mat2str(lookuptable.diode.IMat));
flagSiCSetup = 1; % Flag for setup function executed
0 Comments
Answers (1)
Raghava S N
on 27 Jun 2023
Do check out this documentation link where the SIMetrix and LTSpice results are compared-
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!