Motion Library - Trigger

Name

Description

Return type

MLTrigClearFlag

Clears the flag of an initiated Trigger block

BOOL

MLTrigInit

Initializes a Trigger object

BOOL

MLTrigIsTrigged

Checks if the selected block has been triggered

BOOL

MLTrigReadDelay

Returns the time that the trigger block uses to compensate the delay of the sensor that captures the triggering signal

None

MLTrigReadPos

Returns the position of the block at the moment when it was triggered

None

MLTrigReadTime

Returns the time of the moment where the block was triggered in milliseconds

None

MLTrigSetEdge Sets the edge configuration for a Trigger object BOOL

MLTrigWriteDelay

Sets the time that the trigger block uses to compensate for the delay introduced by the sensor that captures the triggering signal

BOOL

MLTrigClearFlag

Description

Clears the flag of an initiated Trigger block so the block can capture the position and time of the next event. Once triggered, a block has to be reset with this command before it can be triggered again. All events that are sent to a block while in a triggered state are ignored and the position and time information is lost.

Arguments

Input

BlockID

Description

ID number of an initiated Trigger object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

n/a

 

Default

Output

Description

Returns TRUE if function block is executed

 

Data type

BOOL

 

Unit

n/a

Return Type

BOOL

Related Functions

MLAxisRstFastIn

MLTrigIsTrigged

MLTrigReadPos

MLTrigReadTime

Example

Structured Text

 

//Clear Trigger Flag

MLTrigClearFlag( PipeNetwork.TRIGGER );

 

Ladder Diagram

MLTrigClearFlag: LD example

Function Block Diagram

MLTrigClearFlag: FBD example

MLTrigInit

Description

Initializes a Trigger object for use in a PLC Program. Function block is automatically called if a Trigger Block is added to the Pipe Network, with user-defined settings entered in the Pipe Blocks Properties screen.

The Trigger object monitors a selected Fast Input and captures the time of a rising or falling edge event. With the time and pipe position information the Trigger object extrapolates the axis position when the Fast Input event occurred.

Parameters to enter include the name of the Pipe Block, the Axis where the Fast Input is located, the number of the desired Fast Input, and whether to trigger on the rising or falling edge of the input.

See also "Fast inputs" for more details.


  • Trigger objects are normally created in the Pipe Network using the graphical engine. Then you do not have to add MLTrigInit 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 Pipe Block

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

n/a

 

Default

     

Input_Axis

Description

Name of the axis where the Fast Input is located

 

Data type

STRING

 

Range

 

Unit

n/a

 

Default

     

InputID

Description

ID number of the Fast Input

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

n/a

 

Default

     

EdgeID

Description

Trigger at rising or falling edge of Fast Input. Enter 1 for rising edge, 2 for falling edge, and 0 disables the Fast Input

 

Data type

DINT

 

Range

[0 , 2]

 

Unit

n/a

 

Default

1 (Rising edge)

Output

Description

Returns TRUE if function block is executed

 

Data type

BOOL

 

Unit

n/a

Return Type

BOOL

Related Functions

MLTrigIsTrigged

MLTrigReadPos

MLTrigClearFlag

MLAxisRstFastIn

Example

Structured Text

//Create and Initiate a Trigger Pipe Block named “Trigger” and set it up to receive the trigger signal from Axis1, capture engine 0, and the rising edge of the signal
TRIGGER := MLBlkCreate( 'TRIGGER', 'TRIGGER' );
MLTrigInit( TRIGGER, 'Axis1', 0, 1 );

Ladder Diagram

MLTrigInit: LD example

 

Function Block Diagram

MLTrigInit: FBD example

MLTrigIsTrigged

Description

Checks if the selected block has been triggered. When a block has been triggered, it contains the time and position when a Fast Input event occurred. The application has to reset the block before the block can be triggered again. All trigger events that are sent to the block during its triggered state are lost.

MLTrigIsTrigged

 

MLTrigIsTrigged


  • Once triggered, a block has to be reset before it can be triggered again. All events that are sent to a block while in a triggered state are ignored and the position and time information is lost.

Arguments

Input

BlockID

Description

ID number of an initiated Trigger object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

n/a

 

Default

Output

Description

Returns TRUE if the selected Trigger Object has Triggered

 

Data type

BOOL

 

Unit

n/a

Return Type

BOOL

Related Functions

MLTrigReadPos

MLTrigReadTime

Example

//Check if a Trigger Block has been triggered, then save position

IF MLTrigIsTrigged( PipeNetwork.TRIGGER ) THEN

Trig_Position := MLTrigReadPos( PipeNetwork.TRIGGER );

END_IF

 

Ladder Diagram

MLTrigIsTrigged: LD example

 

Function Block Diagram

MLTrigIsTrigged: FBD example

MLTrigReadDelay

Description

