// ------------------------------------------------------------------------------
// Measure phase currents, subtract the offset and normalize from (-0.5,+0.5) to (-1,+1).
// Connect inputs of the CLARKE module and call the clarke transformation macro
// ------------------------------------------------------------------------------
clarke1.As = _IQmpy2(_IQ12toIQ(AdcResult.ADCRESULT1)-offsetA); // Phase A curr. _IQ12toIQ 除以4096 变成(-1,+1),减offsetA 变成(-0.5,+0.5)所以乘以2
clarke1.Bs = _IQmpy2(_IQ12toIQ(AdcResult.ADCRESULT2)-offsetB); // Phase B curr.
CLARKE_MACRO(clarke1)
AdcResult.ADCRESULT1是12位的AD,范围是0~4096,_IQ12toIQ,此处GLOBAL_Q=24,所以相当于除以4096(2^12),AdcResult.ADCRESULT1此时的范围是(0-1),在减去偏移offsetA=0.5,范围就是(-0.5-0.5)
_IQ12toIQ(AdcResult.ADCRESULT1)-offsetA出来的范围是(-0.5-0.5)
乘以2,范围变成(-1-1)