Code generated from Discrete model uses structures defined in rtw_continuous.h
Mostrar comentarios más antiguos
Hi everyone.
Today I've been trying to generate and compile code from a model configured to use the Fixed Step (Discrete) solver, with Matlab Simulink 2023b. I am using the ert TLC, on a Windows11 64bits machine.
Last time i tried to do it, two months ago with 2022b, everything semmed to work fine. So far, the option Support: continuous time (in the Code Generation/Interface tab of the model parameters) was not checked.
Today i tried to do it again. This time, the code generation terminates normally but when i want to compile it, i get the errors "RTWSfcnInfo is undefined" and "SimTimeStep is undefined". These errors look logical since the header files where these structure are defined (rtw_solver.h and rtw_continuous.h) aren't included anywhere in my new generated code.
I compared the newly generated code and the previous one (which compiled fine) and indeed, i find usages of RTWSolverInfo and SimTimeStep that weren't there in the previous generated code.
Here is an extract of the new generated code :
/* Real-time Model Data Structure */
struct tag_RTM_Model_T {
const char_T *errorStatus;
RTWSolverInfo solverInfo;
/*
* Timing:
* The following substructure contains information regarding
* the timing information for the model.
*/
struct {
uint32_T clockTick0;
time_T stepSize0;
uint32_T clockTick1;
SimTimeStep simTimeStep;
time_T *t;
time_T tArray[2];
} Timing;
};
And here is the corresponding extract in the old generated code :
/* Real-time Model Data Structure */
struct tag_RTM_Model_T {
/*
* Timing:
* The following substructure contains information regarding
* the timing information for the model.
*/
struct {
uint32_T clockTick0;
} Timing;
};
If i now check the checkbox "Support: continuous time", then the generated code now includes these two headers at the top of files, and the compilation succeeds.
I find this rather disturbing for several reasons :
1) How can the code generation step terminates with no error when the option Support: continuous time is not activated, whereas the generated code does not compile !?
2) Why does the generated code now uses these new Timing and RTWSolverInfo structures ? I thought maybe it was an evolution of version 2023b. Also I have changed my model quite a lot these last two months, so it might be something I did. Since the missing definitions are located in headers that are included only if i check "continuous time support", i thought maybe it was because my new model now contains continuous time blocks, but i couldn't find any (using this method : How do I find all continuous blocks in a model in order to replace them to use a discrete solver? - MATLAB Answers - MATLAB Central).
3) Having to check "continuous time support" sounds suboptimal since my model is (normally) 100% discrete, and it forces me to uncheck the option Remove error status field in real-time model data structure which is recommended to be checked for efficiency matters.
Thanks a lot for your help !
Clément
5 comentarios
Donghua
el 17 de Abr. de 2025
Hello, I'm facing the same issue and couldn't find useful prompt duing the generation.
Despite setting with explicit 'no continuous time support', Embedded Coder still generates these codes.
Clément
el 28 de Abr. de 2025
Donghua
el 29 de Abr. de 2025
@Clément Hi Clément,
Thank you for your solution and explanation.
Yes, as you mentioned I did check the sample rate view and saw the continuous sample rate in the list.
However, in my case , even I did so, the block couldn't be found.
It must be something hidden in the model and with display error I thought.
I saved the model as a mdl format and checked the contents manually.
This time I found a 'Clock' block exactly inside my model, which has a bad property IOType: siggen, after removing this property the Clock block becomes visible on the panel.
This was quite interesting since Simulink generated( or my incorrect operations?) a bad block in the model and ignored the block while model is being loaded. However, the Embedded Coder recognized this model must be compiled with continuous time supporting and generated the code without warnings.
Donghua
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Simulink Coder en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

