MUX

Select value from multiple channels

The function Multiplexer selects an input variable and writes its value into the output variable. The 1st input variable determines which input variable (IN1or IN2 ...) is to be written into the output variable. The function MUX can be configured for any desired number of inputs.

Parameters

Input

K (INT)

Selects which value is written to the output

IN0 (ANY)

Value 0 is written to the output if K = 0

IN1 (ANY)

Value 1 is written to the output if K = 1

Output

VAR_OUT (ANY)

Result output as 2nd and 3rd input

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.

  • This function can be expanded to a maximum of 28 input contacts, see also modifying elements.

  • The 2nd and 3rd input variables must be of the same data type.

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 : INT:=0;
			(*value '0' to 'n'*)
		channel_0: INT:=0;
			(*all types allowed*)
		channel_1: INT:=0;
			(*all types allowed*)
		output: INT:=0;
			(*all types allowed*)
	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

In channel_select you find the integer value (0, 1...n) for the selection of channel_0 or channel_1. The result will be written into output.

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,MUX-2!,Instance,10,0,15,5,,?DK?DIN0?DIN1?C);
B(B_VARIN,,channel_select,8,1,10,3,);
B(B_VARIN,,channel_0,8,2,10,4,);
B(B_VARIN,,channel_1,8,3,10,5,);
B(B_VAROUT,,output,15,1,17,3,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

output:=MUX( K:= channel_select , IN0:= channel_0 ,
         IN1:= channel_1 );

IL body

LD

channel_select

MUX

channel_0,channel_1

ST

output

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