"ssc_build" Error while converting SPICE model to Simscape

18 views (last 30 days)
Hi everyone,
I am currently working on a full bridge amplifier, that uses the 2EDR7259X gate driver from Infineon and the SPICE model is available on their website. I changed the .lib into .cir to make it compatible, since and the code is clearly SPICE, so there shouldn't be any issues.
I am using the "subcircuit2ssc" and "ssc_build" functions to convert it to a Simscape model. This is the basic scipt I am using:
subcircuit2ssc('2EDR7259X.cir', '+GateDriver');
ssc_build GateDriver;
When I run it, I get the following errors:
Error using sscbuild (line 53)
Failed to generate 'GateDriver_lib'
Error in pm.legacy.internal.support
Error in pm.legacy.internal.support
Error in ssc_build (line 5)
[varargout{1:nargout}] = pm.legacy.internal.support('sscbuild', mfilename, varargin);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in Convert2EDR7259X (line 2)
ssc_build GateDriver;
^^^^^^^^^
Caused by:
'p_th_in_m40' is not defined in this scope.
In GateDriver.two_edr7259x_gd_template (line 152)
In GateDriver.ss_2edr7259x (line 99)
I've never worked with Simscape or did any electrical simulations in Matlab before and it's been years since I've worked with Matlab last time and I'm just getting back into it. I've been trying to resolve the error myself but I can't really find a place to start.
Any help is greately appreciated!

Answers (1)

Shivam Gothi
Shivam Gothi on 4 Dec 2024 at 9:39
As per my understanding, you are trying to make a simulink model from a spice netlist.
I was able to reproduce the issue by taking the same spice model from infinion website, as suggested by you.
Before moving ahead, it will be nice to review some basics:
consider the command:
subcircuit2ssc('2EDR7259X.lib', '+GateDriver'); %Here you can directly pass the .LIB file. No need to change the extension to .CIS.
This will create a directory (namespace): "+GateDriver". Inside that directory, you will find many .SSC files. These are the simscape model file.
According to the documentation:
MATLAB will create one .SSC file for each "subckt" encountered in the spice netlist. You can create simulink library blocks using .SSC files.
The command:
ssc_build GateDriver
will create a simulink library file named "GateDriver" which will be in .SLX extension. You can use the blocks found in the library file in your simulink model.
Refer to the below Mathworks Links for more information regarding the usage of these functions:
Analysing the challenges:
According to the above attached documentation, only a subset of the PSpice netlist language is supported. However, unsupported PSpice commands are identified at the top of the corresponding Simscape component file to facilitate manual conversion. You can use the optional "unsupportedCommands" output argument to generate a struct array that lists unsupported SPICE commands for each subcircuit. Its use is illustrated below:
unsupportedCommands=subcircuit2ssc('2EDR7259X.lib', '+GateDriver');
I executed the above command and found that there were 34 unsupported commands. As a conclusion, the simulink block generated from the netlist may miss some of the features/functions as present in the actual spice model. This may cause a different behaviour than expected.
In order to overcome this, you need to facilitate it manually, as shown in:
I have not done it in the pressent answer. You can do it by refering to the above link.
Resolving the error:
I investigated the file "two_edr7259x_gd_template.ssc", as displayed in the error message. For some reason, the generated file were containing the unresolved symbols. I made some corrections in the line numbers specified in the error messages. Also, I made some modifications in the file "two_edr7259x_deadtime.ssc" on line numbers 179 - 191 (basically, the dead-band feature is not used. You can configure it by refering to the original code).
After making the modifications, the error was resolved and simulink library file "GateDriver_lib.slx" was created in the current working MATLAB directory.
I have attached the folder "+GateDriver" containing the modified files with this answer. I am also attaching the simulink library file.
I am attaching the screen-shot of library file:
You can see that it has created a library block for each .SSC file found in "+GateDriver" directory.
But, the main model block is the "ss_2edr7259x", which has the gate driver model. Its screenshot is attached below:
You can see that it has created exactly the same input ports as stated in the spice netlist.
"CAUTION: As there were some unsupported commands and some modifications are made in the files , the behaviour of simulink model may deviate from the behaviour seen in the spice model. Please validate the simulink block with the spice model"
I hope you find this useful

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!