How do I deal with an unsigned integer in an SLC, PLC5, or MicroLogix processor?


Scenario: A device that uses an INT value to represent a range of 0 to 65535, but in the processor the INT tag has a range of -32768 to 32767.

Since the A/B processor does not have an unsigned Integer data type, you will need to convert this value to represent the full range. Simply take your data value and do a masked move (MVM) into a float tag. Your mask will be 16#7FFF. This will move the least significant 15 bits into the Float tag. Then if bit 15 is set within your original INT tag, add 32768 to the Float tag. This will allow the value to display with a range of 0 to 65535.

Custom Fields

Article ID: 306
Created On: Tue, Jan 23, 2007 at 1:52 PM
Last Updated On: Tue, Sep 29, 2015 at 12:24 AM
Authored by: Administrator

Online URL: https://www.prosoft-technology.com/kb/article.php?id=306