Stress Test PLC - Code

Codeblue

Member
Join Date
Apr 2016
Location
Northern Ireland
Posts
18
Hi guys,

I am running some communication tests with an s7-1500 and I want to see what effect high cpu load / scan time has on my communication timings.

So to try and put some load on the PLC I tried a bunch of ADD / SUBTRACT / MULTIPLY / DIVIDE within a loop, I tried looping 150 million times but my scan time is still 1ms :eek:

So I figure the math operations are far to fast.

What would you recommend to cause some cycle time load?
 
If cycle time matters for your communication your doing something wrong.

ACOS,ASIN,ATAN,COS,EXP,LN,SIN,SQR,SQRT,TAN all are floating point math.
Or use SFC47(WAIT)
 
Last edited:
Thanks

Thanks for the reply's; floating point work did the trick;

I have ran my tests and my results show that there is no difference in read/write times for communications from a PC (Snap7) for cycle times of 1ms or 100ms.

FYI:

All connections are carried out via Snap7's dll in a C#(.net) environment)
Opening a connection to PLC takes 6-10ms
Reading 1 byte takes 1-2ms
Writing 1 byte takes 1-2ms
reading 462 bytes 1-2ms
writing 462 bytes 1-2ms

From trial an error it looks like 462Bytes is the largest packet that snap7 can send/receive i.e. 463bytes takes 3-4ms.
 
Communication like this doesn't depend on the scan time. Depends more on the network. No idea why you'd need 1ms read/write to a PC.
PDU's can range between 240 and 960 bytes, which depends on the CP used, not a limitation in Snap7.

These speeds are similar to what one would expect from Ethernet based comms, excluding RT asynch comms like Profinet.


Anyhow, try SCL vs STL, for bit, byte, word, dword and floats. Try long loops. For bits, use bits from different dword sections. For words/dword, use ones that span different dword sections.
Scratch you head as to why there are such significant performance differences. :D
 
For a S7-1500, you can't use a simple loop to test how long e.g. 10000 additions will take, as the compiler/interpreter does some optimization on the generated code, like dead-code elimination, constant folding etc.

Example code:
#i := 0;
#i := #i + 1;
#i := #i + 1;
#i := #i + 1;
#a := #i;

The compiler may remove the first four code lines, and simply set #i to 3 and then #a to 3 too, and don't do the additions, as the result is the same.
But this optimization steps are only allowed to local variables, as global variables (static variables, global db variables, or bit memory variables) may be accesses from outside / another task.
If you are programming in C, then the volatile keyword has the same effect.

So, if you want to test the performance of an operation, I would recommend to use a bit memory variable for the calculations inside the loop.
 

Similar Topics

Hi All, I'm pretty new at PLC programming, and was wondering if anyone could help me out. I have a 24vdc motor that i am looking to cycle test...
Replies
24
Views
14,511
Hi, I am using M221 reading from 3 different sensors (modbus rs485) sharing same bus (daisy chain). I am currently using READ_VAR (in total...
Replies
0
Views
84
Has anyone had any experience stress testing Wonderware's DASABCIP and DASABTCP I/O servers? I would like to find out the point at which the...
Replies
0
Views
1,360
I did a small ip address change on a freezer. No big deal right? This plant is a pharmaceutical storage. The customer said I could have 22...
Replies
10
Views
3,078
I know that everyone deals with it in different ways...business owners probably more then anyone else. Some of us try and due the best job that...
Replies
22
Views
5,120
Back
Top Bottom