PLCs returning negative values / garbage values

PLC returning negative values


When extracting data from a PLC, e.g., a Mitsubishi, it can happen that the extraction program assumes the value from the PLC is signed, when it is actually unsigned. This can result in a difference of 127 or 32768. If the difference is something else it can be caused by using different endianness.

To verify this, you should compare the given value from the PLC with the display on the HMI.

Solution signed/unsigned

You need to either change the extraction program to use the correct method signed or unsigned. Convert between unsigned and signed - Online Tools

Alternatively, you can correct it by adding 127 or 32768

Solution endianness

You need to either change the extraction program to do a different method (big-endian, little-endian). Endianness It basically means in which order the bytes of a multi-byte value like an integer should be interpreted. To solve this, google for your programming language, e.g., “js convert big-endian to little-endian” (How do I swap endian-ness (byte order) of a variable in javascript )