Table of Contents

Integer Composition

Block name

BD55_INT_COMPOSITION

ST call

PROGRAM BD55
    VAR
     LINT1:LINT;
     ARRAY1 : ARRAY [0..3] OF DINT := [3, 6, 10, 5];
     LOW : ARRAY[0..3] OF LIB.CORE.V1_0.BIT32:= [1, 5, 9, 13];
   HIGH : ARRAY[0..3] OF LIB.CORE.V1_0.BIT32:= [4, 8, 12, 16];
     END_VAR
  LINT1:= LIB.CORE.V1_0.BD55_INT_COMPOSITION(LOW := LOW ,HIGH := HIGH ,BS:=TRUE,IN:=ARRAY1);
END_PROGRAM

Library

LIB\CORE

Version

V1.0

Description

The block composes the output value from up to 4 binary input vectors with defined positioning within the output vector.

Inputs

InputType Description Default value
IN DINT Input data, up to 4 inputs possible [0]
BS BOOL Sign of the output value False
LOW ARRAY[0..3] OF LIB.CORE.V1_0.BIT32first bits of the range, array [0..3] with values 1 to 32[1]
HIGH ARRAY[0..3] OF LIB.CORE.V1_0.BIT32last bits of the range, array [0..3] with values 1 to 32 [1]

Outputs

OutputTypeDescription
⇒ lintOutput value

Function

The block composes the output integer value from up to 4 parts according to given parameters in,low, and high. The output value sign is given by the bs variable. E.g. the input value will have 4 bits and shall be inserted as 5th to 8th bit of the output value: low = [5,0,0,0], high = [8,0,0,0]. The input value itself is e.g. 6: in = [6,0,0,0]. Note that if the ranges overlap  there may be undefined behaviour of the output value.

Application example

Input value composition, in0 occupies bits 1 to 4, in2 occupies bits 5 to 8 etc. The parameters are then set as low = [1,5,9,13] and high = [4,8,12,16].