Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY, CODESYS 3.5 SP19 SAFETY

 

S_LinearRamp (FB)

Description

This function block limits the acceleration and deceleration speed of movements controlled by PWM output.

 

Initialization

Init method is used to initialize the necessary static calculation parameters for the function block instance.

The method shall be called at least once before the actual function block can be called, i.e. at the application initialization phase.

The method checks the validity of input parameters. However, none of the function block outputs are affected by the initialization.

 

A parameter error is diagnosed if:

  • Init method is not called before the main FB call OR

  • i_pEventCode = 0 OR

 

Initialization parameters

Parameter

Data type

Unit

Range

Description

S_i_PosDirAscendRampTime

SAFEUINT

ms

 -

Defines time how long it takes that control signal S_o_PosControl changes from 0 to 10000    

S_i_PosDirDescendRampTime

SAFEUINT

ms

-

Defines time how long it takes that control signal S_o_PosControl changes from 10000 to 0

S_i_NegDirAscendRampTime

SAFEUINT

ms

-

Defines time how long it takes that control signal S_o_NegControl changes from 0 to -10000

S_i_NegDirDescendRampTime

SAFEUINT

ms

-

Defines time how long it takes that control signal

S_o_NegControl changes from -10000 to 0

S_i_EnableCounterControl

SAFEBOOL

-

-

True = S_o_PosControl and S_o_NegControl can be active at same time.

 

False = S_o_PosControl and S_o_NegControl cannot be active at same time.

i_pEventCode

POINTER TO EventCode

-

≠0

Pointer to application variable which is type EventCode.

 

 

Initialization method return value

TRUE: All initialization parameters ok.

FALSE: Error in initialization parameter(s).

 

Operation

The output values S_o_PosControl and S_o_NegControl follows the input value S_i_Control according the ramp parameters. POU has own parameters for positive and negative direction. Ascend and descend parameters defines the time it takes from control signal to change full range 0-10000 or in negative side 0- (-)10000. The output values are calculated based on input value, ascend ramp, descend ramp, application cycle time and S_i_EnableCounterControl flag. In other word the POU limits the change speed of control signal. The S_i_EnableCounterControl flag defines if outputs S_o_PosControl and S_o_NegControl can be active at same time   

 

See figure below where S_i_NegDirAscendRampTime = 200, S_i_NegDirDescendRampTime = 300, S_i_PosDirAscendRampTime = 100 and S_i_EnableCounterControl = TRUE.  

See figure below where S_i_NegDirAscendRampTime = 200, S_i_NegDirDescendRampTime = 300, S_i_PosDirAscendRampTime = 100 and S_i_EnableCounterControl = FALSE.

 

 

Inputs

Input variable name

Data type

Unit

Range

Description

i_Enable

BOOL

-

-

Enable POU operation

S_i_Control

SAFEINT

-

-10000 - (+)10000

Control value

Outputs

Output variable name

Data type

Unit

Range

Description

S_o_PosControl

SAFEINT

-

0-10000

Positive direction ramped value.

S_o_NegControl

SAFEINT

-

-10000-0

Negative direction ramped value.

o_Status

Status

-

 

Status of output value. See Status structure.

Error diagnostic

See Diagnostic Interface library description of error status and event code functionality.

 

Conditions

S_o_

Control

o_Status. OutputValid

o_Status error status

Event code FunctionID

Event code EventID

i_Enable TRUE AND

init parameter error AND

 i_pEventCode valid

0

FALSE

ParameterError

LINEAR_RAMP  

PARAMETER_ERROR

i_Enable TRUE AND

init parameter error AND
i_pEventCode NULL

0

FALSE

ParameterError

-

-

i_Enable TRUE AND

 init parameters ok AND

S_i_Control within range

Attenuated control value

TRUE

-

NO_FUNC

NO_ERROR

i_Enable TRUE AND

 init parameters ok AND

S_i_Control > 10000  

0

FALSE

InputHigh

LINEAR_RAMP

INPUT_TOO_HIGH

i_Enable TRUE AND

 parameters ok AND

S_i_Control <  -10000  

0

FALSE

InputLow

LINEAR_RAMP

 INPUT_TOO_LOW

 

See also

 

 

 

 

Source file topic100404.htm

Last updated 21-Feb-2025