Hi Guys,
Guys,I don't know whether is it right that post my doubt in the Community,If not please give me ansower!
I bought theDual 3-phase PMSM Kit with MPC5643L MCU|NXP from NXP,Nowdays,i am learn the S32 project(MTRCKTDPS5643L Application Software) about the board,i have some question about it.
1# in the file named ADC_MEAS_FLT.c,there is a segment C- code :
tBool ADC_Measure3Ph(pmsmDrive_t *ptr, tFloat Imax)
{
//12bit accuracy,the const 0.5F
ptr->adc.measured.fltPhA.raw = MLIB_Mul(((tFloat)(ioctl(ptr->uni3PeriphCfg.PhABaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhAChnlOffset))/(tFloat)0x0FFF-0.5F),Imax);
ptr->adc.measured.fltPhB.raw = MLIB_Mul(((tFloat)(ioctl(ptr->uni3PeriphCfg.PhBBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhBChnlOffset))/(tFloat)0x0FFF-0.5F),Imax);
ptr->adc.measured.fltPhC.raw = MLIB_Mul(((tFloat)(ioctl(ptr->uni3PeriphCfg.PhCBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhCChnlOffset))/(tFloat)0x0FFF-0.5F),Imax);
ptr->iAbcFbck.fltArg1 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhA, ptr->adc.measured.fltPhA.raw),2);
ptr->iAbcFbck.fltArg2 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhB, ptr->adc.measured.fltPhB.raw),2);
ptr->iAbcFbck.fltArg3 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhC, ptr->adc.measured.fltPhC.raw),2);
return(1);
}
(1) Why the c-code need subtract the 0.5F?
(2) why the c- code need mulitiply the constant 2?
2# in the file named ADC_MEAS_FLT.c,there is another segment C- code :
tBool ADC_ModuleCalib(pmsmDrive_t *ptr)
{
static tFloat fltFiltOutput;
if (!(ptr->adc.flag.B.calibInitDone))
{,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
if (!(ptr->adc.flag.B.calibDone))
{
/* --------------------------------------------------------------
* Phase A - DC offset data filtering using MA recursive filter
* filt= filtered value
* ------------------------------------------------------------ */
ptr->adc.measured.fltPhA.filt = MLIB_Add(ptr->adc.measured.fltPhA.filt,ptr->adc.measured.fltPhA.raw);//?
fltFiltOutput = MLIB_Div(ptr->adc.measured.fltPhA.filt,ptr->adc.param.u16CalibSamples);
ptr->adc.measured.fltPhA.filt = MLIB_Sub(ptr->adc.measured.fltPhA.filt,fltFiltOutput);
ptr->adc.offset[ptr->svmSector].fltPhA = fltFiltOutput;
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
(1) I am not clearly with theroy for Phase A - DC offset data filtering using MA recursive filter?
Who can help me solve it?