Change E-Stop so that it can also work with one string
- Also optimized CV charging
This commit is contained in:
@@ -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}">
|
||||
|
||||
Reference in New Issue
Block a user