MATLAB Answers

Simulink's fixed-point tools ignores saturation limits during range collection

2 views (last 30 days)
Hello community
I'm using an iterative fixed-point conversion to optimize my Simulink model. When collecting the signal ranges by overriting all data types with double precision floating point I got the problem that the tool is ignoring my saturation limit of discrete-time integrator blocks, yielding ridiculously high numbers and thus wrong data type proposals.
How can I fix this?

Accepted Answer

Andy Bartlett
Andy Bartlett on 3 Feb 2021
Edited: Andy Bartlett on 4 Feb 2021
Hi,
When reporting simulation min and max to the Fixed-Point Tool, several Simulink blocks intentionally give ranges that can be wider than the minimum and maximum of the values written to the block's output signal.
A wider range is given to prevent overflows for all the calculations the block will use the output data type for.
As an example, consider a m x n by n x q matrix multiply. The calculation of each output element involves n multiplications and n-1 running summations of those products. Each of those 2*n-1 (except the last one) can have a range different from the final output. Also, each of the n products and n-1 sums uses the output data type to do those individual calculations. To avoid overflows for those 2*n-1 calculations, the selected data type must cover the union of their ranges.
For example, suppose the calculation is
10 * 10 + 15 * 10 + -14 * 10
The three products give values
100
150
-140
the first and second addition give
250 = 100 + 150
110 = 250 + -140
The final output is just the value +110.
But the range of all the calculations was -140 to 250.
So a product block doing that matrix multiply would report sim min of -140 and sim max of +250.
A data type proposed for that range would prevent overflow for all the calculations not just the final value of +110.
The attached model shows an example of this Matrix Multiply range and shows the equivalent calculations done with individual blocks. Simulate the model and compare the scope output to the ranges shown in the Fixed-Point Tool for the matrix multiply block.
I expect the discrete integrtor block is doing something similar. Even though the final output is saturated to -4.5 to 4.5, internal calculations are likely producing much bigger values.
If you are using the integrator for a control systems, you may want to look into PID anti-wind-up techniques. If you are already familiar with this, please pardon the unneeded explaination. Anti-wind-up techniques saturate the PID output and also keep the internal integrator state from growing unbounded. "Anti-wind-up" is an analogy with a rotary spring that is wound up so tight that it causes violent oscillations when the stored energy is allowed to release. The internal state of the integrator is like the spring.
-Andy

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!