Why do I receive an error when using an S-function generated with a explicitly-defined discrete sample time using the Real-Time Workshop S-Function Target from a subsystem that has both continuous-time and discrete-time blocks?

71 次查看(过去 30 天)
Why do I receive an error when using an S-function generated with a explicitly-defined discrete sample time using the Real-Time Workshop S-Function Target from a subsystem that has both continuous-time and discrete-time blocks?
I am creating an S-Function with a fixed-step solver from a subsystem which has continuous and discrete blocks. Some of the discrete blocks have sample times set. Then, I place the subsystem into a model which uses a fixed step solver with a different discrete sample time. This is producing an error that the S-Function can not be used in the model because of the sample time.
Error reported by S-function 'Subsystem_sf' in block 'sampletimes_sfcn/Subsystem/Subsystem_sfcn':
This Real-Time Workshop generated S-function cannot be used in a simulation with the current fixed step size because this S-function was created from a model with a fixed step size of 0.001 and had both continuous blocks and discrete blocks running at this rate. See the Solver page of the simulation parameters dialog

采纳的回答

MathWorks Support Team
The error message is not caused by any sample time mismatches with the subsystem. It typically occurs when you are mixing continuous and discrete time blocks. In certain cases, the Real-Time Workshop generated S-function throws an error message saying that the fixed step size of the model in which it is being used must match the fixed step size with which it was generated. Unfortunately, there is no way to change the fixed step size of the Real-Time Workshop generated S-function. The step size will always be calculated and set based on the blocks in the subsystem, if any of them have a specified (non-inherited) sample time.
This error is used to catch certain rate transition errors, under the following conditions:
1. There are discrete and continuous blocks in the subsystem.
2. Multitasking is turned on (Auto becomes multitasking for multirate systems)
3. The diagnostic for multitask rate transitions is set to 'Error'
Currently, to work around this issue, try changing the solvers to Single Tasking mode before generating the S-function, and in the final model. Alternatively, try changing the diagnostic for Multitask Rate Transition from "Error" to "None" or "Warning". Note that the dynamics of your model could be affected, as all blocks in the S-Function subsystem will be updated at the fixed sample time selected when the S-Function was generated.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by