Siemens S7-1200 question - adding 30 integers together

markymark31

Member
Join Date
Mar 2004
Location
Corby, Northants
Posts
60
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
 
"m12 is clear" := 0;

FOR "m12 is clear count" := 0 TO 29 DO

"m12 is clear" := "m12 is clear" + "M12 Tracking".pos["m12 is clear count"];

END_FOR;

When I "watch" this in action, "m12 is clear" only ever has a value of 0 or 1.
 
add this after the for loop and monitor "m12 is clear aux"


"m12 is clear aux":="m12 is clear";
 
Trouble shooting is trouble shooting, you use the tools you have available. The S7-1200 software I am using doesn't allow for Break Points and Single Stepping in SCL programs so you have to add extra stuff so that you can see what is going on.

To know if the loop is running you can add a variable that increments by 1 each time through the loop.

You can check that "m12 is clear count" ends up at 29.

Once you know that the loop is running then you need to look at the Array. Add Int variables that grab the value from the Array before the loop:
CheckingInt1:="M12 Tracking".pos[1];
CheckingInt2:="M12 Tracking".pos[2];

Then you can monitor the SCL program and start to look for errors.
 

Similar Topics

Hi all, Currently having trouble getting a speed reference to write over modbus to an Omron M1... I can successfully write a run command and...
Replies
6
Views
268
commentaire communiqué siemens s7-1200 avec vfd delta ? (cablage et sur tia portal )
Replies
0
Views
144
Hi, I have a 1214 on ip 192.168.0.100. This is connected to other modules through a switch on same network. I need to connect this to a company...
Replies
1
Views
188
Hi Experts, I would like to make firmware upgrade from v3.0 to v4.5 (S7-1200 CPU 1215C). Can I do it from v3.0 to v4.5? Do I need to take some...
Replies
6
Views
309
Hi Guys, I am trying to establish communication over profinet between Siemens S7-1200 PLC as IO device and codesys plc as IO controller. But I am...
Replies
43
Views
2,917
Back
Top Bottom