UTOI – Unsigned to signed integer number conversion

Block SymbolLicensing group: STANDARD
PIC

Function Description
The UTOI block facilitates the conversion of an unsigned integer to a signed integer using two’s complement representation, which is the common representation used in processors. For instance, in 8-bit representation, the number -1 is represented as 255, and in 16-bit representation as 65535. The parameter bits determines which bit representation is assumed.

This block is primarily used in scenarios where a value from a driver contains multiple signals extracted by masking (typically using INTSM or BITOP blocks). The result of this masking is always an unsigned (positive) number. However, if the signal from the driver is meant to be interpreted as a signed number, this block is used to obtain the correct value.

Since processors may vary in how they store multi-byte numbers (most commonly in little-endian format, where the less significant byte is stored at a lower address, but big-endian format processors also exist, where the opposite is true), the UTOI block offers the option to swap the byte order if it has not been handled by the driver. This adjustment is facilitated by the SWAP parameter.

Caution: Swapping the byte order (by setting SWAP=on) typically addresses issues with different byte orders in the processor only for bits=16 or bits=32 values.

This block propagates the signal quality. More information can be found in the 1.4 section.

Input

u

Unsigned input signal   -9.22337E+18  9.22337E+18

Large (I64)

Parameter

bits

Valid (LSB) bits in input signal   2  64 16

Long (I32)

SWAP

Swap input byte order

Bool

Output

i

Converted (signed) input signal

Large (I64)

2024 © REX Controls s.r.o., www.rexygen.com