2024-05-15 06:43 AM
Hello, in the code I generated using MC workbench 5 or 6, there is something wrong with the part of the code that calculates the phase current value.
You can easily find it by searching in the generated code
PHandle->PhaseAOffset >>= 3;
PHandle->PhaseBOffset >>= 3;
PHandle->PhaseCOffset >>= 3;
I feel that the 3 here is wrong, it should be 4
Because NB_CONVERSIONS is 16, that is, the PhaseAOffset, B, and C obtained by adding and summing the values measured 16 times. This can be seen from the following code
if ( pHandle->PolarizationCounter < NB_CONVERSIONS )
{
pHandle->PhaseAOffset += *pHandle->pParams_str->ADCDataReg1[pHandle->CalibSector];
pHandle->PhaseBOffset += *pHandle->pParams_str->ADCDataReg2[pHandle->CalibSector];
PHandle->PolarizationCounter++;
}
Thanks.
2024-05-16 09:43 AM
Hello @Ywang.3 ,
Could you please detail your configuration, and specifically the STM32 you are using. Some ADCs have their own particularities, I am thinking in particular of the STM32F4.
Regards
Cedric