problem with ssc_build to generate custom simscape library

Hi everyone, I am trying to learn how to make custom simscape blocks.I have written ssc file,and created a new directory (named +gear_
pump) that I added to my Matlab path.Then, I run the ssc_build command to generate my custom library. When run the ssc_build command I get the following error message:
Generating Simulink library 'gear_pump_lib' in the MATLAB package parent directory 'D:\matlab\simscape\' ...
Failed to generate 'gear_pump_lib'
原因:
错误使用 feval
函数或变量 'gear_pump.gear_pump' 无法识别。
(translate in English :
reason:
Incorrect use of festival
Function or variable 'gear'_ pump.gear_ The 'pump' is not recognized)

9 commentaires

Is it possible to share the .ssc file you try to build the library from? It feels like some syntax error in the .ssc file but it would be difficult to identify without the .ssc file itself.
最后的效果应该是这样的
It was able to compile OK on my end, strangely. Just used ssc_build('custom_library') and it generated a custom library. I did need to modify two lines of code later to make the simulation run (has to do with how 'rad' unit is interpreted), but the compiling was OK. The results also seem to make sense.
What version of MATLAB are you using? I can try again in the same version and share the files.
R2022b version
>> ssc_build('gear_pump.ssc')
The provided package name 'gear_pump.ssc' does not match the derived package name 'gear-pump'. When
'ssc_build' is run from within a MATLAB package directory, the provided name must match the name of the
MATLAB package directory from where it is run or the name can be omitted and it will be automatically
derived.
我尝试了几次可是还是出现问题
啊,我明白问题出在哪里了 ... 看Answer部分。
在 +dirname 的上一级目录执行 ssc_build('dirname')
>> ssc_build
Generating Simulink library 'custom_library_lib' in the MATLAB package parent directory 'F:\matlab\' ...
Failed to generate 'custom_library_lib'
原因:
错误使用 custom_library/gearpump>
No matching signature found for function floor.
Argument 1 = {[1x1 double], 'rad'}
phi = {[1x1 double], 'rad'}
z = 14
真的很麻烦您了。我是这个之后,输入ssc_build,出现了问题,无法generate 'custom_library_lib'。
其实非常想加您的联系方式,具体聊一聊。

Connectez-vous pour commenter.

 Réponse acceptée

Yifeng Tang
Yifeng Tang le 5 Mai 2023

0 votes

The input to the ssc_build command should be the directory name, instead of the .ssc file name. The directory can contain multiple .ssc files and they'll all be compiled into a custom library. The directory has to be named to start with a "+", but don't include that "+" in the input to ssc_build.
For example, in the screenshot I shared earlier in the comments, you can see I put the .ssc file in the +custom_library folder, then used ssc_build('custom_library') command to compile. Please give it a try and see if that works for you as well. Here is the documentation page explaining the details: https://www.mathworks.com/help/simscape/ref/ssc_build.html See the first example.
Also, in your gear_pump.ssc file, you may need to delete a few /{1,'rad'} in some equations for it to run correctly. Seems like Simscape treats rad as unitless and complains about unit mismatch.

2 commentaires

Attached are the files and library I was able to compile, and a simple test model.
Once your custom model is working, I'd like to encourage you to consider NOT using the Hydraulic domain and instead using the newer Isothermal Liquid domain. The difference and the advantages of the IL domain can be found on the following documentation pages:
Happy modeling.
Error compiling Simscape network for model untitled.
原因:
确实出现了这个问题,那么 rad弧度单位该怎么替换呢?

Connectez-vous pour commenter.

Plus de réponses (1)

ms z
ms z le 26 Août 2024

0 votes

你好,我遇到了同样的问题,也是在使用ssc_build的时候报错函数或变量无法识别,请问您是怎么解决的,能否指点一下,谢谢

1 commentaire

If you used a MATLAB function in your equations session of the .ssc code, the function has to be one on this list: https://www.mathworks.com/help/simscape/lang/equations.html#brtts6o
If you don't think that's the issue, consider ask in a new question and provide more details.

Connectez-vous pour commenter.

Catégories

Produits

Community Treasure Hunt

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

Start Hunting!