skyfox

What is the fastest method to clear portion of a large array?

7 posts in this topic

NX1P2 CPU. Sysmac Studio 1.45.1

I am trying to find out the fastest way to clear part of a large array short of looping using a for/next loop.

Array1[25000] elements

I want to clear 5,000 elements by giving a starting index and an ending index. I was looking at the "MemCopy" function. To use that for this purpose, one would need to have an Arrray of [5000] elements with blank values just sitting around using up memory. Would like to avoid that approach if there is a better way to do this. Can some one point me in the right direction?

Cheers.

 

Share this post


Link to post
Share on other sites

Caveat: It has been 22 years since I touched an Omron PLC.

What if you have Array1[25000] elements.

Then Array2[5000} aliased using the AT instruction to Array1[6000] for example -- see https://forums.mrplc.com/index.php?/topic/39210-aliasing-possible-in-sysmac-studio/

And Finally use the SetBlock instruction to zero Array2 - https://assets.omron.eu/downloads/manual/en/v4/w502_nx_nj-series_instructions_reference_manual_en.pdf see page 421

The Omron Gurus will tell you if this can work or what I am doing wrong I am sure.

 

Share this post


Link to post
Share on other sites

Use SetBlock to move 0 into the array. Specify the start and quantity.

Capture.PNG

1 person likes this

Share this post


Link to post
Share on other sites

Just be sure that the elements of the AryOut have the same data type as as In.

Made this mistake once before until reading manual.SetBlock.thumb.jpg.b697b9f50ec590de1ff8d

Share this post


Link to post
Share on other sites

SetBlock did the the trick.

THANK YOU ALL!!!

 

Share this post


Link to post
Share on other sites
1 hour ago, skyfox said:

SetBlock did the the trick.

THANK YOU ALL!!!

 

you're welcome - SKYFOX

 

99.95% of problems resolve when you RTFM.

Share this post


Link to post
Share on other sites
2 hours ago, BobLfoot said:

99.95% of problems resolve when you RTFM.

True story

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