embedded coder cant generate reuseable function
조회 수: 57 (최근 30일)
이전 댓글 표시
I set the subsystem to "Treat as Atomic Unit", the function name option is "User Specified --- Pid_Control", and saved it as a library.
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
댓글 수: 2
답변 (1개)
MULI
2024년 12월 11일 7:07
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:
- Ensure identical datatypes, dimensions, and min/max values for all signals driving the subsystem inputs.
- Use a “Signal Specification” block to explicitly define these properties. You can refer to this documentation link for more information on this: https://www.mathworks.com/help/simulink/slref/signalspecification.html
- Set Function Name Options and File Name Options to "Auto" under the Code Generation tab.
- Use the “Simulink.SubSystem.getChecksum” function to compare checksums. You can refer to this link for more information on this function:https://www.mathworks.com/help/simulink/slref/simulink.subsystem.getchecksum.html
Additionally, you may refer this link for detailed guidance on generating reusable code from library subsystems:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!