PROGRAM ST_ByteToBit
VAR
IByte : BYTE; (* Input byte *)
OBit : ARRAY[ 0..1, 0..7 ] OF BOOL; (* Output bits *)
BDec : ByteToBit; (* Byte decompress *)
END_VAR
// *****************************************************************************
// PROGRAM "ST_ByteToBit"
// *****************************************************************************
// This program shows the use of ByteToBit function block.
// -----------------------------------------------------------------------------
// -------------------------------------------------------------------------
// DECOMPRESS BYTE
// -------------------------------------------------------------------------
BDec(In:=IByte);
OBit[0,0]:=BDec.b0; //Output bits
OBit[0,1]:=BDec.b1; //Output bits
OBit[0,2]:=BDec.b2; //Output bits
OBit[0,3]:=BDec.b3; //Output bits
OBit[0,4]:=BDec.b4; //Output bits
OBit[0,5]:=BDec.b5; //Output bits
OBit[0,6]:=BDec.b6; //Output bits
OBit[0,7]:=BDec.b7; //Output bits
// -------------------------------------------------------------------------
// DECOMPRESS BYTE
// -------------------------------------------------------------------------
// The same operation as above executed directly using ST statements.
OBit[1,0]:=TO_BOOL(IByte AND 16#01); //Output bits
OBit[1,1]:=TO_BOOL(IByte AND 16#02); //Output bits
OBit[1,2]:=TO_BOOL(IByte AND 16#04); //Output bits
OBit[1,3]:=TO_BOOL(IByte AND 16#08); //Output bits
OBit[1,4]:=TO_BOOL(IByte AND 16#10); //Output bits
OBit[1,5]:=TO_BOOL(IByte AND 16#20); //Output bits
OBit[1,6]:=TO_BOOL(IByte AND 16#40); //Output bits
OBit[1,7]:=TO_BOOL(IByte AND 16#80); //Output bits
// [End of file]