How to do floating point operation in Q format(S912ZVML32)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to do floating point operation in Q format(S912ZVML32)

跳至解决方案
1,056 次查看
maxxu
Contributor IV

Hi

   Hello everyone,I use S12ZVML32 for oil pump,How to do floating point operation in Q format,

   I use MC9S12ZVM_AMMCLIB  ,

   What functions should be used for multiplication and division of tfrac16 format?

1 解答
891 次查看
pachamatej
NXP Employee
NXP Employee

Hi,

I'm not sure if I'm getting your point correctly, but here is what you can do:

  • Use tFrac16 type to handle your data. Please remember that at any point, the value should fit within -1.0 and 1.0 range (internally stored as Word16 -32768 to 32767).
  • Check out the library documentation - User Guide (available in the install folder) or get the library installer from Automotive Math and Motor Control Library Set | NXP 
  • Use MLIB_Mul_F16 for multiplication and MLIB_DivSat_F16 for division. You can also use another variants of these functions (see the User Guide) - please follow the examples in the User Guide.

If you are referring to the IEEE754 floating point operation, these are not supported by the AMMCLib for S12ZVM (see the User Guide, chapter 1.2). All "floating point" operations on S12ZVM are done in normalized format and represented by tFrac16 or tFrac32. More details are available in the User Guide.

Best regards,

Matej

在原帖中查看解决方案

1 回复
892 次查看
pachamatej
NXP Employee
NXP Employee

Hi,

I'm not sure if I'm getting your point correctly, but here is what you can do:

  • Use tFrac16 type to handle your data. Please remember that at any point, the value should fit within -1.0 and 1.0 range (internally stored as Word16 -32768 to 32767).
  • Check out the library documentation - User Guide (available in the install folder) or get the library installer from Automotive Math and Motor Control Library Set | NXP 
  • Use MLIB_Mul_F16 for multiplication and MLIB_DivSat_F16 for division. You can also use another variants of these functions (see the User Guide) - please follow the examples in the User Guide.

If you are referring to the IEEE754 floating point operation, these are not supported by the AMMCLib for S12ZVM (see the User Guide, chapter 1.2). All "floating point" operations on S12ZVM are done in normalized format and represented by tFrac16 or tFrac32. More details are available in the User Guide.

Best regards,

Matej