embedded coder cant generate reuseable function

13 ビュー (過去 30 日間)
chen
chen 2024 年 12 月 2 日
回答済み: MULI 2024 年 12 月 11 日
I set the subsystem to "Treat as Atomic Unit", the function name option is "User Specified --- Pid_Control", and saved it as a library.
the reuseable subsystem
But when I call the function using Simulink,Embedded Coder generates multiple functions (with different function names but the same function content) instead of reusing the function.
And strangely, sometimes it can be reused successfully. I checked the input signal types of these functions and they are all the same.
What could be the reason? thanks
same function with different code
  2 件のコメント
Jaimin
Jaimin 2024 年 12 月 2 日
Could you please share the Simulink model so I can reproduce the issue?
chen
chen 2024 年 12 月 2 日
this is my simulink model

サインインしてコメントする。

回答 (1 件)

MULI
MULI 2024 年 12 月 11 日
I understand that Embedded Coder generating multiple functions instead of reusing a single function for your reusable subsystem.
It can occur due to following reasons:
  • If there are any differences in datatypes, dimensions, or min/max values of signals driving the subsystem inputs.
  • Even minor differences in subsystem settings or connected signals can prevent reuse.
  • If signals are read at different phases of the simulation (e.g., initialization vs. execution), reuse may not occur.
You can follow these steps to resolve the Issue:
Additionally, you may refer this link for detailed guidance on generating reusable code from library subsystems:

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by