TI中文支持网
TI专业的中文技术问题搜集分享网站

使用eCAP进行BLDC霍尔测速,测速结果跳变很大

我在使用F28030做BLDC速度控制,使用eCAP管脚获取一个霍尔管脚(三相)的信号。用示波器观测速度为600转Rpm左右(正负15转),可是使用eCAP测试结果差别很大,一会800,一会600,跳变严重。文件配置如下:

void InitECapture()
{

ECap1Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap1Regs.ECCTL2.bit.CONT_ONESHT =0; // One-shot
ECap1Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 4 events
ECap1Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap1Regs.ECCTL1.bit.CAP2POL = 0; // edge
ECap1Regs.ECCTL1.bit.CAP3POL = 1; // Falling edge
ECap1Regs.ECCTL1.bit.CAP4POL = 0; // edge

ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through

ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap1Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt

}

interrupt void ECap1_isr(void)
{

 speed();

ECap1Regs.ECCLR.bit.CEVT4 = 1;

ECap1Regs.ECCLR.bit.INT = 1;

ECap1Regs.ECCTL2.bit.REARM = 1;//持续捕捉外部信号

// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

void speed(void)
{
T1=ECap1Regs.CAP1;
T2=ECap1Regs.CAP2;
T3=ECap1Regs.CAP3;
T4=ECap1Regs.CAP4;
T=T1+T2+T3+T4;
n=3600000000.00/T;
if(n>=550&&n<=700)
{
LightLED1();
}
else
{
ShutLED1();
}
}

lin zhou:

自己顶贴,求教大神啊

我在使用F28030做BLDC速度控制,使用eCAP管脚获取一个霍尔管脚(三相)的信号。用示波器观测速度为600转Rpm左右(正负15转),可是使用eCAP测试结果差别很大,一会800,一会600,跳变严重。文件配置如下:

void InitECapture()
{

ECap1Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap1Regs.ECCTL2.bit.CONT_ONESHT =0; // One-shot
ECap1Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 4 events
ECap1Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap1Regs.ECCTL1.bit.CAP2POL = 0; // edge
ECap1Regs.ECCTL1.bit.CAP3POL = 1; // Falling edge
ECap1Regs.ECCTL1.bit.CAP4POL = 0; // edge

ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through

ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap1Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt

}

interrupt void ECap1_isr(void)
{

 speed();

ECap1Regs.ECCLR.bit.CEVT4 = 1;

ECap1Regs.ECCLR.bit.INT = 1;

ECap1Regs.ECCTL2.bit.REARM = 1;//持续捕捉外部信号

// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

void speed(void)
{
T1=ECap1Regs.CAP1;
T2=ECap1Regs.CAP2;
T3=ECap1Regs.CAP3;
T4=ECap1Regs.CAP4;
T=T1+T2+T3+T4;
n=3600000000.00/T;
if(n>=550&&n<=700)
{
LightLED1();
}
else
{
ShutLED1();
}
}

lin zhou:

回复 Young Hu:

嗯,使用DSP自身产生的PWM波做测试很准确,霍尔信号确实有跳变。用示波器看了下霍尔信号,方波形状正常,没变形,除了高电平时附有200mv左右的高频信号。我想知道eCAP模块对输入信号的敏感值是在一个什么样的范围?参考指南里好像没提到过啊。

我在使用F28030做BLDC速度控制,使用eCAP管脚获取一个霍尔管脚(三相)的信号。用示波器观测速度为600转Rpm左右(正负15转),可是使用eCAP测试结果差别很大,一会800,一会600,跳变严重。文件配置如下:

void InitECapture()
{

ECap1Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap1Regs.ECCTL2.bit.CONT_ONESHT =0; // One-shot
ECap1Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 4 events
ECap1Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap1Regs.ECCTL1.bit.CAP2POL = 0; // edge
ECap1Regs.ECCTL1.bit.CAP3POL = 1; // Falling edge
ECap1Regs.ECCTL1.bit.CAP4POL = 0; // edge

ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through

ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap1Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt

}

interrupt void ECap1_isr(void)
{

 speed();

ECap1Regs.ECCLR.bit.CEVT4 = 1;

ECap1Regs.ECCLR.bit.INT = 1;

ECap1Regs.ECCTL2.bit.REARM = 1;//持续捕捉外部信号

// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

void speed(void)
{
T1=ECap1Regs.CAP1;
T2=ECap1Regs.CAP2;
T3=ECap1Regs.CAP3;
T4=ECap1Regs.CAP4;
T=T1+T2+T3+T4;
n=3600000000.00/T;
if(n>=550&&n<=700)
{
LightLED1();
}
else
{
ShutLED1();
}
}

niao cai:

作为一个菜鸟,可能说的不对,但是觉得可能是 3600000000    或者 T1 T2 T3 T变量长度留得不够,换成Uint64 试试。

赞(0)
未经允许不得转载:TI中文支持网 » 使用eCAP进行BLDC霍尔测速,测速结果跳变很大
分享到: 更多 (0)