Gursimran singh Mohar

Help regarding Fixed point implementation.

Discussion created by Gursimran singh Mohar on Sep 16, 2010
Latest reply on Sep 21, 2010 by Gursimran singh Mohar

Hi there,

 

First of all thanks for providing me so much support in this forum. I have come here with another question.

 

I have a project using MC9s12xd256 MCU. I have found that a instruction of this type;

 

 

corr_dc = kp_Dc*error;

 takes around 0.7ms and if kp_dc is float and if i change kp_dc as int, the time of execution is 0.007ms, so there is a big difference. As my application is very time critical. Do you advice me to use fixed point implementation instead of floating point. Here is the all floating code in the main loop of my project.

 

 

 

float kp=0.2;float ki=0.0023;float kd=0.033;correction = kp*error + ki*iterm + kd*dterm;


float com_ratio[7]={23.44,23.44 ...};
for(int i=0;i<7;i++)
{
   com_val = (int)(com_ratio*sen_val);
}

 

I think I can save  a lot of time by implementing fixed point. Also regarding fixed point representation, is there is a library avaliable for mc9s12x or I will have to write it on my own...

Outcomes