Table of Contents

Integer decomposition

Block name

BD54_INT_DECOMPOSITION

ST call

PROGRAM BD54
 VAR
 ARRAY1: ARRAY [0..3] OF DINT;
 ARRAY2: ARRAY [0..3] OF REAL;
 DINT1: DINT := 23139;
 FB: LIB.CORE.V1_0.BD54_INT_DECOMPOSITION := (LOW := [1, 5, 1, 13] ,HIGH := [4, 8, 8, 16]);
 END_VAR
  FB(IN:= DINT1, OUT=>ARRAY1, DY=>ARRAY2);
END_PROGRAM

Library

LIB\CORE

Version

V1.0

Description

The block decomposes the input data to up to four (integer) values composed from defined range of bits.

Inputs

InputType Description Default value
IN DINT Input data - double integer value 0
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

OutputType Description
OUT ARRAY_DINTOutput value, array [0..3]
DY ARRAY_REALOutput value, array [0..3]
bs bool Sign of the input value

Function

The block decomposes the input data according to the low and high parameters. For example, to evaluate the first 4 bits as a value ranged from 0 to 15, fill in low as [1,0,0,0] and high as [4,0,0,0]: the low bit is 1, the high bit is 4. The resulting value will be in the first element of the output array. bs is the sign of the input data. The displayed range may be 2 to 32 bits.

Application example

Input vector decomposition with parameters low = [1,5,1,13] and high = [4,8,8,16]. The first value is composed from bits 1 to 4, the second value is composed from bits 5 to 8, third value from bits 1 to 8, and fourth value from bits 13 to 16 of the input value dint1.