INT to String ControlLogix

jebr2121

Member
Join Date
Feb 2003
Posts
10
I have a scanner that is transmitting data via Ethernet to a ControlLogix. The data is in INT and I need to figure out how to put the Barcode data starting in "Scanner_Ethernet1:I.Data[3]" into a string. I have not had much luck but am sure someone has figured it out. I attached what the data looks like in the Controller Tags.

Thank You in advance.

CAP1.PNG CAP2.PNG
 
You can use the COP instruction to move a block of data from one type of array tag to another, even when they are of different datatypes. The crucial thing is to understand the relative sizes and to specify the Length argument correctly.

The String datatype has a .LEN subelement (a 4-byte DINT) and a .DATA sub-array, which is a array of 82 1-byte SINT[x] elements.

Try just copying the data from one array to another:

MOV
Source: 8
Destination: MyString.LEN

COP
Source: Scanner_Ethernet1:I.Data[3]
Destination: MyString.Data[0]
Length: 8

The Length of a COP instruction is always the number of destination elements. Since we want to move eight characters and the destination has SINT (1-byte, or one-character in ASCII) sub-elements, the length is 8.

Two things might not work correctly:

I don't know if the data in your I/O image is in the correct order. You might need to use the SWPB instruction to swap the high and low bytes before copying the data into the String.

Also, is the length of the string 7 characters, as seen in Scanner_Ethernet1:I.Data[2], or 8 as seen in the number of readable characters ?
 
Take a look at this recent thread where someone else had the same problem with a PLC/5. Post #7 has a tested solution that works. http://www.plctalk.net/qanda/showthread.php?t=76943

RSLogix5 would not allow the use of a COP instruction. Maybe RSLoigx5000 will. If COP doesn't work and you have more than three or four integers to move then consider using FAL.

Be aware that in a PLC/5 a string element is a 16 bit integer that contains two characters, one in the high byte and one in the low byte. The ControlLogix string is a SINT array. A previous post in the same thread shows how you can split an integer into high and low bytes.
 
Last edited:
One of the things that I was grateful for when ASCII support was introduced into the ControlLogix is that the data type / instruction conflicts that were such a pain in the PLC/SLC instruction set were a thing of the past.

Because this is an Input connection, I use the Copy Synchronous (CPS) instruction to copy the String data to an intermediate array tag because there is a small but nonzero chance that the Input data table will get updated in between the instructions that I'm using to manipulate the String.

Attached is an example screenshot, in PDF format, of how the logic I described above works.
 
Thanks to both of you. Ken you had the 1st response I read this morning. I was tied up most of the day but did as you said and then the only issue I had was swapping High/Low. I used the example included in 5000 "Swap_Bytes_In_Array. It used an index so the SWPB was used once and works great. Once refined and documented so it makes sense to people other than me I will post and hope it helps someone else.
Again Thank You
 

Similar Topics

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,121
HI Guys So i am trying to write a real SINt or DINT value into a string tag. If in string browser I write it manually, no problem. But how can I...
Replies
8
Views
5,953
Dears, Is there any simple way to convert single DINT variable to STRING contains single sign based on source DINT (Decimal representative of...
Replies
2
Views
1,815
Hey everybody, Happy New Year! I have a PanelView Plus 600 that has a String Input Enable. This is communicating with a MicroLogix 1400 and...
Replies
11
Views
3,258
HI, My first post on here, Using SLC500 I have a STRING LEN 30 that I need to convert just the first 2 characters (POS 0 , 1) into an INT. any...
Replies
6
Views
2,424
Back
Top Bottom