FB_RampProfile (Function Block)

Generates a ramp signal that rises or falls toward a target value within a configurable duration, then holds at the target.

The rate of change is derived automatically from Target, StartValue, and Duration. Once the output is within one time step of the target it snaps to the target and IsComplete becomes TRUE. If Target or Duration change mid-run the rate is recalculated immediately.

A duration of LTIME#0 snaps the output to Target immediately. If Target equals StartValue, IsComplete is TRUE from the first call.

Calling Reset() returns the output to StartValue and clears IsComplete.

Note

The block is FINAL and must be instantiated, not extended. Use FB_init to set fStartValue, fTarget, and tDuration at declaration time.

Extends: FB_SoComponent

Properties

Duration

Type: LTIME

Gets or sets the duration.

This is the time taken to ramp from StartValue to Target. LTIME#0 snaps the output to the target immediately. Changes take effect immediately.

IsComplete

Type: BOOL

Gets whether the output has reached Target.

Becomes TRUE when the output is within one time step of the target, and FALSE again if Target changes and the output no longer matches.

StartValue

Type: LREAL

Gets or sets the start value.

This is the output value the ramp returns to after a Reset().

Target

Type: LREAL

Gets or sets the target value.

The output ramps toward this value within Duration. Changes take effect immediately, recalculating the rate.

Methods

FB_init

Inputs

Name

Type

Description

bInitRetains

BOOL

if TRUE, the retain variables are initialized (warm start / cold start)

bInCopyCode

BOOL

if TRUE, the instance afterwards gets moved into the copy code (online change)

fStartValue

LREAL

Initial output value.

fTarget

LREAL

Target value to ramp toward.

tDuration

LTIME

Time to reach the target from StartValue. LTIME#0 snaps immediately.

Reset

Returns the output to the start value set in FB_init and clears IsComplete.

Run

Advances the ramp profile by one time step.

Note

Must be called once per cycle on a single PLC task. If the measured cycle time is zero the method returns early without updating the output.