Reputation: 25
I am building the c-code of a Subsystem in Simulink with the embedded coder. The created header file includes the following code-snippet which represents the 6 inports and 2 outports of the subsystem.
/* External inputs (root inport signals with default storage) */
typedef struct {
real_T V_dc_abs_B; /* '<Root>/V_dc_abs_B' */
real_T CM_B; /* '<Root>/CM_B' */
real_T GMEAS_A; /* '<Root>/GMEAS_A' */
real_T GMEAS_B; /* '<Root>/GMEAS_B' */
real_T V_dc_abs_A; /* '<Root>/V_dc_abs_A' */
real_T CM_A; /* '<Root>/CM_A' */
} ExtU_Regelung_T;
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
real_T AO_A; /* '<Root>/AO_A' */
real_T AO_B; /* '<Root>/AO_B' */
} ExtY_Regelung_T;
I also got an example code of a different simulink model which I'm following (I don't have the actual model, only the code). In their code, the external inputs and outputs code-snippet look like this:
/* External inputs (root inport signals with default storage) */
typedef struct {
real_T INPUTS[24]; /* '<Root>/INPUTS' */
} ExtU_WindExample_T;
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
real_T OUTPUTS[21]; /* '<Root>/OUTPUTS' */
} ExtY_WindExample_T;
I would like to change my simulink model in a way that the embedded coder generates my external inputs and outputs the same way as in the example - as an array. I have no idea which blocks to use for this problem and would much appreciate any help. I already tried to use bus creator and selector, but it didn't give me the desired result.
Upvotes: 2
Views: 28
Reputation: 25
I figured it out - you have to use a Mux/Demux Block. This way, the embedded coder creates an array of the inputs and outputs, respectively:
/* External inputs (root inport signals with default storage) */
typedef struct {
real_T INPUTS[6]; /* '<Root>/Inport' */
} ExtU_Regelung_T;
Upvotes: 0