CPT Instruction

outlaw9801

Member
Join Date
Jun 2014
Location
minersville
Posts
22
I am trying to add 15 items together using a cpt instruction in logix5000. All of the items are in the same array is there a way i can type in the first tag and be able to type in like L12 and get it to add all of them up without adding every tag in.
 
check out the FAL instruction instead ... it's pretty "heavy duty" for what you're trying to do - but I think that it's the answer that you're looking for ...

basic idea: you can think of the FAL (File Arithmetic Logic) instruction as something like a CPT instruction - with a built-in For-Next loop that can "cycle" through an array ...
 
Last edited:
If the elements are contiguous within the array, you can get the SUM of them easily by multiplying the AVErage of them by the number of items.

AVE = SUM / LEN

SUM = AVE * LEN

EDIT : The -(RES)- is there so the AVE is performed every scan, and doesn't need a false-to-true rung transition to re-trigger it.

2nd EDIT : Source B in the MUL would be better as AVE_Control.LEN. Then you can manipulate the number of items to SUM, and the MUL will follow it.

2014-07-27_221534.jpg
 
Last edited:
If the elements are contiguous within the array, you can get the SUM of them easily by multiplying the AVErage of them by the number of items.

AVE = SUM / LEN

SUM = AVE * LEN

EDIT : The -(RES)- is there so the AVE is performed every scan, and doesn't need a false-to-true rung transition to re-trigger it.

2nd EDIT : Source B in the MUL would be better as AVE_Control.LEN. Then you can manipulate the number of items to SUM, and the MUL will follow it.

Thats a neat trick, thanks for sharing:beerchug:
 

Similar Topics

I have ran into something I have not seen before and wondering if any one had any ideas. The logic I'm currently troubleshooting is using a...
Replies
3
Views
1,660
Needing help with this, keep getting an error...
Replies
16
Views
4,947
What is the symbol for divide used in a CPT Instruction Expressions - The expression is zero or more lines, with up to 28 characters per line, up...
Replies
11
Views
3,621
Hey Everyone I was wanting to get some advise on the math below on this expression for a SCP instruction...
Replies
17
Views
5,236
I am currently converting a PLC5 over to a Compactlgx. I have the logic converted, am in the middle of making all my new tags and have made some...
Replies
9
Views
2,652
Back
Top Bottom