The following shows logical operation examples.
( ( 100 > 99 ) and ( 200 <> 100 ) )
Result: ON
( ( 100 > 99 ) and ( 200 <> 200 ) )
Result: OFF
( ( 100 > 99 ) or ( 200 <> 200 ) )
Result: ON
( ( 100 < 99 ) or ( 200 <> 200 ) )
Result: OFF
not ( 100 > 99 )
Result: OFF
not ( 100 < 99 )
Result: ON
[ w:[PLC1]D200 ] < 10
Result: True if D200 is smaller than 10.
not [ w:[PLC1]D200 ]
Result: True if D200 is 0.
([ w:[PLC1]D200 ] == 2) or ([ w:[PLC1]D200 ] == 5)
Result: True if D200 is 2 or 5.
([ w:[PLC1]D200 ] < 5) and ([ w:[PLC1]D300 ] < 8)
Result: True if D200 is smaller than 5, and D300 is smaller than 8.
[ w:[PLC1]D200 ] < 10
Result: True if D200 is smaller than 10.
not [ w:[PLC1]D200 ]
Result: True if D200 is 0.
([ w:[PLC1]D200 ] == 2) or ([ w:[PLC1]D200 ] == 5)
Result: True if D200 is 2 or 5.
([ w:[PLC1]D200 ] < 5) and ([ w:[PLC1]D300 ] < 8)
Result: True if D200 is smaller than 5, and D300 is smaller than 8.
The following shows bit operation examples.
[ w:[PLC1]D200 ] << 4
Result: The data in D200 is shifted 4 bits to the left.
[ w:[PLC1]D200 ] >> 4
Result: The data in D200 is shifted 4 bits to the right.
12(0000Ch) is stored in D301, using the BIN format
[ w:[PLC1]D200 ] = [ w:[PLC1]D300 ] >> [ w:[PLC1]D301 ]
Result: The data in D300 is shifted 12 bits to the right and assigned to D200.
[ w:[PLC1]D200 ] << 4
Result: The data in D200 is shifted 4 bits to the left.
[ w:[PLC1]D200 ] >> 4
Result: The data in D200 is shifted 4 bits to the right.
12(0000Ch) is stored in D310, using the BIN format.
[ w:[PLC1]D200 ] = [ w:[PLC1]D300 ] >> [ w:[PLC1]D310 ]
Result: The data in D300 is shifted 12 bits to the right and assigned to D200.
Bitwise AND
0 & 0 // Result is 0
0 & 1 // Result is 0
1 & 1 // Result is 1
0x1234 & 0xF0F0 // Result is 0x1030
Bitwise OR
0 | 0 // Result is 0
0 | 1 // Result is 1
1 | 1 // Result is 1
0x1234 | 0x9999 // Result is 0x9BBD
Logical OR
0 ^ 0 // Result is 0
0 ^ 1 // Result is 1
1 ^ 1 // Result is 0
Bitwise 1's Complement (When the Data Format is BIN16+)
~ 0 // Result is 0xFFFF
~ 1 // Result is 0xFFFE
Conditional Branch Usage Calculation Examples
Control program flow using "if-endif" and "if-else-endif"
if - endif
if (condition)
{expression1}
endif
If the condition is true, Process 1 is run. If false, skips Process 1.
For example,
if ( [ w:[PLC1]D200 ] < 5 )
{
[ w:[PLC1]D100 ] = 1
}
endif
If data in D200 is less than 5, then assigns 1 to D100.
if - else - endif
if (condition)
{expression1}
else
{expression2}
endif
If the condition is true, runs Process 1. If false, runs Process 2.
For example,
if ( [ w:[PLC1]D200 ] < 5 )
{
[ w:[PLC1]D100 ] = 1
}
else
{
[ w:[PLC1]D100 ] = 0
}
endif
If the value in D200 is less than 5, assigns 1 to D100. Otherwise, assigns 0.
Offset Address Usage Calculation Examples
Offset Specification: Special Calculation Examples Using [w:D00100]#[t:0000].
Script I/O: 16 bit unsigned, [t:0000]= 65526, the resulting address is [w:[PLC1]D00090].
100+65526=64(Hex)+FFF6(Hex)=1005A*1(Hex)→005A(Hex)=90
Script I/O: 16 bit signed, [t:0000]= -10, the resulting address is [w:[PLC1]D00090].
100+(-10)=64(Hex)+FFF6(Hex)=1005A*1(Hex)→005A(Hex)=90
Script I/O: 32 bit unsigned, [t:0000]= 4294901840, the resulting address is [w:[PLC1]D00180].
100+4294901840=64(Hex)+FFFF0050(Hex)=FFFF00B4*1(Hex)→00B4(Hex)=180
Script I/O: 32 bit signed, [t:0000]= -65456, the resulting address is [w:[PLC1]D00180].
100+(-65456)=64(Hex)+FFFF0050(Hex)=FFFF00B4*1(Hex)→00B4(Hex)=180
Offset addresses are always treated as 16 bit Bin values, regardless of the script's Bit Length and Data Type settings. If the result exceeds 16 bits (Maximum Value: 65535), Bits 0 to 15 are treated as the valid bits, and bits 16 and higher are discarded.