Change E-Stop so that it can also work with one string

- Also optimized CV charging
This commit is contained in:
Matthias Heisig
2025-10-07 16:23:37 +02:00
parent 8ea7fd74e2
commit eaaa2371e8
16 changed files with 689 additions and 346 deletions

View File

@@ -8,6 +8,7 @@ VAR_INPUT
rKp : REAL;
rTn : REAL;
xEnable : BOOL;
xSaturated : BOOL := FALSE;
END_VAR
VAR_OUTPUT
@@ -19,6 +20,9 @@ VAR
_rIntegral : REAL := 0.0;
_rProportinal : REAL := 0.0;
_rErrorSign : REAL;
_xHoldIntegrator : BOOL;
_fbGetCurTaskIdx : GETCURTASKINDEX;
_rT : REAL;
END_VAR
@@ -31,10 +35,18 @@ _rError := rSP - rPV;
_rProportinal := rKp * _rError;
// Calculate controller output
rMV := _rProportinal + _rIntegral;
IF xEnable THEN
rMV := _rProportinal + _rIntegral;
ELSE
rMV := 0.0;
END_IF
_rErrorSign := _rError * rMV;
_xHoldIntegrator := xSaturated AND (_rErrorSign > 0);
// Stop integrator if saturated
IF (NOT xSaturated) AND (rTn <> 0) THEN
IF (NOT _xHoldIntegrator) AND (rTn <> 0) THEN
_rIntegral := _rIntegral + (rKp * _rT / rTn) * _rError;
END_IF
@@ -56,7 +68,7 @@ END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[// Get current task time
_fbGetCurTaskIdx();
_rT := UDINT_TO_LREAL(TwinCAT_SystemInfoVarList._TASKInfo[_fbGetCurTaskIdx.index].CycleTime) * 10E-5;]]></ST>
_rT := LREAL_TO_REAL(UDINT_TO_LREAL(TwinCAT_SystemInfoVarList._TASKInfo[_fbGetCurTaskIdx.index].CycleTime) * 10E-5);]]></ST>
</Implementation>
</Method>
<Action Name="Reset" Id="{4227580c-e163-4250-9575-dd60ff3083af}">