Description
Depending on the signal state at switch (input G), the "Select" instruction selects one of the inputs IN0 or IN1 and moves its content to the output OUT. When the input G has the signal state "0", the value at the input IN0 is moved. When the input G has the signal state "1", the value at the input IN1 is moved to the output OUT.
The instruction can only be executed if the enable input EN has the signal state "1" and the tags of all parameters are of the same data type.
Parameters
The following table shows the parameters of the "Select" instruction:
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
||
|---|---|---|---|---|---|---|
|
S7-1200 |
S7-1500 |
S7-1200 |
S7-1500 |
|||
|
EN |
Input |
BOOL |
BOOL |
I, Q, M, D, L or constant |
I, Q, M, D, L or constant |
Enable input |
|
ENO |
Output |
BOOL |
BOOL |
I, Q, M, D, L |
I, Q, M, D, L |
Enable output |
|
G |
Input |
BOOL |
BOOL |
I, Q, M, D, L or constant |
I, Q, M, D, L, T, C or constant |
Switch |
|
IN0 |
Input |
Bit strings, integers, floating-point numbers, timers, TOD, DATE, CHAR, WCHAR |
Bit strings, integers, floating-point numbers, timers, TOD, LTOD, DATE, TDT, CHAR, WCHAR |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
First input value |
|
IN1 |
Input |
Bit strings, integers, floating-point numbers, timers, TOD, DATE, CHAR, WCHAR |
Bit strings, integers, floating-point numbers, timers, TOD, LTOD, DATE, TDT, CHAR, WCHAR |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
Second input value |
|
OUT |
Output |
Bit strings, integers, floating-point numbers, timers, TOD, DATE, CHAR, WCHAR |
Bit strings, integers, floating-point numbers, timers, TOD, LTOD, DATE, TDT, CHAR, WCHAR |
I, Q, M, D, L, P |
I, Q, M, D, L, P |
Result |
You can select the data type of the instruction from the "???" drop-down list of the instruction box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
The following table shows how the instruction works using concrete operand values:
|
Parameters |
Operand |
Value |
|
|---|---|---|---|
|
G |
TagIn_G |
0 |
1 |
|
IN0 |
TagIn_Value0 |
W#16#0000 |
W#16#4C |
|
IN1 |
TagIn_Value1 |
W#16#FFFF |
W#16#5E |
|
OUT |
TagOut_Value |
W#16#0000 |
W#16#5E |
If the "TagIn" operand has signal state "1", the instruction is executed. Based on the signal state at the input "TagIn_G", the value at input "TagIn_Value0" or "TagIn_Value1" is selected and copied to output "TagOut_Value". If the instruction is executed without errors, the enable output ENO has the signal state "1" and the "TagOut" output is set.