WordsToDouble, word to double conversion
Questa funzione permette di convertire due variabili WORD in una variabile DWORD. L'operando MSW è trasferito nei 16 bits alti, l'operando LSW è trasferito nei 16 bits bassi.
Approfondimenti
- In questo topic tecniche di trasferimento array di variabili BOOL sul pannello operatore.
Descrizione
| Parametro | Tipo | Descrizione |
|---|---|---|
| MSW | WORD | MSW del valore in uscita. |
| LSW | WORD | LSW del valore in uscita. |
| Out | DWORD | La funzione ritorna una DWORD. |
Esempi
Come utilizzare gli esempi.
Nell'esempio due variabili WORD con valore 16#1234 e 16#5678 sono trasferite in una variabile DWORD il risultato sarà 16#12345678.
LogicLab (Ptp114, IL_WordsToDouble)
PROGRAM IL_WordsToDouble
VAR
High : WORD := 16#1234; (* MSW word *)
Low : WORD := 16#5678; (* LSW word *)
Result : DWORD; (* Compress result *)
END_VAR
(* ************************************************************************** *)
(* PROGRAM "IL_WordsToDouble" *)
(* ************************************************************************** *)
(* This program shows the use of WordsToDouble function. *)
(* ------------------------------------------------------------------------- *)
LD High (* MSB byte *)
WordsToDouble Low
ST Result (* Compress result *)
(* [End of file] *)
LogicLab (Ptp114, ST_WordsToDouble)
PROGRAM ST_WordsToDouble
VAR
High : WORD := 16#1234; (* MSW word *)
Low : WORD := 16#5678; (* LSW word *)
Result : ARRAY[0..1] OF DWORD; (* Compress result *)
END_VAR
// *****************************************************************************
// PROGRAM "ST_WordsToDouble"
// *****************************************************************************
// This program shows the use of WordsToDouble function.
// -----------------------------------------------------------------------------
// -------------------------------------------------------------------------
// COMPRESS WORD
// -------------------------------------------------------------------------
// Compress byte using the FB.
Result[0]:=WordsToDouble(High, Low); //Compress result
// -------------------------------------------------------------------------
// COMPRESS WORD
// -------------------------------------------------------------------------
// The same operation as above executed directly using ST statements.
Result[1]:=(TO_DWORD(High)*16#10000)+TO_DWORD(Low); //Compress result
// [End of file]