unsigned int get_tp(unsigned int j,unsigned int n,unsigned int tc,unsigned int f)
{
float kconst;
unsigned int Um;
//====================calculate Um=======================//
Um=PARA_SET[4];
if(f <PARA_SET[0])
{Um=(Um-UP_VOLTAGE)*10/PARA_SET[0]; //mutiply 10 to avoid float calculation and to make sure accuracy
Um=Um*f/10; //calculate seperately to avoid overflow
}
//==================================
kconst=2*3.1415926*f*PARA_SET[4];
switch(n)
{case 24:
{ TAB_pointer=table67_80;
break;
}
case 30:
{ TAB_pointer=table56_66;
break;
}
case 36:
{ TAB_pointer=table42_55;
break;
}
case 48:
{ TAB_pointer=table34_41;
break;
}
case 60:
{ TAB_pointer=table26_33;
break;
}
case 78:
{ TAB_pointer=table20_25;
break;
}
case 102:
{ TAB_pointer=table15_19;
break;
}
case 138:
{ TAB_pointer=table11_14;
break;
}
case 198:
{ TAB_pointer=table7_10;
break;
}
case 330:
{ TAB_pointer=table0_6;
break;
}
default:
break;
}//end switch
if(j> (n/2))
j=j-n/2;
kconst=*(TAB_pointer+j)/kconst;
Um=(unsigned int)((tc+((float)Um)*kconst)/2.0);//错误常在这句程序之后产生。
return(Um);
}