Clear Filters
Clear Filters

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

87 views (last 30 days)
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 Comments
Michael Girbino
Michael Girbino on 12 Oct 2018
Edited: Michael Girbino on 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);

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!