Real-Time Workshop    

The Download Mechanism

In external mode, Simulink does not simulate the system represented by the block diagram. By default, when external mode is enabled, Simulink downloads current values of all parameters to the target system. After the initial download, Simulink remains in a waiting mode until you change parameters in the block diagram or until Simulink receives data from the target.

When you change a parameter in the block diagram, Simulink calls the external interface MEX-file, passing new parameter values (along with other information) as arguments.

The external interface MEX-file contains code that implements one side of the interprocess communication (IPC) channel. This channel connects the Simulink process (where the MEX-file executes) to the process that is executing the external program. The MEX-file transfers the new parameter values via this channel to the external program.

The other side of the communication channel is implemented within the external program. This side writes the new parameter values into target's parameter structure (rtP).

The Simulink side initiates the parameter download operation by sending a message containing parameter information to the external program. In the terminology of client/server computing, the Simulink side is the client and the external program is the server. The two processes can be remote, or they can be local. Where the client and server are remote, a protocol such as TCP/IP is used to transfer data. Where the client and server are local, shared memory can be used to transfer data.

The following diagram illustrates this relationship

Simulink calls the external interface MEX-file whenever you change parameters in the block diagram. The MEX-file then downloads the parameters to the external program via the communication channel.

.

Figure 6-11: External Mode Architecture


  External Mode Communications Overview Inlined and Tunable Parameters