stackint

PLCopen motion icon

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Manages a stack of DINT integers.

Inputs

Input

Data Type

Range

Unit

Default

Description

PUSH

BOOL

 

 

 

Command:

When changing from FALSE to TRUE, the value of IN is pushed on the stack.

POP

BOOL

 

 

 

Pop command:

When changing from FALSE to TRUE, deletes the top of the stack.

R1

BOOL

 

 

 

ResetClosed New start of the microprocessor. command:

If TRUE, the stack is emptied and its size is set to N.

IN

DINT

 

 

 

Value to be pushed on a rising pulseClosed When the step gets activated, the action is activated for a single execution, and possibly once again when the step is deactivated. of PUSH.

N

DINT

 

 

 

Maximum stack size.

Cannot exceed 128.

Outputs

Output

Data Type

Range

Unit

Description

EMPTY

BOOL

 

 

TRUE if the stack is empty.

OFLO

BOOL

 

 

TRUE if the stack is full.

OUT

DINT

 

 

Value at the top of the stack.

Remarks

  • Push and pop operations are performed on rising pulse of PUSH and POP inputs.
  • The specified size (N) is taken into account only when the R1 (reset) input is TRUE.

FBD Language Example

FFLD Language Example

  • In the FFLD language, the input rung is the PUSH command.
    • The output rung is the EMPTY output.

IL Language Example

(* MyStack is a declared instance of STACKINT functionClosed A function calculates a result according to the current value of its inputs. 
A function has no internal data and is not linked to declared instances. block *)
Op1: CAL MyStack (PUSH, POP, R1, IN, N)
     FFLD MyStack.EMPTY
     ST EMPTY
     FFLD MyStack.OFLO
     ST OFLO
     FFLD MyStack.OUT
     ST OUT

ST Language Example

(* MyStack is a declared instance of STACKINT function block *)
MyStack (PUSH, POP, R1, IN, N);
EMPTY := MyStack.EMPTY;
OFLO := MyStack.OFLO;
OUT := MyStack.OUT;

See Also