Bus signals giving errors in Subsystem

30 vues (au cours des 30 derniers jours)
Bastian
Bastian le 7 Mar 2012
Hello, I am using MATLAB2010bSp1 Simulink with targetLink 3.2 extension. In a simulink model I have a Subsystem with a lot of constants different datatypes going on a bus creator, thats end is going on an outport. On the root I have another subsystem thats input is the output of the subsystem with the bus creator. In this subsystem I have a Inport and a lot of another subsystems. With Bus selectors I broadcast the signals to each subsystem. In some cases I'm only forwarding signals to the outport, but exactly this is making problems. I always getting an error: Input port cannot accept mixed data types. Input port 9 of 'Testing/Subsystem' expects a signal with unique data type. However, it is driven by a signal with elements of differing data types. This can be usually fixed by inserting a Signal Conversion block with the 'Bus copy' option selected, at the output of block '9'. Alternatively, if this input port is within a function-call subsystem, consider checking the 'Latch input for feedback signals of function-call subsystem outputs' option.
With an simple conversion block, or with an AND (one Inport) with itself (if datatype is boolean). Its making no problems (But for designing wishes its not wanted). In other subsystems there is no problems. But now the courios thing in this case . If I delete the subsystem with the bus selector and put its content on the root there is no problem. So it seems to me, that this is a bug of MATLAB. The only differences is, that on Inport and one Outport is missing. All Inports in simulink are configurated as inherit:signal.

Réponses (1)

JzHartmut
JzHartmut le 27 Sep 2017
==Sfunction Input with a Bus input==
I have had this error message on connection a bus to a Sfunction. The Inport port was 'DYNAMICALLY_TYPED'. That's good to connect simple numeric types maybe with arrays (using ssSetInputPortWidth(..., DYNAMICALLY_SIZED). But it is not proper to connect a bus.
To connect a bus to an inport port of a S-function, the type have to be set with the correct bus type. That can be given with a String parameter. Write:
char type[256];
mxGetString(ssGetSFcnParam(simstruct, 1), type, sizeof(type));
if (type[0] != 0){ //not an empty param
#if defined(MATLAB_MEX_FILE)
if (ssGetSimMode(simstruct) != SS_SIMMODE_SIZES_CALL_ONLY) {
DTypeId dataTypeIdReg;
ssRegisterTypeFromNamedObject(simstruct, type, &dataTypeIdReg);
if (dataTypeIdReg == INVALID_DTYPE_ID) return;
ssSetInputPortDataType(simstruct, 1, dataTypeIdReg);
}
#endif
In the moment I don't know whether '#if defined(MATLAB_MEX_FILE)' is necessary - get experience.

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by