220 lines
9.8 KiB
Plaintext
220 lines
9.8 KiB
Plaintext
// FB1809
|
|
// Block Type: FB
|
|
// Block Name (Original): SyrBrix Autocorrection
|
|
// Block Number: 1809
|
|
// Original Network Languages: LAD
|
|
// Block Comment:
|
|
// Syrup Autocorrection means that the measured syrup brix AND syrup density from
|
|
// meter, are used instead
|
|
// OF the one from the recipe, TO calculate the volumetric ratio.
|
|
// Activated only IF the beverage is sugar based.
|
|
|
|
FUNCTION_BLOCK "SyrBrix_Autocorrection"
|
|
{ S7_Optimized_Access := 'TRUE' }
|
|
VERSION : 0.1
|
|
|
|
VAR_INPUT
|
|
i_Value : Real;
|
|
i_Num : Int;
|
|
i_Enable : Bool;
|
|
END_VAR
|
|
|
|
VAR_OUTPUT
|
|
FilterOut : Real;
|
|
END_VAR
|
|
|
|
VAR_STAT
|
|
mProdSyrFact : Real;
|
|
mSyrMFMFact : Real;
|
|
mAuxONS : Bool;
|
|
mAuxONS1 : Bool;
|
|
mAuxONS2 : Bool;
|
|
mSyrBrix_AutoCorrReqTPON : Bool;
|
|
Syrup_Fact_Fltd : "LowPassFilter";
|
|
SyrupMFM_Fact_Fltd : "LowPassFilter";
|
|
mSyrBrix_AutoCorrReqTP : "TP:v1.0";
|
|
END_VAR
|
|
|
|
VAR_TEMP
|
|
Latch_ONS : Bool;
|
|
sec2_ONS : Bool;
|
|
mProdSyrFactAcq : Bool;
|
|
mZeroTest : Bool;
|
|
mZeroTest1 : Bool;
|
|
SyrBrix : Real;
|
|
SyrBrixMaxCorr : Real;
|
|
SyrBrixMaxValveOp : Real;
|
|
END_VAR
|
|
|
|
BEGIN
|
|
|
|
// Network 1: (Original Language: LAD)
|
|
|
|
"Procedure_Variables"."SyrAuto_Corr"."Qualifier" := "gBlenderProdMode" AND "Blender_Variables_Pers"."gSugarBeverage" AND "Procedure_Variables"."First_Production"."Done" AND "gBlenderSuppliesOk" AND NOT "Blender_Variables_Pers"."gWaterRecipe" AND NOT "gBlenderRinseMode";
|
|
|
|
// Network 2: SyrBrix_AutoCorrReq (Original Language: LAD)
|
|
|
|
// PBox SymPy processed, logic in consumer
|
|
"SyrAutoCorrReq" := "HMI_Variables_Cmd"."Commands_From_HMI"."CMD_SyrAutoReq" AND NOT "Procedure_Variables"."Syr_RunOut"."Latch"; // P_TRIG("HMI_Variables_Cmd"."Commands_From_HMI"."CMD_SyrAutoReq" AND NOT "Procedure_Variables"."Syr_RunOut"."Latch") - Mem: "SyrAutoCorrReq"
|
|
|
|
"Procedure_Variables"."SyrAuto_Corr"."Request" := ("Procedure_Variables"."Syr_RunOut"."Latch" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Latch") OR ("HMI_Variables_Cmd"."Commands_From_HMI"."CMD_SyrAutoReq" AND NOT "SyrAutoCorrReq" AND NOT "Procedure_Variables"."Syr_RunOut"."Latch");
|
|
|
|
// Network 3: (Original Language: LAD)
|
|
|
|
"Procedure_Variables"."SyrAuto_Corr"."Reset" := NOT "Procedure_Variables"."SyrAuto_Corr"."Qualifier";
|
|
|
|
// Network 4: (Original Language: LAD)
|
|
|
|
"Procedure_Variables"."SyrAuto_Corr"."Wait" := NOT "gBlenderEnToRamp" OR ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_SyrBrixMeter" AND "mPDS_SYR_PA_Data"."Input_From_mPDS"."gPAmPDS_CommErr") OR ("gFTP302_Fault" AND NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_SyrBrixMeter");
|
|
|
|
// Network 5: (Original Language: LAD)
|
|
|
|
"Procedure_Variables"."SyrAuto_Corr"."Latch" := ("Procedure_Variables"."SyrAuto_Corr"."Request" AND NOT "AUX Start CPU" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Done" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Reset" AND NOT "Procedure_Variables"."Syr_RunOut"."Done") OR ("Procedure_Variables"."SyrAuto_Corr"."Latch" AND NOT "AUX Start CPU" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Done" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Reset" AND NOT "Procedure_Variables"."Syr_RunOut"."Done");
|
|
|
|
// Network 6: MIX - (Original Language: LAD)
|
|
|
|
// Edge Logic handled by Coil 28_dup4
|
|
"SyrAutoCorrLatch" := "Procedure_Variables"."SyrAuto_Corr"."Latch"; // P_TRIG("Procedure_Variables"."SyrAuto_Corr"."Latch") - Mem: "SyrAutoCorrLatch"
|
|
|
|
"SyrAutoCorrLatch" := "Procedure_Variables"."SyrAuto_Corr"."Latch";; // P_TRIG("Procedure_Variables"."SyrAuto_Corr"."Latch") - Mem: "SyrAutoCorrLatch"
|
|
"Latch_ONS" := "Procedure_Variables"."SyrAuto_Corr"."Latch" AND NOT "SyrAutoCorrLatch";
|
|
|
|
"Procedure_Variables"."SyrAuto_Corr"."Running" := "Procedure_Variables"."SyrAuto_Corr"."Latch" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Wait";
|
|
|
|
// Network 7: (Original Language: LAD)
|
|
|
|
SyrBrix_SyrupCorrPerc();
|
|
|
|
// Network 8: MIX - Blender Variables - Persistent (Original Language: LAD)
|
|
|
|
// Edge Logic handled by Coil 26_dup1
|
|
"SyrAutoCorrBlink2Sec" := "AUX Blink_2.0S"; // P_TRIG("AUX Blink_2.0S") - Mem: "SyrAutoCorrBlink2Sec"
|
|
|
|
"SyrAutoCorrBlink2Sec" := "AUX Blink_2.0S";; // P_TRIG("AUX Blink_2.0S") - Mem: "SyrAutoCorrBlink2Sec"
|
|
"sec2_ONS" := "AUX Blink_2.0S" AND NOT "SyrAutoCorrBlink2Sec";
|
|
|
|
// Network 9: (Original Language: LAD)
|
|
|
|
"mProdSyrFactAcq" := "gBlenderEnToRamp" AND "gPV_SyrBrixOk" AND "sec2_ONS" AND "Procedure_Variables"."First_Production"."Done" AND "Procedure_Variables"."SyrAuto_Corr"."Qualifier";
|
|
|
|
// Network 10: (Original Language: LAD)
|
|
|
|
"mZeroTest" := Eq("mProdSyrFact", 0) OR Eq("Blender_Variables"."gProdRunSyrFact", 0);
|
|
|
|
// Network 11: (Original Language: LAD)
|
|
|
|
"mZeroTest1" := Eq("mSyrMFMFact", 0) OR Eq("Blender_Variables"."gProdRunSyrMFMFact", 0);
|
|
|
|
// Network 12: (Original Language: LAD)
|
|
// This segment calculates the Syrup Factor during the production, so when the
|
|
// Surup Run Out starts OR the Autocorrection is activated, the actual syrup brix
|
|
// doesn't change, the actual ratio doesn't change too
|
|
|
|
SEL_R(G := Eq("Blender_Variables"."gMeterSyrBrix", 0.0), IN0 := "Blender_Variables"."gMeterSyrBrix", IN1 := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupBrix");
|
|
|
|
"SyrBrix" := "SyrBrix" * "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupFactor";
|
|
|
|
"SyrBrix" := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupBrix" / "SyrBrix";
|
|
|
|
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_SyrBrixMeter" AND "mProdSyrFactAcq" AND NOT "mZeroTest" THEN
|
|
SEL_R(G := "Procedure_Variables"."Syr_RunOut"."Latch" OR "Procedure_Variables"."SyrAuto_Corr"."Latch", IN0 := "SyrBrix", IN1 := "mProdSyrFact");
|
|
END_IF;
|
|
|
|
// Network 13: (Original Language: LAD)
|
|
// This segment calculates the Syrup Factor during production, so when the Syrup
|
|
// Run Out starts OR the Autocorrection is activated, the actual syrup brix
|
|
// doesn't change, the actual ratio doesn't change too
|
|
|
|
SEL_R(G := Eq("Profibus_Variables"."gFTP302_Brix", 0.0), IN0 := "Profibus_Variables"."gFTP302_Brix", IN1 := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupBrix");
|
|
|
|
"SyrBrix" := "SyrBrix" * "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupFactor";
|
|
|
|
"SyrBrix" := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupBrix" / "SyrBrix";
|
|
|
|
IF "mProdSyrFactAcq" AND NOT "mZeroTest1" THEN
|
|
SEL_R(G := "Procedure_Variables"."Syr_RunOut"."Latch" OR "Procedure_Variables"."SyrAuto_Corr"."Latch", IN0 := "SyrBrix", IN1 := "mSyrMFMFact");
|
|
END_IF;
|
|
|
|
// Network 14: (Original Language: LAD)
|
|
|
|
IF "mZeroTest" OR "Procedure_Variables"."First_Production"."Latch" OR "gSyrBrixOutSpec_Fault" OR "gBlenderCIPMode" OR "gBlenderRinseMode" THEN
|
|
"mProdSyrFact" := 1.0;
|
|
"Blender_Variables"."gProdRunSyrFact" := 1.0;
|
|
END_IF;
|
|
|
|
// Network 15: (Original Language: LAD)
|
|
|
|
IF "mZeroTest1" OR "Procedure_Variables"."First_Production"."Latch" OR "gSyrBrixOutSpec_Fault" THEN
|
|
"mSyrMFMFact" := 1.0;
|
|
"Blender_Variables"."gProdRunSyrMFMFact" := 1.0;
|
|
END_IF;
|
|
|
|
// Network 16: (Original Language: LAD)
|
|
|
|
IF "mProdSyrFactAcq" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Latch" THEN
|
|
"Syrup_Fact_Fltd"(i_Enable := "AUX TRUE", i_Num := 12, i_Value := "mProdSyrFact");
|
|
END_IF;
|
|
|
|
// Network 17: (Original Language: LAD)
|
|
|
|
IF "mProdSyrFactAcq" AND NOT "Procedure_Variables"."SyrAuto_Corr"."Latch" THEN
|
|
"SyrupMFM_Fact_Fltd"(i_Enable := "AUX TRUE", i_Num := 12, i_Value := "mSyrMFMFact");
|
|
END_IF;
|
|
|
|
// Network 18: (Original Language: LAD)
|
|
// ??
|
|
|
|
IF "Procedure_Variables"."SyrAuto_Corr"."Request" AND "AUX FALSE" THEN
|
|
"HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupFactor" := "Blender_Variables"."gProdRunSyrFact" * "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupFactor";
|
|
END_IF;
|
|
|
|
"HMI_Variables_Cmd"."Recipe_Updates"."SyrFactUpdate" := "Procedure_Variables"."SyrAuto_Corr"."Request" AND "AUX FALSE";
|
|
|
|
// Network 19: MIX - Maximum Syrup Brix Autocorr Acheaved - minimum ratio - (Original Language: LAD)
|
|
|
|
"gMinRatio" := "HMI_PID"."RMP302"."Out" > 80.0;
|
|
|
|
// Network 20: MIX - Maximum Syrup Brix Autocorr Acheaved maximum autocorr per (Original Language: LAD)
|
|
// Creato due parametri per la Massima Correzzione.
|
|
// per la Produzione con Brix Sciroppo inferiori a 15 la massima correzzione
|
|
// passada 40 a 10. W.O.28/01/2025
|
|
|
|
"M1743.5" := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupBrix" <= 15.0;
|
|
|
|
IF "AUX TRUE" AND NOT "M_validat_27_01_25" AND NOT "M1743.5" THEN
|
|
"SyrBrixMaxCorr" := 40.0;
|
|
END_IF;
|
|
|
|
IF "AUX TRUE" AND "M1743.5" AND NOT "M_validat_27_01_25" THEN
|
|
"SyrBrixMaxCorr" := 10.0;
|
|
END_IF;
|
|
|
|
"gMaxSyrAutoCorrDone" := "HMI_Variables_Status"."Analog_Values"."SyrupBrixCorrection" > "SyrBrixMaxCorr";
|
|
|
|
_HMI_Alarms___gH_Status__8_ := "HMI_Variables_Status"."Analog_Values"."SyrupBrixCorrection" > "SyrBrixMaxCorr";
|
|
|
|
// Network 21: MIX - Maximum Syrup Brix Autocorr Acheaved - minimum ratio - (Original Language: LAD)
|
|
|
|
IF NOT "Procedure_Variables"."SyrAuto_Corr"."Latch" THEN
|
|
"gMinRatio" := FALSE;
|
|
END_IF;
|
|
|
|
IF NOT "Procedure_Variables"."SyrAuto_Corr"."Latch" THEN
|
|
"gMaxSyrAutoCorrDone" := FALSE;
|
|
END_IF;
|
|
|
|
// Network 22: (Original Language: LAD)
|
|
|
|
"HMI_Variables_Status"."Procedures"."SyrBrixAutoRun" := "Procedure_Variables"."SyrAuto_Corr"."Latch";
|
|
|
|
// Network 23: Syrup Autocorrection Running (Original Language: LAD)
|
|
// Message Syrup Autocorrection Running TO HMI
|
|
|
|
_HMI_Alarms___gH_Status__4_ := "Procedure_Variables"."SyrAuto_Corr"."Running";
|
|
|
|
// Network 24: (Original Language: LAD)
|
|
|
|
"Procedure_Variables"."SyrAuto_Corr"."Done" := ("Procedure_Variables"."SyrAuto_Corr"."Running" AND "gMinRatio" AND "Procedure_Variables"."Syr_RunOut"."Latch") OR ("Procedure_Variables"."SyrAuto_Corr"."Running" AND "gMaxSyrAutoCorrDone" AND "Procedure_Variables"."Syr_RunOut"."Latch") OR ("Procedure_Variables"."SyrAuto_Corr"."Request" AND NOT "Latch_ONS" AND NOT "Procedure_Variables"."Syr_RunOut"."Latch");
|
|
|
|
END_FUNCTION_BLOCK
|