Code generation from level-2 s-function without tlc-file
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Bettina
el 9 de Dic. de 2013
Comentada: liangjunfu
el 26 de Mayo de 2023
Hello,
I`m using R2012b. I have a problem generating code for a xpc-target system. I have written a level 2 Matlab S-function in which I have called a c-code (which I have mex-ed before). I can call this C-Code inside the Simulink Matlab S-Function and it runs fine on the normal mode.
But now I have tried to compile this model to be run in a xpc-target system. I have added the corresponding c-file by parameters-> code generation -> custom code -> include list of additional -> source file = the c-file and -> libraries = the dll-file and the mexw64-file. But when building the model, I get the error: The corresponding "xxxx.tlc" file for the Matlab S-function "xxx" in block "xxx" must be located in the current working directory, the Matlab S-function directory, or the directory "xxx\tlc_c".
It is not possible to automatically create a tlc-file, when using a Matlab S-function. Is it really necessary to write the tlc-file manually? If yes, for what did I have to write the S-function? Could I call a C-code (legacy code) in an tlc-file?
Thanks in advance for any answers!
Bettina
1 comentario
Or Hirshfeld
el 19 de Feb. de 2015
did you found any solution to by pass full coding in TLC because i have similar problem where i have level 2 s-function and i want to run the model in External mode in Windows Real-Time target
Respuesta aceptada
Rajiv Ghosh-Roy
el 10 de Dic. de 2013
In order to use this with code generation, everything you call must be in C (i.e. no M). The only exception would be if you were using a MATLAB function block.
In your case, the myfunc and myconstraint MATLAB files must also have a C equivalent. Without this, it would be hard to proceed.
Más respuestas (1)
Rajiv Ghosh-Roy
el 9 de Dic. de 2013
You can either write a C S-function, or add a simple TLC file for your MATLAB S-function. The TLC file could be as simple as calling an external function from your external C file.
Note that you will have to call LibAddToModelSources in order to inform the code generator of your external C-file, and also the external function call should be a C-style call, not a mex-file.
2 comentarios
liangjunfu
el 26 de Mayo de 2023
How did you solve this problem? I recently encountered the same problem.
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!