• 沒有找到結果。

InitVal → Index

B → C Index ≤ EndVal

A TRUE

TRUE

TRUE

FALSE INT#0 → InitVal

INT#10 → EndVal INT#1 → StepVal

StepVal > 0 and InitVal < EndVal

END

FALSE

FALSE

If the value of A is TRUE, the repeat processing is ended immediately. The value of C is retained.

START

Precautions for Correct Use

• Always place this instruction between the FOR and NEXT instructions.

• If you nest FOR and NEXT instructions, one BREAK instruction is required for each nesting level to end all of the repeat processing.

• Do not use Jump Instructions (e.g., the JMP instruction) to interrupt repeat processing. Always use the BREAK instruction to cancel repeat processing.

Sequence Control Instructions

2

BREAK

Comparison Instructions

Instruction Name Page

EQ (=) Equal page 2-102

NE (<>) Not Equal page 2-105

LT (<), LE (<=), GT (>), and GE (>=)

Less Than/Less Than Or Equal/Greater Than/Greater Than Or Equal page 2-108

EQascii Text String Comparison Equal page 2-111

NEascii Text String Comparison Not Equal page 2-113

LTascii, LEascii, GTascii, and GEascii

Text String Comparison Less Than/Text String Comparison Less Than or Equal/Text String Comparison Greater Than/Text String Comparison Greater Than or Equal

page 2-115

Cmp Compare page 2-118

ZoneCmp Zone Comparison page 2-120

TableCmp Table Comparison page 2-122

AryCmpEQ and AryCmpNE Array Comparison Equal/ Array Comparison Not Equal page 2-125

AryCmpLT, AryCmpLE, Ar-yCmpGT, and AryCmpGE

Array Comparison Less Than/Array Comparison Less Than Or Equal/

Array Comparison Greater Than/Array Comparison Greater Than Or Equal

page 2-127

AryCmpEQV and AryCmpNEV Array Value Comparison Equal/Array Value Comparison Not Equal page 2-130 AryCmpLTV, AryCmpLEV,

Ar-yCmpGTV, and AryCmpGEV

Array Value Comparison Less Than/Array Value Comparison Less Than Or Equal/Array Value Comparison Greater Than/Array Value Comparison Greater Than Or Equal

page 2-132

2

EQ (=)

The EQ (=) instruction determines if the values of two or more variables are all equivalent.

Instruction Name FB/

FUN Graphic expression ST expression

EQ(=) Equal FUN (@)=

EN Out In1

: InN :

(@)EQ

EN Out In1

: InN :

Out:=(In1=In2) & (In2=In3) & ··· &

(InN-1=InN);

Variables

Meaning I/O Description Valid range Unit Default

In1 to InN Comparison data Input Values to compare N = 2 to 5

Depends on

da-ta type. --- 0*1

Out Comparison result Output Comparison result Depends on

da-ta type. ---

---*1. If you omit the input parameter that connects to InN, the default value is not applied, and a building error will occur.

For example, if N is 3 and the input parameters that connect to In1 and In2 are omitted, the default values are applied, but if the input parameter that connects to In3 is omitted, a building error will occur.

Boo

lean Bit strings Integers

Real num-bers

Times, durations, dates, and text strings

BOOL BYTE WORD DWORD LWORD USINT UINT UDINT ULINT SINT INT DINT LINT REAL LREAL TIME DATE TOD DT STRING

In1 to InN OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK

*1

OK

*1

OK

*1

OK

*1

OK

*1

Enumerations can also be specified.

Out OK

*1. You can specify TIME, DATE, TOD, DT, and STRING data with Sysmac Studio version 1.02 or higher. If you open a project that was created with Sysmac Studio version 1.01 or lower on Sysmac Studio version 1.02 or higher and then use any of these data types, refresh the display. To refresh the display, right-click the instruction in the Edit Pane and select Update. If you do not refresh the display, a building error will occur.

Function

The EQ (=) instruction determines if the contents of from two to five variables In1 to InN are all equiva-lent.

The comparison result Out is TRUE only when all values are equivalent. Otherwise, the value of Out is

FALSE.

When comparing STRING data, "equivalent" means that both the lengths and contents of the text strings are the same.

