Code generation with MATLAB while using simscape components

Hi
I tried to generate a code to deploy it into an STM32F7 MCU.
I generated a simple RC simulation with a DC voltage source. then I did the setting for the code generation and got a lot of depencendy error regarding the library while i was builing the C project.
is this even possible to use the generated code while using simscape components? I did a simple simulation with simple add/product component and it was fine on the MUC.

回答 (1 件)

Satwik
Satwik 2024 年 11 月 22 日

0 投票

Hi,
I tried to reproduce the issue you encountered but did not find any errors while generating and building code for an RC circuit with a DC voltage source using Simulink or Embedded Coder. However, the dependency errors you are experiencing while building the C project related to libraries may be due to incorrect handling of spaces in the path to the MATLAB root directory.
For example, if your path is something like C:/Users/Owner/Program Files/MATLAB/R2020a..., the space between Program and Files might cause the path to truncate to Files/MATLAB/R2020a..., creating an invalid include path that leads to build failures. To work around this issue, you can reinstall MATLAB to a location without spaces in the path.
Please feel free to share the error message you encounter. Doing so will enable the community to assist you more effectively.
Furthermore, the documentation linked below outlines the scope of usage of generated code for Simscape components: https://www.mathworks.com/help/simscape/ug/about-code-generation-from-simscape-models.html
I hope this helps!

5 件のコメント

Mohammadreza Adib
Mohammadreza Adib 2024 年 11 月 22 日
移動済み: Walter Roberson 2024 年 11 月 22 日
Hello, Thanks dear Satwik to taking the time to answer my question.
I'll ckeck the solution you provided and share the results here. In the meanwhile, can you please share the .slx and the generated C code?
I want to deploy the code on a stm32 MCU to ckeck the result and see the settings for the solver and parameters configuration (ctrl+E).
One thing that I forgot to mention is that i could generate code with simple blocks like step, sum and so on and deploy the code on the MCU .
Kind regards.
Satwik
Satwik 2024 年 11 月 22 日
移動済み: Walter Roberson 2024 年 11 月 22 日
Hi, I pasted the generated C code into 'RCwithDC_Ccode.txt'. I have attached the .slx file and the .txt file with this comment.
Mohammadreza Adib
Mohammadreza Adib 2024 年 11 月 23 日
移動済み: Walter Roberson 2024 年 11 月 23 日
Dear Satwik,
can you export the file for version R2023b?
I could generate the C code, however, while bulding the entire project in Keil (For a STM32 MCU), I encountered the issues I mentioned earlier.
Meanwhile, I check the issue regarding the path of the installation.
once again thanks for your time.
Mohammadreza Adib
Mohammadreza Adib 2024 年 11 月 23 日
移動済み: Walter Roberson 2024 年 11 月 23 日
Note that I have developed my model based on sps_lib componentes. I use the 'powergui' as the solver of the simulation.
Walter Roberson
Walter Roberson 2024 年 11 月 23 日
Please only use Answer this question for posts that are proposing solutions to the question that was asked. All other material should go into the "Comment on this question" field or one of the "Comment on this answer" fields

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

カテゴリ

ヘルプ センター および File ExchangeSimscape Electrical についてさらに検索

質問済み:

2024 年 11 月 19 日

コメント済み:

2024 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by