0
$\begingroup$

I'd like to ask you if a C mex s-function model in Simulink can get the dSpace execution time lower, rather than having a model with blocks and functions.

$\endgroup$

1 Answer 1

0
$\begingroup$

Short Answer: It depends on what blocks you're replacing, and even then the effects might be negligible.

An interconnected set of standard Simulink blocks (gain, sum, integral, derivative, etc.) will definitely be equally-fast or faster than any custom function you write, CMEX or not. On the other hand, replacing a MATLAB Function Block with a CMEX S-Function might have some effect, but it's very difficult to determine.

The effects of using a CMEX S-Function will depend on your skill at writing efficient C code, and even then the effect could be small compared to the execution time of other parts of your model.

It's also not as simple as asking which block is more efficient in 'Normal mode' Simulink. dSpace uses a combination of the Simulink Coder and their own proprietary software to translate your Simulink model into C code that is then compiled into an executable. That executable is then run in real time by the dSpace hardware. Therefore, during the translation process from Simulink to C code the benefits of using the CMEX S-Function might be negated.

*Note: I have not worked with dSpace but I do use a very similar software package in my research called QUARC, which is basically the Canadian equivalent.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.