CPT Instruction

Prayder

Lifetime Supporting Member
Join Date
Jun 2014
Location
Arkansas
Posts
254
Needing help with this, keep getting an error

((((((((((((((((C5[20].ACC+C5[19].ACC)+C5[18].ACC)+C5[17].ACC)+C5[16].ACC)+C5[15].ACC)+C5[13].ACC)+C5[1].ACC)+C5[2].ACC)+C5[3].ACC)C5[4].ACC)+C5[5].ACC)+C5[6].ACC)+C5[7].ACC)C5[8].ACC)+C5[9].ACC)+C5[10].ACC)+C5[11].ACC

When I try to verify the rung I get

Error: Rung 453, CPT, Operand 1: Invalid expression or tag.
 
C5[20].ACC+C5[19].ACC+C5[18].ACC+C5[17].ACC+C5[16].ACC+C5[15].ACC+C5[13].ACC+C5[1].ACC+C5[2].ACC+C5[3].ACC+C5[4].ACC+C5[5].ACC+C5[6].ACC+C5[7].ACC+C5[8].ACC+C5[9].ACC+C5[10].ACC+C5[11].ACC

Try this.
Edit...Didn't notice the missing +
 
Last edited:
I'd be wary of suggesting a loop to perform this sum, has no-one else noticed that C5[12] and C5[14] acc. values are missing....

Unless, of course, that's just another two mistakes to add to the missing + signs, and the fact you don't need parentheses at all...
 
FAL Musings

has no-one else noticed that C5[12] and C5[14] acc. values are missing

Were it not for this, a FAL would be convenient:

FAL1.jpg

Skipping elements is still workable, but now more ugly:

FAL2.jpg

EDIT: If you were really going to do this, the EQU tests would be for 10 and 12 to skip accumulators 12 and 14.
 
Last edited:
Were it not for this, a FAL would be convenient:

View attachment 44844

Skipping elements is still workable, but now more ugly:

View attachment 44845

EDIT: If you were really going to do this, the EQU tests would be for 10 and 12 to skip accumulators 12 and 14.

Instead of the tests, you could just let the FAL do its job, then SUB the counter accumulators you didn't want.

I suspect that it would execute faster than the CPT solution, even without the superfluous parentheses.

If I get the time and the inclination I would test it
 
Last edited:
Does'nt say what processor is being used, but if structured text is available,

For index := 0 to 20 do;
total := total + c5[index].acc;
end_for;

It's what it does best number crunching.

Also it's easy to subtract any counter accumulators not required.

Steve
 
Last edited:
Does'nt say what processor is being used, but if structured text is available,

For index := 0 to 20 do;
total := total + c5[index].acc;
end_for;

It's what it does best number crunching.

Steve

Shouldn't that be
For index := 1 to 20 do;
total := total + c5[index].acc;
end_for;
total
:= total - c5[12].acc;
total := total - c5[14].acc;


Anyway, I'm guessing it's Logix5000 because of the square bracketed array index...

If so, I might be tempted to create an AOI that contains a string of ADD instructions, which I am certain would give the fastest execution.

 

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
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 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...
Replies
4
Views
2,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