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]D00200] < 10
Result: True if D200 is less than 10.
not [w:[PLC1]D00200]
Result: True if D200 is 0.
([w:[PLC1]D00200] == 2) or ([w:[PLC1]D00200] == 5)
Result: True if D200 is 2 or 5.
(5 < [w:[PLC1]D00200]) and ([w:[PLC1]D00200] < 10)
Result: True if D200 is greater than 5 and less than 10.
([w:[PLC1]D00200] < 5) and ([w:[PLC1]D00300] < 8)
Result: True if D200 is less than 5, and D300 is less than 8.
The following shows bit operation examples.
[w:[PLC1]D00200] << 4
Result: The data in D200 is shifted 4 bits to the left.
[w:[PLC1]D00200] >> 4
Result: The data in D200 is shifted 4 bits to the right.
Store the value 12(0000Ch) to D301, in BIN format.
[w:[PLC1]D00200] = [w:[PLC1]D00300] >> [w:[PLC1]D00301]
Result: The data in D300 is shifted 12 bits to the right and assigned to D200.
[w:[PLC1]D00200] << 4
Result: The data in D200 is shifted 4 bits to the left.
[w:[PLC1]D00200] >> 4
Result: The data in D200 is shifted 4 bits to the right.
Store the value 12(0000Ch) to D310, in BIN format.
[w:[PLC1]D00200] = [w:[PLC1]D00300] >> [w:[PLC1]D00310]
Result: The data in D300 is shifted 12 bits to the right and assigned to D200.
Bitwise AND
0 & 0 // Result: 0
0 & 1 // Result: 0
1 & 1 // Result: 1
0x1234 & 0xF0F0 // Result: 0x1030
Bitwise OR
0 | 0 // Result: 0
0 | 1 // Result: 1
1 | 1 // Result: 1
0x1234 | 0x9999 // Result: 0x9BBD
Logical OR
0 ^ 0 // Result: 0
0 ^ 1 // Result: 1
1 ^ 1 // Result: 0
Bitwise 1's Complement (When the Data Format is BIN16+)
~ 0 // Result: 0xFFFF
~ 1 // Result: 0xFFFE
Conditional Branch Usage Calculation Examples
Control program flow using "if-endif" and "if-else-endif"
if - endif
if (condition)
{Process 1}
endif
If the condition is true, Process 1 is run. If false, skips Process 1.
For example,
if ([w:[PLC1]D00200] < 5)
{
[w:[PLC]D00100] = 1
}
endif
If data in D200 is less than 5, then assigns 1 to D100.
if - else - endif
if (condition)
{Process 1}
else
{Process 2}
endif
If the condition is true, runs Process 1. If false, runs Process 2.
For example,
if ([w:[PLC1]D00200] < 5)
{
[w:[PLC1]D00100] = 1
}
else
{
[w:[PLC1]D00100] = 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:[PLC1]D00100]#[t:0000].
Script: 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: 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: 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: 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.