CMP

PLCopen motion icon

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Comparison with detailed outputs for integer inputs.

Inputs

Input

Data Type

Range

Unit

Default

Description

IN1

DINT

 

 

 

First value.

IN2

DINT

 

 

 

Second value.

Outputs

Output

Data Type

Range

Unit

Description

EQ

BOOL

 

 

TRUE if IN1 = IN2.

GT

BOOL

 

 

TRUE if IN1 > IN2.

LT

BOOL

 

 

TRUE if IN1 < IN2.

Remarks

None

FBD Language

CmpFbd.gif (1358 octets)

FFLD Language

  • In the FFLD language, the rung input (EN) validates the operation.
    • The rung output is the result of LT (lower than) comparison).
    • The comparison is executed only if EN is TRUE.

CmpLd.gif (1476 octets)

IL Language

(* MyCmp is declared as an instance of CMP function block *)
Op1: CAL MyCmp (IN1, IN2)
     LDClosed "Ladder diagram" Ladder logic is a method of drawing electrical logic schematics. It is now a very popular graphical language for programming Programmable Logic Controllers (PLCs). It was originally invented to describe logic made from relays. The name is based on the observation that programs in this language resemble ladders, with two vertical "rails" and a series of horizontal "rungs" between them  MyCmp.LT
     ST  bLT
     LD  MyCmp.EQ
     ST  bEQ
     LD  MyCmp.GT
     ST  bGT

ST Language

(* MyCmp is declared as an instance of CMP function block. *)
MyCMP (IN1, IN2);
bLT := MyCmp.LT;
bEQ := MyCmp.EQ;
bGT := MyCmp.GT;

See Also