Buses as inputs/outputs in C MEX S-Functions
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (4)
Kaustubha Govind
am 11 Mai 2011
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
am 12 Mai 2011
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 Kommentar
Amittai Aviram
am 8 Mai 2017
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
am 16 Mai 2011
1 Kommentar
Kaustubha Govind
am 18 Mai 2011
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
am 10 Mai 2014
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 Kommentare
Siehe auch
Kategorien
Mehr zu Author Blocks Using S-Function Builder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!