LB-LMC solver with Simulink S-function #11
Replies: 2 comments 1 reply
-
Hello @ZhouDuu, For the first question:One way to use instances of C++ function templates (like the generated solvers) in S-Functions (or in tools like Xilinx Vivado HLS) is to call the parameterized function template from within a regular wrapper function that will be used as the S-function in Simulink. An example wrapper function would look like this:
You would call As you suggested in another discussion, Simulink's S-Function Builder can also be used. More information on this tool can be found here: The solver functions use the LB-LMC solver method (see references in readme file) and are optimized for power electronics real-time simulations with small time steps of 1us or below for FPGA execution using HLS tools. Depending on your model in the solver function, the solver might not work well at larger time steps. So you will need to run the Simulink model with the corresponding solver S-Function at same small time step the solver function was configured for (1us or below) for it to work correctly. Alternatively, you can run the Simulink model at larger time step and have the generated solver function with its smaller time step called multiple times each Simulink time step. For instance, if the Simulink model's time step is 10us and the generated solver function's time step is 1us, you would call the solver function 10 times each Simulink time step. This setup can be done simply by having the solver's wrapper call the solver function multiple times within a C++ loop. In this multi-rate setup, the Simulink and solver function time steps must be integer multiples of one another. Note that running the generated solver functions in Simulink is primarily used to validate the power electronics model in the solver and test it with various controller/protection logic offline before deploying the solver onto a FPGA with HLS tools to run in real-time with small time steps (like 50ns and below) for HIL testing or power electronics emulation applications. For the second question:The included version of the DAB component model is an early prototype developed by a student for a project of his. The DAB component has not been tested as well yet as the other components available that were presented in papers. So, the DAB component might have some bugs in it. Development on the DAB component is currently on hold at the moment but there are plans to revisit this component soon to support future internal projects. Updates will be posted when the DAB component is ready for public use. Hope this information helps you. BTW, I merged your two questions into one post since all following posts after the question are treated as possible answers in Github's Q&A discussion format. |
Beta Was this translation helpful? Give feedback.
-
Discussion closed and locked due to inactivity. |
Beta Was this translation helpful? Give feedback.
-
I am interested in the generated function templates for use in Simulink. However, so far I am not very clear about how such function templates can be used in s-function builder. Does the developer have an example that I can use for reference?
Also, in my testing, I found that most of the models supported by LB-LMC have relevant papers published. However, when I tested DAB, there were some minor problems, mainly on the 2 times side. Specifically, when using S-function and simulink's own model to connect the same control system, I found that the voltage of the primary side can match well, but the voltage and current of the secondary side are very different, can you help me to see where the problem is? Also, it seems that i2 and i3 in the model are interchanged with the pdf you provided. Can you check the code? I have put the netlist file of the test DAB below.
`% -- PARAMETERS OF MODEL --
#name Dual_Active_Bridge_Converter
#const DT 50.0e-9
#const DC_VG 700.0
#const DC_RG 0.001
#const DAB_RIN 0.001
#const DAB_ROUT 0.001
#const DAB_RTRANIN 10.0e-4
#const DAB_RTRANOUT 10.0e-4
#const DAB_RMAG 20.0
#const DAB_LMAG 2.2e-6
#const DAB_CIN 4500.0e-6
#const DAB_COUT 4500.0e-6
#const DAB_LIN 30.0e-6
#const DAB_LOUT 30.0e-6
#const DAB_RATIO 1.0
#const LOAD_R 20
#const GROUND_R 1
#const CM 10.0e-9
% -- COMPONENT LISTINGS OF MODEL --
% DC generator sources
VoltageSource dc_src(DC_VG, DC_RG) {1,0}
% DAB converter
DualActiveBridgeConverter_IdealSwitches DAB(DT, DAB_RIN, DAB_ROUT, DAB_RTRANIN, DAB_RTRANOUT, DAB_RMAG, DAB_LMAG, DAB_CIN, DAB_COUT, DAB_LIN, DAB_LOUT, DAB_RATIO) {1,0,2,3}
% Resistive loads for DAB converters
Resistor rload (LOAD_R) {2,3}
Capacitor CCCC (DT, CM) {3,4}
Resistor rgroundd (GROUND_R) {4,0}`
Beta Was this translation helpful? Give feedback.
All reactions