Obsidean_VM/04-SIDEL/00 - MASTER/Source/source/FillerControl.md

10 KiB

// Block Type: FC
// Block Number: 2028
// Original Network Languages: STL, LAD

FUNCTION "FillerControl" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1

VAR_TEMP
  Buffer : Bool;
  EnableNextRecipe : Int;
  mFillerTracked : Bool;
  mAuxCalc : Real;
  mAuxCalc1 : DInt;
  mAuxRunOut : Int;
  mAuxProdTemp : Int;
  mAuxProductCarbo : Int;
  mAuxProdTankPress : Int;
  mAuxRecCarbo : Real;
  mAuxProdCO2PressSP : Real;
END_VAR

BEGIN

  // Network 1: To Filler Production (Original Language: LAD)

  "gOUT_FillerProduction" := ("gBlenderProdMode" AND "gBlenderRinseMode") OR ("gBlenderProdMode" AND "System_RunOut_Variables"."FastChangeOverActivated");

  // Network 2: #mFillerTracked (Original Language: LAD)

  "mAuxCalc" := "Blender_Variables"."gMinProduction" / 2.0;

  "mAuxCalc" := "Blender_Variables"."gEstimateFillerSpeed" + "mAuxCalc";

  "mFillerTracked" := "Blender_Variables"."gActual_Prod_SP" >= "mAuxCalc";

  // Network 3: To Filler Product Available (Original Language: LAD)

  "gProdAvailable" := "gBlenderProdMode" AND "Procedure_Variables"."First_Production"."Done" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Latch";

  // Network 4: To Filler Minimum Level (Original Language: LAD)

  "gOUT_FillerMinimumLevel" := "gBlenderLevelOk" AND "gProdAvailable";

  // Network 5: To Filler Product Available (Original Language: LAD)

  "gOUT_FillerProductAvail" := ("gPrdTank_Empty" AND "gIN_VoltageOk" AND "gPrdTank_Press_Fault" AND "HMI_Device"."PPM303"."Alarm" AND "gProdAvailable") OR ("gIN_VoltageOk" AND "gPrdTank_Press_Fault" AND "HMI_Device"."PPM303"."Alarm" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Latch" AND "gProdAvailable");

  // Network 6: RunOut Request (Original Language: LAD)

  "System_RunOut_Variables"."Out_Flr_FillerRunOutReq" := "System_RunOut_Variables"."ToFillerProdRunOut";

  // Network 7: Product Completed (Original Language: LAD)

  "System_RunOut_Variables"."Out_Flr_ProductCompleted" := "System_RunOut_Variables"."ToFillerProductCompleted";

  // Network 8: Filler RunOut (Original Language: LAD)

  // PBox SymPy processed, logic in consumer
  "M19013" := "System_RunOut_Variables"."In_Flr_WaterRinseRequest" OR "System_RunOut_Variables"."In_Flr_LastContainer"; // P_TRIG("System_RunOut_Variables"."In_Flr_WaterRinseRequest" OR "System_RunOut_Variables"."In_Flr_LastContainer") - Mem: "M19013"

  IF ("System_RunOut_Variables"."In_Flr_WaterRinseRequest" AND NOT "M19013") OR ("System_RunOut_Variables"."In_Flr_LastContainer" AND NOT "M19013") THEN
    "System_RunOut_Variables"."FillerRanOut" := TRUE;
  END_IF;

  // Network 9: Fast Rinse Complete (Original Language: LAD)

  "System_RunOut_Variables"."FromFillerFastRinseCompl" := "System_RunOut_Variables"."In_Flr_FastRinseComplete";

  // Network 10: Fast Rinse Request (Original Language: LAD)

  // Network 10 did not produce printable SCL code.

  // Network 11: Water Rinse Ready (Original Language: LAD)

  "System_RunOut_Variables"."Out_Flr_WaterRinseReady" := ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" AND "Procedure_Variables"."Blender_Rinse"."Latch" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done") OR ("System_RunOut_Variables"."FillerTankRinseLoaded" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done" AND "System_RunOut_Variables"."FastChangeOverActivated") OR ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FillerRinseTank" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done" AND "System_RunOut_Variables"."FastChangeOverActivated");

  // Network 12: To Filler Rinse Mode (Original Language: LAD)

  "gOUT_FillerRinseMode" := "gBlenderRinseMode" AND "Procedure_Variables"."Blender_Run"."Latch";

  // Network 13: To Filler CIP Mode (Original Language: LAD)

  "gOUT_FillerCIPMode" := ("Procedure_Variables"."Blender_Run"."Latch" AND "gBlenderCIPMode" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_LocalCIP") OR ("Procedure_Variables"."Blender_Run"."Latch" AND "gBlenderCIPMode" AND "gIN_CIP_CIPMode");

  // Network 14: Caustic Recovery Run (Original Language: LAD)

  // PBox SymPy processed, logic in consumer
  "M19022" := "gIN_CIP_ChangeSanitize" AND "gWorkshopTest"; // P_TRIG("gIN_CIP_ChangeSanitize" AND "gWorkshopTest") - Mem: "M19022"

  // Network 15: To Filler CIP Running (Original Language: LAD)

  "gOUT_FillerCIPRunning" := ("gBlenderCIPMode" AND "HMI_Digital"."LSM302L"."Filtered" AND "gIN_CIP_CIPRunning") OR ("gBlenderCIPMode" AND "gBlenderMinLevel" AND "gIN_CIP_CIPRunning") OR ("Procedure_Variables"."Blender_Run"."Latch" AND "gBlenderCIPMode" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_LocalCIP" AND "HMI_Digital"."LSM302L"."Filtered" AND "gP_CIPRunning") OR ("Procedure_Variables"."Blender_Run"."Latch" AND "gBlenderCIPMode" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_LocalCIP" AND "gBlenderMinLevel" AND "gP_CIPRunning");

  // Network 16: To Filler CIP (Original Language: LAD)

  "gOUT_FillerCIPChangeSani" := ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_LocalCIP" AND "gP_CIPChangeSanitize") OR ("CIP_Program_Variables"."Status"."CausticRecoveryRun" AND "CIP_Program_Variables"."Status"."BlenderEmpty");

  // Network 17: To Filler CIP Drain Request (Original Language: LAD)

  "gOUT_FillerCIPDrainReq" := "gIN_CIP_DrainRequest" OR ("CIP_Program_Variables"."Status"."BlenderDrainRunning" AND "CIP_Program_Variables"."Status"."Completed");

  // Network 18: To Filler CIP Completed (Original Language: LAD)

  "gOUT_FillerCIPCompleted" := ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_LocalCIP" AND "CIP_Program_Variables"."Status"."Completed") OR ("gIN_CIP_CIPCompleted" AND "Interlocking_Variables"."FILLER_MIXER_RECEIVE"."CIP_Selected");

  // Network 19: Wait Filler Product Request After First Production (Original Language: LAD)
  //   Wait Filler Product Request After First Production

  "HMI_Alarms"."gH_Message" := ("gBlenderProdMode" AND "gFirstProdStop") OR ("gBlenderProdMode" AND "gFiilerStopBlender");

  // Network 20: Wait Filler Rinse Completed Signal (Original Language: LAD)
  //   Wait Filler Rinse Completed

  // PBox SymPy processed, logic in consumer
  "M19023" := "System_RunOut_Variables"."FastChangeOverActivated" AND "Procedure_Variables"."Blender_Rinse"."Running"; // P_TRIG("System_RunOut_Variables"."FastChangeOverActivated" AND "Procedure_Variables"."Blender_Rinse"."Running") - Mem: "M19023"

  // Network 21: Filler Loads next recipe (Original Language: LAD)
  //   Filler Loads next recipe on the rising edge OF the Product Completed Signal, so 
  //   AT that point the next recipe must be already selected.

  IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe" THEN
    "EnableNextRecipe" := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_FillerNextRecipeNum";
  END_IF;

  IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe" THEN
    "EnableNextRecipe" := 0;
  END_IF;

  IF "System_RunOut_Variables"."FastChangeOverActivated" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe" AND "Procedure_Variables"."Syr_RunOut"."Done" THEN
    "System_RunOut_Variables"."FillerNextRecipeNum" := "EnableNextRecipe";
  END_IF;

  IF "System_RunOut_Variables"."FastChangeOverActivated" OR "Procedure_Variables"."Syr_RunOut"."Done" THEN
    "System_RunOut_Variables"."FillerNextRecipeNum" := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_FillerNextRecipeNum";
  END_IF;

  "Buffer" := "System_RunOut_Variables"."FastChangeOverActivated" OR "Procedure_Variables"."Syr_RunOut"."Done";

  // Network 22: RunOut Amount (Original Language: LAD)

  // Network 22 did not produce printable SCL code.

  // Network 23: RunOut Amount (Original Language: STL)

  // --- BEGIN STL Network 23 ---
   
     	A_BRACK
     	L	"System_RunOut_Variables".TotalProductAvailable
     	DTR
     	T	"mAuxRunOut"
     	SET
     	SAVE
     	CLR
     	A	_Statusword_?
     	BRACKET
     	JNB	_007
     	L	"mAuxRunOut"
     	T	"MW116"
     _007:   		NOP_0
   
  // --- END STL Network 23 ---

  // Network 24: RunOut Amount (Original Language: LAD)

  "Interlocking_Variables"."SIDEL_FILLER_SEND_DATA"."Run_Out_Amount1" := "MB116";

  // Network 25: RunOut Amount (Original Language: LAD)

  "Interlocking_Variables"."SIDEL_FILLER_SEND_DATA"."Run_Out_Amount2" := "MB117";

  // Network 26: Product Temperature (Original Language: STL)

  // --- BEGIN STL Network 26 ---
   
     	A_BRACK
     	L	"HMI_PID".RVM319_H2O.Pv
     	RND
     	T	"mAuxProdTemp"
     	SET
     	SAVE
     	CLR
     	A	_Statusword_?
     	BRACKET
     	JNB	_008
     	L	"mAuxProdTemp"
     	T	"MB118"
     _008:   		NOP_0
   
  // --- END STL Network 26 ---

  // Network 27: Product Temperature (Original Language: LAD)

  "Interlocking_Variables"."SIDEL_FILLER_SEND_DATA"."Product_Temperature" := "MB118";

  // Network 28: mAuxRecCarbo (Original Language: LAD)

  "mAuxRecCarbo" := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_CO2Vols" * 10.0;

  // Network 29: AuxRecCarbo (Original Language: STL)

  // --- BEGIN STL Network 29 ---
   
     	A_BRACK
     	L	"mAuxRecCarbo"
     	RND
     	T	"mAuxProductCarbo"
     	SET
     	SAVE
     	CLR
     	A	_Statusword_?
     	BRACKET
     	JNB	_009
     	L	"mAuxProductCarbo"
     	T	"MB120"
     _009:   		NOP_0
   
  // --- END STL Network 29 ---

  // Network 30: Product Carbonation (Original Language: LAD)

  "Interlocking_Variables"."SIDEL_FILLER_SEND_DATA"."Product_Carbonation" := "MB120";

  // Network 31: Product C02 Pressure SP (Original Language: LAD)
  //   "Blender_Variables".gSP_CO2

  "mAuxProdCO2PressSP" := "HMI_PID"."RVM301"."Pv" * 10.0;

  // Network 32: Product C02 Pressure (Original Language: STL)

  // --- BEGIN STL Network 32 ---
   
     	A_BRACK
     	L	"mAuxProdCO2PressSP"
     	RND
     	T	"mAuxProdTankPress"
     	SET
     	SAVE
     	CLR
     	A	_Statusword_?
     	BRACKET
     	JNB	_00a
     	L	"mAuxProdTankPress"
     	T	"MB122"
     _00a:   		NOP_0
   
  // --- END STL Network 32 ---

  // Network 33: Product Tank Pressure SP (Original Language: LAD)

  "Interlocking_Variables"."SIDEL_FILLER_SEND_DATA"."Prod_Tank_Press_SP" := "MB122";

  // Network 34: Filler Data Send (Original Language: LAD)

  IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" THEN
    FillerControl_DataSend();
  END_IF;

  // Network 35: Next Recipe (Original Language: LAD)

  "Interlocking_Variables"."SIMO_FILLER_SEND_DATA"."Next_Recipe" := "System_RunOut_Variables"."FillerNextRecipeNum";

END_FUNCTION