Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Control Real-Time Application at Target Computer Command Line

The Simulink® Real-Time™ software provides a set of commands that you can use to interact with the real-time application after it has been loaded to the target computer. Using these commands, you can start and stop execution, configure and control the scopes for that application, and tune parameters.

These commands are useful with standalone real-time applications that are not connected to the development computer. You type commands directly from a keyboard attached to the target computer. As you start to type, a command window appears on the target computer screen.

The target computer commands are case-sensitive, but the arguments are not. For more information, see Target Computer Commands.

To read the target computer console log, call SimulinkRealTime.utils.getConsoleLog.

Trace Signals at Target Computer Command Line

After you have built and downloaded a real-time application to the target computer, you can use target computer commands to create and configure scopes.

To add signals to a scope, you must specify the signals by signal number. For more information, see Find Signal and Parameter Indexes.

  1. To start the real-time application, in the command line, type:

    start
  2. To add a target scope (scope 2), type:

    addscope 2

    The Simulink Real-Time software adds another scope graphic to the target computer monitor. The command window displays a message to indicate that the new scope has registered.

    Scope 2, created, type is target
  3. To add a signal (0) to the new scope, type:

    addsignal 2=0

    The command window displays a message to indicate that the new signal has registered.

    Scope 2, signal 0 added

    You can add more signals to the scope.

  4. To start scope 2, type:

    startscope 2

    The target scope 2 starts and displays the signals you added in the default format (graphical).

    If you add a target scope from the target computer, you must start that scope manually. If a target scope is in the model, starting the real-time application starts that scope automatically.

  5. To collapse scope 2 into an icon, type:

    hide Scope 2
  6. To expand scope 2 from an icon, type:

    show Scope 2
  7. To check the value of signal 0, type:

    s0

    The command window displays a message to show the value of signal 0.

    S0 has value 5.1851
  8. To stop scope 2, type:

    stopscope 2
  9. To change the number of samples (to 1000) to acquire in scope 2, type:

    numsamples 2=1000

    You must stop the scope before changing a scope parameter.

  10. To start scope 2, type:

    startscope 2

    The target scope 2 starts and displays the signal values with the updated sample count.

  11. To stop scope 2, type:

    stopscope 2
  12. To stop the real-time application, type:

    stop

Tune Parameters at Target Computer Command Line

After you have built and downloaded a real-time application to the target computer, you can use target computer commands to tune parameters.

To tune parameters, you must specify them by parameter number. For more information, see Find Signal and Parameter Indexes.

  1. To check the frequency of the signal generator (parameter 6) of the model xpcosc, type:

    p6

    The command window displays a message to indicate that the new parameter has registered.

    p[6] is set to 20.00000
  2. To change the frequency of the signal generator, type:

    setpar 6=30

    The command window displays a message to indicate that the new parameter has registered.

    p[6] is set to 30.00000

    The target computer command setpar does not work for vector parameters.

  3. To change the stop time to 1000, type:

    stoptime = 1000

    The parameter changes are made to the real-time application but not to the target object. When you type a Simulink Real-Time command in the MATLAB® Command Window, the target computer returns the current properties of the target object.

Alias Commands at Target Computer Command Line

You can use target computer command-line variables to tag (or alias) unfamiliar commands, parameter indexes, and signal indexes with more descriptive names.

  1. To create the aliases on and off for a parameter (7) that controls a motor, type:

    setvar on = p7 = 1
    setvar off = p7 = 0
    

    The target computer command window is activated when you start to type, and a command line opens.

  2. To run a command sequence, type the variable name. For example, to turn on the motor, type:

    on
    

    The parameter P7 is changed to 1, and the motor turns on.

Find Signal and Parameter Indexes

To find signal and parameter indexes using MATLAB language:

  1. Build and download the model to the target computer.

  2. At the Command Line, type:

    tg = slrt
    
    Target: TargetPC1
       Connected         = Yes
       Application       = xpcosc
    .
    .
    .
       Scopes            = No Scopes defined  
       NumSignals        = 7
       ShowSignals       = off
    
       NumParameters     = 7
       ShowParameters    = off
    
  3. To display signal numbers, type:

    tg.ShowSignals='on'
    
    Target: TargetPC1
       Connected         = Yes
       Application       = xpcosc
    .
    .
    .
       Scopes            = No Scopes defined  
       NumSignals        = 7
       ShowSignals       = on
       Signals           = INDEX   VALUE          BLOCK NAME       . . .
                           0       0.000000       Gain             . . .
                           1       0.000000       Gain1            . . .
                           2       0.000000       Gain2            . . .
                           3       0.000000       Integrator       . . .
                           4       0.000000       Integrator1      . . .
                           5       0.000000       Signal Generator . . .
                           6       0.000000       Sum              . . .
    
    
       NumParameters     = 7
       ShowParameters    = off
    

    Use the Signals INDEX number in target computer commands such as addsignal.

  4. To display parameter numbers, type:

    tg.ShowParameters='on'
    
    Target: TargetPC1
       Connected         = Yes
       Application       = xpcosc
    .
    .
    .
       NumParameters     = 7
       ShowParameters    = on
       Parameters        = INDEX   VALUE   . . .  PARAMETER NAME   . . .
                           0       1000000 . . .  Gain             . . .
                           1       400     . . .  Gain             . . .
                           2       1000000 . . .  Gain             . . .
                           3       0       . . .  InitialCondition . . .
                           4       0       . . .  InitialCondition . . .
                           5       4       . . .  Amplitude        . . .
                           6       20      . . .  Frequency        . . .
    

    Use the Parameters INDEX number in target computer commands such as setpar.

See Also

Related Topics

Was this topic helpful?