Motion Library - Comparator

Name

Description

Return type

MLCompCheck

Checks if the reference of a comparator Pipe Block has been crossed. Returns TRUE if the reference has been crossed

BOOL

MLCompInit

Initializes a comparator Pipe Block with user-defined settings

BOOL

MLCompReadRef

Returns the reference position of a comparator block

None

MLCompReset

Clears the Transition Flag of a comparator Pipe Block

BOOL

MLCompWriteRef

Sets the reference position of a comparator block

BOOL

 

FunctionMLCompCheckPipe Network motion icon

Description

Check if the reference of a comparator Pipe Block has been crossed. Returns the Transition Flag of a comparator object, which turns TRUE if the input position to the comparator is greater or equal to the reference. The Comparator Transition Flag stays TRUE until it is reset.

MLCompCheck

Figure 8-90: MLCompCheck

Arguments

Input

BlockID

Description

ID number of an initiated Comparator object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

N/A

 

Default

Output

Default (.Q)

Description

Returns TRUE if reference position of the Comparator object has been crossed

See more details here.

 

Data type

BOOL

 

Unit

N/A

Return Type

BOOL

Related Functions

MLCompReset

MLCompWriteRef

MLCompReadRef

Example

Structured Text

 

//Check if Comparator Reference has been reached

bCrossed := MLCompCheck( PipeNetwork.MyComp );

 

 

Ladder Diagram

MLCompCheck: LD example

 

Function Block Diagram

MLCompCheck: FBD example

Go back to the top of the page [Top]

FunctionMLCompInitPipe Network motion icon

Description

Initializes a comparator Pipe Block for use in a PLCClosed"Programmable Logic Controller" A Programmable Logic Controller, PLC, or Programmable Controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. Used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events Program. FunctionClosedA 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 is automatically called if a Comparator Block is added to the Pipe Network, with user-defined settings entered in the Pipe Blocks Properties screen.

The Transition Flag of a comparator object turns TRUE if the input position to the comparator is greater or equal to the reference. The Comparator Transition Flag stays TRUE until it is reset.

If the input ThroughZero is set to TRUE, system must cross zero and then the reference position before the Transition Flag is set. If ThroughZero is FALSE, Transition Flag is set immediately if the input pipe position is greater or equal to the Reference value.


  • Comparator objects are normally created in the Pipe Network using the graphical engine. Then you do not have to add MLCompInit function blocks to their programs. Parameters are entered directly in pop-up windows, and the code is then automatically added to the current project.

Arguments

Input

BlockID

Description

ID number of a created Comparator Pipe Block

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

N/A

 

Default

ModuloPosition

Description

Value of the period of a cyclic system

 

Data type

LREAL

 

Range

 

Unit

User unit

 

Default

ThroughZero

Description

When TRUE, system must cross zero and then the reference position before the Transition Flag is set. If FALSE, Transition Flag is set immediately if the input pipe position is greater then or equal to the Reference value.

 

Data type

BOOL

 

Range

0, 1

 

Unit

N/A

 

Default

Reference

Description

Set the reference position in the new Comparator object

 

Data type

LREAL

 

Range

 

Unit

User unit

 

Default

Output

Default (.Q)

Description

Returns TRUE when function starts to execute

See more details here.

 

Data type

BOOL

 

Unit

N/A

Return Type

BOOL

Related Functions

MLBlkCreate

MLCompCheck

MLCompReset

MLCompWriteRef

Example

Structured Text

      //Initiate a created Comparator Block named “MyComp” to:
// Modulo of 360
// Require the input position to first cross 0 before the
// MLCompCheck output is triggered
// Input compared position to 45

MyComp := MLBlkCreate( 'MyComp', 'COMPARATOR' );
MLCompInit( MyComp, 360.0, TRUE, 45.0 );

Ladder Diagram

MLCompInit: LD example

 

Function Block Diagram

MLCompInit: FBD example

Go back to the top of the page [Top]

