Strings in RSLogix?

SirCumference

Member
Join Date
Aug 2014
Location
Milwaukee
Posts
24
I'm pretty new to Logix PLC's, but I'm trying to write some Structured Text code to run on one. I'm having trouble assigning a string value to a string tag. I found Rockwell's Structured Text programming manual online, and the only two examples it shows for how to do this are

Code:
string1.DATA[0]:= 65;
and
Code:
string1.DATA[0]:= string2.DATA[0];

Can you seriously only change strings one character at a time? Please tell me I'm missing something here! Why the heck is Rockwell's string support so mind-blowingly bad?
 
For better or for worse, there is no String literal or String constant in the Logix 5000 operating system.

So you can copy arrays of data from the .Data[x] SINT array, or poke character values in there one at a time in each .Data[x] element.

But you can't just assign a literal string to a String datatype tag, like

MyStringTag.Data := 'Twas brillig and the slithy toves' ;

Such a structure and method exists in IEC1131-3 Structured Text when you're creating variables. But as far as I know, it doesn't exist in Logix 5000.

I generally create String tags, then go type in the values I want in the Tag Database editor.
 
If you will always be writing the same string(s) you build a set of string tags that are constants, e.g. Always65String. Then use a COP(Always65String,string1,50). The 50 is where you put the length of your string.
 
In RsLogix 5000 to assign a string value to a tag (TAG_1) you must have a tag (TAG_2) with the value that you want. From there you can perform a COP/CPS(TAG_2, TAG_1, 1) to copy that string value into to TAG_1. If you want to clear out a string you can perform a FLL(0, TAG_1, 1) to fill the file with all 0's to clear out the string data structure. In the newer version of RsLogix 5000, I believe v31+ you can compare a tag to a literal string with an EQU instruction. I.E. EQU(TAG_1, "Test").

I hope this helps.
 
I'm sure the OP has a solution after 5 years...

I'm not sure you realize that when you search the forum for help you are looking at the answers to other people's questions.
I joined to look for help, just so happens that I was looking at help for this, I agree with you, people might have found a solution but others who search for answers might need them a later date.
 
Short answer is yes, you change a string value directly

To help understand you must first understand what a string is
A string is an array of ASCII characters each character is 4 bits
Look up ASCII table
In Logix5000 the default
string .LEN[0] DINT as Decimal
string .Data[82] SINT as ASCII
If you change the string (Data) you need to also change the LEN to match the number of characters of your new string
The system only reads the number of characters in the LEN
So if you have a string “STRING 1” ( 8 characters long )
You will need to set the .LEN to 8
The processor only reads the data array to the .LEN value if the .LEN value was 0 the string value would be empty
And If the .LEN were to be 10 it would append 2 spaces on the end of the string
It took me a little while to figure it out

String Data Type.PNG
 

Similar Topics

I've been trying for several days now to get a String from my CompactLogix PLC over to my GE HMI. Does anyone have any experience with this exact...
Replies
3
Views
2,304
Hello, Have aoi written in Ladder to pass in and out string variables. String VAriables that interact with PLC program are declared as InOut...
Replies
5
Views
4,257
Hey guys im trying to fill my array of SInts with blank spaces in SCL. would it be ok for me to equalize every member of array with 32 or? i...
Replies
1
Views
1,338
Hiya, For a machine im using a recipe that has 20 lines. Each line contains a free enter field for the customer to enter whatever into (String)...
Replies
3
Views
6,576
Hello guys Im having one trouble when copying partial strings I use an index variable but im loosing the first 4 charaters of the string...
Replies
2
Views
2,654
Back
Top Bottom