How can I build code for a Level-2 M S-function block in Simulink such that it runs on the xPC real-time target?

조회 수: 2 (최근 30일)
Hello and thanks for reading this. I have a problem building a custom block for the xPC real-time target system. This block was developed entirely in .m code as a Level-2 M S-function and hence requires a .tlc file that describes the algorithm to be provided. My question is: is there any way I can auto-generate this .tlc file? Writing it from scratch seems like a very bad idea specially that the algorithm is complex and makes calls to three other external functions which are also written in .m. This means that I not only have to manually write the code for the S-function but also for the three other external functions which basically requires the repetition of work done in a previous master thesis. The other approach I tried was to use the S-function builder to create the .tlc and .c files, but for some reason it does not like receiving structs as dialogue parameters, which is what the algorithm is based on. Is there no work-around that alleviates this .tlc problem and allows me to build my function such that it can be downloaded to the xPC target? Thanks a lot for all your help and support.
Regards; Nawal

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2013년 7월 3일
If your MATLAB code only uses functions/constructs supported for code generation, it looks like the MATLAB Function block might be a better option for you.
  댓글 수: 3
Nawal El Boghdady
Nawal El Boghdady 2013년 7월 4일
Dear Kaustubha;
Thank you for your swift reply. I have indeed tried converting the code from an m S-function to a regular Matlab function block, however I have a problem that it does not allow dialogue parameters of type struct. What I am trying to do is take a struct in through the dialogue parameters perform some computation on its contents and then modify the struct accordingly. For some reason it gives me an error stating that either it cannot extract field X from type double or type mxArray. I also tried taking the struct from the workspace using the "From Workspace" block and providing it as input to the M-function, however that doesn't work either because the struct is not a timeseries. Any suggestions how to overcome this problem? Thanks a lot for all your help and time.
Regards; Nawal
Kaustubha Govind
Kaustubha Govind 2013년 7월 8일
Could you please paste a portion of the code you put in the MATLAB Function block around the lines where the error occurs?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by