FP_RAMP

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.

Parameters

Input

s1_Initial (INT, DINT, UINT, UDINT, REAL, LREAL)

Initial value from which the output value increases or decreases.

s2_Target (INT, DINT, UINT, UDINT, REAL, LREAL)

Target value to which the output value increases or decreases.

s3_RiseTime (INT, DINT, UINT, UDINT)

Time range in ms for the output value to increase or decrease from the initial value to the target value.

Values: 1–30000

Output

d (INT, DINT, UINT, UDINT, REAL, LREAL)

Output value

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • 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.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • 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.

Related topics:

Example

POU header

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

POU body

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

    1.  (1) Data is initialized when the system detects the trigger's rising edge.
  • Time chart for decreasing the output value:

    Example values: iInitialValue = 6000, iTargetValue = 3000, iRiseTime = 1000

    1.  (1) Data is initialized when the system detects the trigger's rising edge.

LD body

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

ST body

IF bRun THEN 
    FP_RAMP(s1_Initial := iInitialValue, s2_Target := iTargetValue, s3_RiseTime := iRiseTime, d => iOutputValue);
END_IF;

Modified on: 2022-07-04Feedback on this pagePanasonic hotline