Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 230332

Forum Post: RE: Erratic motor behaviour after upgrading to Motorware 11.

$
0
0

regarding the int32 and float, the code is correct, but good question! It certainly does look backwards upon initial inspection.

This is a coding trick to get fpu32 enabled code to work with fixed point execute only ROM libraries.  

When fpu32 is enabled, the compiler thinks that all returned values are through the floating point registers, but the ROMed libraries return floating point values through the accumulator. So in order to trick the compiler so that it reads returned values from the accumulator, we declare the functions as if they return integers. Then, we do a union in the project lab, so it reads as an integer, but we interpret the result as a float

 ex:

  union

  {

    int32_t   long_value;

    float_t float_value;

  } interface;

 

  // get the stator resistance

  interface.long_value = EST_getRs_Ohm(obj->estHandle);

  gMotorVars.Rs_Ohm = interface.float_value;

 


Viewing all articles
Browse latest Browse all 230332

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>