%% Mapping Tunable Parameters to Structured Text
% 
% This model shows how to map tunable parameters from the Simulink(R) model to the
% generated Structured Text code.

%   Copyright 2012-2013 The MathWorks, Inc.

mdl = 'plcdemo_tunable_params';
load_system(mdl);
open_system('plcdemo_tunable_params/SimpleSubsystem');

%%
% This model shows the different implementations of tunable parameters in the generated code.
% It makes use of three parameters K1, K2, and K3 defined in the MATLAB base workspace. 
% To build the subsystem, right-click on the subsystem block and select PLC Code Generation > 
% Generate Code for Subsystem. The Diagnostic Viewer with hyperlinks to the generated code is 
% displayed automatically. 
% 

%%
% In this model:
%
% * K1 is set to "Auto" storage class
% * K2 is set to "ExportedGlobal" storage class 
% * K3 is set to "ExportedGlobal" constant storage class 
% 
% In the generated Structured Text code for compatible IDE targets:
%
% * K1 is mapped to a Function Block local variable
% * K2 is mapped to a global variable
% * K3 is mapped to a global constant 
% 
% For the RSLogix 5000 Add On Instruction (AOI) format:
%
% * K1 is mapped to an AOI local tag
% * K2 and K3 are mapped to AOI input tags
% 
% For the RSLogix 5000 Routine format:
%
% * K1 is mapped to routine instance tag
% * K2 and K3 are mapped to global program tags
% 
% See the Simulink PLC Coder documentation on tunable parameter code
% generation for more information.

%%
% You can generate PLC Structured Text code for this subsystem by 
% right-clicking on the subsystem block and select 
% PLC Code -> Generate Code for Subsystem
% Alternatively, you can use the following command
% generatedFiles = plcgeneratecode('plcdemo_tunable_params/SimpleSubsystem');

%%
% After the code generation, the Diagnostic Viewer window 
% is displayed with hyperlinks to the generated code files.
% You can open the generated files by clicking on the links.