ST to update the same element in 100 Tagnames

TheWaterboy

Lifetime Supporting Member + Moderator
Join Date
May 2006
Location
-27.9679796,153.419016
Posts
1,924
Using Logix 5000 on Contrologix

Once a day I need to update the same 3 elements in 100 Tags, the tags are numbered (so to speak) N100...N199.
This is the pseudocode.
Code:
FOR X := 101 to 150 DO // Partial TAG name Site101 for example
 SiteX[5] := ExistingTag1 // Concatenated tag name, "X" = 101 to 150
 SiteX[6] := ExistingTag2
 SiteX[7] := ExistingTag3;
End_For;
I have tried to DTOS the X and then CONCAT to combine the string "Site" with the incrementing number X, but the resulting string variable is not then recognized in the code as a tagname for assignment to "ExistingTag1"

I would appreciate ideas or direction. I'm stuck. 300 ALIAS assignments maybe?
 
Alias's won't help, you'd still need to address the Alias tags individually, because alias tags must be unique tags so can't be part of an array, for example.

If the code only executes once a day, I'd use the "brute force" method of having 100 rungs with 3 MOV instructions on each rung. The code would most likely be quicker than any iterative methods.

Entering the code is relatively easy, you can put one rung in, export the project to L5K, find the code you just entered, and use a word processor or spreadsheet to replicate the rung another 99 times, incrementing the tag addresses as you go. Paste the expanded text back into the L5K, and import.

If it is important to you, you might want to suspend interrupt handling while this code executes once, by putting -(UID)- before, and -(UIE)- after, the code.

300 simple MOV instructions should execute pretty rapidly anyway - you can look it up in the instruction set reference, just make sure the source and destination tag elements are all DINTs (or REALs) if possible, and it should fly through without having to convert anything.
 
Last edited:
Oh man... I really dont want to do that. I would prefer an iterative construction to creating 100 rungs for this. I know it would work that way, but this should be what ST is good at.
 
See attached file.

Please take a look at rung 21, "For" instruction.

Use an array with 100 elements.

My index is Cont_Producto, goes from 0 to 188.

In this example my routine name is ("Pesaje_Codigo"), you create your one.
Your index has to go from 0 to 100.

- Next steps must be inside your routine:

- Your values will be copied from Site[0] up to Site[100] using index variable.

-Each Site[x] is and UDT with three variables 5,6 and 7, so in your goal routine you have to copy site[index] to newsite 100 times (just one instruction, routine will run 100 times due to index) and all your values will be copied to another place.

regards,

william

uno.jpg
 
Last edited:
The problem is - his 'SiteX' tag names are not an array using the 'X', they are individual tagnames. Even though there is a number they may not be indexed by it.

Can you backtrack and redesign the storage such that you have an array? Perhaps redefine each of you siteX tagnames to be aliases into that array.
 
Last edited:
Oh man... I really dont want to do that. I would prefer an iterative construction to creating 100 rungs for this. I know it would work that way, but this should be what ST is good at.

It doesn't make any difference what language you use, you cannot "create" tagnames using any form of string manipulation that I know of. Don't forget that what gets loaded into the controller is compiled code, the compiler would not know how to compile an indirection in tagnames.

Now as Bernie suggests, if you can re-work your data storage into array elements, then it is easy to manipulate the array index, and use iterative code to do the job.

I still say the 100 rungs or ST commands would execute faster....
 
Bernie
Cant redesign the data tags at this point, a million other things are already built around the current structure that work too well. My code would have been a patch for an idea that we wanted to try.

If Daba is right that I can't create a tagname reference like this like you could in the PLC5 days, which fits what I am seeing, then I have to rethink my end of this. There are alway other options.

Thanks guys, I'll start over.
 
Bernie
Cant redesign the data tags at this point, a million other things are already built around the current structure that work too well. My code would have been a patch for an idea that we wanted to try.

If Daba is right that I can't create a tagname reference like this like you could in the PLC5 days, which fits what I am seeing, then I have to rethink my end of this. There are alway other options.

