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

M/T测速问题,机器实测测得速度波动较大,开发板上面测试的稳定度很好,不知道啥问题,求助

下面是实际测量波形

下面是我用M法测得波形,比我用m/t的波形好多了;

附:我做m/t的程序代码,哪位大神指导下,

void eQEP_pos_speed_get_Init(EQEP_POS_SPEED_GET *p)

{

 Uint32 QUPRD;

  EALLOW;

#if (CPU_FRQ_150MHZ)

  QUPRD=(Uint32)150000000>>9;    // Unit Timer for speed_intfre at 150 MHz

#endif

EQep1Regs.QUPRD=QUPRD;

EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

EQep1Regs.QEPCTL.bit.FREE_SOFT=2;

EQep1Regs.QEPCTL.bit.PCRM=1;        // PCRM=3 mode – QPOSCNT reset on unit time

EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout enable

EQep1Regs.QEPCTL.bit.QCLM=1;        // time out锁存计数值

EQep1Regs.QPOSINIT=0;

EQep1Regs.QPOSCNT=EQep1Regs.QPOSINIT;

EQep1Regs.QPOSMAX=0xffffffff;

EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

 

//设置eQEP Edge Capture功能

EQep1Regs.QCAPCTL.bit.CCPS = 4;     //设定CAPCLK时钟为SYSCLK的16分频=4.6875M

EQep1Regs.QCAPCTL.bit.UPPS = 1;     //11: 设定UPEVNT事件为QCLK的1分频

EQep1Regs.QCAPCTL.bit.CEN  = 1;      //1:QEP CAP enable

EDIS;

}

void posspeed_calc(POSSPEED *p)

{

long m1,m2,fc;

if(EQep1Regs.QEPSTS.bit.UPEVNT==0)

return;

if(EQep1Regs.QEPSTS.bit.COEF==0)            // No Capture overflow

m2=(unsigned long)EQep1Regs.QCPRDLAT;

else             

m2=0xFFFF+(unsigned long)EQep1Regs.QCPRDLAT;

 

//采用MT法进行测速

//speedhz_raw_h=m1*fc/(m2*enc_rev)*pole_pairs

m1=LSign(p->cnt_delta)*2;//LSign取正传反转符号

fc=CPU_FRQ>>4;//系统时钟分频

p->SpeedHz_raw_h=IQdiv(m1*fc, m2*(p->enc_rev), MOTOR_FRQ_Q);

p->SpeedHz_raw_h=IQmpy(p->SpeedHz_raw_h,p->pole_pairs,0);

EQep1Regs.QEPSTS.all=0x88;

return;

}

Seven Han:

那测试环境都是相同的吗?两者的硬件电路是否一样呢,可以多查看下硬件这块。

下面是实际测量波形

下面是我用M法测得波形,比我用m/t的波形好多了;

附:我做m/t的程序代码,哪位大神指导下,

void eQEP_pos_speed_get_Init(EQEP_POS_SPEED_GET *p)

{

 Uint32 QUPRD;

  EALLOW;

#if (CPU_FRQ_150MHZ)

  QUPRD=(Uint32)150000000>>9;    // Unit Timer for speed_intfre at 150 MHz

#endif

EQep1Regs.QUPRD=QUPRD;

EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

EQep1Regs.QEPCTL.bit.FREE_SOFT=2;

EQep1Regs.QEPCTL.bit.PCRM=1;        // PCRM=3 mode – QPOSCNT reset on unit time

EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout enable

EQep1Regs.QEPCTL.bit.QCLM=1;        // time out锁存计数值

EQep1Regs.QPOSINIT=0;

EQep1Regs.QPOSCNT=EQep1Regs.QPOSINIT;

EQep1Regs.QPOSMAX=0xffffffff;

EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

 

//设置eQEP Edge Capture功能

EQep1Regs.QCAPCTL.bit.CCPS = 4;     //设定CAPCLK时钟为SYSCLK的16分频=4.6875M

EQep1Regs.QCAPCTL.bit.UPPS = 1;     //11: 设定UPEVNT事件为QCLK的1分频

EQep1Regs.QCAPCTL.bit.CEN  = 1;      //1:QEP CAP enable

EDIS;

}

