Simulink RTW IO handling

Hello,
I am building a model in Simulink, with two levels of IO. In the root level I have input pins (right now specified as ports) that are meant to be written to by a model every step. Think of it as the valve position. Under the root level I have different subsystems, and I have constants that I want to be read from a database. Like 'K_Bias'. These will be held somewhere and written in.
In simulation I could fool Simulink into running by writing a m-file, but in this application I want to leave in handles to that my model calling the .exe can fill in the constants and input my signal. When I try to compile, I get the Block Error "error evaluating parameter" saying its an undefined function/variable. How do I work around this error? I was trying to understand placing variables as globally tunable and inline signals...but the documentation is a bit over my head.
Final note, running 2010b, have all the needed licenses/toolboxes.
Thanks in advance, Becky

6 Comments

I'm sorry - I have some trouble understanding your question. Did you mean that your root-level inputs are being imported from a MATLAB-file during simulation, but after code generation, you want to be able to feed your own inputs to the generated EXE? If yes, you simply have to modify the main() in the generated code to interface with your code that generates the inputs. Search your help documentation for the demo titled "Integrating the Generated Code into the External Environment" for an example.
B. J.
B. J. on 25 Apr 2011
Hi,
Yes, I was trying to say I'm having in trouble compiling the handles for these signals. Do I have to modify the main program in C, or is there a setting in Simulink I can set so that it understands to call for this variable.
How does your external program define/declare the required input data? You could either modify the main program, or use Simulink.Signal objects for your root I/O ports as described in the section "Signal Considerations": http://www.mathworks.com/help/toolbox/rtw/ug/f1070804.html
Specifically, see "Interfacing Signals to External Code".
B. J.
B. J. on 26 Apr 2011
Hi,
I was trying to find the equivalent in 2010b...I can't get to the signal considerations or find anyway to declare them.
B. J.
B. J. on 26 Apr 2011
Hmm...I must be explaining this wrong. Okay, so I have a simple simulink model. I am having trouble defining the IO properly to compile down to C. I do want to use the RTW to build it, without dependancies on any m-files. I get the error "Error evaluating parameter 'Value' in 'Proposedcontrol/Controls/AttStmTempSP/Constant6': Undefined function or variable 'ATTout_TsatB'.".
The ATTout_TsatB is a constant block that I want to be passed from an external source.
I know I can't define it as a constant block, so I tried a port. Problem is, I am going to have two different ports objectives - one will be to input something from a temperature signal, the other this constant. I'd like to have it be efficient in terms of knowing Port1 is a constant - don't scan and keep checking for it, and Port2 every step update. This is a 'like' not a 'need' for my system.
One option for you is to use the Environment Controller block (http://www.mathworks.com/help/toolbox/simulink/slref/environmentcontroller.html). You connect the Constant block to the "Sim" input and the Inport block to the "Coder" input.

Sign in to comment.

Answers (1)

B. J.
B. J. on 17 Jun 2011

0 votes

My fix was to just create two programs - one for compiling with ports, one for testing with constants. It works, even if a bit much to maintain two programs.

1 Comment

Becky: You could also consider using Model Reference for your main algorithm, and then reference that from two harness models. That way, you have only one copy of your algorithm.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Asked:

on 25 Apr 2011

Community Treasure Hunt

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

Start Hunting!