Most Efficient Way to Get SUM of All Arrays in a Data Type

btaaa

Member
Join Date
May 2012
Location
Metro Detroit
Posts
16
RSLogix5000

I have an application where I would like to be able to ADD the values of multiple arrays, or even "all" the arrays, in a given data type, using the simplest/shortest command.

SampleDATA DINT[100]

I know that I can do this with the CPT instruction. However, to do so seems to require the lengthy expression, (SampleDATA[0]+SampleDATA[1]+SampleDATA[2], Etc. . .)

I then tried to use the FAL instruction, and it seems to require the same lengthy expression.

Is there not a simpler method of telling an instruction to go ahead and add the values of "all" arrays in a given data type?

FYI, I'm not worried about math overflow. There will only be a value in one or two arrays at any given time. Long story. Thanks.
 
Do you require constant addition? Or a snapshot at the end of a production run for example.

Could be done with a nested loop.
 
Not familiar with nested looping. Have looked at manual, searched the forum, and have googled it. Nothing quick coming to me. Will have to research this one. Thanks.
 
Never uploaded a photo before. I'm sure there are better ways of doing it but this popped into my head.
 
Couple of things a loop can do is fault the plc, I recommend messing with this on an emulator or test plc.

1 way I found a fault is you can actually remove the label and still have a jump to no where.
 
Couple of things a loop can do is fault the plc, I recommend messing with this on an emulator or test plc.

1 way I found a fault is you can actually remove the label and still have a jump to no where.

Thanks. Yea, I'm running this from a desk PLC to test.
 

Similar Topics

Hello, I have to deal with iFix again and am looking at the most efficient way to create alarms to display in iFix, i.e. not creating an...
Replies
0
Views
149
Hey all, I'm doing a more standardize version of one of my programs and organizing things into UDTs and whatever else I can do to shrink the...
Replies
0
Views
413
Hello All, I’m working on a project that requires filling/discharging from 30 batch tanks that are the exact same. Simplifying things some here...
Replies
7
Views
1,853
Hello, I have a modicon background where there is a "Pulse" function that accepts an input for the deisred pulse time length. I effectively...
Replies
8
Views
2,023
Hi. I am looking for a cheep PLC+HMI (in a single box) (just like Unitronics Jazz/M91) which would have a native screw terminal COM port...
Replies
8
Views
2,372
Back
Top Bottom