With S32k144 and BLDC control, how to convert fixed-point number to floating-point number?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

With S32k144 and BLDC control, how to convert fixed-point number to floating-point number?

954 Views
fedora
Contributor III

Hello all:

    In the MCSPTE1AK144-BLDC_6Step project, I saw the use of FRAC16() macro to convert floating-point to fixed-point number, but I did not find how to convert fixed-point to floating-point number. May I ask if it is not necessary to convert fixed-point  to floating-point number in the motor control process?

For example, the following code:

NextCmtPeriod = MLIB_Mul_F16(NextCmtPeriod, FRAC16(mcat_startCmtAcceler));

The NextCmdPeriod is fixed-point number,why not convert to floating-point number?

Thanks for your help!

 

Best regards,

Fed.ora

 

0 Kudos
Reply
1 Reply

526 Views
nancy865miler
Contributor I

Hi! 

In the MCSPTE1AK144-BLDC_6Step project (and many motor control projects using fixed-point math), you often see conversions from floating-point to fixed-point using macros like FRAC16(). This is because the motor control algorithms and the underlying hardware (DSP or MCU) typically work most efficiently with fixed-point arithmetic for speed and resource constraints.

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1975163%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EWith%20S32k144%20and%20BLDC%20control%2C%20how%20to%20convert%20fixed-point%20number%20to%20floating-point%20number%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1975163%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20all%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%26nbsp%3BIn%20the%20MCSPTE1AK144-BLDC_6Step%20project%2C%20I%20saw%20the%20use%20of%20FRAC16()%20macro%20to%20convert%20floating-point%20to%20fixed-point%20number%2C%20but%20I%20did%20not%20find%20how%20to%20convert%20fixed-point%20to%20floating-point%20number.%20May%20I%20ask%20if%20it%20is%20not%20necessary%20to%20convert%20fixed-point%26nbsp%3B%20to%20floating-point%20number%20in%20the%20motor%20control%20process%3F%3C%2FP%3E%3CP%3EFor%20example%2C%20the%20following%20code%EF%BC%9A%3C%2FP%3E%3CP%3ENextCmtPeriod%20%3D%20MLIB_Mul_F16(NextCmtPeriod%2C%20FRAC16(mcat_startCmtAcceler))%3B%3C%2FP%3E%3CP%3EThe%20NextCmdPeriod%20is%26nbsp%3Bfixed-point%20number%2Cwhy%20not%20convert%20to%20floating-point%20number%EF%BC%9F%3C%2FP%3E%3CP%3EThanks%20for%20your%20help!%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EBest%20regards%EF%BC%8C%3C%2FP%3E%3CP%3EFed.ora%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2150794%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20With%20S32k144%20and%20BLDC%20control%2C%20how%20to%20convert%20fixed-point%20number%20to%20floating-point%20number%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2150794%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi!%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20MCSPTE1AK144-BLDC_6Step%20project%20(and%20many%20motor%20control%20projects%20using%20fixed-point%20math)%2C%20you%20often%20see%20conversions%20from%20floating-point%20to%20fixed-point%20using%20macros%20like%20FRAC16().%20This%20is%20because%20the%20motor%20control%20algorithms%20and%20the%20underlying%20hardware%20(DSP%20or%20MCU)%20typically%20work%20most%20efficiently%20with%20fixed-point%20arithmetic%20for%20speed%20and%20resource%20constraints.%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E