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.

Distributed Closed-Loop Control with GE® Fanuc PCI-5565 Boards

This example shows a closed-loop control system using two Simulink® Real-Time™ models communicating over shared memory. The controller and plant models run on separate target computers and run at different rates. The controller has a sample time of 10 msec and the plant has a sample time of 1 msec. Communication between the controller and plant is accomplished over shared/reflective memory using GE® Fanuc PCI-5565 boards. Both the PCI-5565PIORC and the (formerly VMIC) VMIPCI-5565 boards are supported.

The MATLAB® script, sm5565CLPartDef.m, constructs the node and partition read/write buffers. This script is executed in the PreLoadFcn callback of each model as found under File --> Model Properties.

Open, Build, and Download the Controller to TargetPC1

Open the controller model sm5565CLCon. Under the model's configuration parameter Simulink Real-Time option settings, the following settings are specified:

  • System target file: slrt.tlc

  • Specify target computer name: TargetPC1

  • Name of Simulink Real-Time object created by build process: tgC

Building the model will create the application, sm5565CLCon.mldatx, which is downloaded to TargetPC1.

% Open the controller model and send/receive subsystems.
mdl='sm5565CLCon';
mdlOpen = 0;
systems = find_system('type', 'block_diagram');
if ~any(strcmp(mdl, systems))
  mdlOpen = 1;
  open_system(mdl);
end

open_system([mdl,'/Remote Interface Send']);

open_system([mdl,'/Remote Interface Receive']);

% Build the model and download to the controller target computer, TargetPC1.
set_param(mdl,'RTWVerbose','off'); % Configure for a non-Verbose build.
rtwbuild(mdl);                     % Build and download application.

% Close the model if we opened it.
if (mdlOpen)
  bdclose(mdl);
end
### Starting Simulink Real-Time build procedure for model: sm5565CLCon
Warning: This model contains blocks that do not handle sample time
changes at runtime. To avoid incorrect results, only change
the sample time in the original model, then rebuild the model. 
### Successful completion of build procedure for model: sm5565CLCon
### Looking for target: SLRTLABTGT8
### Download model onto target: SLRTLABTGT8

Open, Build, and Download the Plant to TargetPC2

Open the plant model sm5565CLPla. Under the model's configuration parameter Simulink Real-Time option settings, the following settings are specified:

  • System target file: slrt.tlc

  • Specify target computer name: TargetPC2

  • Name of Simulink Real-Time object created by build process: tgP

Building the model will create the application, sm5565CLPla.mldatx, which is downloaded to TargetPC2.

% Open the plant model and send/receive subsystems.
mdl='sm5565CLPla';
mdlOpen = 0;
systems = find_system('type', 'block_diagram');
if ~any(strcmp(mdl, systems))
  mdlOpen = 1;
  open_system(mdl);
end

open_system([mdl,'/Remote Interface Send']);

open_system([mdl,'/Remote Interface Receive']);

% Build the model and download to the plant target computer, TargetPC2.
set_param(mdl,'RTWVerbose','off'); % Configure for a non-Verbose build.
rtwbuild(mdl);                     % Build and download application.

% Close the model if we opened it.
if (mdlOpen)
  bdclose(mdl);
end
### Starting Simulink Real-Time build procedure for model: sm5565CLPla
Warning: This model contains blocks that do not handle sample time
changes at runtime. To avoid incorrect results, only change
the sample time in the original model, then rebuild the model. 
### Successful completion of build procedure for model: sm5565CLPla
### Looking for target: SLRTLABTGT9
### Download model onto target: SLRTLABTGT9

Run Both Models

Using the Simulink Real-Time object variables tgC and tgP, start the models.

start(tgP);                              % Start plant model.
start(tgC);                              % Start controller model.
pause(6);                                % Wait while the models run.

Display the Controller Target Computer Scope

Display of the closed-loop step response.

tgC.viewTargetScreen

% EOF sm5565CLDemo.m

Was this topic helpful?