It is not allowed to convert implicitly from a larger type to a smaller type (for example, from INT to BYTE or from DINT to WORD). To achieve this, you have to perform special type conversions. You can basically convert from any elementary type to any other elementary type.
Typed conversion: <elem.type1>_TO_<elem.type2>
Overloaded conversion: TO_<elem.type2>
NOTE: At ...TO_STRING conversions the string is generated as left-justified. If it is defined too short, it will be cut from the right side.
The following type conversions are supported:
oconversion between integral number types
oREAL_TO-/ LREAL_TO conversions
oTIME_TO/TIME_OF_DAY conversions
oTRUNC (conversion to DINT)
oANY_NUM_TO_<numeric data type>