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:
Test a Status bit, such as the In Position bit.
Test and Error bit, such as the Fault Input bit.
Soft Limit Switch , such as comparing whether the Actual Position is greater than a ceratin value.
Discrete I/O, such as checking if a discrete input is on.
Entering Directly
In the Condition box of a Program Trigger or a link type, double-click the Condition box. The Expression Editor will open.
Enter the expression:
Double-click any item in the lists on the Tags, Functions or Operators tabs to insert into the expression.
Type other items, such as register addresses or numeric values.
To mix data types, you must explicitly convert them. For example, you cannot directly assign a fractional value to an integer variable. You must use the data type conversion functions.
If you enter multiple expressions in the Expression command, each expression must end with a semi-colon. See the examples below.
If the expression is invalid, the Expression Builder give an error. When no errors are listed, the expression is valid.
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
Copyright © 2024 Delta Computer Systems, Inc. dba Delta Motion