SEL

Select value from one of two channels

With the first input variable (data type BOOL) of SEL you define which input variable is to be written into the output variable. If the Boolean value = 0 (FALSE), the input variable IN0 will be written into the output variable, otherwise IN1.

Parameters

Input

G (BOOL)

1st input: selects between input value IN0 or IN1

IN0 (ANY)

2nd input: value is written into the output variable if G = FALSE

IN1 (ANY)

3rd input: value is written into the output variable if G = TRUE

Output

VAR_OUT (ANY)

Result value as IN0 or IN1

Remarks

When using the data type STRING with small PLCs like FP-e or FP0, make sure that the length of the result string is equal to or greater than the length of the source string.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		channel_select: BOOL:=FALSE;
		channel_0: INT:=0;
		channel_1: INT:=0;
		output: INT:=0;
	END_VAR

In this example the input variables (channel_select, channel_0 and channel_1) have been declared. Instead, you may enter a constant directly at the input contact of a function.

POU body

If channel_select has the value 0, channel_0 will be written into output, otherwise channel_1.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_F,SEL!,Instance,15,0,20,5,,?DG?DIN0?DIN1?C);
B(B_VARIN,,channel_0,13,2,15,4,);
B(B_VARIN,,channel_1,13,3,15,5,);
B(B_VAROUT,,output,20,1,22,3,);
B(B_CONTACT,,channel_select,7,1,9,3,);
L(1,2,7,2);
L(9,2,15,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

output := SEL(G := channel_select, IN0 := channel_0, IN1 := channel_1);

IL body

LD

channel_select

SEL

channel_0,channel_1

ST

output

Modified on: 2019-01-26Feedback on this pagePanasonic hotline