How can I implement variable resistor and variable inductor models for HDL code generation when using Simscape in MATLAB R2023b?

5 visualizzazioni (ultimi 30 giorni)
I am using MATLAB R2023b. My Simulink model includes variable resistors and variable inductors from the Simscape Electrical library. However, when I try to implement HDL code generation on my model, I get the following error:
Nonlinear Partitions are not supported for HDL Code Generation. Please refer to the Simscape Statistics viewer for more information on partitions within the System.
How can I implement variable resistors and variable inductors for HDL code generation?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 5 Apr 2025
As of MATLAB R2023b, variable resistors and variable inductors form the Simscape Electrical library are not compatible with HDL code generation. This persists in MATLAB R2024b. The reason behind this is the fact that they are "nonlinear" in the Simscape environment as explained below. Please note that this is different than mathematical nonlinearity.
In order to use variable resistors and variable inductors in a Simscape model for HDL code generation, you can try the following workarounds:
  1. You can try using the "Partitioning" local solver which is detailed in the Understanding How the Partitioning Solver Works documentation page. Please note that depending on your system and on the structure of your model, there is a possibility that this solver might not work for you.
  2. If this solver is not suitable for your model, you can try adding a "Simscape Component" block in which you change the model from variable resistor to piecewise linear as shown in the attached file "pwl_resistor.ssc" file. This workaround is based on assigning resistance values "R" in a piecewise manner based on a unitless input value (in this case called "u"). This allows the voltage value "v" being computed to no longer be directly dependent on the previous input value "R". Rather, it will be indirectly dependent on the new input value "u", all while having the resistance value "R" defined inside the script.
The attached example code includes only two values of "R", but additional values can be added. You can add the "SSC" code to a "Simscape Component" block according to the Simscape Component documentation page. Please ensure the "SSC" file is located in your MATLAB path when adding it to a "Simscape Component" block.
A similar workflow can be followed for variable inductors.  
The documentation page for resolving issues for nonlinearities provides additional information on how to make the model compatible for HDL coder.

Più risposte (0)

Categorie

Scopri di più su Creating Custom Components and Libraries in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by