How do I fix Simulink.DataType object not in scope while using c caller?
72 ビュー (過去 30 日間)
古いコメントを表示
I am using c caller and function used in that is pid controller. While simulating that its showing error like "Unable to resolve 'PID_vars' to a valid type for input port 0 of 'pidexmpl/C Caller'.
Caused by:
Simulink.DataType object 'PID_vars' is not in scope from 'pidexmpl/C Caller'". Can someone tell me how to resolve this error?
2 件のコメント
Raghava S N
2024 年 8 月 8 日
Hi @AKHILA, could you share the Simulink model you are working with? That would help in debugging your issue.
David Balbuena
2024 年 8 月 8 日
What is PID_vars? Is it a type defined in your external code? If so, you need to represent that in Simulink. The Simulink.importExternalCTypes function can help import that type for Simulink.
採用された回答
arushi
2024 年 8 月 9 日
Hi Akhila,
The error message you're encountering indicates that Simulink is unable to resolve the PID_vars data type for the input port of the C Caller block. This typically happens when the data type is not properly defined or not in the scope where it is being used.
Here are some steps to resolve this issue:
1. Define PID_vars as a Simulink.Bus Object
First, ensure that PID_vars is defined as a Simulink.Bus object. This object should define the structure and data types of the elements used in your PID controller.
2. Ensure PID_vars is in the Model's Workspace
Make sure that PID_vars is available in the model's workspace. You can do this by running the script that defines PID_vars before running the simulation or by adding the definition to the model's PreLoadFcn callback.
3. Verify Data Type Scope
Ensure that PID_vars is in the scope of the C Caller block. If you are using a data dictionary, make sure that PID_vars is defined in the data dictionary and that the dictionary is linked to your model.
4. Check the C Caller Block Configuration
Ensure that the C Caller block is correctly configured to use PID_vars as an input type. Double-check the input port settings in the C Caller block.
Hope this helps.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!