Thanks guys, I'll start over.

The other options include 300 MOV instructions which will fly through, can't go wrong, and be perfectly "transparent" to others looking at the code. Most times the long-winded brute-force method wins hands-down. How long have you spent on trying to find an alternative solution, it could have been coded and forgotten by now.
 
Yea, I get that. Before I go that route I'm just going to revisit the root problem and see if there is a better solution all around.

You've had answers and comments -

1. You can't create indirect references to tags...

2. You (said yourself) can't rework the data storage...

3. You've already spent too much time trying to make it "elegant" ...

4. Now you want to spend more time (See No.3) trying to do something which is not possible with the way your data is arranged (See No.2)...

If I was a gambling man, I'd bet you end up with a "brute force" solution, whether it is in ST or Ladder, or any other language.

I used to be like you, I always wanted the "clever", "elegant", "minimal code", but I've learnt that these goals nearly always produce a solution that runs slower, is hard to understand, is difficult to modify (e.g. more tags, or less tags), and took longer to code.

In the classes I take, time permitting, I demonstrate a 2-instruction solution for "Traffic-Lights", which is a bread-and-butter application for training. Yes - I did say 2 instructions, in the whole processor !! But would I put this out in the field, as a commercial enterprise ? No I would not, the 2-instruction solution is inflexible, hard to program, and even harder to modify, even though it produces a "result".

In this game, we aim to get solid proven code out the door as fast as possible, so we can spend more time on the issues that really matter. For me that's earning a crust, and spending time with family and friends.

Sorry if I sound negative, but I believe your time would be best spent elsewhere, just do the 300 element coding, test it, sign it off, accept that it may not be the way you wanted it, and move forward.
 
You misunderstand, I've accepted your solution to the problem as I have laid it out. I admit defeat. I'm not shouting at the rain.

My intention now is to see if the original problem this was meant to work around can be engineered out further up the logic so that this isn't necessary at all. If it can't, your solution is obviously what I will do.
 
TheWaterboy said:
Cant redesign the data tags at this point, a million other things are already built around the current structure that work too well.

TheWaterboy said:
You misunderstand, I've accepted your solution to the problem as I have laid it out. I admit defeat. I'm not shouting at the rain.

My intention now is to see if the original problem this was meant to work around can be engineered out further up the logic so that this isn't necessary at all. If it can't, your solution is obviously what I will do.
Contradictory posts - My advice - don't go changing existing data structures to make this little add-on easier, I'm sure you WILL regret it.

Instead, just do what you gotta do with what you got, and keep breathing, knowing that you ain't breaking anything else
 
And if you use excel to "autofill" the tag names, then export or copy the results to your word editor, then copy them back into the logic as rung mnemonics, the work may be a lot easier to accomplish than meets the eye. I think TConnolly has posted something along this line to automate logic generation on the forum some months or years ago.

EDIT: This example is aimed at SLC/PLC type addressing but it should work about the same for Logix5000 tagnames since Excel may be smart enough to increment when you use autofill.

And, if excel won't increment your tagnames properly, you could get more fancier ;) and use the concatenate function in excel to put the number and the text back together. For this many rungs, a little time spent automating the process should pay off.
 
Last edited:

Similar Topics

Hello, Say I am using an AOI with a default value of 1. Now I want the default value for the same AOI to be 2. Is there a way to update all...
Replies
4
Views
1,946
How do you install update on Red Lion Crimson ver 3.1. Do I just need to run the exe file on the host server?
Replies
1
Views
107
Has anyone found a way to convert/replace/update the firmware on old Parker TS80xx series HMIs (i.e. TS8010, TS8006, etc) to accept Crimson...
Replies
0
Views
91
Hi All, we've recently upgraded from FTView SE v10 to v12. Since the upgrade we've been having a problem where the HMI is slow to update tags in...
Replies
0
Views
87
Hi, I have an iFIX 5.5 project (Windows 7) that needs to be updated to version 6.5 (Windows 10). iFIX communicates with the "Siemens Industrial...
Replies
1
Views
172
Back
Top Bottom