The TestABitN instruction assigns the inverted value of the bit at bit position Pos in the bit string In to the bit value Out when EN is TRUE.
When EN is FALSE, the value of Out is FALSE.
Precautions for Correct Use
• If the TestABit instruction and the TestABItN instruction are used in a ladder diagram, the value of
Out changes to FALSE when an error occurs in the previous instruction on the rung.• An error occurs in the following case. Out will be FALSE.
a) The value of Pos is greater than the number of bits in In - 1.
Sequence Input Instructions
2
TestABit and TestABitN
Sequence Output Instructions
Instruction Name Page
RS Reset-Priority Keep page 2-56
SR Set-Priority Keep page 2-59
Set and Reset Set/Reset page 2-62
SetBits and ResetBits Reset Bits/Reset Bits page 2-66 SetABit and ResetABit Set A Bit/Reset A Bit page 2-69
OutABit Output A Bit page 2-71
2
RS
The RS instruction retains the value of a BOOL variable. It gives priority to the Reset input if both the Set input and the Reset input are TRUE.
Instruction Name FB/
FUN Graphic expression ST expression
RS Reset-Priority
Keep FB
RS Set Q1 Reset1
RS_instance
RS_instance(Set, Reset1, Q1);
Variables
Meaning I/O Description Valid range Unit Default
Set *1 Set
Input Set input Depends on
da-ta type. --- 0
Reset1 *1 Reset Reset input
Q1 Keep Output Keep output Depends on
da-ta type. ---
---*1. On Sysmac Studio version 1.03 or higher, you can use S instead of Set and R1 instead of Reset1 to more clearly show the correspondence between the variables and the parameter names in ST expressions.
For example, you can use the following notation: RS_instance(S:=A, R1:=B, Q1=>abc);.
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
Set OK
Reset1 OK
Q1 OK
Function
The RS instruction forms a self-holding output that gives priority to resetting. The following table shows input values and resulting output values.
Value of Set Value of Reset1 Value of Q1
TRUE TRUE FALSE
TRUE FALSE TRUE
FALSE TRUE FALSE
FALSE FALSE Not changed.
The following figure shows a programming example and timing chart.
RS_instance(A, B, abc);
LD ST
B
A RS abc
Set Q1 Reset1
RS_instance
Set = A
Reset1 = B TRUE FALSE TRUE FALSE
Q1 = abc TRUE FALSE
Additional Information
• The RS instruction behaves like the following self-holding rung.
A B abc
abc
• However, if the RS instruction is in a master control region and the master control region is reset, the behavior will not be the same as the above self-holding rung.
Instruction/rung Value of B Value of abc RS instruction TRUE Not changed.
FALSE FALSE
Self-holding rung TRUE
FALSE FALSE
Precautions for Correct Use
• Never use an NC bit directly from an external device for the Reset1 input. The internal power supply in the Controller will not turn OFF immediately when the AC power is interrupted (even for momenta-ry interruptions), and the input from the Input Unit may change to ON first. This could cause the
Reset1 input to change to TRUE.• If this instruction is used in a ladder diagram, the value of Q1 is retained when an error occurs in the previous instruction on the rung.
• If this instruction is not executed due to the execution of a jump instruction (e.g., the JMP instruc-tion), Q1 retains the value from the last execution.
Sequence Output Instructions
2
RS
• If this instruction is in a master control region and the master control region is reset, the operation is as follows:
a) If the value of Reset1 is TRUE, the value of Q1 is retained. If the value of Reset1 is FALSE, the value of Q1 changes to FALSE.
b) FALSE is input to the instruction that is connected to Q1 even if the value of Q1 is TRUE.
• Even if you connect a parameter with a Retain attribute to Q1, the value will not be retained when
the power is interrupted. After the power supply is restored, the value of Q1 will change to FALSE
when the operating mode is changed to RUN mode and the instruction is executed. If the
self-hold-ing rung given in Additional Information on page 2-57 is used, the value is retained even after the
power supply is restored.
SR
The SR instruction retains the value of a BOOL variable. It gives priority to the Set input if both the Set input and Reset input are TRUE.
Instruction Name FB/
FUN Graphic expression ST expression
SR Set-Priority
Keep FB
SR Set1 Q1 Reset
SR_instance
SR_instance(Set1, Reset, Q1);
Variables
Meaning I/O Description Valid range Unit Default
Set1 *1 Set
Input Set input Depends on
da-ta type. --- 0
Reset Reset Reset input
Q1 Keep Output Keep output Depends on
da-ta type. ---
---*1. On Sysmac Studio version 1.03 or higher, you can use S1 instead of Set1, and R instead of Reset to more clearly show the correspondence between the variables and the parameter names in ST expressions.
For example, you can use the following notation: SR_instance(S1:=A, R:=B, Q1=>abc);.
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
Set1 OK
Reset OK
Q1 OK
Function
The SR instruction forms a self-holding output that gives priority to setting. The following table shows input values and resulting output values.
Value of Set1 Value of Reset Value of Q1
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE FALSE
FALSE FALSE Not changed.
The following figure shows a programming example and timing chart.
Sequence Output Instructions
2
SR
SR_instance(A, B, abc);
LD ST
B
A SR abc
Set1 Q1 Reset
SR_instance
Set1 = A
Reset = B
TRUE FALSE TRUE FALSE
Q1 = abc TRUE FALSE
Additional Information
• The SR instruction behaves like the following self-holding rung.
A abc
abc B
• However, if the SR instruction is in a master control region and if the master control region is reset, the behavior will not be the same as the above self-holding rung.
Instruction/rung Value of B Value of abc SR instruction TRUE Not changed.
FALSE FALSE
Self-holding rung TRUE
FALSE FALSE
Precautions for Correct Use
• Never use an NC bit directly from an external device for the Reset input. The internal power supply in the Controller will not turn OFF immediately when the AC power is interrupted (even for momenta-ry interruptions), and the input from the Input Unit may change to ON first. This could cause the
Reset input to change to TRUE.• If this instruction is used in a ladder diagram, the value of Q1 is retained when an error occurs in the previous instruction on the rung.
• If this instruction is not executed due to execution of a jump instruction (e.g., the JMP instruction),
Q1 retains the value from the last execution.• If this instruction is in a master control region and the master control region is reset, the operation is as follows:
a) If the value of Reset is TRUE, the value of Q1 is retained. If it is FALSE, the value of Q1 changes to FALSE.
b) FALSE is input to the instruction that is connected to Q1 even if the value of Q1 is TRUE.
• Even if you connect a parameter with a Retain attribute to Q1, the value will not be retained when the power is interrupted. After the power supply is restored, the value of Q1 will change to FALSE when the operating mode is changed to RUN mode and the instruction is executed. If the self-hold-ing rung given in Additional Information is used, the value is retained even after the power supply is restored.
Sequence Output Instructions
2
SR