Buses as inputs/outputs in C MEX S-Functions
8 次查看(过去 30 天)
显示 更早的评论
Hello, I have a question:
Is it possible to make a hand-written C S-Function which handles with buses as inputs/outputs? My buses are composed by different type signals.
I need to do it manually, I cannot use the S-Function Builder. Is there any way to do it? Maybe with the legacy code tool?
If it is possible, it would be great if someone could provide me a little example.
My software version is Simulink 7.0 (R2007b).
Thanks in advance,
Iban
0 个评论
回答(4 个)
Kaustubha Govind
2011-5-11
There is actually a demo titled "Using Buses with Legacy Functions Having Structure Arguments" that shows how to use the Legacy Code Tool to generate S-function wrappers with input/output bus signals. You can type "showdemo sldemo_lct_bus_script" at the MATLAB prompt to see it.
For your future reference, the S-function Builder can also generated S-functions with input or output buses when you configure the "Bus" and "Bus Name" columns in the Input/Output ports pane (type "sfbuilder_bususage" at the MATLAB prompt to see an example).
Guy Rouleau
2011-5-12
Yes it is possible.
What I recommend is to use the S-Function builder as a starting point. Use the S-Function Builder to generate a basic s-function with an architecture similar to what you need. Then throw the S-function Builder block away and call this s-function from the S-function block.
This will give you a good example as a starting point and you can modify it manually as you wish and tell everyone you wrote the whole thing yourself;-)
1 个评论
Amittai Aviram
2017-5-8
Sorry--I do not understand what you mean. If you use the S-Function Builder, you must finish by clicking on "Build," which produces a binary MEX file (*.mexa64), which you can neither examine nor alter. How can you use this "as a starting point"? How can you "modify it manually"?
Iban
2011-5-16
1 个评论
Kaustubha Govind
2011-5-18
Iban: Are you saying that neither your input nor your output signal is a bus? What exactly is a structure in your code? Local/Parameter data?
Riccardo Spica
2014-5-10
Hello,
I am trying to develop an s-function with a bus signal as output. I managed to do that using the sfunction builder. In normal mode everything works but if I try external mode or rapid accelerator mode I get the following error:
The model that you are trying to run in External mode does not match the application running on your target. Rebuild the model, run it on your target, and start External mode simulation again.
I have the same error also running the example sfbuilder_bususage. Any hint? Thanks in advance.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!