AnsweredAssumed Answered

About the ADC_ModuleCalib() function in the Dual motor demo board MPC5643L C-code project

Question asked by Eden Li on Jul 5, 2017
Latest reply on Jul 14, 2017 by Petr Fajmon

Hidumitru-daniel.popa,

   Firstly, I'am sorry to bother you again,Because i posted my  question to another  Community named MPC5XXX,the link:The question about the S32 C-code project of dual motor demo board for MPC5643L ,but Nobody reply to me,so whether the Web address is right about the dual motor demo board C-code?

   Daniel,Can you give me the link abou the Community?

  BTY,Can you help me slove my follow question,shown as below?

A C-code segment in the main.c shown as below:

tBool ADC_ModuleCalib(pmsmDrive_t *ptr)
{
static tFloat fltFiltOutput;

if (!(ptr->adc.flag.B.calibInitDone))
{
ptr->adc.calibCntr = 4096; // 2^(8 + 4) order to accommodate settling time of the filter

ptr->adc.measured.fltPhA.filt = 0.0F;
ptr->adc.measured.fltPhB.filt = 0.0F;
ptr->adc.measured.fltPhC.filt = 0.0F;
ptr->adc.measured.fltUdcb.filt = 0.0F;

ptr->adc.flag.B.calibDone = 0;
ptr->adc.flag.B.calibInitDone = 1;// initial setup for DC offset calibration done
}

if (!(ptr->adc.flag.B.calibDone))
{
/* --------------------------------------------------------------
* Phase A - DC offset data filtering using MA recursive filter
* filt= filtered value
* ------------------------------------------------------------ */

PART A:
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;

 

, , , ,,,,,,,,,,,,,,,,,,,,,,,,,,,,

 

if ((--ptr->adc.calibCntr)<=0)
{
ptr->adc.flag.B.calibDone = 1; // end of DC offset calibration
}
}

return (ptr->adc.flag.B.calibDone);
}

Analysis:

  According to the C-code segment,we can conclude that in the ADC_ModuleCalib() function ,will execute 4096 cycles in the ADC_ModuleCalib() funtion, then jump out the ADC_ModuleCalib().

The Value of u16CalibSamples is defined 256 in the stateInit().

The reference AN4518:

 

question:

1#,Why we assign the 4096 to ptr->adc.calibCntr,rather than  ptr->adc.calibCntr=.u16CalibSamples?

I thought we should sum the ptr->adc.measured.fltPhA.raw,and then averaged the values,that is the sum divide u16CalibSamples.

2#,I seemly not cleary with the Phase A - DC offset data filtering using MA recursive filter?

and the theory is,that is How to comprehend the the four lines C-code in the PART A ?

 

Outcomes