Table of Contents

Bit decomposition

Block name

BD19_BIT_DECOMPOSITION

ST call

PROGRAM BD19_TEST
 
VAR 
 
    I1: LINT;
 
    O1: ARRAY [0 .. 63] OF BOOL;
 
    FB: LIB.CORE.V1_0.BD19_BIT_DECOMPOSITION;
END_VAR
 
 
 
    FB(IN := I1, OUT=>O1);
 
END_PROGRAM

Library

LIB\CORE

Version

V1.0

Description

The function decomposes an integer value to bits (which are formed in an array).

Inputs

Input TypeDescription
ENABLEDBOOLEnable of function.
IN LINTInput value

Outputs

OutputType Description
OUT ARRAY [0 .. 63] OF BOOLOutput array of values
BS BOOL Sign of the out output, if OUT<0 then BS=FALSE

Function

The block decomposes the input integer value IN to individual bits OUT[0..63]. If IN<0 then BS=FALSE, else BS=TRUE.

Note: The output array elements are numbered from 0, while the optional binary outputs out1, out2, out3 etc. start with index 1. Thus, e.g. out3 binary output is the value of the out[2] array element.

Application example


The block is used to extract bits from an integer value, i.e. status and alarm bits communicated from a 3rd party device.