LD
The LD instruction reads the value of the specified BOOL variable and outputs it to the next instruc-tion.
If the value of the specified variable is TRUE, then TRUE is output. If the value is FALSE, then FALSE is output.
Use the LD instruction for the first NO bit from the bus bar or for the first NO bit of a logic block.
The operation is as shown below if you do not specify upward or downward differentiation.
Instruction Value of variable Output value
LD TRUE TRUE
FALSE FALSE
If you specify upward or downward differentiation, the operation depends on the following: the value of the variable the last time the instruction was executed and the current value of the variable. This is shown below.
Instruction Differentiation specification Value of variable at last execution and current value of variable
Output val-ue
LD
Upward differentiation FALSE at the last execution → Currently TRUE TRUE
Other than the above. FALSE
Downward differentiation TRUE at the last execution → Currently FALSE TRUE
Other than the above. FALSE
The following figure shows a programming example and timing chart.
A
A
A
B1
B3
B5
TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE A
B1
B3
B5
Instruction execution
LDN
The LD instruction reads the inverse of the value of the specified BOOL variable and outputs it to the next instruction.
If the value of the specified variable is TRUE, then FALSE is output. If the value is FALSE, then TRUE is output.
Use the LDN instruction for the first NC bit from the bus bar or for the first NC bit of a logic block.
The operation is as shown below if you do not specify upward or downward differentiation.
Instruction Value of variable Output value
LDN TRUE FALSE
FALSE TRUE
If you specify upward or downward differentiation, the operation depends on the following: the value of the variable the last time the instruction was executed and the current value of the variable. This is shown below.
Instruction Differentiation specification Value of variable at last execution and current value of variable
Output val-ue
LDN
Upward differentiation FALSE at the last execution → Currently TRUE FALSE
Other than the above. TRUE
Downward differentiation TRUE at the last execution → Currently FALSE FALSE
Other than the above. TRUE
The following figure shows a programming example and timing chart.
Ladder Diagram Instructions
2
LD and LDN
A
A
A
B2
B4
B6
TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE A
B2
B4
B6
Instruction execution
Precautions for Correct Use
• An error occurs in the following case and the output value from the last execution is retained.
a) You specify an array element for the variable value and the element does not exist.
Example: A BOOL array a[0..5] is defined, but the instruction is executed using a[10] as the vari-able.
• Do not use these instructions as the rightmost instruction on a rung. If you do, an error occurs on the
Sysmac Studio and you cannot transfer the user program to the Controller.
AND and ANDN
AND : Takes the logical AND of the value of a BOOL variable and the input value.
ANDN : Takes the logical AND of the inverted value of a BOOL variable and the input value.
Instruction Name FB/
FUN Graphic expression ST expression
AND AND
---Upward differentiation
Downward differentiation Variable
Variable Variable result:=vBool1 AND vBool2;
result:=vBool1 & vBool2;
ANDN AND NOT
---Upward differentiation
Downward differentiation Variable
Variable Variable result:=vBool1 AND NOT vBool2;
Variables
None
Function
AND
The AND instruction takes the logical AND of the value of a specified BOOL variable and the execu-tion condiexecu-tion and outputs it to the next instrucexecu-tion.
Use the AND instruction for a NO bit connected in series with the previous instruction.
The following figure shows a programming example of the AND instruction. It takes the logical AND of variable A and variable B and outputs it to variable C.
A B C
LD instruction
Out instruction AND
instruction
B
A C
It takes the logical AND of variable A and variable B and outputs the result to variable C.
Ladder Diagram Instructions
2
AND and ANDN
The operation is as shown below if you do not specify upward or downward differentiation.
Instruction Combination of variable value and execution condition Output value AND
Variable value: TRUE
Execution condition: TRUE TRUE
Other than the above. FALSE
If you specify upward or downward differentiation, the operation depends on the following: the value of the variable the last time the instruction was executed, the current value of the variable, and the exe-cution condition. This is shown below.
Instruc-tion
Differentiation specifica-tion
Combination of value of variable at last execution, current value of variable, and execution condition
Output value
AND
Upward differentiation
Variable value: FALSE at the last execution → Current-ly TRUE
Execution condition: TRUE
TRUE
Other than the above. FALSE
Downward differentiation
Variable value: TRUE at the last execution → Currently FALSE
Execution condition: TRUE
TRUE
Other than the above. FALSE
ANDN
The ANDN instruction takes the logical AND of the inverse of the value of a specified BOOL variable and the execution condition and outputs it to the next instruction.
Use the ANDN instruction for a NC bit connected in series with the previous instruction.
The operation is as shown below if you do not specify upward or downward differentiation.
Instruction Combination of variable value and execution condition Output value ANDN
Variable value: FALSE
Execution condition: TRUE TRUE
Other than the above. FALSE
If you specify upward or downward differentiation, the operation depends on the following: the value of the variable the last time the instruction was executed, the current value of the variable, and the exe-cution condition. This is shown below.
Instruc-tion
Differentiation specifica-tion
Combination of value of variable at last execution, current value of variable, and execution condition
Output value
ANDN
Upward differentiation
Variable value: FALSE at the last execution → Current-ly TRUE
Execution condition: TRUE FALSE
Variable value: Ignored Execution condition: FALSE
Other than the above. TRUE
Downward differentiation
Variable value: TRUE at the last execution → Currently FALSE
Execution condition: TRUE FALSE
Variable value: Ignored Execution condition: FALSE
Other than the above. TRUE
Precautions for Correct Use
• An error occurs in the following case and the output value from the last execution is retained.
a) You specify an array element for the variable value and the element does not exist.
Example: A BOOL array a[0..5] is defined, but the instruction is executed using a[10] as the vari-able.
• Do not use these instructions as the rightmost instruction on a rung. If you do, an error occurs on the Sysmac Studio and you cannot transfer the user program to the Controller.
• You cannot connect these instructions directly to the bus bar.
Ladder Diagram Instructions
2
AND and ANDN