How do I fix Simulink.DataType object not in scope while using c caller?

조회 수: 76 (최근 30일)
AKHILA
AKHILA 2024년 8월 8일
댓글: AKHILA 2024년 8월 16일
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
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
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
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 CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by