The Simulink® Real-Time™ software has a Web server that allows you to interact with your real-time application through a Web browser. You can access the Web browser with either an Ethernet or serial (RS-232) connection.
Note: RS-232 communication type will be removed in a future release. Use TCP/IP instead.
The Simulink Real-Time Web server is built into the kernel that allows you to interact with your real-time application using a Web browser. If the target computer is connected to a network, you can use a Web browser to interact with the real-time application from a development computer connected to the network.
If your development computer and target computer are connected with a network cable, you can connect the real-time application on the target computer to a Web browser on the development computer.
The TCP/IP stack on the Simulink Real-Time kernel supports only one simultaneous connection, because its main objective is real-time applications. This connection is shared between the MATLAB® interface and the Web browser. You must close the other open connections to the target computer before you connect using the development computer Web browser. This also means that only one browser or the MATLAB interface is able to connect at one time.
Note: Close the other connections to the target computer. For example, if you are currently connected to the target computer through Simulink Real-Time Explorer, right-click on that target computer icon and select Disconnect or click the Disconnect icon on the toolbar.
In the MATLAB window, type
The MATLAB interface is disconnected from the target computer, and the connection is reset for connecting to another client. If you do not use this command immediately before opening the Web interface, your browser might not be able to connect to the target computer.
Open a Web browser. In the address box, enter the IP address and port number you entered in the Simulink Real-Time Explorer window. For example, if the target computer IP address is 192.168.0.10 and the port is 22222, type
The browser loads the Simulink Real-Time Web interface frame and panes.
If the development computer and target computers are connected with a serial cable instead of a network cable, you can still connect the real-time application on the target computer to a Web browser on the development computer. The Simulink Real-Time software includes a TCP/IP to RS-232 mapping program. This program runs on the development computer and writes whatever it receives from the RS-232 connection to a TCP/IP port, and it writes whatever is receives from the TCP/IP port to the RS-232 connection. TCP/IP port numbers must be less than 216 = 65536.
In the MATLAB window, type
The MATLAB interface is disconnected from the target computer, leaving the target computer ready to connect to another client. The TCP/IP stack of the Simulink Real-Time kernel supports only one simultaneous connection. If you do not use this command, the TCP/IP to RS-232 gateway might not be able to connect to the target computer.
Open a DOS command window, and enter
the command to start the TCP/IP to RS-232 gateway. For example, if
the target computer is connected to COM1 and you would like to use
the TCP/IP port
22222, type the following:
c:\<MATLAB root>\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -v -t 22222 -c 1
For a description of the
see Syntax for the xpctcp2ser Command.
The TCP/IP to RS-232 gateway starts running, and the DOS command window displays the message
*--------------------------------------------------------------* * Simulink Real-Time TCP/IP to RS-232 gateway * * Copyright 2000 The MathWorks * *--------------------------------------------------------------* Connecting COM to TCP port 22222 Waiting to connect
If you did not close the MATLAB to real-time application
xpxtcp2ser displays the message
not initialize COM port.
Open a Web browser. In the address box, enter
The Web browser loads the Simulink Real-Time Web interface panes.
Using the Web interface, start and stop the real-time application, add scopes, add signals, and change parameters.
In the DOS command window, press Ctrl+C.
The TCP/IP to RS-232 Gateway stops running, and the DOS command window displays the message
interrupt received, shutting down
The gateway program has a handler that responds to Ctrl+C by disconnecting and shutting down cleanly. In this case, Ctrl+C is not used to abort the real-time application.
In the MATLAB Command Window, type
The MATLAB interface reconnects to the real-time application and lists the properties of the target object.
If you did not close the gateway program, the MATLAB window displays the message
Error in ==> C:\MATLABR13\toolbox\rtw\targets\xpc\xpc\@xpc\xpc.m On line 31 ==> sync(xpcObj);
You must close the MATLAB interface and then restart it.
xpctcp2ser command starts the TCP/IP
to RS-232 gateway. The syntax for this command is
xpctcp2ser [-v] [-n] [-t tcpPort] [-c comPort] xpctcp2ser -h
The options are described in the following table.
Command- Line Option
Verbose mode. Produces a line of output every time a client connects or disconnects.
Allows nonlocal connections. By default, only clients from the same computer that the gateway is running on are allowed to connect. This option allows anybody to connect to the gateway.
you do not use this option, only the development computer that is
connected to the target computer with a serial cable can connect to
the selected port. For example, if you start the gateway on your development
computer, with the default ports, you can type in the Web browser
Use TCP port
Print a help message.
Use COM port
The Main pane is divided into four parts, one below the other. The four parts are System Status, Simulink Real-Time Properties, Navigation, and WWW Properties.
After you connect a Web browser to the target computer, you can use the Main pane to control the real-time application:
In the left frame, click the Refresh button.
System status information in the top cell is uploaded from the target computer. If the right frame is either the Signals List pane or the Screen Shot pane, updating the left frame also updates the right frame.
Click the Start Execution button.
The real-time application begins running on the target computer, the Status line is changed from Stopped to Running, and the Start Execution button text changes to Stop Execution.
Update the execution time and average task execution time (TET). Click the Refresh button. To stop the real-time application, click the Stop Execution button.
Enter new values
in the StopTime and SampleTime boxes, then click the Apply button. You can enter
the StopTime box for an infinite
The new property values are downloaded to the real-time application. Note that the SampleTime box is visible only when the real-time application is stopped. You cannot change the sample time while a real-time application is running. (See Alternative Configuration and Control Methods for limitations on changing sample times.)
Select scopes to view on the target computer. From the ViewMode list, select one or all of the scopes to view.
After entering values, the screen looks like this:
Note: The ViewMode control is visible in the Simulink Real-Time Properties pane only if you add two or more scopes to the target computer.
The WWW Properties cell in the left frame contains fields that control the display on the Web interface itself, and not the real-time application. There are two fields: maximum signal width to display and refresh interval.
In the Maximum
Signal Width box enter
only scalar signals),
2 (show scalar and vector
signals less than or equal to 2 wide), or
signals with a width less than or equal to
Signals with a width greater than the value you enter are not displayed on the Signals pane.
In the Refresh Interval box, enter a value greater than 10. For example, enter 20.
The signal pane updates automatically every 20 seconds. Entering
not automatically refresh the pane.
Sometimes, both the frames try to update simultaneously, or
the auto refresh starts before the previous load has finished. This
problem can happen with slow network connections. In this case, increase
the refresh interval or manually refresh the browser (set the Refresh Interval =
This can also happen when you are trying to update a parameter or property at the same time that the pane is automatically refreshing.
Sometimes, when a race condition occurs, the browser becomes confused about the format, and you might have to refresh it. This should not happen often.
The Signals pane is a list of the signals in your model.
After you connect a Web browser to the target computer you can use the Signals pane to view signal data:
In the left frame, click the Signals button.
The Signals pane is loaded in the right frame with a list of signals and the current values.
On the Signals pane in the right frame, click the Refresh button.
The Signals pane is updated with the current values. Vector/matrix signals are expanded and indexed in the same column-major format that the MATLAB interface uses. This can be changed by the Maximum Signal Width value you enter in the left frame.
In the left frame, click the Screen Shot button.
The Screen Shot pane is loaded and a copy of the current target computer screen is displayed. The screen shot uses the portable network graphics (PNG) file format.
The Parameters pane displays the tunable parameters in your model. Row and column indices for vector/matrix parameters are also shown.
After you connect a Web browser to the target computer, you can use the Parameters pane to change parameters in your real-time application while it is running in real time:
In the left frame, click the Parameters button.
The Parameter List pane is loaded into the right frame.
If the parameter is a scalar parameter, the current parameter value is shown in a box that you can edit.
If the parameter is a vector or matrix, click the Edit button to view the vector or matrix. You can edit the parameter in this pane.
In the Value box, enter a new parameter value, and then click the Apply button.
The Web browser interface allows you to set access levels to the real-time application. The different levels limit access to the real-time application. The highest level, 0, is the default level and allows full access. The lowest level, 4, only allows signal monitoring and tracing with your real-time application.
In the Simulink window, click Simulation > Model Configuration Parameters.
The Configuration Parameters dialog box for the model is displayed.
Click the Code Generation node.
The code generation pane opens.
In the Target
selection section, access levels are set in the System target file box. For example, to set
the access level to
If you do not specify
the highest access level (
0) is set.
The various fields disappear, depending on the access level. For example, if your access level does not allow you access to the parameters, you do not see the button for parameters.
There are various access levels for monitoring, which allow different levels of hiding. The proposed setup is described below. Each level builds on the previous one, so only the incremental hiding of each successive level is described.
Level 0 — Full access to the panes and functions.
Level 1 — Cannot change the sample and stop times. Cannot change parameters, but can view parameters.
Level 2 — Cannot start and stop execution of the real-time application or log data.
Level 3 — Cannot view parameters. Cannot add new scopes, but can edit existing scopes.
Level 4 — Cannot edit existing scopes on the Scopes pane. Cannot add or remove signals on the Scopes pane. Cannot view the Signals pane and the Parameters pane, and cannot get scope data.