Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Significantly improve ADC performance
In 5eb9139 and previously a398d0c, work was done to identify ADC performance issues. In the meantime, ST released new errata for the STM32G474 ADC which more accurately describes problematic configurations when multiple ADCs are used simultaneously. * ES0430 - Rev 8, 2.7.9 Notably, to achieve optimal results, the documented workaround is to use a synchronous clock mode with a prescaler no more than 1 (!), and also to trigger all ADCs simultaneously by using a hardware trigger. Using a prescaler of exactly 1 is hard for moteus, since that would run the ADC too fast, at 85Mhz. Instead, now switch to a synchronous clock with a prescaler of 2, and rely on the fact that we are already starting all the ADCs at a fixed phase relative to the system cycle counter. While we are at it, use some inline assembly to get the ADC sample starts to be much closer together in time. The combined result of this change is that nearly all noise that varies with ADC value is removed except for that near 2048, and that is only around 3-5 LSB. Previously depending exactly the phase things ended up in, there could be significant additional noise every 8 LSB, and an increased window of noise around the 2048 mark up to 10 LSB or more.
- Loading branch information
Showing
5 changed files
with
126 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters