Simulink: use of inport block to control parameters

Discussion in 'MATLAB' started by Nick Clark, Sep 27, 2010.

  1. Nick Clark

    Nick Clark Guest

    Hi all,
    Is there any way to use the inport block to control the rate of a sine generator, or other block parameters that can otherwise be set using Matlab workspace variables?

    Many thanks
    N
     
    Nick Clark, Sep 27, 2010
    #1
    1. Advertisements

  2. Nick Clark

    Nick Clark Guest

    bump
     
    Nick Clark, Sep 28, 2010
    #2
    1. Advertisements

  3. Nick Clark

    Phil Goddard Guest

    Yes and No.

    A signal, i.e. data that is being calculated/propagated down a black line and that "flows" though inports and outports, is very different from a parameter, i.e. data entered into a dialog box.

    Parameters are typically constant, and get evaluated during model initialization.
    Signals can/may/usually change from one time step to the next.

    Since the rate of the Sine Wave block is a parameter it cannot be controlled by a signal.

    However, in the specific case of a sine wave, you could construct what you want by using the Trigonometric Block, selecting it's sine wave option, and then constructing a signal with the correct rate being fed into it as a signal.

    Phil.
     
    Phil Goddard, Sep 28, 2010
    #3
  4. Nick Clark

    Nick Clark Guest

    Thanks for taking the time to write a response. It is appreciated.

    :)
    This is normally true but I am compiling my model as a DLL and wish to control the parameters in real time using an executable that calls the DLL. Anything that I can hook up to the inport block can be easily controlled in realtime. This is why I ask. for example, the end user may want to tweak a parameter in a GUI and get a feel for what effect that parameter change has on a running simulation.
    Thanks for the tip. That might solve one problem. However, I also need to change the filter coefficients in the digital FIR block in real time. If only I could add an extra input or two to the blocks.

    Any suggestions would be welcomed!

    Thanks again,
    Nick
     
    Nick Clark, Sep 28, 2010
    #4
  5. Nick Clark

    Phil Goddard Guest

    Many parameters are tunable in real-time code.
    (Are you using the dll target of the RTW Embedded Coder)
    This is to allow for easy tuning of things like gains in controllers and filters.
    Search the RTW doc for Tunable Parameters to see how to specify a block's parameter to be tunable.

    You'll most likely find that for a filter block the length (i.e. the number) of coefficients isn't tunable.
    That would require more/less memory to be allocated which RTW code typically does not do.

    Phil.
     
    Phil Goddard, Sep 28, 2010
    #5
  6. Nick Clark

    Nick Clark Guest

    ********************
    No. We currently do not have that product (Embedded Coder). A the moment I am using this guide:
    http://www.mathworks.com/matlabcentral/fileexchange/9709
    I have had some luck with this so far changing gain blocks to multiplication blocks and connecting an inport to one of the inputs. This is obviously not ideal though.
    ********************
    ********************
    I found a page in the RTW help titled:
    Parameter Storage, Interfacing, and Tuning

    I'll take a look and see if I get any inspiration.
    ********************
    ********************
    Makes sense. Hopefully I will not need to do that.
    Thanks again for your help.
    ********************
     
    Nick Clark, Sep 28, 2010
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.