Quantcast

Documentation Center

  • Trial Software
  • Product Updates

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 sm5565CLConsm5565CLCon. Under the model's configuration parameter Simulink Real-Time option settings, the following settings are specified:

  • System target file: slrt.tlc

  • Specify target PC name: TargetPC1

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

Building the model will create the application, sm5565CLCon.dlm, 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
### Generated code for 'sm5565CLCon' is up to date because no structural, parameter or code replacement library changes were found.
### Successful completion of build procedure for model: sm5565CLCon
### Looking for target: TargetPC1
### Download model onto target: TargetPC1

Open, Build, and Download the Plant to TargetPC2

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

  • System target file: slrt.tlc

  • Specify target PC name: TargetPC2

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

Building the model will create the application, sm5565CLPla.dlm, 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
### Generated code for 'sm5565CLPla' is up to date because no structural, parameter or code replacement library changes were found.
### Successful completion of build procedure for model: sm5565CLPla
### Looking for target: TargetPC2
### Download model onto target: TargetPC2

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
Warning: The EraseMode property will be removed in a future release. 

Was this topic helpful?