4 sint hex registers to 1 decimal register

jcfkevin

Member
Join Date
Sep 2006
Location
Orange County
Posts
7
Hi,
I am using an HMS Anybus AB7007 to translate from Modbus RTU to Ethernet/IP. The data is brought into RSLogix 5000 as an I/O sint array in hex. In otherwords, one input point might take up 4 sint registers in the controller tag database.

Tag Value Data Type
AnyBus_Comm:I AB:Ethernet_Module
AnyBus_Comm:I.Data sint[4]
AnyBus_Comm:I.Data[0] 16#00 sint
AnyBus_Comm:I.Data[1] 16#01 sint
AnyBus_Comm:I.Data[2] 16#24 sint
AnyBus_Comm:I.Data[3] 16#f8 sint

The information I need to extract from this device is as follows:
00 01 24 f8 = 75000 (The value in my RS485 devise is 75.000)
Does anyone know how to convert "4" 8-bit registers into "1" decimal [datatype]?

I need a tag with the value of the "4" sint registers combined.

Tag Value Data Type
Temp_Setpoint 75000 AnyDataType

Thanks in advance,
Kevin
 
The solution to this problem is to use Bit Field Distribute (BTD) into a dint. a sint is 8-bits and a dint is 32 bits. Move the most sig. sint into the 24th bit of the dint and 2nd most sig. sint into the 16th bit of the dint and so on. What I ended up with is:

00000000+010000+2400+f8 = 0+65536+9216+248 = 75000

Thanks for looking!
Kevin
 
Here's an alternative
swap.jpg
 
Thanks, I did that, but I just figured out how to do a byte swap in the AnyBus device. Now I can use the copy function and the data comes in in the right order.
 

Similar Topics

Hello i have been trying to figure out a good way to take hex and convert it to an array of SINT[]. Here is what my failed attempt looks like.
Replies
5
Views
1,259
Howdy, I am currently struggling with an array of values that I want to re-arrange in a programmatic way. My program is a mix of ladder and STX...
Replies
6
Views
387
Hello PLC folks, Could someone please help me out here? I am trying to convert SINT to STRING (rslogix5000) but could not get it to work. I used...
Replies
4
Views
1,095
All, i nto fully get it. I read trough some froums but not finaly make it running. so I try to ask. Hopefully anybody has the kindness to answers...
Replies
7
Views
1,187
Hello! I am completely new to PLCs, so I apologize in advance if this is a dumb question. I have a device that sends out its data as a number of...
Replies
5
Views
2,126
Back
Top Bottom