void posspeed_calc(POSSPEED *p)

{

long m1,m2,fc;

if(EQep1Regs.QEPSTS.bit.UPEVNT==0)

return;

if(EQep1Regs.QEPSTS.bit.COEF==0)            // No Capture overflow

m2=(unsigned long)EQep1Regs.QCPRDLAT;

else             

m2=0xFFFF+(unsigned long)EQep1Regs.QCPRDLAT;

 

//采用MT法进行测速

//speedhz_raw_h=m1*fc/(m2*enc_rev)*pole_pairs

m1=LSign(p->cnt_delta)*2;//LSign取正传反转符号

fc=CPU_FRQ>>4;//系统时钟分频

p->SpeedHz_raw_h=IQdiv(m1*fc, m2*(p->enc_rev), MOTOR_FRQ_Q);

p->SpeedHz_raw_h=IQmpy(p->SpeedHz_raw_h,p->pole_pairs,0);

EQep1Regs.QEPSTS.all=0x88;

return;

}

hao guo2:

回复 Seven Han:

这两个波形的硬件是一样的,io配置一样,qep模块配置不一样对应算法不一样! 结果波动大!硬件用m法测过没问题!

下面是实际测量波形

下面是我用M法测得波形,比我用m/t的波形好多了;

附:我做m/t的程序代码,哪位大神指导下,

void eQEP_pos_speed_get_Init(EQEP_POS_SPEED_GET *p)

{

 Uint32 QUPRD;

  EALLOW;

#if (CPU_FRQ_150MHZ)

  QUPRD=(Uint32)150000000>>9;    // Unit Timer for speed_intfre at 150 MHz

#endif

EQep1Regs.QUPRD=QUPRD;

EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

EQep1Regs.QEPCTL.bit.FREE_SOFT=2;

EQep1Regs.QEPCTL.bit.PCRM=1;        // PCRM=3 mode – QPOSCNT reset on unit time

EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout enable

EQep1Regs.QEPCTL.bit.QCLM=1;        // time out锁存计数值

EQep1Regs.QPOSINIT=0;

EQep1Regs.QPOSCNT=EQep1Regs.QPOSINIT;

EQep1Regs.QPOSMAX=0xffffffff;

EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

 

//设置eQEP Edge Capture功能

EQep1Regs.QCAPCTL.bit.CCPS = 4;     //设定CAPCLK时钟为SYSCLK的16分频=4.6875M

EQep1Regs.QCAPCTL.bit.UPPS = 1;     //11: 设定UPEVNT事件为QCLK的1分频

EQep1Regs.QCAPCTL.bit.CEN  = 1;      //1:QEP CAP enable

EDIS;

}

void posspeed_calc(POSSPEED *p)

{

long m1,m2,fc;

if(EQep1Regs.QEPSTS.bit.UPEVNT==0)

return;

if(EQep1Regs.QEPSTS.bit.COEF==0)            // No Capture overflow

m2=(unsigned long)EQep1Regs.QCPRDLAT;

else             

m2=0xFFFF+(unsigned long)EQep1Regs.QCPRDLAT;

 

//采用MT法进行测速

//speedhz_raw_h=m1*fc/(m2*enc_rev)*pole_pairs

m1=LSign(p->cnt_delta)*2;//LSign取正传反转符号

fc=CPU_FRQ>>4;//系统时钟分频

p->SpeedHz_raw_h=IQdiv(m1*fc, m2*(p->enc_rev), MOTOR_FRQ_Q);

p->SpeedHz_raw_h=IQmpy(p->SpeedHz_raw_h,p->pole_pairs,0);

EQep1Regs.QEPSTS.all=0x88;

return;

}

Seven Han:

回复 hao guo2:

请问开发板是TI的吗?不确定相同的硬件抗干扰是否有差异。

下面是实际测量波形

下面是我用M法测得波形,比我用m/t的波形好多了;

