Add a space between 2 strings in Logix500

beethoven_ii

Lifetime Supporting Member
Join Date
Nov 2006
Location
Central England
Posts
409
I have 2 strings which I need to concatenate to create an identifier for my client but they want a space between them. Both strings are just numbers read by a Scada system such as 13 and 25666. When I concatenate the strings I get 1325666 and the client wants it to be read as 13 25666.

Any tips on how to do this would be greatly appreciated.
 
Haven't done much to speak of with strings in 500, but one obvious possibility suggests itself to me: add a third string, " ", and use two concatenate operations.
 
I haven't used strings in Logix500 before either. I am not sure how to create a string with just a space in it. " " works in Siemens but I'm not sure it means the same thing in Logix 500. I can type " " into a spare string in the data table but that is exactly how it appears and not as a space.
 
I have a figured out a way of using a spare sting and putting a space into it so I can add this to my 1st string to get the space I need. What I'd like to know now is how I can ensure this doesn't get overwritten by a download or by someone else. Is there a way in the ladder code I can permanently move or copy a space into my string register?
 
It sounds like a task better done in SCADA. Presumably the SCADA system has better string handling capability than Logix500.

If you must do it in the PLC, set up an array of integer words. Then move a value of 49 (ASCII code for "1") into the low byte of the first word, move a value of 51 into the high byte of the first word, move a value of 32 (ASCII code for a space) into the low byte of the the second word, move a value of 50 into the high byte of the second word, etc. Then set up a string tag in the SCADA linked to the address of the first integer in the PLC array. The PLC ladder logic to do it will be ugly.
 
I found that I couldn't enter just a space on it's own into a String register in the data table. I then I discovered that if I typed a character first then a space and hit enter it saved the string with a length of 2. I was then able to edit the string in the data table and remove the 1st character, leaving me with just a space in the string with a length of 1. I can now concatenate this with my other string which has 13 in it so that I get 13 and a space which I then concatenate with the string with the other number in.
 
Is there a way in the ladder code I can permanently move or copy a space into my string register?

In 5000 you could set a tag as constant, or if the controller was recent enough just use a string literal. Unfortunately, you're stuck with the limitations of 500 which isn't great for working with strings.

You might be able to do something with MOVing the ASCII value for a space into the data register of the string, but I fear it's going to end up ugly.
 
Last edited:
In 5000 you could set a tag as constant, or if the controller was recent enough just use a string literal. Unfortunately, you're stuck with the limitations of 500 which isn't great for working with strings.

You might be able to do something with MOVing the ASCII value for a space into the data register of the string, but I fear it's going to end up ugly.

You can do this in RSLogix500 as well. Just populate a ST element data field with the characters you want and use the ACN (String Concatenate) instruction to stick it to the end of the first item (after using AIC to convert it to a string) and then another ACN to stick that result together with the 2nd string.

Are these always integers? If there are floats involved and you're PLC is a Micrologix other than a 1400, there are special steps you have to take to get a float converted properly to a string.
 
Last edited:
You can do this in RSLogix500 as well. Just populate a ST element data field with the characters you want and use the ACN (String Concatenate) instruction to stick it to the end of the first item (after using AIC to convert it to a string) and then another ACN to stick that result together with the 2nd string.

This is what has been suggested already, and essentially what is being done.

The desired output of the concatenation operation has been achieved, the question is how to populate the data field in such a manner that it is difficult for the space being added to be overwritten by someone else.
 
This is what has been suggested already, and essentially what is being done.

The desired output of the concatenation operation has been achieved, the question is how to populate the data field in such a manner that it is difficult for the space being added to be overwritten by someone else.

That's what I get for skimming over the replies too quickly.

To ensure that the string is not overwritten you could create a new file and make it Static (data file properties, Protection) to hold the string constant. I don't think that will protect it from being edited by a programmer with RSLogix500, but would at least protect it from inadvertent access by a HMI or SCADA.
 
That's what I get for skimming over the replies too quickly.

To ensure that the string is not overwritten you could create a new file and make it Static (data file properties, Protection) to hold the string constant. I don't think that will protect it from being edited by a programmer with RSLogix500, but would at least protect it from inadvertent access by a HMI or SCADA.

Good idea; if I once knew about the ability to make data files Static I'd long forgotten it.

My idea had been to copy a literal (requires online/offline edit to change), and try to work around the lack of a string literal by using an integer literal of the ASCII for a space. Even that wouldn't stop someone changing the literal value offline and then downloading, but at least he'd have to be looking at the value in the logic not merely changing a data table value.

Short of password-protecting the entire program or locking it in RUN so they can't go to REMOTE or PROGRAM I'm not aware of much you can do in 500 to stop a programmer with RSLogix500 who really wants to change something.
 
I believe the Scada is Wonderware InTouch but I am not doing the Scada. I would need someone to connect remotely to make changes if needed. I have it working as the client wants it to now but was concerned about losing my string with the space in it if someone else does a download or makes changes at a later date. After reading the other replies it would seem that maybe getting Scada to write a space to the String tag in the plc might be the best solution or creating a new data table in the plc and making it Static as OkiePC suggested. I've left site for now but there is more work to be done at a later date and so I'll look at again when I return.
 

Similar Topics

Hi, I have questions. I have Analog Input that need to put into Ignition Designer. But I don't know how to put?
Replies
1
Views
119
I have just installed Studio 5000 V30.11 on my Windows 11 Pro machine. First I had an "Invalid Pointer" error that required me to update Factory...
Replies
2
Views
121
Im trying to create a level indicator for water Tank i have used the ADD function while the pump is on and level increasing everything works...
Replies
33
Views
1,076
We are trying to poll data coming from a PLC for remote monitoring we have the IP address of the PLC and the default port number and the path is...
Replies
25
Views
590
Back
Top Bottom