FunctionMLCompReadRefPipe Network motion icon

Description

Returns the reference position of a comparator block. The Transition Flag of a comparator object turns TRUE if the input position to the comparator is greater or equal to the reference. The Comparator Transition Flag stays TRUE until it is reset.

Arguments

Input

BlockID

Description

ID number of an initiated Comparator object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

N/A

 

Default

Output

Reference

Description

Returns the current reference position of the Comparator object

 

Data type

LREAL

 

Unit

User unit

Related Functions

MLCompWriteRef

MLCompReset

MLCompCheck

Example

Structured Text

//Return the Comparator Reference value
CompRef := MLCompReadRef( PipeNetwork.MyComp );

Ladder Diagram

MLCompReadRef: LD example

 

Function Block Diagram

MLCompReadRef: FBD example

Go back to the top of the page [Top]

FunctionMLCompResetPipe Network motion icon

Description

Clear the Transition Flag of a comparator Pipe Block. The Transition Flag of a comparator object turns TRUE if the input position to the comparator is greater or equal to the reference. The Comparator Transition Flag stays TRUE until it is reset.

Arguments

Input

BlockID

Description

ID number of an initiated Comparator object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

N/A

 

Default

Output

Default (.Q)

Description

Returns TRUE when function starts to execute

See more details here.

 

Data type

BOOL

 

Unit

N/A

Return Type

BOOL

Related Functions

MLCompCheck

MLCompReadRef

MLCompWriteRef

Example

Structured Text

//Clear the Transition Flag of a Comparator object
MLCompReset( PipeNetwork.MyComp );

Ladder Diagram

MLCompReset: LD example

Function Block Diagram

MLCompReset: FBD example

Go back to the top of the page [Top]

FunctionMLCompWriteRefPipe Network motion icon

Description

Set the reference position of a comparator block. The Transition Flag of a comparator object turns TRUE if the input position to the comparator is greater or equal to the reference. The Comparator Transition Flag stays TRUE until it is reset.

If the input ThroughZero is set to TRUE, system must cross zero and then the reference position before the Transition Flag is set. If ThroughZero is FALSE, Transition Flag is set immediately if the input pipe position is greater then or equal to the Reference value.

MLCompWriteRef

Figure 8-91: MLCompWriteRef

Arguments

Input

BlockID

Description

ID number of an initiated Comparator object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

N/A

 

Default

ThroughZero

Description

When TRUE, system must cross zero and then the reference position before the Transition Flag is set. If FALSE, Transition Flag is set immediately if the input pipe position is greater then or equal to the Reference value.

 

Data type

BOOL

 

Range

0, 1

 

Unit

N/A

 

Default

Reference

Description

New reference position to set in the selected Comparator object

 

Data type

LREAL

 

Range

 

Unit

User unit

 

Default

Output

Default (.Q)

Description

Returns TRUE when function starts to execute

See more details here.

 

Data type

BOOL

 

Unit

N/A

Return Type

BOOL

Related Functions

MLCompCheck

MLCompReadRef

MLCompReset

Example

Structured Text

 

//Set the Comparator Reference value

MLCompWriteRef( PipeNetwork.MyComp , TRUE , 45 );

 

Ladder Diagram

MLCompWriteRef: LD example

Function Block Diagram

MLCompWriteRef: FBD example

Go back to the top of the page [Top]

Usage example of Comparator Functions

When you call the MLCompWriteRef function, the output for MLCompCheck becomes True as soon as the input value reaches the reference.

Comparator Functions Usage

Comparator Functions Usage

The same function can also be called for a cyclic input value.

Comparator Functions Usage

Comparator Functions Usage

When the THROUGH_ZERO parameter is set to YES, the output for MLCompCheck becomes True as soon as the input value reaches the reference, but not before it has passed through zero.

Comparator Functions Usage

Comparator Functions Usage

Figure 8-92: Comparator Functions Usage

Go back to the top of the page [Top]