Clear Filters
Clear Filters

How is this data type conversion working?

3 views (last 30 days)
I am trying to understand this host model for pmsm - mcb_pmsm_host_model_f28069m.slx
There is a PU conversion happening inside the transmission block which I have replicated in the image attached.
I have put displays after different operations. The first display is showing value after the gain block divides the input 3000 with 3582
The second display is after the Data Type Conversion2 block and third display is after the Data Type Conversion3 block
The Data Type Conversion2 is set to output fixdt(1,16,12) with Real World Value and floor rounding
The Data Type Conversion3 is set to output uint16 with Stored Integer and floor rounding.
I need to understand that how is a data type conversion block transforming my value of 0.8375 to 3430?

Accepted Answer

KrishnaKumar
KrishnaKumar on 4 Oct 2023
For information on Stored Integer, please refer to fixed-point documentation and basics. You can also refer to Scaling - MATLAB & Simulink (mathworks.com), Configure Blocks with Fixed-Point Output - MATLAB & Simulink and Stored integer value of fi object - MATLAB storedInteger for how Stored Integer conversion works.
The host model is transmitting the data to the target model as an unsigned integer. This value would be interpreted by the target model as an unsigned integer and further operations (e.g. re-conversion to single datatype to obtain original value) might be performed on the same.
In the above figure, the input to data type conversion3 has a fractional bit count of 12 and hence when its converted to uint16 with stored integer, it gives a value equal to 0.8375*2^12 3430, which would be transmitted to the target model.

More Answers (0)

Categories

Find more on Motor Control Blockset in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!