The following example is for when In1 is INT#3, In2 is INT#5 and In3 is INT#10. The value of variable

abc will be FALSE.

abc:=(INT#3=INT#5)&(INT#5=INT#10);

LD ST

INT#3 INT#5 INT#10

EQ abc EN In1 In2 In3

INT#3 INT#5 INT#10

FALSE Out = abc

In1 In2 In3

Compared to see if they are equivalent.

The EQ instruction determines if In1 to In3 are all equivalent.

If they are different, the value of abc will be FALSE.

Different.

Additional Information

• The functions of the EQ instruction and the = instruction are exactly the same. Use the form that is easier to use.

• When you compare TIME, DT, or TOD data, adjust the accuracy of their values so that the compari-son can be based on the same accuracy. Use the following instructions to adjust the accuracy:

TruncTime on page 2-698, TruncDt on page 2-702, and TruncTod on page 2-706.

Precautions for Correct Use

• If the data types of In1 to InN are different, they will be expanded to a data type that includes the ranges of all of the data types.

• You cannot compare bit string data (BYTE, WORD, DWORD, or LWORD) with integers(SINT, INT, DINT, LINT, USINT, UINT, UDINT, and ULINT). You cannot compare bit string data to real number data (REAL and LREAL).

• Signed integers (SINT, INT, DINT, and LINT) cannot be compared to unsigned integers (USINT, UINT, UDINT, and ULINT).

• Always compare data with the same data type for TIME, DATE, TOD, DT, and STRING data. If vari-ables with different data types are specified, a building error will occur.

• You can compare enumerations only to other enumerations. The data types must also be the same to compare enumerations.

• Two values that are positive infinity or two values that are negative infinity are equivalent.

• If any of the values of In1 to InN is nonnumeric data, the value of Out is FALSE.

• If this instruction is used in a ladder diagram, the value of Out changes to FALSE if an error occurs in the previous instruction on the rung.

Comparison Instructions

2

EQ (=)

• If In1 to InN are real numbers, the desired results may not be achieved due to rounding error. Do not use this instruction to check if two values are equal when one or more of them is a real number. Use a value comparison instruction and check to see if the difference in the absolute values is within the allowable range. For example, the following programming can be used to check to see if the sum of REAL variables real_a and real_b is equal to 0.1. If the value of BOOL variable boolv is TRUE, the two values are considered to be equal.

boolv:=(ABS((real_a + real_b) - 0.1) < threshold);

threshold: Value for allowable range

NE (<>)

The NE (<>) instruction determines if the values of two variables are not equivalent.

Instruction Name FB/

FUN Graphic expression ST expression

NE(<>) Not Equal FUN (@)<>

EN Out In1

In2 (@)NE

EN Out In1

In2

Out:=(In1<>In2);

Variables

Meaning I/O Description Valid range Unit Default

In1 and In2 Comparison data Input Values to compare Depends on

da-ta type. --- *1

Out Comparison result Output Comparison result Depends on

da-ta type. ---

---*1. If you omit an input parameter, the default value is not applied. A building error will occur.

Boo

lean Bit strings Integers

Real num-bers

Times, durations, dates, and text strings

BOOL BYTE WORD DWORD LWORD USINT UINT UDINT ULINT SINT INT DINT LINT REAL LREAL TIME DATE TOD DT STRING

In1 and In2 OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK

*1

OK

*1

OK

*1

OK

*1

OK

*1

Enumerations can also be specified.

Out OK

*1. You can specify TIME, DATE, TOD, DT, and STRING data with Sysmac Studio version 1.02 or higher. If you open a project that was created with Sysmac Studio version 1.01 or lower on Sysmac Studio version 1.02 or higher and then use any of these data types, refresh the display. To refresh the display, right-click the instruction in the Edit Pane and select Update. If you do not refresh the display, a building error will occur.

Function

The NE (<>) instruction determines if the contents of two variables In1 and In2 are not equivalent.

If they are not equivalent, the comparison result Out is TRUE. If they are equivalent, it is FALSE.

When comparing STRING data, "equivalent" means that both the lengths and contents of the text strings are the same.

The following example is for when In1 equals In2 (both have a value of INT#5). The value of variable

abc will be FALSE.

Comparison Instructions

2

NE (<>)

abc:=(INT#5<>INT#5);

LD ST

INT#5 INT#5

NE abc EN In1 In2

INT#5 INT#5

FALSE Out = abc

In1 In2

Compared to see if they are different.

The NE instruction determines if In1 and In2 are different.

If they are the same, the value of abc will be FALSE.

Equivalent

Additional Information

• The functions of the NE instruction and the <> instruction are exactly the same. Use the form that is easier to use.

• When you compare TIME, DT, or TOD data, adjust the accuracy of their values so that the compari-son can be based on the same accuracy. Use the following instructions to adjust the accuracy:

TruncTime on page 2-698, TruncDt on page 2-702, and TruncTod on page 2-706.

Precautions for Correct Use

• If the data types of In1 and In2 are different, the smaller one is expanded to a data type that in-cludes the ranges of both of the data types.

• You cannot compare bit string data (BYTE, WORD, DWORD, or LWORD) with integers (SINT, INT, DINT, LINT, USINT, UDINT, ULINT). You cannot compare bit string data with real number data (RE-AL and LRE(RE-AL).

• Signed integers (SINT, INT, DINT, and LINT) cannot be compared to unsigned integers (USINT, UINT, UDINT, and ULINT).

• Always compare data with the same data type for TIME, DATE, TOD, DT, and STRING data. If vari-ables with different data types are specified, a building error will occur.

• You can compare enumerations only to other enumerations. The data types must also be the same to compare enumerations.

• Two values that are positive infinity or two values that are negative infinity are equivalent.

• If the value of either In1 or In2 is nonnumeric data, the value of Out is TRUE.

• If this instruction is used in a ladder diagram, the value of Out changes to FALSE if an error occurs in the previous instruction on the rung.

• If In1 and In2 are real numbers, the desired results may not be achieved due to rounding error. Do

not use this instruction to check if two values are different when one or both of them is a real

num-ber. Use a value comparison instruction and check to see if the difference in the absolute values is

greater than the allowable range. For example, the following programming can be used to check to

see if the sum of REAL variables real_a and real_b is not equal to 0.1. If the value of BOOL variable

boolv is TRUE, the two values are considered to be not equal.

boolv:= (ABS((real_a + real_b) - 0.1) > threshold);

threshold: Value for allowable range

Comparison Instructions

2

NE (<>)

LT (<), LE (<=), GT (>), and GE (>=)

These instructions compare the sizes of two or more values.

LT (<) : Performs a less than comparison.

LE (<=) : Performs a less than or equal comparison.

GT (>) : Performs a greater than comparison.

GE (>=) : Performs a greater than or equal comparison.

Instruction Name FB/

FUN Graphic expression ST expression

LT(<) Less Than FUN (@)<

EN Out In1

: InN :

(@)LT

EN Out In1

: InN :

Out:=(In1<In2) & (In2<In3) & ··· &

(InN-1<InN);

LE(<=) Less Than Or

Equal FUN (@)<=

EN Out In1

: InN :

(@)LE

EN Out In1

: InN :

Out:=(In1<=In2) & (In2<=In3) & ···

& (InN-1<=InN);

GT(>) Greater Than FUN (@)>

EN Out In1

: InN :

(@)GT

EN Out In1

: InN :

Out:=(In1>In2) & (In2>In3) & ··· &

(InN-1>InN);

GE(>=) Greater Than

Or Equal FUN (@)>=

EN Out In1

: InN :

(@)GE

EN Out In1

: InN :

Out:=(In1>=In2) & (In2>=In3) & ···

& (InN-1>=InN);

Variables

Meaning I/O Description Valid range Unit Default

In1 to InN Comparison data Input Values to compare N = 2 to 5

Depends on

da-ta type. --- *1

Out Comparison result Output Comparison result Depends on

da-ta type. ---

---*1. If you omit the input parameter that connects to InN, the default value is not applied, and a building error will occur.

For example, if N is 3 and the input parameters that connect to In1 and In2 are omitted, the default values are applied, but if the input parameter that connects to In3 is omitted, a building error will occur.

Boo

lean Bit strings Integers

Real num-bers

Times, durations, dates, and text strings

BOOL BYTE WORD DWORD LWORD USINT UINT UDINT ULINT SINT INT DINT LINT REAL LREAL TIME DATE TOD DT STRING

In1 to InN OK

*1

OK

*1

OK

*1

OK

*1 OK OK OK OK OK OK OK OK OK OK OK

*1

OK

*1

OK

*1

OK

*1

OK

*1

Out OK

*1. You can specify BYTE, WORD, DWORD, LWORD, TIME, DATE, TOD, DT, and STRING data with Sysmac Studio ver-sion 1.02 or higher. If you open a project that was created with Sysmac Studio verver-sion 1.01 or lower on Sysmac Studio version 1.02 or higher and then use any of these data types, refresh the display. To refresh the display, right-click the instruction in the Edit Pane and select Update. If you do not refresh the display, a building error will occur.

Function

These instructions compare the data in In1 to InN (N = 2 to 5).

The output value Out is shown below for each instruction.

Instruction Value of Out

LT (<) If In1 < In2 < ... < InN, Out is TRUE. Otherwise, it is FALSE.

LE (<=) If In1 <= In2 <= ... <= InN, Out is TRUE. Otherwise, it is FALSE.

GT (>) If In1 > In2 > ... > InN, Out is TRUE. Otherwise, it is FALSE.

GE (>=) If In1 >= In2 >= ... >= InN, Out is TRUE. Otherwise, it is FALSE.

The relationship between values with data types that are not integers or real numbers are determined as given in the following table.

Data type Relationship

BYTE, WORD,

DWORD, or LWORD The data is compared as unsigned integers.

TIME The numerically larger value is considered to be larger.

DATE, TOD, or DT Later dates or times of day are considered to be larger.

STRING

The specifications are the same as for the instructions, LTascii, LEascii, GTascii, and GEascii on page 2-115.

Refer to the specified page for details.

The following example shows the LE instruction when In1 is INT#3, In2 is INT#5 and In3 is INT#10.

The value of variable abc will be TRUE.

Comparison Instructions

2

LT (<), LE (<=), GT (>), and GE (>=)

abc:=(INT#3<= INT#5)&(INT#5<=INT#10);

LD ST

INT#3 INT#5 INT#10

LE abc EN In1 In2 In3

INT#3 INT#5 INT#10

TRUE Out = abc

In1 In2 In3

Values are compared to see if In1 ≤ In2 ≤ In3.

The LE instruction determines if In1 ≤ In2 ≤ In3.

If the comparison conditions are met, the value of abc will be TRUE.

Comparison conditions met.

Additional Information

• The functions of the LT and < instructions, the LE and <= instructions, the GT and > instructions, and the GE and >= instructions are exactly the same. Use the form that is easier to use.

• When you compare TIME, DT, or TOD data, adjust the accuracy of their values so that the compari-son can be based on the same accuracy. You can use the following instructions to adjust the accu-racy: TruncTime on page 2-698, TruncDt on page 2-702, and TruncTod on page 2-706.

Precautions for Correct Use

• If the data types of In1 to InN are different, they will be cast to a data type which can accommodate every possible value in all the types before comparison.

• Signed integers (SINT, INT, DINT, and LINT) cannot be compared to unsigned integers (USINT, UINT, UDINT, and ULINT).

• You cannot compare bit string data (BYTE, WORD, DWORD, or LWORD) with integers (SINT, INT, DINT, LINT, USINT, UINT, UDINT, or ULINT). You cannot compare bit string data with real number data (REAL or LREAL).

• Always compare data with the same data type for TIME, DATE, TOD, DT, and STRING data. If vari-ables with different data types are specified, a building error will occur.

• If In1 to InN are real numbers and include any non-terminating decimal numbers, error may cause unexpected processing results.

• Two values that are positive infinity or two values that are negative infinity are equivalent.

• If any of the values of In1 to InN is nonnumeric data, the value of Out is FALSE.

• If this instruction is used in a ladder diagram, the value of Out changes to FALSE when an error

occurs in the previous instruction on the rung.

在文檔中 Instructions Reference Manual (頁 158-171)