FB_Hysteresis (Function Block)

Implements a hysteresis controller with two thresholds and latching behaviour.

The output switches low when the input rises above UpperThreshold and switches high when the input falls below LowerThreshold. Between the two thresholds the output latches at its current state.

This convention suits heating applications, the output drives a heater that turns on when the process falls below the lower threshold and off when it exceeds the upper threshold.

Note

The block is FINAL and must be instantiated, not extended. Use FB_init to set fUpperThreshold and fLowerThreshold at declaration time.

Extends: FB_SiComponent

Properties

LowerThreshold

Type: LREAL

Gets or sets the lower threshold.

When the input falls below this value the output switches high. Must be less than UpperThreshold for correct operation.

Output

Type: BOOL

Gets the current output state.

TRUE when the process is below LowerThreshold. FALSE when above UpperThreshold.

UpperThreshold

Type: LREAL

Gets or sets the upper threshold.

When the input rises above this value the output switches low. Must be greater than LowerThreshold for correct operation.

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)

fUpperThreshold

LREAL

Input level above which the output switches low.

fLowerThreshold

LREAL

Input level below which the output switches high.

Reset

Evaluates the current input against the thresholds and sets the output immediately, rather than waiting for the input to cross a threshold.

If the input is above UpperThreshold the output is set low. If below LowerThreshold the output is set high. If between the two thresholds the output defaults to low as a safe state.

Run

Evaluates the input against the thresholds and updates the output.