Sign in to follow this  
Followers 0
TechJunki

Add Array in Logix 5000

5 posts in this topic

I am looking for examples or methods used for adding an entire Array. For Example I have an array "TestArray[100]" and would like to get the sum of all 101 elements in the array and move the resulting value to a single DINT. I thought about doing some looping or such but was wondering if there was a way to evaluate this all at once other than doing Result = TestArray[0] +TestArray[1] +TestArray[2] +TestArray[3] + .........TestArray[100] Any examples you may use would be appreciated. Thanks

Share this post


Link to post
Share on other sites
Have you thought of using an FAL or ADD instruction and a Counter .ACC (as an indirect address). Use a scan pulse to increment the counter and use an [integer] file to continually add the TestArray elements to itself. I don't believe I'm explaining it very well so this may be a better explanation: ADD FUNCTION SOURCE A TestArrayTOTAL SOURCE B TestArray[Counter.ACC] DESTINATION TestArrayTOTAL Where are you getting your array numbers from? Hope it helps a little...d2b

Share this post


Link to post
Share on other sites
Just did this yesterday, read about FAL instruction in "help on instructions"

Share this post


Link to post
Share on other sites
FAL is the instruction to use. You can configure the instruction to make the sum in a single scan or over multiple scans.

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