Adding input for valid parameter in Simscape block
33 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I have a question about Simscape blocks. Specifically, this question concerns the “The SI Combustion Cylinder” block.
I have already managed to create my own block that contains the same source code as the original block.
In the block, the gas constant R_air is entered as a “parameter”.
Now I want to define R_air as an “input”, as is done with the “Air-Fuel-Ratio” (AFR), for example. This way, I want to be able to read R_air via the Matlab workspace, as I do with other input values such as the speed or the intake manifold pressure.
When I adapt the program code in the same way as for the AFR, I have the problem that the following error appears when creating my own Simulink library:
“Error using ssc_build
Failed to generate 'UserBib_lib'
Caused by:
Invalid use of value 'R_air'. All entities referenced in this expression must be valid parameters.
• In UserBib.EngineSICombustionCylinderModified2 (line 297)”
In line 297, R_air is used for another formula.
How can I ensure that I can add values like “R_air” to the model via an input port?
I would be very happy to receive a reply.
Kind regards,
Florian
2 件のコメント
Walter Roberson
2025 年 2 月 17 日 16:50
Getting R_air via From Workspace means that R_air would be a signal
But I am getting the hint from "In the block, the gas constant R_air is entered as a “parameter”. " that you are trying to use R_air as a parameter . Parameters are pure numeric objects, with no time components, and so are incompatible with signals
採用された回答
Yifeng Tang
2025 年 2 月 24 日 20:17
I think it's possible. The Simscape code of this block is visible. You may find it in the Description tab of the block dialog box and click on the Source Code. You may save it as a .ssc file, modify the code and implement as a custom block or library block.
You may move "R_air" (line 49) from parameter section to the inputs section (around line 130), and that should give an input port for R_air. You may refer to the documentation on Simscape language syntax and how to use custom components in model:
But, be very careful about the implication of making R an input. For example, does this lead to creating energy out of nowhere? Go through all other equations that involves R (and the varaibles that calculated using R), to make sure.
3 件のコメント
Yifeng Tang
約20時間 前
If the goal is to use different R value in each run, with R remains a constant within each run, what you are doing sounds like the best approach. Making the R a modifiable parameter and change that parameter when you set up the run.
You may also benefit from setting up Simulink SimulationInput object to manage the runs. See documentation here: https://www.mathworks.com/help/simulink/slref/simulink.simulationinput.html
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Engines & Motors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!