Code covered by the BSD License  

Highlights from
ECALS (supervisory control of fermentors)

ECALS (supervisory control of fermentors)

by

 

30 Aug 2012 (Updated )

Enables supervisory control of bioreactors using arbitrary MATLAB functions via OPC

...
function [terminateFlag saveStateFlag logFlag caOutputs] = ...
cycle_tag( ...
    recipestepObj,...
    ~,...
    initFlag,...
    ~,...
    runTime,...
    ~)
%%
%CA
%CA  INPUTS
%CA
%CA  OUTPUTS
%CA     output_tag  double
%CA
%CA  PARAMETERS
%CA     value_1 double 25.0
%CA     value_1_stdev double 1.0
%CA     value_2 double 75.0
%CA     value_2_stdev double 0.0
%CA     duration_1_min double 5
%CA     duration_2_min double 5
%CA

% cycles the output tag between two values. Each of the two cycled values can
% have a randomized fluctuation. This function was developed to test a control
% communication problem.

saveStateFlag = false;
logFlag = false;
terminateFlag = false;  

% parameters
value_1         = recipestepObj.caParamStruct.value_1.value;
value_1_stdev   = recipestepObj.caParamStruct.value_1_stdev.value;
value_2         = recipestepObj.caParamStruct.value_2.value;
value_2_stdev   = recipestepObj.caParamStruct.value_2_stdev.value;
duration_1_min  = recipestepObj.caParamStruct.duration_1_min.value;
duration_2_min  = recipestepObj.caParamStruct.duration_2_min.value;

if(initFlag)
    recipestepObj.caData.current_value = value_1;
    recipestepObj.caData.change_time = runTime + duration_1_min;
    output = value_1;
end

if runTime >= recipestepObj.caData.change_time
    switch recipestepObj.caData.current_value
        case value_1
            recipestepObj.caData.current_value = value_2;
            recipestepObj.caData.change_time = runTime + duration_2_min*60;
        case value_2
            recipestepObj.caData.current_value = value_1;
            recipestepObj.caData.change_time = runTime + duration_1_min*60;
    end
end

% apply random noise
switch recipestepObj.caData.current_value
    case value_1
        output = value_1 + value_1_stdev*(rand-rand);
    case value_2
        output = value_2 + value_2_stdev*(rand-rand);
end


%%%%%%%%%%%%%%% BEGIN OUTPUTS ASSIGNMENT %%%%%%%%%%%%%%%%%
caOutputs.output_tag           = output;

Contact us