Looking for a trig function library
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-11 5:39 AM
Hello ST Community,
I'm working on an application using the STM32F103C8T6 microcontroller that implements a Sliding Mode Observer (SMO) and Park/Clarke transformations. I'm facing significant performance challenges due to the computational overhead of the floating-point trigonometric functions atan2f.
My system requires a 50us loop execution time, but the SMO alone is taking approximately 20us, largely due to these trigonometric functions. I need to optimize this to meet my timing requirements.
Here's a breakdown of my current implementation:
- MCU: STM32F103C8T6
- Application: SMO and Park/Clarke transformations
- Problem: Excessive execution time of and atan2f within a 50us loop.
- Current Performance: SMO takes ~20us.
- Compiler: stm32cubeide
- Optimization Flags: O2
- Clock Frequency: 20khz
Please tell me solution
Solved! Go to Solution.
- Labels:
-
STM32F1 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-11 8:43 AM
Not the first to have these types of problems, perhaps consider Google, et al
https://gist.github.com/volkansalma/2972237
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-11 5:44 AM
Perhaps move to fixed point and use the precompiled DSP library.
https://github.com/ARM-software/CMSIS-DSP/tree/main/Source/FastMathFunctions
Floating point calculation on a chip without an FPU are going to be incredibly slow. Plenty of inexpensive chips out there with an FPU.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-11 5:48 AM
Lookup tables?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-11 8:43 AM
Not the first to have these types of problems, perhaps consider Google, et al
https://gist.github.com/volkansalma/2972237
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-12 12:07 AM
Sir please provide same for tanf , sinf, and cosf
Your solution is helpful for me, Thanks for reply and providing solution sir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-12 12:08 AM
Sir Thankyou so much Please can you provide me implementation for lookup table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-12 1:10 AM
... and maybe add interpolation to that lookup table too.
https://wirelesspi.com/3-ways-to-approximate-atan2-in-hardware/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-12 1:26 AM
Sir Please send me same for tanf
