Jump to content
OMRON Forums

computational efficiency


steveneads
 Share

Recommended Posts

My application is gradually growing the PPMAC processor loading, and so I'm always trying to ensure that I write my code as efficiently as I can. I use a significant amount of trig function calculations and I want to have some guidance on what methods are most efficient.

 

My code is running in C from script from PLC 0. I used this to do some timing tests evaluating some functions 1000 times. This yielded the following approximate times (microsecs) on a 465 PPMAC:

 

atan2(x,y): 97

atan: 0.12

sqrt(1 + x*x): 57

1/x: 0.1

cos: 0.12

acos: 57

 

I was staggered to see the differences between atan2 and atan in particular and was also surprised by some of the other differences. I'm almost doubting my own results.

 

Can DeltaTau shed any light on why atan2 and atan are so different in efficiency, and what functions are very costly / efficient? I remember some notes being provided on this years ago with the original PMACs!

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi Curt / Dro

 

Thanks for looking into this. We have done some more investigation here and have found the root cause of my results. It looks like I was being fooled by some sort of compiler optimization which meant that for some of the function tests, the calculation wasn't really being repeated the number of times that I thought is was.

 

However, we have noticed that using the rticplc seems to be significantly slower than using a C from script call from PLC 0 for the same function test. It's particularly bad for sqrt.

 

Is this what you would expect?

 

Thanks

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...