How to share outputs of a Button Checker model (slx file) to the other models(other slx files)

Button checker model 1(slx file) is built with 8 inputs (up, down , right, left, menu,back, home, power) and 8 outputs (up_k, down_k , right_k, left_k, menu_k,back_k, home_k, power_k). I get the button inputs from application.
Model 1 outputs has to be fed as inputs to Model2 (slx file)
I tried using Reference model approach. I made the Button checker model 1 as referene model in Model 2 slx file. I generated code. I got .c and .h files separately for Model 1 and 2. Integrated with application but my Model 2 is not able to get inputs from Model 1.
How do i do it. Please Help.

Risposte (1)

To resolve this issue you can follow the below approches:
Approach 1: You can use a Subsystem Instead of a Model Reference:
  • Convert the logic in Model 1 into a subsystem.
  • Place this subsystem directly in Model 2.
  • This way, Simulink generates integrated code, and the signals will be connected as expected in the generated code.
Approach 2: Explicitly Connect Models in Application Code:
  • If you need to keep the Model Reference structure, you must manually connect the outputs of Model 1 to the inputs of Model 2 in your application code after code generation.
  • This means, after calling the Model 1 step function and getting its outputs, you must assign those outputs as inputs to Model 2 before calling Model 2’s step function.
You can refer to the following links for more information on reusable Library Subsystem

Categorie

Scopri di più su Simulink Coder in Centro assistenza e File Exchange

Prodotti

Release

R2022a

Richiesto:

il 8 Apr 2025

Commentato:

il 30 Apr 2025

Community Treasure Hunt

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

Start Hunting!

Translated by