Effacer les filtres
Effacer les filtres

Why do I get the error "Invalid output port data type" in my Simulink model?

87 vues (au cours des 30 derniers jours)
When I try to run my Simulink model, I get the following errors in reference to a Stateflow block:
Invalid output port data type. Data type of output port 2 of 'regcontrol_model/RegControl' is invalid.
An error occurred while propagating data type 'uint8' through 'regcontrol_model/RegControl'.
I determined that the first error will occur on output 2 regardless of the order of my output ports.
I'm wondering why these errors occur, and are they related?
  3 commentaires
TAB
TAB le 12 Oct 2018
It would be nice if you can share your model or an example model.
Michael Girbino
Michael Girbino le 12 Oct 2018
Modifié(e) : Michael Girbino le 12 Oct 2018
In the process of removing my model's workspace dependencies so I can post the just the .slx file, I solved my problem.
I have a bus containing 32 constants whose values come from the MATLAB workspace:
In the definition of the bus object, my integer values are meant to be uint8:
TapLimitPerChange = Simulink.Parameter;
TapLimitPerChange.DataType = 'uint8';
TapLimitPerChange.Value = RCReg1.TapLimitPerChange;
EquipElems(5) = Simulink.BusElement;
EquipElems(5).Name = 'TapLimitPerChange';
EquipElems(5).Dimensions = 1;
EquipElems(5).DimensionsMode = 'Fixed';
EquipElems(5).DataType = 'uint8';
EquipElems(5).SampleTime = -1;
EquipElems(5).Complexity = 'real';
...But in the class definition used by the object RCReg1, the integers are typed as int32:
properties (PropertyType = 'int32 scalar')
TapLimitPerChange
end
This is why there was an error in data type propagation.
For reasons unknown to me, 'uint8 scalar' is not an acceptable PropertyType, so the solution is to typecast.
TapLimitPerChange.Value = uint8(RCReg1.TapLimitPerChange);

Connectez-vous pour commenter.

Réponse acceptée

Michael Girbino
Michael Girbino le 12 Oct 2018
Answer is in the comments.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by