Twos Complement to Decimal conversion

coasterbp

Member
Join Date
Dec 2008
Location
Las Vegas
Posts
12
So I'm using a P&F optical read head for positioning. The position data comes into the PLC as two SINT bytes. Monitoring those SINTs in my 1769 controller, they range in values from -127 to 127. When the higher resolution SINT crosses from -1 to 0, is when the lower resolution bit increases 1 digit.

The manual states:
The X position is output in the two's complement.
4 byte consistent Input data 32-bit X data
LSB first
LSB = least significant byte
Resolution: 0.1 mm, 1 mm, 10 mm, binary coded
At a resolution of 1 mm and 10 mm: Lmax = 10.00 km =
10,000,000 mm

Any help in converting this to a decimal position?

Thanks!
 
The manual you quoted states 4 bytes. That is 4 SINT's.
Get them into adjacent memory locations (like an array of SINT[4]), then copy the start of that array to a DINT. (COP SINT[0] MyPosDINT 1)
 

Similar Topics

Hey Guys, I am doing some changes on an older omron CJ2M plc using CX programmer. I am adding an ethernet device that is actually using a Two's...
Replies
4
Views
1,043
Hello All, I will be communicating with some GE Multilin MPR over Modbus. I will be reading some RTD values from the multilin. The Multilin sends...
Replies
17
Views
10,982
As you can see from the title, I have a number of questions/issues; Two different situations/issues: 1. Im reading Oil Pressure and Fuel Pressure...
Replies
17
Views
9,557
In S7/TIA Portal, is there a function to round a real to a specified number of decimal places? e.g. If I have 22.519432 and I want to round it to...
Replies
16
Views
1,654
I am using a Micro 850E PLC (the new one with implicit messaging capability) to drive a Kinetix 5100 servo drive. The error code number on the...
Replies
7
Views
1,649
Back
Top Bottom