XMC4800 trigonometric calculations

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User20798
Level 1
Level 1
Dear alll,

sorry for the (possibly) silly question but I am quite new to the XMC4800 MCU. I have acquired a XMC4800 EtherCAT relax kit, I am now simply implementing a field oriented control (FOC) for a PMSM .
I realised that the calculation time is quite high for the basic trigonometric functions. I am using the standard math.h library and the single precision float functions sinf, cosf hoping to have faster calculations.
It seems weird to me that such a MCU could be that slow, do you have any suggestions? compilers?..

Many thanks,

Luca24
0 Likes
3 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked
Hi Luca24,

Could you please let us know how much slow the results are when you are using trigonometric calculation?

Best Regards,
Vasanth
0 Likes
User20798
Level 1
Level 1
Dear Vasanth,

i get a calculation time of around 2 us using the sinf math.h function while a calculation time of around 800 ns when using my own LUT for the sin trigonometric function.
In order to evaluate the calculation time I toggle a digital IO pin and monitor it on the scope, therefore the time measured contains as well the time required to toggle high and low the IO pin.
When I try to implement a field oriented control for a PM machine at 50 KHz I am having great issues to fit all the controller (clark, rotation, PI...) in the 20 us time period.

Best Regards,

Luca24
0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked
Hi Luca,

The 2us value seems to reasonable seeing the generate code. What is the time period you are observing in the controller loop as of now ? I guess you can get a marginal improvement using the optimization in the tool chain.
Right click on project ->Properties ->C/C++ Build -> Settings -> ARM GCC compiler optimization. Change the optimization from none and see the performance. Make sure that the parts in you code are not optimized out and functionality is not lost.

Best Regards,
Vasanth
0 Likes