附:我做m/t的程序代码,哪位大神指导下,

void eQEP_pos_speed_get_Init(EQEP_POS_SPEED_GET *p)

{

 Uint32 QUPRD;

  EALLOW;

#if (CPU_FRQ_150MHZ)

  QUPRD=(Uint32)150000000>>9;    // Unit Timer for speed_intfre at 150 MHz

#endif

EQep1Regs.QUPRD=QUPRD;

EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

EQep1Regs.QEPCTL.bit.FREE_SOFT=2;

EQep1Regs.QEPCTL.bit.PCRM=1;        // PCRM=3 mode – QPOSCNT reset on unit time

EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout enable

EQep1Regs.QEPCTL.bit.QCLM=1;        // time out锁存计数值

EQep1Regs.QPOSINIT=0;

EQep1Regs.QPOSCNT=EQep1Regs.QPOSINIT;

EQep1Regs.QPOSMAX=0xffffffff;

EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

 

//设置eQEP Edge Capture功能

EQep1Regs.QCAPCTL.bit.CCPS = 4;     //设定CAPCLK时钟为SYSCLK的16分频=4.6875M

EQep1Regs.QCAPCTL.bit.UPPS = 1;     //11: 设定UPEVNT事件为QCLK的1分频

EQep1Regs.QCAPCTL.bit.CEN  = 1;      //1:QEP CAP enable

EDIS;

}

void posspeed_calc(POSSPEED *p)

{

long m1,m2,fc;

if(EQep1Regs.QEPSTS.bit.UPEVNT==0)

return;

if(EQep1Regs.QEPSTS.bit.COEF==0)            // No Capture overflow

m2=(unsigned long)EQep1Regs.QCPRDLAT;

else             

m2=0xFFFF+(unsigned long)EQep1Regs.QCPRDLAT;

 

//采用MT法进行测速

//speedhz_raw_h=m1*fc/(m2*enc_rev)*pole_pairs

m1=LSign(p->cnt_delta)*2;//LSign取正传反转符号

fc=CPU_FRQ>>4;//系统时钟分频

p->SpeedHz_raw_h=IQdiv(m1*fc, m2*(p->enc_rev), MOTOR_FRQ_Q);

p->SpeedHz_raw_h=IQmpy(p->SpeedHz_raw_h,p->pole_pairs,0);

EQep1Regs.QEPSTS.all=0x88;

return;

}

hao guo2:

回复 Seven Han:

开发板是南京研旭的板子,在这上面测试的程序数据稳定度还可以,把程序放到电机控制器上效果不理想。但是在电机控制器上用M法测试的效果还不错。

下面是实际测量波形

下面是我用M法测得波形,比我用m/t的波形好多了;

附:我做m/t的程序代码,哪位大神指导下,

void eQEP_pos_speed_get_Init(EQEP_POS_SPEED_GET *p)

{

 Uint32 QUPRD;

  EALLOW;

#if (CPU_FRQ_150MHZ)

  QUPRD=(Uint32)150000000>>9;    // Unit Timer for speed_intfre at 150 MHz

#endif

EQep1Regs.QUPRD=QUPRD;

EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

EQep1Regs.QEPCTL.bit.FREE_SOFT=2;

EQep1Regs.QEPCTL.bit.PCRM=1;        // PCRM=3 mode – QPOSCNT reset on unit time

EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout enable

EQep1Regs.QEPCTL.bit.QCLM=1;        // time out锁存计数值

EQep1Regs.QPOSINIT=0;

EQep1Regs.QPOSCNT=EQep1Regs.QPOSINIT;

EQep1Regs.QPOSMAX=0xffffffff;

EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

 

//设置eQEP Edge Capture功能

EQep1Regs.QCAPCTL.bit.CCPS = 4;     //设定CAPCLK时钟为SYSCLK的16分频=4.6875M

EQep1Regs.QCAPCTL.bit.UPPS = 1;     //11: 设定UPEVNT事件为QCLK的1分频

EQep1Regs.QCAPCTL.bit.CEN  = 1;      //1:QEP CAP enable

EDIS;

}

