Condition Expressions

Condition expressions are used in the Condition box of a Program Trigger item, and in the Wait For and Conditional Jump link types. A condition expression must evaluate to True or False.

Simple condition expressions can also be entered with the New Condition Wizard.

Sample Expressions

1. _Axis[0].Status.InPos = True                            //checks if the in Axis 0 Status Bit named "In Position " is on.

 

2._Axis[1].ActPos< 4.0 AND MyInput = True

 

3._Axis[0].ActPos > Pos1 AND _Axis[1].ActPos < 4.0

 

4.MyVariable + SQRT(_Axis[1].ActPrs) >= 12900.1

 

5.counter >= 300

Entering an Expression

Using a Wizard

In the Condition box of a Program Trigger or a link type, click the ellipsis button . The New Condition Wizard will open. Use the wizard to create the following types of expressions:

Entering Directly

  1. In the Condition box of a Program Trigger or a link type, double-click the Condition box. The Expression Editor will open.

  2. Enter the expression:

  1. Click OK to close the dialog and enter the expression in the command.

 

Using Boolean Values in Condition Expressions

To test a boolean value, such as discrete inputs, it can be compared to True or False, or simply placed by itself, since it is already a boolean value. The two expressions below are identical:

 

MyInput1 = True OR MyInput2 = False

 

MyInput1OR NOTMyInput2

 

Testing Bits in DWORD Tags

Appending the Bit Number

To test an individual bit in a DWORD tag, append the bit number or bit name to the tag name. For example:

 

_Axis[0].Status.TGDone

MyDWORD.0

 

Bit Masking

Individual bits in DWORD tags can be tested by using bit masking. The New Condition wizard uses this method for multiple bits. The example below shows how to check if both bits 0 and 7 are set in the variable MyDWORD. The parentheses must be present. Due to the order of precedence, the "=" would be evaluated first if the parentheses were not present.

 

(MyDWORD AND 16#00000081) = 16#00000081

 

 

See Also

Expressions Overview | Assignment Expressions | Operators | Functions


Send comments on this topic.

Copyright © 2024 Delta Computer Systems, Inc. dba Delta Motion