For Programmers: Free Programming Magazines  


Home > Archive > Matlab > May 2005 > Using Legacy Code with RTW and Embedded Targets









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using Legacy Code with RTW and Embedded Targets
Matthew Dares

2005-05-30, 4:01 pm

Hello,

I am trying to stream line our modeling to development phase of code
generation for our group. Currently we are using TI C2000 DSPs, and
would like to be using RTW with the C2000 target to automatically
generate our control code from a simulink model. I have this working
with very few problems.

The problem is that we have some sections (functions) in the current
production control code I want to leave alone which are written in
assembler and C. What I would ideally like to be able to do is create
a block which simulates the legacy function but which passes the
legacy code to the complier when real time workshop builds the
function.

To explain this a different way I want to be able to model the legacy
code in simulink (which is easy) but when RTW does the code
generation for that block(s) I want it to pass my legacy assembler/C
code to the compiler rather then generate it from that section of the
model.

I know this is somewhat confusing to read, but I would appreciate any
help,

Matthew
Titus Edelhofer

2005-05-31, 9:14 am

Hi Matthew,
the best (but also I admit, not the easiest way) is to write a non-inlined
S-Function, i.e,
- write a "usual" S-function in C, which simulates your legacy function
- write a TLC-File for your S-function, which just passes your legacy
code to RTW

Titus

"Matthew Dares" <mdares@rogers.com> schrieb im Newsbeitrag
news:ef07837.-1@webx.raydaftYaTP...
> Hello,
>
> I am trying to stream line our modeling to development phase of code
> generation for our group. Currently we are using TI C2000 DSPs, and
> would like to be using RTW with the C2000 target to automatically
> generate our control code from a simulink model. I have this working
> with very few problems.
>
> The problem is that we have some sections (functions) in the current
> production control code I want to leave alone which are written in
> assembler and C. What I would ideally like to be able to do is create
> a block which simulates the legacy function but which passes the
> legacy code to the complier when real time workshop builds the
> function.
>
> To explain this a different way I want to be able to model the legacy
> code in simulink (which is easy) but when RTW does the code
> generation for that block(s) I want it to pass my legacy assembler/C
> code to the compiler rather then generate it from that section of the
> model.
>
> I know this is somewhat confusing to read, but I would appreciate any
> help,
>
> Matthew



riccardo

2005-05-31, 9:14 am

Titus Edelhofer wrote:
>
>
> Hi Matthew,
> the best (but also I admit, not the easiest way) is to write a
> non-inlined
> S-Function, i.e,
> - write a "usual" S-function in C, which simulates your legacy
> function
> - write a TLC-File for your S-function, which just passes your
> legacy
> code to RTW
>
> Titus
>
> "Matthew Dares" <mdares@rogers.com> schrieb im Newsbeitrag
> news:ef07837.-1@webx.raydaftYaTP...
> code
> and
automatically[color=darkred]
> working
> current
> in
> create
the[color=darkred]
> legacy
> assembler/C
of[color=darkred]
> the
appreciate[color=darkred]
> any
>
>
>


Matthew,
if you are lucky enough (i.e. depending on you legacy code) a TLC
wrapper may turn out to be what you need.
Have a look at the s-function builder block (same library as the
s-function block): if you can use it, the associated TLC wrapper is
generated automatically.
HTH
riccardo
riccardo~-_carrozzo~@-yahoo-~.~co-.uk~
(no tildes nor hyphens in my address)
Matthew Dares

2005-05-31, 4:05 pm

Thank you both,

I see how this works now, and a closer read of the documentation
would have served me well. I misunderstood the use of the tlc
wrappers.

Thanks,
Dares
Brad Phelan

2005-05-31, 4:05 pm

Matthew Dares wrote:
> Hello,
>
> The problem is that we have some sections (functions) in the current
> production control code I want to leave alone which are written in
> assembler and C. What I would ideally like to be able to do is create
> a block which simulates the legacy function but which passes the
> legacy code to the complier when real time workshop builds the
> function.


Matthew,

My company provides a blockset which enables you to inline legacy code
into the block diagram without any knowledge of the S-Function API or
having to write TLC. You just need to specify the location of the C file
s and header files and the code you wish to insert into the generated code.

The block parses your piece of C code and automatically assigns the
correct number of input and output ports.

If this is of interest to you then there is more detailed information here

http://xtargets.com/cms/XTargets-Ne...d-Blockset.html
http://xtargets.com/products/xteb/d...d_blockset.html

With regards to switching between two different control paths depending
on simulation or code generation have a look at the "environment
controller block" under the "signal routing" sub menu. This block has
two inputs "sim" and "rtw". The smart thing about the block is that all
blocks upstream from the "sim" port are eliminated during code
generation and that during simulation all blocks upstream from the "RTW"
port are ignored.


--
Brad Phelan
http://xtargets.com


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com