Vai all indice del manuale di programmazione
Ecco un suggerimento su come utilizzando i blocchi funzione DoubleToWord, WordToByte, ByteToBit sia possibile espandere una variabile DWORD in 32 variabili BOOL.
Operazione Bitwise
Con il rilascio della versione 5.22.x.xx di LogicLab è stata introdotta la possibilità di eseguire operazioni sui bits. Nel programma ST_DWToBitConversion un esempio di utilizzo.
Esempi
LogicLab (Ptp114, FBD_DWToBitConversion)
PROGRAM FBD_DWToBitConversion
VAR
DdToWd : DoubleToWord; (* Double to word *)
WdToByH : WordToByte; (* Word to bytes *)
WdToByL : WordToByte; (* Word to bytes *)
ByToBtHH : ByteToBit; (* Byte to bits *)
ByToBtHL : ByteToBit; (* Byte to bits *)
ByToBtLH : ByteToBit; (* Byte to bits *)
ByToBtLL : ByteToBit; (* Byte to bits *)
Value : DWORD; (* Value to convert *)
Bit : ARRAY[0..31] OF BOOL; (* Bit status *)
END_VAR

LogicLab (Ptp114, ST_DWToBitConversion)
PROGRAM ST_DWToBitConversion
VAR
Value : DWORD; (* Value to convert *)
Bit : ARRAY[0..31] OF BOOL; (* Bit status *)
END_VAR
// *****************************************************************************
// PROGRAM "ST_DWToBitConversion"
// *****************************************************************************
// An example how to use the data conversion.
// -----------------------------------------------------------------------------
// -------------------------------------------------------------------------
// DATA CONVERT BITWISE
// -------------------------------------------------------------------------
// Data conversion bitwise.
Bit[31]:=Value.31;
Bit[30]:=Value.30;
Bit[29]:=Value.29;
Bit[28]:=Value.28;
Bit[27]:=Value.27;
Bit[26]:=Value.26;
Bit[25]:=Value.25;
Bit[24]:=Value.24;
Bit[23]:=Value.23;
Bit[22]:=Value.22;
Bit[21]:=Value.21;
Bit[20]:=Value.20;
Bit[19]:=Value.19;
Bit[18]:=Value.18;
Bit[17]:=Value.17;
Bit[16]:=Value.16;
Bit[15]:=Value.15;
Bit[14]:=Value.14;
Bit[13]:=Value.13;
Bit[12]:=Value.12;
Bit[11]:=Value.11;
Bit[10]:=Value.10;
Bit[9]:=Value.9;
Bit[8]:=Value.8;
Bit[7]:=Value.7;
Bit[6]:=Value.6;
Bit[5]:=Value.5;
Bit[4]:=Value.4;
Bit[3]:=Value.3;
Bit[2]:=Value.2;
Bit[1]:=Value.1;
Bit[0]:=Value.0;
// [End of file]