Studio 5000 add prefix to all tags

aarmcc01

Member
Join Date
Apr 2023
Location
Coventry
Posts
11
I am currently working on a project which requires me to move two (seemingly identical) PLCs into one, however both PLCs have all tags being the same. I want to add a prefix to all tags, something like PLC1_xxx and PLC2_xxx and then export/import them into my new project.

Is there any way of doing this that is not manually going through the tags? I have over 2000 and this will take way too much time.

I cant use the .csv/l5k files and find/replace text as that is not quite what I want to do, the tags do not all begin with the same letter/symbol.
 
Silly question, but why?
I believe the tags are going to be referenced in the main program of the PLC. the project I am working on involves moving 2 PLCs into another, and replacing the hardware with 2 Remote IO racks. I am trying to keep everything as close to the original setup as possible.

****EDIT****

I have just thought, if I convert the current controller tags to program tags then I believe you could be correct. I could just write to/from the local tags from the main PLC (original program), as currently message blocks are used to write to/from the PLCs
 
Last edited:
I'm just going to throw this out there because I think it needs saying.

Your local Bubba is NOT going to be happy when they see a program with identical tag names, and the only difference being the scope of the tag. That is going to make their life harder than it should be.

Bubba.
 
I have just thought, if I convert the current controller tags to program tags then I believe you could be correct. I could just write to/from the local tags from the main PLC (original program), as currently message blocks are used to write to/from the PLCs
I know I am... but good of you to review your assumptions.

Your local Bubba is NOT going to be happy when they see a program with identical tag names, and the only difference being the scope of the tag. That is going to make their life harder than it should be.

Maybe Bubba should stick to spanners?
 
Maybe Bubba should stick to spanners?


I knew my comment would get some push back, and it's okay.



Just remember that how well Bubba likes you is directly proportional to how likely he his to call you at 0130. If you get too far to the wrong end of the spanner, you will get that call while he is holding the blown fuse that is the source of the problem in his hand. (y)




Bubba.
 
I have just thought, if I convert the current controller tags to program tags then I believe you could be correct. I could just write to/from the local tags from the main PLC (original program), as currently message blocks are used to write to/from the PLCs

Can one of you please elaborate on this solution? I am trying to get my head around it and I was not able to follow this solution. Apologies for my ignorance.

If it helps any, I have found myself changing lots of tag names recently and have used a scripting program (AHK; Autohotkey) to automate much of my renaming.
 
Can one of you please elaborate on this solution? I am trying to get my head around it and I was not able to follow this solution. Apologies for my ignorance.

When creating a tag, one of the options is to select the scope of the new tag. The scope can either be the controller, or any one of your programs -- 'program' here being used in the specific sense of the hierarchy level below Task and above Routine.

A 'controller' scoped tag can be used anywhere in the controller. Program-scoped tags can only be used inside the program they are scoped to. Because of this, you can re-use tag names between program-scoped tags from different programs -- for example ProgramA and ProgramB can each have their own bit InAutoMode.

This setup eases code re-use, but can confuse someone who doesn't realise what's going on, as what appears to be the same tag in two locations is in fact two separate, unrelated tags.

When accessing program-scoped tags from outside the controller (eg with an HMI) the syntax is slightly different as you have to specify which program to access, not just the controller as a whole.

EDIT: If you look at the Controller Organizer, at the top under the Controller folder, the first item is the Controller Tags. Under each Program within the Tasks section the first item is 'Parameters and Local Tags', which will contain the program-scoped tags for that program.
 
I could just write to/from the local tags from the main PLC (original program), as currently message blocks are used to write to/from the PLCs

I'd make the communication variables parameters that you could use to link both programs thus avoiding having to write logic for them. I would however make sure there's some spare spacing in there.

Just remember that how well Bubba likes you is directly proportional to how likely he his to call you at 0130. If you get too far to the wrong end of the spanner, you will get that call while he is holding the blown fuse that is the source of the problem in his hand. (y)

That's fine... guess who's deciding Bubba's performance bonus... this being said, dumbing down PLC logic is not the solution. Actually testing and creating diagnostics is.
 
When creating a tag...
...the controller as a whole..

Thank you. I will spend some time studying the structure tomorrow.

Another Question. What is the advantage/value of allowing controller tags to be duplicated within a single program?

As i understood it, controller tags are your inputs and outputs, (please do not hate me if i do not understand the complete picture). This said, would it not be a disadvantage to have duplicate tags referencing the controller tags?
 
I probably would not name the controller tag the same as a program tag. I would also probably prepend a code, (like "L_" for "Local") to the program scoped tags and explain what that means. That can help Bubba not have to call you in the middle of the night. Not having any authority to re-train or discipline Bubba, I learned the hard way to write code in a way that will protect my sleep.
 
Answering what I think was the original question...If you just want to prepend something onto all tagnames, open the tag export .csv in MS Excel and use a formula like: =IF(A8="TAG","PLC1_"&C8,C8)

Explanation: If the item in the Type column (column A) is "TAG", prepend PLC1_ to the name (column C), else keep the name as is. Put the formula in an unused column and then fill down to the end of the data. Then copy the new column and paste the values into the Name column. Then delete the new column, save the .csv and import it back in to Logix.

EDIT: I think you will also have to modify the SPECIFIER column in a similar way. This should work: =IF(F8="",F8,"PLC1_"&F8).
EDIT 2: Also, you probably don't want to prepend the tag name to any AOIs, so stop filling down when you get to any tag names that end in :AOI.
 
Last edited:
Another Question. What is the advantage/value of allowing controller tags to be duplicated within a single program?
I may have misunderstood the question. But it's Rockwell's attempt at dealing with complaints about lack of reusable code. If you have two identical machines, you can make one program for that machine and then simply copy/paste it and that's it. If you must have controller scoped tags, you can then have the different program have output parameters that you link to the controller scoped tags to make them available for everyone.

Obviously, Rockwell being Rockwell, this strategy breaks down fairly quickly since you can't change much online, but that's the concept and what they intended with it.

As i understood it, controller tags are your inputs and outputs, (please do not hate me if i do not understand the complete picture). This said, would it not be a disadvantage to have duplicate tags referencing the controller tags?

They don't have to be the inputs and outputs. Can simply be shared memory between programs and tasks. As for the disadvantage, depends on the number of "repeated code" you have to create. As I mentioned, it's still a copy so not really reusable in the usual sense of the word with Engineering focused brands, but it sure makes things simpler for some developers.
This is one example where it would make sense to do so to save on Engineering time. Not necessarily in operation and maintenance time.

A good strategy to understand Rockwell, I find, is to look at them as a Systems Integrator first and manufacturer of control devices second. Since Systems integrator has priority, their focus when developing the control devices is to cut down on their development hours, not the end users. Hence why they're platform is light years behind true device manufacturers since they're focused on selling kit only.
 

Similar Topics

Hello Everyone, I have about 135 controller PIDE loops that I need to add to my Studio 5000 and that means I will probably have to create about...
Replies
8
Views
1,921
Hi All, On my site, the standard template for storing recipes in the PLC is to create a tag called PartRecipe which is an 2D array - for example...
Replies
4
Views
1,476
Is it possible to add Rung Comments or Tag Descriptions when creating rungs with a text file? I think not but just checking.
Replies
5
Views
1,642
Hello, I just installed Studio 5000 V34 and when I try to create the project (with Compact logix Cpu), I get the below picture error message. I...
Replies
5
Views
2,920
Can you add a MicroLogix 1400 to the IO Tree in Studio 5000? I can't find an entry for it or anything that is 1762 for that mater. I just want to...
Replies
5
Views
2,317
Back
Top Bottom