Industrielle styresystemer - Wiki
FUNCTION_BLOCK FbEndBrakes VAR_INPUT EB_TL: BOOL; EB_TR: BOOL; EB_BL: BOOL; EB_BR: BOOL; actPos: LREAL; setPos: LREAL; END_VAR VAR_OUTPUT pos: LREAL; Execute: BOOL; END_VAR VAR upperLimit: BOOL; bottomLimit: BOOL; topPosSet: BOOL; bottomPosSet: BOOL; END_VAR
// Top enbreakers upperLimit:= EB_TL OR EB_TR; IF upperLimit AND NOT topPosSet THEN pos:=actPos; Execute:=FALSE; topPosSet :=TRUE; END_IF IF topPosSet AND (setPos < actPos) THEN pos:= setPos; Execute:=TRUE; IF NOT upperLimit THEN topPosSet := FALSE; END_IF END_IF // Bottom endbreakers bottomLimit:= EB_BL OR EB_BR; IF bottomLimit AND NOT bottomPosSet THEN pos:=actPos; Execute:=FALSE; bottomPosSet :=TRUE; END_IF IF bottomPosSet AND (setPos > actPos) THEN pos:= setPos; Execute:=TRUE; IF NOT bottomLimit THEN bottomPosSet := FALSE; END_IF END_IF // Set pos equal to setpoint if not bottom or top limit IF NOT upperLimit AND NOT bottomLimit THEN pos:= setPos; END_IF