DoubleToWord, conversie dublă în cuvânt

Listă

Această pagină face parte din Manual de programare IEC 61131-3. Mergeți la index.

Acest bloc de funcții vă permite să convertiți o variabilă DWORD în două variabile WORD. Biți 16 mari de In va fi transferat la operand MSW, biții 16 scăzute vor fi transferați pe operand LSW.

Blocarea funcției
CODESYS: Nu este disponibil
LogicLab: eLLabUtyLib

In (DWORD) Variabilă de convertit.

MSW (WORD) MSW a valorii de intrare.

LSW (WORD) LSW a valorii de intrare.

Exemple

Cum se utilizează exemplele.
În exemplu o variabilă DWORD cu valoarea 16 # 12345678 este transferat în două variabile WORD care va avea valoarea 16 # 1234 și 16 # 5678. În exemplul în limbaj ST se evidențiază modul în care aceeași operație este mult mai simplă scriind-o direct cu operandurile limbii.

LogicLab (Ptp114)
PROGRAM ST_DoubleToWord
VAR
    DData : DWORD := 16#12345678; (* Double word data *)
    High : ARRAY[ 0..1 ] OF WORD; (* MSW word *)
    Low : ARRAY[ 0..1 ] OF WORD; (* LSW word *)
    DDec : DoubleToWord; (* Double decompress *)
END_VAR

// *****************************************************************************
// PROGRAM "ST_DoubleToWord"
// *****************************************************************************
// This program shows the use of DoubleToWord function block.
// -----------------------------------------------------------------------------

    // -------------------------------------------------------------------------
    // DECOMPRESS DWORD
    // -------------------------------------------------------------------------
    // Decompress word using the FB.

    DDec(In:=DData);
    High[0]:=DDec.MSW; //MSW word
    Low[0]:=DDec.LSW; //LSW word

    // -------------------------------------------------------------------------
    // DECOMPRESS DWORD
    // -------------------------------------------------------------------------
    // The same operation as above executed directly using ST statements.

    High[1]:=TO_WORD(DData/16#10000); //MSW word
    Low[1]:=TO_WORD(DData); //LSW word

// [End of file]
A fost util acest articol?