markymark31
Member
Hi,
I have an array of 30 integers :-
db1.tracking[0] to db1.tracking[29]
What's the best / easiest way to add them all together ?
They are all either 1 or 0 so the maximum value will only ever be 30.
I'm only really a ladder man but I've had a go in SCL with a FOR / END_FOR loop. However I am guessing that the SCL function is called every cycle so it only ever adds the first integer to the total, I don't think it runs 30 times.
Is this correct ? How do I / can I run the whole loop in one scan ?
The integer values are updated every 100ms, the scan time is averaging 10ms at the moment so if it added one every scan it would take 300ms to complete which would be no good .....
All advice would be appreciated.
Thank you,
Mark
I have an array of 30 integers :-
db1.tracking[0] to db1.tracking[29]
What's the best / easiest way to add them all together ?
They are all either 1 or 0 so the maximum value will only ever be 30.
I'm only really a ladder man but I've had a go in SCL with a FOR / END_FOR loop. However I am guessing that the SCL function is called every cycle so it only ever adds the first integer to the total, I don't think it runs 30 times.
Is this correct ? How do I / can I run the whole loop in one scan ?
The integer values are updated every 100ms, the scan time is averaging 10ms at the moment so if it added one every scan it would take 300ms to complete which would be no good .....
All advice would be appreciated.
Thank you,
Mark