November 19, 2023

#171 - PLC conversions and operations

> Convert a Real value to a Time value:

DINT_TO_TIME(REAL_TO_DINT(#myValue * 1000)) //myValue entered in seconds

> Convert an Analog In/Out value to devices that have different endianness (little/big endian) in Word:
IN: WORD_TO_INT(SWAP(#myWord)) //myWord is the value being read

OUT: SWAP(DWORD_TO_WORD(INT_TO_DWORD(#myInt))) //myInt is the value calculated

> Convert the DB number to DINT:
UINT_TO_DINT(DB_ANY_TO_UINT(#myDB)) //myDB


 

No comments:

Post a Comment