Part Number:TMS320F280049COther Parts Discussed in Thread:TMDXIDDK379D, C2000WARE
我基于C2000Ware_MotorControl_SDK_3_03_00_00中的工程,工程路径D:\ti\c2000\C2000Ware_MotorControl_SDK_3_03_00_00\solutions\tmdxiddk379d\f28004x。调试电机发现几个问题,希望TI的工程师帮忙解答。
我在FCL_LEVEL2 条件下验证电机开环运行,正常。其中,工程中进行SVPMW计算时调用的runSVGenDQ(&svgen1);
static inline void runSVGenDQ(SVGEN * in)
{
in->tmp1 = in->Ubeta;
in->tmp2 = (in->Ubeta / 2) + (0.866 * in->Ualpha);
in->tmp3 = in->tmp2 – in->tmp1;
in->VecSector = 3;
in->VecSector = (in->tmp2 > 0)?(in->VecSector – 1):in->VecSector;
in->VecSector = (in->tmp3 > 0)?(in->VecSector – 1):in->VecSector;
in->VecSector = (in->tmp1 < 0)?(7 – in->VecSector):in->VecSector;
if(in->VecSector == 1 || in->VecSector == 4)
{
in->Ta = in->tmp2;
in->Tb = in->tmp1 – in->tmp3;
in->Tc = -in->tmp2;
}
else if(in->VecSector == 2 || in->VecSector == 5)
{
in->Ta = in->tmp3 + in->tmp2;
in->Tb = in->tmp1;
in->Tc = -in->tmp1;
}
else
{
in->Ta = in->tmp3;
in->Tb = -in->tmp3;
in->Tc = -(in->tmp1 + in->tmp2);
}
}
然后调用EPWM_setCounterCompareValue(uint32_t base, EPWM_CounterCompareModule compModule,
uint16_t compCount)设置PWM。
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A,
(uint16_t)((INV_PWM_HALF_TBPRD * svgen1.Ta) +
INV_PWM_HALF_TBPRD));
EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_A,
(uint16_t)((INV_PWM_HALF_TBPRD * svgen1.Tb) +
INV_PWM_HALF_TBPRD));
EPWM_setCounterCompareValue(EPWM3_BASE, EPWM_COUNTER_COMPARE_A,
(uint16_t)((INV_PWM_HALF_TBPRD * svgen1.Tc) +
INV_PWM_HALF_TBPRD));
static inline void
EPWM_setCounterCompareValue(uint32_t base, EPWM_CounterCompareModule compModule,
uint16_t compCount)
{
uint32_t registerOffset;
//
// Check the arguments
//
ASSERT(EPWM_isBaseValid(base));
//
// Get the register offset for the Counter compare
//
registerOffset = EPWM_O_CMPA + (uint16_t)compModule;
//
// Write to the counter compare registers.
//
if((compModule == EPWM_COUNTER_COMPARE_A) ||
(compModule == EPWM_COUNTER_COMPARE_B))
{
//
// Write to COMPA or COMPB bits
//
HWREGH(base + registerOffset + 0x1U) = compCount;
}
else
{
//
// Write to COMPC or COMPD bits
//
HWREGH(base + registerOffset) = compCount;
}
}
其中HWREGH(base + registerOffset + 0x1U) = compCount;设置的时CMPA寄存器的高16位,即未使用高分辨率epwm功能。
但是在验证FCL_LEVEL3电流环时,电机抱轴卡死。发现调用的SVPWM函数有差异。通过调用FCL_SVGEN_PWM_PDATE_MACRO();
#define FCL_SVGEN_PWM_PDATE_MACRO() \
/* \
* —————————————————————————-\
* Call the space vector gen. macro \
* —————————————————————————-\
*/ \
svgen2.Tb = (svgen2.Ubeta – svgen2.Ualpha) / 2; \
svgen2.Tc = svgen2.Tb – svgen2.Ubeta; \
\
svgen2.tmp2 = __fmax(__fmax(svgen2.Ualpha, svgen2.Tc), svgen2.Tb); \
svgen2.tmp2 += __fmin(__fmin(svgen2.Ualpha, svgen2.Tc), svgen2.Tb); \
\
svgen2.tmp1 = ((-svgen2.tmp2) / 2) + FCL_params.carrierMid; \
\
/* \
* —————————————————————————-\
* Computed Duty and Write to CMPA register \
* —————————————————————————-\
*/ \
FCL_PWM_UPDATE_STYLE_3();
这部分跟通常的pwm时间计算不一样,不知道这里是如何计算ta,tb,tc的时间,其中也没有关于扇区的计算,但是的debug时发现svgen2.VecSector这个值是实时更新的。能否帮忙解释一下。
另外,在更新pwm时,调用FCL_PWM_UPDATE_STYLE_3() ;
*(pwmCompA) = (uint32_t)(svgen2.Tc + svgen2.tmp1); \
*(pwmCompB) = (uint32_t)(svgen2.Tb + svgen2.tmp1); \
*(pwmCompC) = (uint32_t)(svgen2.Ualpha + svgen2.tmp1);
直接对CMPA寄存器赋值,其中就用到低16位,即CMPAHR,
应该时用到了高分辨率epwm,但是查看HRepwm的相关配置寄存器,却没有进行配置。请问,这里是否使用了HREPWM功能?如果使用了,在哪里配置的?
如果没有使用,将svpwm计算值直接赋值给32位CMPA寄存器,是不是不正确啊?
Green Deng:
你好,工程师将在工作时间为你解答。
,
Green Deng:
你好,关于这款套件的问题建议你直接发布到英文E2E论坛,英文论坛有专司电机控制的工程师会为你解答:e2e.ti.com/…/c2000-microcontrollers-forum