assigning a value to a large number of tags using structured text

david90

Member
Join Date
Apr 2010
Location
ca
Posts
202
I have tag bits0, bits1, bits2 ... bits1000. Is there a way to use a "fFor" loop in structured text to assign the value 0 to bits0..1000?
 
If bits are a boolean array then yes, a for loop will do it.
Code:
For i:0 to 1000 do
   MyBoolArray[i] := 0;
End_For;
If you have 1001 different boolean tags, which is what it looks like from what you wrote, then brute force one by one is your sole remedy. You can use excel and its autofill feature to rapidly generate PLC code for repetitive tags that differ by only one number. See this post to see an example - its logix500 but it works the same way in logix5000. You could probably create ST for it in less than ten minutes. It will be a long program but if its any consolation it will execute faster than looping 1001 times as it is still the same number of assignments but without the loop overhead.

In Logix5000, Boolean tags are not the same thing as B tags in the SLC and PLC/5 platforms. B addresses were still integers with a bit addressing scheme. Stand alone Boolean tags are different. If you have to initialize them then you should start with boolean arrays embedded in a UDT.
 
Last edited:
I see by your posting history you have dealt with AB Controllogix, is that the system you are referring to here?

Are the tags actually 'bits0', 'bits1' etch or are they elements in an array - 'bits[0]', 'bits[1]', 'bits[2]' etc. ?

TConnolly preatty well covered it.
 
Last edited:
If they have addresses like %MX0.0 etc you can manipulate %MW0
if the names are bits123 and have no addresses then change to an array with a texteditor to bits[ and on the back with a ]
or have a look at www.oscat.de he has made a big library in ST with all kinds of functions.
 
If I'm not mistaken, I think I did something like this just the other day using FLL command or COP or one of the other file commands.. I only had ten elements in an array but I suppose it would work for a thousand and one .. or maybe it was CLR ... I don't remember ... Although I know my dementia is not particularly helpful, my point is that I did it to an array without doing a loop.

This is assuming you want to put a zero in each element

If I remember when I get to work ( if I remember to go to work ) I'll look and post it.... I know I did it without a loop though

I'll tell you what... sometimes I wonder ... I posted a question on this forum about it last week ... I knew I saw it somewhere

You asked about structured text , and this is ladder logic but http://www.plctalk.net/qanda/showthread.php?t=89293
 
Last edited:

Similar Topics

I can't seem to figure out how to add descriptors to I/O points on an RMC using PCCU. Say, for example, I want to use "Valve_1" as a descriptor...
Replies
0
Views
73
Hello all. A little ashamed of myself that I can't remember how to do this but..... I have a 1734-AENT that I set the wheels to "888" applied...
Replies
9
Views
4,071
Hey everyone I'm working on a PLC project for a series of 4 vacuum pumps. I need to be able to rotate each pump into a different priority based on...
Replies
18
Views
6,471
Hi all, I am in the throes of commissioning a single S7-1517 cpu and I'm utilising both ethernet ports, X1 and X2, with individual IP addresses...
Replies
2
Views
1,714
With FactoryTalk ME is it possible to use a single Trend object and list of pens being displayed using macros? Would like to have one Trend object...
Replies
2
Views
1,763
Back
Top Bottom