Wrap/Saturate on overflow

조회 수: 45(최근 30일)
Giuseppe Galioto
Giuseppe Galioto 2019년 12월 21일
댓글: Walter Roberson 2020년 1월 13일
Hi there,
I'm trying to simulate a control algorithm with the fixed point tool. When I apply the fixed point data types and try to simulate the model, I get many wrap/saturate on overflow warnings. What's the right method to avoid overflows and fix them?
Thanks in advance
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 12월 21일
편집: Walter Roberson 2020년 1월 3일
Typically there are two ways to approach this:
  1. Increase the permitted range for your fixed point objects, so that they do not overflow; Or
  2. Re-examine the mathematics of your equations to figure out why you are getting overflows, and repair the algorithm
It is not uncommon that you need to do both of those -- not uncommon that when you examine your code in detail that you find some mistake in it, but that you also find some reason why it is reasonable for the control values to need to go outside the range you have permitted.

댓글을 달려면 로그인하십시오.

답변(1개)

MathWorks Fixed Point Team
MathWorks Fixed Point Team 2020년 1월 3일
I think it’s important to understand if these overflows are a concern in the context of the numerical behavior of your control algorithm i.e. Is the fixed point response within a reasonable tolerance compared to the floating point response?
If the answer is no, you can try two quick things:
  1. Increase the word length choice in the Fixed-Point Tool to check if greater precision improves the numerical behavior or
  2. Specify a larger safety margin that will accommodate for a larger operating range as Walter suggested (see image below)
safety_margin.png
It might help to check out these how to videos on Fixed-Point Tool:
  댓글 수: 3
Walter Roberson
Walter Roberson 2020년 1월 13일
Thanks, Evangelos, that is useful.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by