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

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

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

472 Views
edenli
Contributor V

Hi Guys,

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:

pastedImage_34.png

 

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 ?

0 Kudos
Reply
0 Replies