microchip-pic-avr-tools / powersmart-dcld

MPLAB® PowerSmart™ SDK - Digital Control Library Designer Configuration Tool & Code Generator
https://microchip-pic-avr-tools.github.io/powersmart-dcld/
14 stars 4 forks source link

Add Option to Reduce Numerical Error In Compensator Output #11

Closed westonb closed 2 years ago

westonb commented 2 years ago

For some values of compensator coefficients, typically when the frequencies of the poles and zeros are small compared to the sampling frequency, there is significant numerical error in the compensator output, which leads to a failure to integrate the error for small error values and an offset in the controller.

The root cause is that the sum of the X terms is smaller than one bit, so the error fails to integrate between updates in the compensator.

It would be useful if the software checked the coefficients for these issues and warned the user, similar to how it checks for numerical error in the coefficients themselves.

Additionally, if the lower 16 bits of the Y terms are stored and used in the calculations of future Y terms this issue would be greatly reduced/eliminated. Doing so should only take ~3 instructions per Y term in the compensator and would be a very useful software option.

areiter128 commented 2 years ago

Hi westonb, Thank you very much for opening this issue and your comments!

Since we moved this tool to the more powerful design tool MPLAB PowerSmart, some improvements on the analysis of limited number resolutions have been added. This doesn't really solve the problems you mentioned, but at least helps users to better optimize the number resolution in each of the respective number scaling options.

The next real resolution improvement will be introduced with the next release, where a second floating point number scaling option will be added storing floating point numbers to the control output history. This will still have a slightly lower resolution than your proposed solution but will definitely improve the recent limitations while only adding a minimum of additional CPU load. This will not be the end, just one more iteration. If this is still not good enough, a full 32 bit resolution implementation would be the logical next step.

These changes, however, won't be released anymore with this stand-alone version of DCLD here on Github. They will only be available in the new, official Microchip version, which can be found here: https://www.microchip.com/powersmart

Thanks again and best regards!