How to Fix Negative Values (Garbage Values) Returned by PLC Data Tags
In this troubleshooting guide, you will learn how to solve the problem of negative values (garbage values) returned by PLC data tags. This issue can occur when extracting data from a PLC, such as a Mitsubishi, and the extraction program assumes the value is signed when it is actually unsigned.
When extracting data from a PLC, you may encounter negative values (garbage values) when the extraction program assumes the value is signed, when it is actually unsigned. This issue can cause problems with your application and prevent it from functioning properly. In this guide, we will provide step-by-step instructions on how to fix negative values (garbage values) returned by PLC data tags.
- Verify the issue by comparing the given value from the PLC with the display on the HMI.
Option 1: Signed/Unsigned
Option a) Change the extraction program to use the correct method signed or unsigned. You can use online tools to convert between unsigned and signed values.
Option b) Alternatively, correct it by adding 127 or 32768 to the value.
Option 2: Endianness
- Change the extraction program to use a different method, such as big-endian or little-endian. Endianness refers to the order in which the bytes of a multi-byte value like an integer should be interpreted.
- To solve this, google for your programming language and "convert big-endian to little-endian" or a similar query.