void posspeed_calc(POSSPEED *p)

{

long m1,m2,fc;

if(EQep1Regs.QEPSTS.bit.UPEVNT==0)

return;

if(EQep1Regs.QEPSTS.bit.COEF==0)            // No Capture overflow

m2=(unsigned long)EQep1Regs.QCPRDLAT;

else             

m2=0xFFFF+(unsigned long)EQep1Regs.QCPRDLAT;

 

//采用MT法进行测速

//speedhz_raw_h=m1*fc/(m2*enc_rev)*pole_pairs

m1=LSign(p->cnt_delta)*2;//LSign取正传反转符号

fc=CPU_FRQ>>4;//系统时钟分频

p->SpeedHz_raw_h=IQdiv(m1*fc, m2*(p->enc_rev), MOTOR_FRQ_Q);

p->SpeedHz_raw_h=IQmpy(p->SpeedHz_raw_h,p->pole_pairs,0);

EQep1Regs.QEPSTS.all=0x88;

return;

}

mangui zhang:

回复 hao guo2:

反馈的波形应该与测速的方法没关系啊 

下面是实际测量波形

下面是我用M法测得波形,比我用m/t的波形好多了;

附:我做m/t的程序代码,哪位大神指导下,

void eQEP_pos_speed_get_Init(EQEP_POS_SPEED_GET *p)

{

 Uint32 QUPRD;

  EALLOW;

#if (CPU_FRQ_150MHZ)

  QUPRD=(Uint32)150000000>>9;    // Unit Timer for speed_intfre at 150 MHz

#endif

EQep1Regs.QUPRD=QUPRD;

EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

EQep1Regs.QEPCTL.bit.FREE_SOFT=2;

EQep1Regs.QEPCTL.bit.PCRM=1;        // PCRM=3 mode – QPOSCNT reset on unit time

EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout enable

EQep1Regs.QEPCTL.bit.QCLM=1;        // time out锁存计数值

EQep1Regs.QPOSINIT=0;

EQep1Regs.QPOSCNT=EQep1Regs.QPOSINIT;

EQep1Regs.QPOSMAX=0xffffffff;

EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

 

//设置eQEP Edge Capture功能

EQep1Regs.QCAPCTL.bit.CCPS = 4;     //设定CAPCLK时钟为SYSCLK的16分频=4.6875M

EQep1Regs.QCAPCTL.bit.UPPS = 1;     //11: 设定UPEVNT事件为QCLK的1分频

EQep1Regs.QCAPCTL.bit.CEN  = 1;      //1:QEP CAP enable

EDIS;

}

void posspeed_calc(POSSPEED *p)

{

long m1,m2,fc;

if(EQep1Regs.QEPSTS.bit.UPEVNT==0)

return;

if(EQep1Regs.QEPSTS.bit.COEF==0)            // No Capture overflow

m2=(unsigned long)EQep1Regs.QCPRDLAT;

else             

m2=0xFFFF+(unsigned long)EQep1Regs.QCPRDLAT;

 

//采用MT法进行测速

//speedhz_raw_h=m1*fc/(m2*enc_rev)*pole_pairs

m1=LSign(p->cnt_delta)*2;//LSign取正传反转符号

fc=CPU_FRQ>>4;//系统时钟分频

p->SpeedHz_raw_h=IQdiv(m1*fc, m2*(p->enc_rev), MOTOR_FRQ_Q);

p->SpeedHz_raw_h=IQmpy(p->SpeedHz_raw_h,p->pole_pairs,0);

EQep1Regs.QEPSTS.all=0x88;

return;

}

hao guo2:

回复 mangui zhang:

反馈的波形就是我实测的波形呀,我查阅资料,我的算法应该是对的。您帮我看看我的算法可有问题,谢谢

赞(0)
未经允许不得转载:TI中文支持网 » M/T测速问题,机器实测测得速度波动较大,开发板上面测试的稳定度很好,不知道啥问题,求助
分享到: 更多 (0)