最近学习TI的InstaSpin-FOC,看见里面初始化了滤波器参数,但程序没用到滤波器过滤电流。是我没找到操作代码还是程序中就没用。
下面是电流读取代码到clarke部分;下面是Lab 1C 。
HHAL_readAdcData中只从ADC寄存器中读取了滤波器ADC值,并进行了简单的比例和IQ转化,没有滤波;
CLARKE_run中直接进行clarke变化,也没有滤波。
剩下代码中都没有关于adc的操作。
既然InstaSPIN 初始化了滤波器参数,为什么不用呢?
TI demo板有一个RC 低通滤波器,截止频率在450KHZ,远不能滤除噪声。必定还要其他滤波才能行。但一直没找到。
谁能帮我解答一下。
static inline void HAL_readAdcData(HAL_Handle handle,HAL_AdcData_t *pAdcData) {HAL_Obj *obj = (HAL_Obj *)handle;_iq value;_iq current_sf = HAL_getCurrentScaleFactor(handle);_iq voltage_sf = HAL_getVoltageScaleFactor(handle);// convert current A// sample the first sample twice due to errata sprz342f, ignore the first samplevalue = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_1);value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[0];// divide by 2^numAdcBits = 2^12pAdcData->I.value[0] = value;// convert current Bvalue = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_2);value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[1];// divide by 2^numAdcBits = 2^12pAdcData->I.value[1] = value;// convert current Cvalue = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_3);value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[2];// divide by 2^numAdcBits = 2^12pAdcData->I.value[2] = value;// convert voltage Avalue = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_4);value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[0];// divide by 2^numAdcBits = 2^12pAdcData->V.value[0] = value;// convert voltage Bvalue = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_5);value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[1];// divide by 2^numAdcBits = 2^12pAdcData->V.value[1] = value;// convert voltage Cvalue = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_6);value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[2];// divide by 2^numAdcBits = 2^12pAdcData->V.value[2] = value;// read the dcBus voltage valuevalue = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_7);// divide by 2^numAdcBits = 2^12value = _IQ12mpy(value,voltage_sf);pAdcData->dcBus = value;return; } // end of HAL_readAdcData() function
static inline void CLARKE_run(CLARKE_Handle handle,const MATH_vec3 *pInVec,MATH_vec2 *pOutVec) {CLARKE_Obj *obj = (CLARKE_Obj *)handle;uint_least8_t numSensors = obj->numSensors;_iq alpha_sf = obj->alpha_sf;_iq beta_sf = obj->beta_sf;if(numSensors == 3){pOutVec->value[0] = _IQmpy(lshft_1(pInVec->value[0]) - (pInVec->value[1] + pInVec->value[2]),alpha_sf);pOutVec->value[1] = _IQmpy(pInVec->value[1] - pInVec->value[2],beta_sf);}else if(numSensors == 2){pOutVec->value[0] = _IQmpy(pInVec->value[0],alpha_sf);pOutVec->value[1] = _IQmpy(pInVec->value[0] + lshft_1(pInVec->value[1]),beta_sf);}return; } // end of CLARKE_run() function
user5919672:请问老哥 弄明白了吗,可以讲解一下吗