Curr_Components SVPWM_3ShuntGetPhaseCurrentValues(void) { Curr_Components Local_Stator_Currents; s32 wAux; switch (bSector) { case 4: //È¡µÃÔÚÄǸöÉÈÇøµÄʱºòÔÚ¶ÁÈ¡AD ÒòΪADCÊý¾ÝÑ¡ÔñÁË×ó¶ÔÆë£¬ÔÚ×¢ÈëͨµÀÀïÓзûºÅλËùÒÔ²ÅÓÐÊý¾ÝֵΪÎÞ·ûºÅ65535£¨ÓзûºÅÔò32767£© case 5: //Current on Phase C not accessible // Ia = (hPhaseAOffset)-(ADC Channel 11 value) wAux = (s32)(hPhaseAOffset)- ((ADC1->JDR1)<<1); //Saturation of Ia if (wAux < S16_MIN) { Local_Stator_Currents.qI_Component1= S16_MIN; } else if (wAux > S16_MAX) { Local_Stator_Currents.qI_Component1= S16_MAX; } else { Local_Stator_Currents.qI_Component1= wAux; } // Ib = (hPhaseBOffset)-(ADC Channel 12 value) wAux = (s32)(hPhaseBOffset)-((ADC2->JDR1)<<1); // Saturation of Ib if (wAux < S16_MIN) { Local_Stator_Currents.qI_Component2= S16_MIN; } else if (wAux > S16_MAX) { Local_Stator_Currents.qI_Component2= S16_MAX; } else { Local_Stator_Currents.qI_Component2= wAux; } break; case 6: case 1: //Current on Phase A not accessible // Ib = (hPhaseBOffset)-(ADC Channel 12 value) wAux = (s32)(hPhaseBOffset)-((ADC1->JDR1)<<1); //Saturation of Ib if (wAux < S16_MIN) { Local_Stator_Currents.qI_Component2= S16_MIN; } else if (wAux > S16_MAX) { Local_Stator_Currents.qI_Component2= S16_MAX; } else { Local_Stator_Currents.qI_Component2= wAux; } // Ia = -Ic -Ib wAux = ((ADC2->JDR1)<<1)-hPhaseCOffset- Local_Stator_Currents.qI_Component2; //Saturation of Ia if (wAux> S16_MAX) { Local_Stator_Currents.qI_Component1 = S16_MAX; } else if (wAux <S16_MIN) { Local_Stator_Currents.qI_Component1 = S16_MIN; } else { Local_Stator_Currents.qI_Component1 = wAux; } break; case 2: case 3: // Current on Phase B not accessible // Ia = (hPhaseAOffset)-(ADC Channel 11 value) wAux = (s32)(hPhaseAOffset)-((ADC1->JDR1)<<1); //Saturation of Ia if (wAux < S16_MIN) { Local_Stator_Currents.qI_Component1= S16_MIN; } else if (wAux > S16_MAX) { Local_Stator_Currents.qI_Component1= S16_MAX; } else { Local_Stator_Currents.qI_Component1= wAux; } // Ib = -Ic-Ia; wAux = ((ADC2->JDR1)<<1) - hPhaseCOffset - Local_Stator_Currents.qI_Component1; // Saturation of Ib if (wAux> S16_MAX) { Local_Stator_Currents.qI_Component2=S16_MAX; } else if (wAux <S16_MIN) { Local_Stator_Currents.qI_Component2 = S16_MIN; } else { Local_Stator_Currents.qI_Component2 = wAux; } break; default: break; } return(Local_Stator_Currents); }
收藏0 举报
CS_Police 发表于 2015-6-9 21:12 楼主可以看下STM32F103的ADC外设,它有两个ADC模块,也就是可以同时读取两路的电流信号,所以三电阻采样可 ...
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
人才类勋章
时间类勋章
等级类勋章
发帖类勋章
2
4
0
扫码关注 21ic 官方微信
扫码关注嵌入式微处理器
扫码关注电源系统设计
扫码关注21ic项目外包
扫码浏览21ic手机版
本站介绍 | 申请友情链接 | 欢迎投稿 | 隐私声明 | 广告业务 | 网站地图 | 联系我们 | 诚聘英才
京公网安备 11010802024343号