Influence When Simulink Executes Custom C-Code

7 Ansichten (letzte 30 Tage)
Alexander
Alexander am 25 Jul. 2013
Hello,
I'm currently writing a hardware driver in C to integrate into a Simulink model. The model will then be compiled and built into a single executable using the Embedded Coder. I'm trying to figure out if there is way to influence at what time during each execution step Simulink will call one of the functions that I write, e.g. at the start or at the end of a time step.
Any help would be greatly appreciated!
Thanks!
  2 Kommentare
Kaustubha Govind
Kaustubha Govind am 26 Jul. 2013
Do you plan to write an S-function to call into your C code? If so, are you going to hand-write it, or use the Legacy Code Tool to auto-generate it?
Alexander
Alexander am 26 Jul. 2013
I'm fine doing either one, would one or the other be more preferable to use in this situation?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 30 Jul. 2013
It is in general easier to use the Legacy Code Tool, and perhaps then adjust the generated S-function and TLC if needed, especially if you're new to S-functions. However, the tool does have its limitations, so if you are attempting to write a more sophisticated S-unction, you might need to hand-write it.
In any case, for the Legacy Code Tool, please see Declaring Legacy Code Tool Function Specifications to see how you can specify what code gets called in each S-function runtime method. Please see Simulink Engine Interaction with C S-Functions to understand the stages of simulation at which each method gets called.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by