Azzera filtri
Azzera filtri

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

87 visualizzazioni (ultimi 30 giorni)
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 Commenti
TAB
TAB il 12 Ott 2018
It would be nice if you can share your model or an example model.
Michael Girbino
Michael Girbino il 12 Ott 2018
Modificato: Michael Girbino il 12 Ott 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);

Accedi per commentare.

Risposta accettata

Michael Girbino
Michael Girbino il 12 Ott 2018
Answer is in the comments.

Più risposte (0)

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by