Ramp output
This FP instruction calculates a linear ramp based on an initial value, a target value and a time range if the trigger EN is TRUE. The output value d increases or decreases until the target value is reached.
Input
Initial value from which the output value increases or decreases.
Target value to which the output value increases or decreases.
Time range in ms for the output value to increase or decrease from the initial value to the target value.
Values: 1–30000
Output
Output value
if the area specified using the index modifier exceeds the limit.
if the output time range specified by s3_RiseTime is smaller than 1 or larger than 30000.
if the area specified using the index modifier exceeds the limit.
if the output time range specified by s3_RiseTime is smaller than 1 or larger than 30000.
Corresponding F instructions: F284_RAMP
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
iInitialValue: INT:=3000;
iTargetValue: INT:=6000;
iRiseTime: INT:=1000;
iOutputValue: INT:=0;
bRun: BOOL:=FALSE;
END_VAR
When the variable bRun is switched to TRUE, the function is carried out and iOutputValue increases from 3000 (iInitialValue) to 6000 (iTargetValue) in 1000ms (according to iRiseTime).
Time chart for increasing the output value:
Example values: iInitialValue = 3000, iTargetValue = 6000, iRiseTime = 1000
Time chart for decreasing the output value:
Example values: iInitialValue = 6000, iTargetValue = 3000, iRiseTime = 1000
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 7 ;
NETWORK_BODY
B(B_F,FP_RAMP!,,12,1,21,7,,?DEN?Ds1_Initial?Ds2_Target?Ds3_RiseTime?AENO?Cd);
B(B_CONTACT,,bRun,4,2,6,4,);
B(B_VARIN,,iInitialValue,10,3,12,5,);
B(B_VARIN,,iTargetValue,10,4,12,6,);
B(B_VARIN,,iRiseTime,10,5,12,7,);
B(B_VAROUT,,iOutputValue,21,3,23,5,);
L(1,3,4,3);
L(6,3,12,3);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF bRun THEN
FP_RAMP(s1_Initial := iInitialValue, s2_Target := iTargetValue, s3_RiseTime := iRiseTime, d => iOutputValue);
END_IF;