This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am working on my college final project which is an inverter and we are using the TMS320F28335 microcontroller. My supervisor, that has been working on these topics for a long time, recommended me to do all the control calculations (inside the microcontroller) in PU (per unit) instead of using the IS (International System) units. I guess that is what he has learnt from working in other projects like this since many years ago but to me it seems something we are just dragging from the past, when FPUs were not commonly available in microcontrollers. I understand that using fixed point arithmetic allows us to develop firmware compatible with older/cheaper microcontrollers but, without taking this into account, is there another reason why we should keep on using PU? IS units are far easier to understand.
And another thing related to this. I have seen examples in ControlSuite and, there, the data type for the control calculations is _iq. That data type, depending on the used microcontroller could be float or fixed. My question is, do we have the same precision with float or fixed data? Intuitively I would think that if we are working in PU, with 32 bits numbers, using fixed data with many decimals (let's say Q29) should be more precise than floats because they, with the same amount of bits, should be able to represent many numbers >1.0 (let's say >4.0 to compare with Q29) that would not be used.
To summarize:
1) Why to use PU in the control algorithm calculations (despite of compatibility with older/cheaper microcontrollers)?
2) If using PU (assuming that values will not overcome the limits of the representable range), would not it be more precise to use fixed arithmetic with plenty of decimals rather than floats? Of course, if not using PU, the only choice (at least in the general case) would be floats I guess. And an extra: if using fixed arithmetic would be more precise, would it be as fast as with floats (with the FPU)? I do not know if multiplication, division, trigonometric calculations, etc. are equally fast with fixed arithmetic.
Thanks in advance.
I think the 'FPU primer' document referenced in the previous thread does a good job of explaining the benefits of working in floating-point. You're really reading resolution against range: when working in fixed point the resolution is the same for all numbers represented in the same IQ format, but the numerical range is limited so the programmer has to ensure that all calculation results fall within the representable range of the chosen format. In floating point, numerical resolution changes with the size of the number, but the representable range is far greater so it's very rarely necessary to check that results are numerically representable. There are indeed cases where fixed point has better resolution than floating point, however in general I think most programmers choose floating point on the grounds of simplicity of coding alone.
BTW, there has been no C2000 device without floating point capability for several years and it's unlikely there will be again. These days, the availability of hardware support for floating point is more-or-less expected. Anyway, to answer the specific questions:
1) Mainly to control the numerical range when working with fixed point. There are occasions where it makes sense to normalise variables in a control application, but in floating point it's not generally necessary to do so.
2) See above for the range vs. resolution part. Regarding execution speed it depends on the calculation - you may pay a small cycle penalty for some FPU operations compared with fixed.
One last point: the F28335 is not a very recent device. Newer C2000 devices include a TMU accelerator which has hardware support for float operations such as sine, cosine, and division, which take 4-5 cycles to compute. If your application needs these sorts of computations the improvement will be large.
I hope this helps.
Regards,
Richard
Thank you for your answer!
Just one last question related to this thing you wrote: ..."you may pay a small cycle penalty for some FPU operations compared with fixed"... This could mean another advantage for using fixed arithmetic. Even if you use the Fast RTS Library, in general we could say that fixed data tends to allow faster calculations than floats?
On your FPUFastRTS library, I have a comment - FPUFast RTS library is nowhere as fast as the TMU. For example,