Electronic sensors are not able to respond immediately to a signal. Sensors usually require a certain amount of time to process a change of state in their input signal. This function returns the delay that has been programmed in a trigger block by the MLTrigWriteDelay function to compensate for this reaction time required by the sensor.

Input

BlockID

Description

Identifier of the trigger block whose delay is requested

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

n/a

 

Default

En

Description

Enables execution
 

Data type

BOOL
 

Unit

n/a
 

Default

-

Output

Delay

Description

Value of the delay compensation currently applied by the trigger block

 

Data type

LREAL

 

Unit

microseconds

OK

Description

Returns true when the function successfully executes
 

Data type

BOOL
 

Unit

n/a

Related Functions

MLTrigWriteDelay

MLTrigReadPos

Description

Returns the position of the block at the moment when it was triggered by the Trigger Block's selected Fast Input. This value is only valid when TrigIsTrigged() returns TRUE. The Trigger block extrapolates the output value based on the timestamp of the Fast Input event to provide an accurate position even if the event occurs in the middle of a program cycle.

Once triggered, a block has to be reset before it can be triggered again. All events that are sent to a block while in a triggered state are ignored and the position and time information is lost.

See also "Fast inputs" for more details.

MLTrigReadPos

MLTrigReadPos

Arguments

Input

BlockID

Description

ID number of an initiated Trigger object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

n/a

 

Default

Output

Position

Description

Returns the position of the selected block's Axis at the moment when it was triggered

 

Data type

LREAL

 

Unit

User unit

Related Functions

MLTrigIsTrigged

MLTrigReadTime

MLTrigClearFlag

MLAxisRstFastIn

Previous Function Name

MLTrigGetPos

Example

Structured Text

 

//Save position of Axis when Fast Input event occurs

Trig_Position := MLTrigReadPos( PipeNetwork.TRIGGER );

 

Ladder Diagram

MLTrigReadPos: LD example

 

Function Block Diagram

MLTrigReadPos: FBD example

MLTrigReadTime

Description

Returns the time of the moment where the block was triggered in milliseconds. This value is only valid when TrigIsTrigged() returns TRUE. The output is computed from the timestamp of a Fast Input time event

Once triggered, a block has to be reset before it can be triggered again. All events that are sent to a block while in a triggered state are ignored and the position and time information is lost.

See also "Fast inputs" for more details.

MLTrigReadTime

 

MLTrigReadTime

Arguments

Input

BlockID

Description

ID number of an initiated Trigger object

 

Data type

DINT

 

Range

[-2147483648, 2147483648]

 

Unit

n/a

 

Default

Output

Time

Description

Returns the time that the Trigger Block's selected Fast Input was triggered

 

Data type

LREAL

 

Unit

milliseconds

Related Functions

MLTrigIsTrigged

MLTrigReadPos

MLTrigClearFlag

MLAxisRstFastIn

Previous Function Name

MLTrigGetTime

Example

//Save time when Fast Input event occurs

Trig_Time := MLTrigReadTime( PipeNetwork.TRIGGER );

 

Ladder Diagram

MLTrigReadTime: LD example

 

Function Block Diagram

MLTrigReadTime: FBD example

MLTrigSetEdge

Description

Sets the edge configuration (rising, falling, etc.) for a trigger block. This block should be called prior to calling MLAxisCfgFastIn. Also the value at the Edge input must match the value at MLAxisCfgFastIn’s Mode input.

Arguments

Input

BlockID Description Identifier of the trigger block

 

Data type DINT

 

Range [-2147483648, 2147483647]

 

Unit n/a

 

Default
Edge Description The edge on which to trigger
0 = disable the fast input
1 = rising edge
2 = falling edge
  Data type DINT
  Range [0,2]
  Unit n/a
  Default 1 (rising edge)

Output

Q Description True if block executed successfully
False if execution is not successful

 

Data type BOOL

 

Unit n/a

Return Type

BOOL

Examples

Function Block Diagram

Ladder Diagram

Structured Text

MLTrigWriteDelay

Description

Electronic sensors are not able to respond immediately to a signal. Sensors usually require a certain amount of time to process a change of state in their input signal. This function allows the trigger block to calculate the exact moment at which a signal was triggered by letting you specify the delay introduced by the sensor.

Input

BlockID Description Identifier of the trigger block

 

Data type DINT

 

Range [-2147483648, 2147483648]

 

Unit n/a

 

Default
Delay Description Reaction time of the sensor that the trigger block has to compensate

 

Data type LREAL

 

Range

 

Unit microseconds

 

Default

Output

Description Returns TRUE if the delay is successfully set

 

Data type BOOL

 

Unit n/a

Return Type

BOOL

Related Functions

MLTrigReadDelay

Usage example of Trigger Functions

When you call the MLTrigClearFlag function, the flag for trigger is reset to False.

When a Fast Input is set, the MLTrigIsTriggered function returns True.

Then you can call the MLTrigReadPos and MLTrigReadTime functions to get more details.

Trigger Functions Usage

Trigger Functions Usage