I have model with fixed step solver and a specified fixed step size 0.00065. When I generate an S-function for a subsystem in the model, I received the following error message:
Invalid setting for fixed-step size (0.00065) in model 'model_name'. All sample times in your model must be an integer multiple of the fixed-step size.
When I look at the generated code subsystem_sf.c, I found that the sample time is set as the following:
/* task periods */ssSetSampleTime(S, 0, 0.0);ssSetSampleTime(S, 1, 0.4);
This is incorrect. The second sample time should be 0.00065 as I specified in the model Simulation Parameters Solver panel.
When I try to build this subsystem, in the generated code subsystem.rtw I found in the structure FixedStepOpts, the FixedStep is also set incorrectly.
Both cases are not a problem in the Real-Time Workshop 4.1.1 (R12.1). The incorrect code of sample time only happens since Real-Time Workshop 5.0 (R13).
Best Answer