You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old June 12th, 2019, 09:30 AM   #61
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,737
OK, I have redone LDs tests on a Siemens IM151-8.
Results:
1: //indexed multiply with non-zero data - 1680ms
2: //non indexed multiply with non-zero data - 430ms
3: //some trig functions - 1770ms
4: //non indexed multiply with non-zero data, more calcs, for loop smaller - 280ms
5: //non indexed divide with non-zero data - 560ms
6: //non indexed multiply with zero data - 440ms
7: //Boolean logic - 310ms
8: //Bitwise operation - 300ms
9: //bubble sort - fails to finish within 6000ms (maximum cycle time for IM151-8)

edit: btw, the arrays were too big for the available memory, so I reduced them by a factor 10 and extrapolated the results accordingly.
__________________
Jesper
See my profile interests for Q&A

Last edited by JesperMP; June 12th, 2019 at 10:18 AM.
  Reply With Quote
Old June 12th, 2019, 09:37 AM   #62
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,776
Quote:
Originally posted by L D[AR2,P#0.0]:

3: // some trig functions - 13.5ms
#rData1 := 0.1;
#rData2 := 0.2;
FOR #diIndex := 0 TO 99999 DO
#diResult := REAL_TO_DINT(TAN(#rData1) * TAN(#rData2));
END_FOR;
That doesn't make any sense. This test is running faster than the multiplying of two reals case. Is it possible that since the values of #rData1 and #rData2 are being explicitly set just prior to entry into the FOR loop that the compiler is optimizing the result of the TAN function to a constant?

Keith
  Reply With Quote
Old June 12th, 2019, 10:16 AM   #63
NetNathan
Lifetime Supporting Member
United States

NetNathan is offline
 
Join Date: Nov 2011
Location: Corona, CA
Posts: 1,573
Interesting data...
__________________
****Control Freak****
Net is where I be and Nathan is me.
  Reply With Quote
Old June 12th, 2019, 10:25 AM   #64
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,737
LD's tests done with a Siemens S7-1512SP (optimized block access)
Results:
1: //indexed multiply with non-zero data - 434ms
2: //non indexed multiply with non-zero data - 557ms
3: //some trig functions - 498ms
4: //non indexed multiply with non-zero data, more calcs, for loop smaller - 455ms
5: //non indexed divide with non-zero data - 540ms
6: //non indexed multiply with zero data - 320ms
7: //Boolean logic - 54ms
8: //Bitwise operation - 51ms
9: //bubble sort - 1250ms

Again, due to the memory requirements I had to reduce the array sizes and extrapolate the results.

edit: I think that Kamenges is right, that in test 3 (and possibly some of the other tests) the TIA compiler detects that the variable doesnt get changed, so that it is a de-facto constant, and thus optimises the code by substituting the calculation by a simple value assignment of the result of the formula.

edit again: That could mean that the tests should be reviewed and possibly changed to avoid that from happening. Otherwise the test results are skewed.
__________________
Jesper
See my profile interests for Q&A

Last edited by JesperMP; June 12th, 2019 at 10:31 AM.
  Reply With Quote
Old June 12th, 2019, 10:29 AM   #65
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,776
By the way, trig functions are not friendly to the L71. I ran the math test with the real multiply replaced with TAN(REAL1). This is less than half as intense as the test L D[AR2,P#0.0] ran on the S7-1517. The scan time came in at 1860 msec.

X to the power of Y was a bigger hit. In the math test I replaced (Real1 * Real2) with (Real1 ** Real2), which in AB-speak is Real11^Real2. That took 3805 msec.

Keith
  Reply With Quote
Old June 12th, 2019, 10:45 AM   #66
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,737
LD's tests done with a Siemens S7-1512SP (non-optimized block access)
Results:
1: //indexed multiply with non-zero data - 785ms (*)
2: //non indexed multiply with non-zero data - 523ms
3: //some trig functions - 588ms
4: //non indexed multiply with non-zero data, more calcs, for loop smaller - 460ms
5: //non indexed divide with non-zero data - 555ms
6: //non indexed multiply with zero data - 322ms
7: //Boolean logic - 119ms (**)
8: //Bitwise operation - 63ms
9: //bubble sort - 2200ms (*)

*: One can see that when there is access from the code to global DB, there is a penalty when the DB is non-optimized.
**: Even if only TEMP memory of the block is used, non-optimized costs a penalty for boolean code.
__________________
Jesper
See my profile interests for Q&A
  Reply With Quote
Old June 12th, 2019, 12:37 PM   #67
Jmeadows7676
Member
United States

Jmeadows7676 is offline
 
Join Date: Oct 2013
Location: Alabama
Posts: 35
Test Re-do

1769-L24ER vr 31
Using Archies File

MathTest = 313ms
Bubble Sort = 1.57sec
IndexTest = 147ms
BitwiseTest = 167ms

Not Calling Routine. Using it as MAIN

Last edited by Jmeadows7676; June 12th, 2019 at 12:38 PM. Reason: Add Wording
  Reply With Quote
Old June 12th, 2019, 06:35 PM   #68
chelton
Member
Australia

chelton is offline
 
Join Date: Jan 2012
Location: melbourne
Posts: 78
LD's tests done with a Omron NJ101-9000
Results:
1: //indexed multiply with non-zero data - 100ms
2: //non indexed multiply with non-zero data - 84ms
3: //some trig functions - 225ms
4: //non indexed multiply with non-zero data, more calcs, for loop smaller - 80ms
5: //non indexed divide with non-zero data - 103ms
6: //non indexed multiply with zero data - 31ms
7: //Boolean logic - 8ms
8: //Bitwise operation - 11ms
9: //bubble sort - 82ms
  Reply With Quote
Old June 13th, 2019, 02:19 AM   #69
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 5,690
The trig functions return a lower test time due to the the magnitude of the numbers involved - the smaller the number the less time a floating point multiply takes.


I modified case 3 so that the tans would return 100.0 and 1000.0 so it would be comparable with case 2 and now it does take longer to execute.



Code:
    3:  // some trig functions - 15.0ms
        #rData1 := LREAL_TO_REAL(ATAN(100.0));
        #rData2 := LREAL_TO_REAL(ATAN(1000.0));
        #diResult := REAL_TO_DINT(TAN(#rData1) * TAN(#rData2));
        FOR #diIndex := 0 TO 99999 DO
            #diResult := REAL_TO_DINT(TAN(#rData1) * TAN(#rData2));
        END_FOR;
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com
  Reply With Quote
Old June 13th, 2019, 06:39 AM   #70
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,737
Quote:
Originally Posted by L D[AR2,P#0.0] View Post
The trig functions return a lower test time due to the the magnitude of the numbers involved - the smaller the number the less time a floating point multiply takes.
Even so, it is odd that doing trig functions before multiplying, is executing faster than just multiplying.
One should think that adding the extra trig instructions should take longer time.

I wonder if it makes a difference if you change rData1 and rData2 from TEMP to STAT or to global DB.
__________________
Jesper
See my profile interests for Q&A
  Reply With Quote
Old June 13th, 2019, 08:26 AM   #71
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,776
Quote:
Originally posted by L D[AR2,P#0.0]:

The trig functions return a lower test time due to the the magnitude of the numbers involved - the smaller the number the less time a floating point multiply takes.
It's not the multiplies. It is the trig functions. There are two "typical" ways to handle trig functions in a CPU. One is interpolation into a look-up table. At a minimum that will require two indexed data accesses with multiple subtractions and divides (assuming linear interpolation). The other method is to approximate the value with a power series which is even more processor intensive. So the fact that ANY operation including a trig function can complete faster than a similar operation without a trig function seem really odd.

Keith
  Reply With Quote
Old June 14th, 2019, 06:59 PM   #72
Archie
Member
United States

Archie is offline
 
Join Date: May 2002
Location: Orangeburg, SC
Posts: 1,887
I did some tests on an L85E using firmware 28 and 32. I was surprised to find a difference:

v28
MathTest 7.5
IndexTest 3.7
BitWiseTest 2.6
BubbeSort 83


v32
MathTest 9.5
IndexTest 3.5
BitWiseTest 2.4
BubbeSort 77
__________________
Expectations lead to disappointment. Appreciation leads to satisfaction.

AdvancedHMI - HMI Software without the license key hassles
  Reply With Quote
Old Yesterday, 05:54 AM   #73
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,737
LD's tests done with a Siemens S7-1515SP Open Controller (optimized block access)

This is not the latest version. As far as I know, the latest version essentially has 4 cores instead of 2 cores. It is still only 1 core for the Open Controller PLC. It is the Windows side that gets bumped from 1 to 3 cores. So the test results should be valid even for the newest version.

Also of note, the 1515SP should be approximately equivalent to an S7-1516.

I am not going to repeat the test with non-optimized block access.

Results:
1: //indexed multiply with non-zero data - 28ms
2: //non indexed multiply with non-zero data - 27ms
3: //some trig functions - 24ms
4: //non indexed multiply with non-zero data, more calcs, for loop smaller - 27ms
5: //non indexed divide with non-zero data - 27ms
6: //non indexed multiply with zero data - 14ms
7: //Boolean logic - 1ms
8: //Bitwise operation - 1ms
9: //bubble sort - 51ms
__________________
Jesper
See my profile interests for Q&A
  Reply With Quote
Old Yesterday, 07:19 AM   #74
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,737
I did non-optimized anyway

LD's tests done with a Siemens S7-1515SP Open Controller (non-optimized block access)

Results:
1: //indexed multiply with non-zero data - 76ms
2: //non indexed multiply with non-zero data - 27ms
3: //some trig functions - 25ms
4: //non indexed multiply with non-zero data, more calcs, for loop smaller - 27ms
5: //non indexed divide with non-zero data - 29ms
6: //non indexed multiply with zero data - 25ms
7: //Boolean logic - 12ms
8: //Bitwise operation - 11ms
9: //bubble sort - 246ms
__________________
Jesper
See my profile interests for Q&A
  Reply With Quote
Old Yesterday, 08:15 AM   #75
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,776
Quote:
Originally posted by JesperMP:

3: //some trig functions - 25ms
Have you determined if this is valid yet and, if so, how it is so blazingly fast? If that is accurate it is truly impressive.

Keith
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Mitsubishi PLC died. Twice. JRoss LIVE PLC Questions And Answers 11 January 29th, 2019 09:35 PM
More questions about RSemulator, PLC network, and career path... timcph2008 LIVE PLC Questions And Answers 0 March 8th, 2018 11:04 AM
PLC Update - Back Issues Collection Now Available! Phil Melore LIVE PLC Questions And Answers 11 October 22nd, 2015 02:17 AM
Siemens PLC won't auto-run after power-up Lamboom LIVE PLC Questions And Answers 5 August 19th, 2014 04:32 PM
PC to PLC Protocol TheRixta LIVE PLC Questions And Answers 13 December 17th, 2008 12:56 PM


All times are GMT -5. The time now is 08:37 PM.


.