ChangeStateUpDown

ChangeStateUpDown (FB)

FUNCTION_BLOCK ChangeStateUpDown

Short description

Switching between freely definable states (UP and DOWN button) Prerequisite: Connection of a suitable array to the input 'arStates' with elements of type 'stChangeStateUpDown' Typical application: Switching operating modes

Representation

Interfaces

Inputs

Name
Data type
Value range
Initial value
Function

xStateUp

BOOL

FALSE

Switch to the next higher state (rising edge)

xStateDown

BOOL

FALSE

Switch to the next lower state (rising edge)

xResInit

BOOL

FALSE

Switch to the initialization state (rising edge)

bInitState

BYTE

0

Index of the initialization state

arStates

stChangeStateUpDown

Array with the individual states

Outputs

Name
Data type
Value range
Initial value
Function

sStateName

STRING

Name of the current state

iStateNumber’

INT

Number of the current state

Function description

This FB is used to switch between freely definable states (each state is defined by a state text and a state number) via the inputs 'xStateUp' and 'xStateDown'. After the first download, a subsequent download, every online change and at every rising edge on the 'xResInit' input, the initial state is set. The index of the initial state is defined by the input 'bInitState'.

circle-info

In case of error, the string 'Error' is output at the 'sStateName' output and the value -1 is output at the 'iStateNumber' output.

This function block can be applied as follows:

This function block can be applied as follows:

CODESYS

InOut:

Scope
Name
Type
Initial

Input

xStateUp

BOOL

FALSE

Input

xStateDown

BOOL

FALSE

Input

xStateInit

BOOL

FALSE

Input

bInitState

BYTE

0

Output

sStateName

STRING

Output

iStateNumber

INT

Input

arStates

POINTER TO stChangeStateUpDown

Last updated