Sign in to follow this  
Followers 0
MaTT Divel

Clearing an Array in RSLogix 5000

13 posts in this topic

Hi, I have an array: TAG1[0] to TAG1[100] for example. In a certain condition i want to clear all the array. With the instruction CLR, i can only clear once at a time or i don't know how to clear all in once instruction. So that way i wold need like 100 CLR instructions. The other option that I though is to use a FOR loop with one CLR instruction, but I'm sure there is an easiest way to do it, but I don't know how. Let me know if you have an idea please. Your help will be appreciated. Edited by MaTT Divel

Share this post


Link to post
Share on other sites
You can create a UDT to contain the boolean array and use FLL on the tag of the UDT type.

Share this post


Link to post
Share on other sites
Not sure what is a UDT. But if i use the FLL with those operands: Source = 0, Dest = TAG1[0], Length = 100. Do you think it could work? Because i dont have the PLC here and can't test it online. thanks for your fast reply.

Share this post


Link to post
Share on other sites
Yes, the FLL instruction will work and is the best option.

Share this post


Link to post
Share on other sites
The answer to this question depends somewhat on the type of data which TAG represents. Can you provide more information?
1 person likes this

Share this post


Link to post
Share on other sites
Create a blank tag array (no data, all zeros) with the same dimensions of the tag array you want clear. then Copy the blank tag array to the one you want to Clear.

Share this post


Link to post
Share on other sites
That would be the best solution. COP instructions don't always execute in one scan (but the CPS instructions do). They also take a LOT more time than a FLL, not to mention the wasted memory of creating a blank copy. If you wish to clear a UDT, there is a neat trick where you do a FLL with source of zero, destination is the UDT tag, and a length of 1. I'm not sure if it matters what revision of firmware you have, but it works with 15 or higher for me.

Share this post


Link to post
Share on other sites
This is incorrect statement, COP will always execute completely before going to the next instruction, exactly same as CPS. The only difference is that CPS guarantee data integrity. Take a look at TN 50235 that is written buy one of the lead controller engineers- it explains in details how it works.

Share this post


Link to post
Share on other sites
Just wanted to highlight the following of technote 50235. Step 4 is the actual copying of the data
1 person likes this

Share this post


Link to post
Share on other sites
PUISSANCE_MESUREE_EC_23 <normal> REAL[16] Standard Float Tableau de la puissance mesurée normalisée, station de tests finaux EC23 This is what i have in my controller tags sheet. The tag is a REAL[16]. so i'll try it with the FLL because i have 7 differents tag like that to clear, so it will be way faster with the FLL instruction instead of using 16 CLR for each of those tags. thanks for your reply

Share this post


Link to post
Share on other sites
Thanks for the corrections, I'll have to mention this to the guy who told me otherwise.

Share this post


Link to post
Share on other sites
Don't thank me, thank Contr_Conn. I had always wondered what the true functional difference between the COP and the CPS instruction was, he pointed us to the right technote

Share this post


Link to post
Share on other sites
I think this is the best explanations that I saw for COP/CPS instruction functionality as well as UID/UIE. Recently one of my customers experienced short time local I/O connection loss while using CPS instructions with very large arrays of internal tags. I was told to check this technote and replacing CPS with UID/COP/UIE resolved the issue. Edited by Contr_Conn

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
Sign in to follow this  
Followers 0