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

75 views (last 30 days)
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 Comments
Raghava S N
Raghava S N on 8 Aug 2024
Hi @AKHILA, could you share the Simulink model you are working with? That would help in debugging your issue.
David Balbuena
David Balbuena on 8 Aug 2024
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.

Sign in to comment.

Accepted Answer

arushi
arushi on 9 Aug 2024
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.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!