05.05.2014 Views

csmstr - Omega Engineering

csmstr - Omega Engineering

csmstr - Omega Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SIMPLE MATH<br />

CRIMSON USER MANUAL - MODULAR CONTROLLER<br />

has been entered, any changes to the name of the tag will modify all of the expressions that<br />

make reference to it, so there is no need to re-edit the expressions to “fix” the name.<br />

COMMUNICATIONS REFERENCES<br />

References to registers in master communications devices can be entered into an expression<br />

by means of a syntax comprising an opening square bracket, the register name, and a closing<br />

square bracket. An optional device name may be prefixed to the register name and separated<br />

by a period. The device name need not be specified for registers in the first (or only) device<br />

within the database. Examples of this syntax are shown below…<br />

EXAMPLE<br />

[D100]<br />

[AB.N7:0]<br />

[FX.D100]<br />

MEANING<br />

Register D100 in first device.<br />

Register N7:0 in device AB.<br />

Register D100 in device FX.<br />

SIMPLE MATH<br />

As mentioned above, expressions often contain more than one data value, with their values<br />

being combined mathematically. The simplest of these expressions may add a pair of values,<br />

while a more complex expression might obtain the average of three values. These operations<br />

are performed using the familiar syntax you will have seen in applications such as Excel. The<br />

examples below show the basic operations that can be performed…<br />

OPERATOR PRIORITY EXAMPLE<br />

Addition Group 4 Tag1 + Tag2<br />

Subtraction Group 4 Tag1 - Tag2<br />

Multiplication Group 3 Tag1 * Tag2<br />

Division Group 3 Tag1 / Tag2<br />

Remainder Group 3 Tag1 % Tag2<br />

Although the examples show spaces surrounding the operators, these are not required.<br />

OPERATOR PRIORITY<br />

You will have noticed the Priority column in the above table. As you no doubt recall from<br />

your algebra classes, when several operators are used together, they are evaluated in a defined<br />

order. For example, multiplication is always evaluated before addition. Crimson implements<br />

this ordering by means of what are known as operator priorities, with each operator being put<br />

in a group, and with operators being applied in order from the lowest numbered group to the<br />

highest. (Except where noted otherwise in the text, operators within a group are evaluated<br />

left-to-right.) The default order of evaluation can be overridden by using parentheses.<br />

TYPE CONVERSION<br />

Normally, Crimson will automatically decide when to switch from evaluating an expression<br />

in integer math to evaluating it using floating-point. For example, if you divide an integer<br />

PAGE 262<br />

http://www.redlion.net/controller

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!