Speed of Sfunction builder in Simulink
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
gdz
el 7 de Feb. de 2023
Editada: Fangjun Jiang
el 8 de Feb. de 2023
Hi,
I have a S-function builder in Simulink, which reading and delopy data from/to arduino. I have also set the Fixed-step time(Fundamental sample time) to 0.1s. I would like to know what is the processing speed that executed the S-function. Is it equal to the sample time? If it is equal to the sample time, what is the minumum sample time I could set?
Thank you.
0 comentarios
Respuesta aceptada
Fangjun Jiang
el 8 de Feb. de 2023
Editada: Fangjun Jiang
el 8 de Feb. de 2023
The execution time of the S-function depends on the processing task and the CPU. Generally, more complex task, more time. More powerful CPU, less time.
In simulation, it doesn't really matter. It could take 1 second to finish the task, and then the simulation moves to the next 0.1 time step. There is no constrain between the sample time and processing time. The speed of the simulation calculation could be faster or slower than the simulation clock. You can use Simulink Profiler to find out the processing time of each block.
In real-time simulation/execution involving hardware, of course, the processing time needs to be smaller (preferably quite smaller) than the sample time. Use the tools supplied by the hardware (arduino, dSPACE RTI, etc.) to find out the worst case execution time and then decide the proper sample time. Some system may report an "overrun" flag if execution time is longer than the sample time. The processing time could vary due to some processing being conditionally executed. So make sure to exercise the worst case processing.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Block and Blockset Authoring en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!