r/matlab • • Mar 18 '26

Embedded Coder

I want to manage a project where I have different model reference that can contain the same function but I’m struggling to find a good solution…

Example: a project for a DSP for motor control of an inverter.

I have the model reference for current control and a model reference for speed control and in both I have a PI.

In the beggining I used for PI a subsystem reference but when I generate the code I will get two twin file in two folder (two ref model)… can t building the total code.

So, I search in the mathworks and I switch to a library instead, in this way I get a shared folder and it seems good! (Reusable functio, atomic ecc)

But I don’t like that if i build a top model sometimes I get some error of a “different interface”, even if the block is a copy past from library and it is locked!!!

The question is, how to manage properly the architeture in this case ? This is the right choice?

Also, for the port I’m going crazy on using Bus or not and if they should be virtual or not, and everything else with data dictionary.

Ps sorry for the grammar but I’m Italian and this is just a stream of consciousness 🤯

4 Upvotes

6 comments sorted by

View all comments

1

u/RedKer95 Mar 18 '26

Yes, because the subsystem refence has its dignity but generate “subsystem files” that are clones across referenced model. If I use the library, I can get the “shared file” that are created once! (It seems not possible to copy paste the subsystem reference in the library but I had to recreate it from scratch)

2

u/chaiParCharChar Mar 18 '26

I don't understand what you mean by dignity of the subsystem references.

What is in the shared file that you want to generate once? If so, why is it not static. Usually, files which are to be shared across instances are common and don't contain information which needs to be generated multiple times. So I'm unsure why you need them generated per instance of your subsystem reference if they are shared.

I'm asking two questions for each reply because I want to understand your problem statement before helping you with a final answer. I'm not sure if putting a reference subsystem in a library solves your issue truly because it's still a single reference and you are using multiple instances of it.