simplefoc / Arduino-FOC-drivers

Drivers and support code for SimpleFOC
https://docs.simplefoc.com/drivers_library
MIT License
146 stars 63 forks source link

STM32G4 CORDIC driver #7

Closed runger1101001 closed 1 year ago

runger1101001 commented 2 years ago

See if a driver for the STM32G4's CORDIC peripheral has any impact on performance in terms of either speed or quality.

https://www.st.com/content/ccc/resource/training/technical/product_training/group0/df/3d/f3/88/05/ae/42/67/STM32G4-Peripheral-Cordic_Coprocessor_CORDIC/files/STM32G4-Peripheral-Cordic_Coprocessor_CORDIC.pdf/jcr:content/translations/en.STM32G4-Peripheral-Cordic_Coprocessor_CORDIC.pdf

It unfortunately doesn't operate directly on floating point numbers, so it may not be worth it.

runger1101001 commented 1 year ago

This has been quite extensively tested, please see: https://community.simplefoc.com/t/embedded-world-2023-stm32-cordic-co-processor/3107/98

Use of the CORDIC for individual operations is not faster than optimised lookup table based solutions. But it is a lot more accurate, agreeing with the stdlib sin() function almost completely.

The result of this testing is that we have made the _sin() function in SimpleFOC weakly bound so users can easily replace it with their own implementations. If someone wants to use the CORDIC, they now can :-)