SINT to INT in ControlLogix

Join Date
Jul 2007
Location
Kiruna
Posts
600
Hi Guys,

I am using a Prosoft Profibus Master on a Control Logix PLC. The Input data is recieved to a structure as follows.

MVI156.InputData[250] Type SINT
MVI156.OutputData[250] Type SINT

Using BTD instruction I was able to form an INT Upperbyte InputData[1] & Lower Byte InputData[0]

Has anyone a clever way to do this? SINT to INT conversion instruction perhaps?
 
COP ?

To copy for example 250 SINT's to 125 INT's, make an array of INT[125], and do COP SINT_DATA[0] INT_DATA[0] 125

-- Edit --
COP will copy as many elements of the source as required to fill the DEST at the length requested. The Length specifies the number of DESTINATION elements to fill, so above, if you were combining the SINT's into DINT's, and wanted 50 DINT's from the first 200 SINT's, you would just COP SINT_DATA[0] DINT_DATA[0] 50

Of course, if you have endian related problems, the straight copy won't work.
 
Last edited:
You should be able to change the data format or type in the user defined tag for the module to INT. You have to do this offline.
 
rdrast is correct.

COP instruction is best to perform various datatype converstions. Read rdrast post on the length to use.
 
cciblazer said:
You should be able to change the data format or type in the user defined tag for the module to INT. You have to do this offline.

Changing the data format for a 'generic' type module is a very bad idea. It can often cause a complete loss of comms to a module, always leave it as what the manufacturer recommends, unless you absolutely know better.

Even for my own applications on ProSoft modules, I send all data back and forth in plain SINT arrays, and handle the combination's and conversions to INT/DINT/REAL in the PLC.
 
Prosoft Profibus Master on Control Logix issue

Hi Guys,

I am using a Prosoft Profibus Master on a Control Logix PLC. The Input data is recieved to a structure as follows.

MVI156.InputData[250] Type SINT
MVI156.OutputData[250] Type SINT

Using BTD instruction I was able to form an INT Upperbyte InputData[1] & Lower Byte InputData[0]

Has anyone a clever way to do this? SINT to INT conversion instruction perhaps?

Hi, I´m working with a Prosoft Profibus Master on a Control Logix PLC at this moment, and having a similar situation like you described.
Please, would you be able to send me an example of the routine used to do the sint <--> int convertion (I think I have endian format troubles)
Thanks very much
 
As mentioned the COP statement is the easiest way, this will copy the 8 bits of the SINT tag over to an INT value. However, you do have to be careful using this instruction with SINT-INT conversions. The COP statement in Logix will copy as many of the source elements required to fill the destination tag for the length specified. So if you have the following:

COP = Source: SINT_tag[0] Dest: INT_tag[0] Length: 1

This instruction will take the contents of SINT_tag[0] and [1] (16 bits) to place in the INT_tag[0] field. If in the PROFIBUS mapping, you can allocate a blank space to the next SINT field, then the COP will work fine. But if the PROFIBUS device has other valid data in the next SINT field, then you will have to use different logic.

So if you are doing something like taking a SINT tag on PROFIBUS that represents an unsigned value (range 0-255) instead of the SINT format of RSLogix 5000 (signed byte -128 to 127), then you would instead want to do something like a BTD or an MVM to move bits 0-6, and if bit 7 is on (signed bit) you would add 128 to the value).
These types of instructions will handle the conversion of a unsigned SINT value on the PROFIBUS network, and convert this to a signed INT value that will give you the proper range in the Logix processor.
 
Today I had the opportunity to do some tests. I’m using the cop instruction to convert Sint data (Prosoft Profibus DP board) to Int data (Contrologix). Effectively, I had an endian format issue, so I’m using the SWPB instruction to swap de bytes into the int.
Thanks to everyone for the help
 

Similar Topics

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
393
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,102
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,193
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,267
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,135
Back
Top Bottom