Akif KC

PLC Tag Creation

16 posts in this topic

Hi,

I am trying to write a program in Allen Bradley PLC and I have a coding to write which does exact same thing over and over again, in other words the process is the same for this code. So I am looking for how to write that PLC tag in which I can define the tag inside the tag. So it will increment from the tag and I don't  have to write the code again and again. I know there is a way to do that but I forgot it. Can someone please help me in this? Really appreciate it. Thank you very much. 

Akif.

Share this post


Link to post
Share on other sites

Can someone please help me on this? Thanks.

Akif.

Share this post


Link to post
Share on other sites

I am not clear on what you are asking?  Are trying to write a Do loop like in Basic?

Share this post


Link to post
Share on other sites

I am sorry, I am talking about the ladder logic. What I am looking for is writing Tag inside the tag, for example, instead of writing Counter[0], counter [1], counter [2], separately in different lines, I want to make a tag ' Counter[number]' in which the number will increment in other line and changes the counter automatically. I hope that makes clear. Thanks, and appreciate it.

Share this post


Link to post
Share on other sites

This is called indirect addressing. It is available in most Allen Bradley PLCs. Please state precisely which PLC model you are using. Also please supply (as an attachment) an example of the basic logic you want to replicate using different tags.

1 person likes this

Share this post


Link to post
Share on other sites

What A-B PLC are you working with?  There is a difference in programming tools.

This example you describe sounds like "indirect addressing".  

Expand on what you desire to achieve.

1 person likes this

Share this post


Link to post
Share on other sites

Exactly, that's what I am looking for. I remember the name now when you guys mentioned. I used it before, but I forgot about that.

I am using Allen Bradley 5370 Guard logix PLC and version 28. I have around 30 instants to copy, instead of writing 30 lines of ladder logic I want to write a line of code with indirect addressing. Hope you guys will understand what I want. Thank you very much for your valuable replies.

Share this post


Link to post
Share on other sites
19 hours ago, Akif KC said:

What I am looking for is writing Tag inside the tag, for example, instead of writing Counter[0], counter [1], counter [2], separately in different lines, I want to make a tag ' Counter[number]' in which the number will increment in other line and changes the counter automatically.

It looks like you know exactly what you need to do.

For your 'Counter' tag, go to the Tag Properties then expand on the Data Type. Here you can set Dim 0 for the number of Counters you want in your array.

Create a new tag 'number' of type DINT and use it just as you typed it above. You can manipulate this tag as you wish (ADD,  SUB, MOV, etc...) 

1 person likes this

Share this post


Link to post
Share on other sites

Thank you very much. I forgot that I can just add the tag 'number' inside the brackets of tag 'counter', which will work the way I want.

Thank you very much guys, really appreciate it. :)

Share this post


Link to post
Share on other sites

I highly recommend AGAINST indirect addressing!  It is a pain in the butt to troubleshoot from a technician or maintenance perspective, not going down the path of indirect addressing will save you a lot of time, headaches and getting called everything under the sun the comes after you to work on that code.

1 person likes this

Share this post


Link to post
Share on other sites

Keep in mind (along with JackDempsey's comments)...with indirect addressing, make sure to add limit tests.  If you increment the indexer beyond the dimension of the array, the processor will fault.  Unplanned downtime, scrap product created, late order delivery, your name next to a staff note...been there.

1 person likes this

Share this post


Link to post
Share on other sites

To Jack and Will's point, write the code in an AOI and pass in the "number".  With the AOI, you can then debug all the instances of the duplicate code for the specific "number".

1 person likes this

Share this post


Link to post
Share on other sites

I know Jack, it is really boring to write around 100 lines of code which does the same job, you know, that is why I am thinking about using the Indirect addressing.

Well, thank you very much guys for your valuable replies. Really appreciate it.
And yeah, Kaiser_Will, thank you very much for reminding me about the processor fault thing. I literally forgot about that, it had happened with me before. Thanks again for reminding. :):-)

Share this post


Link to post
Share on other sites

And yeah, Pcmmcarthy, I didn't understand the AOI thing. Can you please explain that to me if you don't mind? Thank you very much.

Share this post


Link to post
Share on other sites

AOI = Add-On instruction

Thinks of it as a way for you to create reusable logic. I've attached a couple that I have made over the years. One for calculating rate of change, one for things like always off, reading the clock, etc. and one for calculating gas flow through an orifice. By far, the gas flow routine is the largest. I removed the NX-19 calc section (measurement people will know what that is) because it nearly doubled the routine.

To view them go to the Add-On Instruction area of the program tree and right click / import them to the routine. AGA3 and SI are typically used as function blocks (by me) and Rate of change has to be used in a Periodic task

AGA3.L5X

Rc.L5X

SI.L5X

Share this post


Link to post
Share on other sites

PS- If some day you write an AOI for a Fourier or Laplace transform I'd be glad to test it for you :)

I should add that for anyone else that downloads the Rate of Change calc and uses it, it has a moving average for the output. To this day I still kick myself for not adding an enable / disable bit for it. I've never needed it. In fact, I added it because I needed it. It can be modified offline easily enough. 

What is it used for? 2 things (oil and gas industry)

(1) Tank level rate of change. Tank level is somewhat noisy. That's why there is a moving average section in the Rc AOI. We use it to predict time to full and time to empty AND if a floating roof tank is experiencing a stick roof or collapsed roof. If the tank is filling at a rate of 5,000 BPH and suddenly the rate of change jumps 50,000 BPH positive or negative then there is a problem. The periodic task for tank level is usually 5-10 seconds

(2) Gas pipeline leak detection. A spike downward here is an indication that something isn't right. However, over time the reading will normalize so keep that in mind.  

Edited by Michael Lloyd

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now