Hello,
I want to create a FC function that uses SCL code that checks deviation of a controllers actual measured value from its setpoint and then gives an alarm if the actual measured value is above or below the setpoint by a certain %. The alarm should be delayed by 15 seconds. I have some code that I am trying to use but I am not sure how to incorporate an SFB4 TON into the SCL source code. Can someone help me to understand how to use the SFB4 so I can trigger it within the function and give the alarm after 15 seconds?
VAR_INPUT
nFlowSetpointNs: INT; // Flow Nominal Setpoint
nFlowMe: DINT; // Flow Actual Measurement
nFlowDevUpPercentNs: DINT; // Flow Deviation Setpoint Upper Percentage
nFlowDevLowPercentNs: DINT; // Flow Deviation Setpoint Lower Percentage
tFlowDevTimeDly: TIME; // Flow Deviation Time Delay Nominal Setpoint
END_VAR
Var_OUTPUT
bFlowDeviationAlarmSt :BOOL; // Flow Deviation Alarm Status
END_VAR
BEGIN
IF nFlowMe < nFlowSetpointNs * nFlowDevUpPercentNs OR nFlowMe > nFlowSetpointNs / nFlowDevLowPercentNs
THEN bFlowDeviationAlarmSt := True;
ELSE bFlowDeviationAlarmSt := False;
END_IF;
Thanks
Peter
I want to create a FC function that uses SCL code that checks deviation of a controllers actual measured value from its setpoint and then gives an alarm if the actual measured value is above or below the setpoint by a certain %. The alarm should be delayed by 15 seconds. I have some code that I am trying to use but I am not sure how to incorporate an SFB4 TON into the SCL source code. Can someone help me to understand how to use the SFB4 so I can trigger it within the function and give the alarm after 15 seconds?
VAR_INPUT
nFlowSetpointNs: INT; // Flow Nominal Setpoint
nFlowMe: DINT; // Flow Actual Measurement
nFlowDevUpPercentNs: DINT; // Flow Deviation Setpoint Upper Percentage
nFlowDevLowPercentNs: DINT; // Flow Deviation Setpoint Lower Percentage
tFlowDevTimeDly: TIME; // Flow Deviation Time Delay Nominal Setpoint
END_VAR
Var_OUTPUT
bFlowDeviationAlarmSt :BOOL; // Flow Deviation Alarm Status
END_VAR
BEGIN
IF nFlowMe < nFlowSetpointNs * nFlowDevUpPercentNs OR nFlowMe > nFlowSetpointNs / nFlowDevLowPercentNs
THEN bFlowDeviationAlarmSt := True;
ELSE bFlowDeviationAlarmSt := False;
END_IF;
Thanks
Peter
Last edited: