working on quadrature encoders of MPC5604P any sample code for capture and diection?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

working on quadrature encoders of MPC5604P any sample code for capture and diection?

跳至解决方案
2,023 次查看
vramalingam
Contributor II

Working on with quad encoders. used A[0] and A[1] pins. I kept ctrl register as 8001. still I counter is not counting.. I also want direction register to set.  any sample code or Application note will be helpful.

标签 (1)
1 解答
1,766 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

See attached example testing quadrature count mode of the eTimer module.

It sets some eTimer channels and FlexPWM to generate quadrature signals and another eTimer channel for a Quadrature count mode.

BR, Petr

在原帖中查看解决方案

3 回复数
1,766 次查看
vramalingam
Contributor II

Hi petr,

   Thanks for reply.. Now counter is running..

But how to find speed and direction. Now Encoder input is applied with train of pulses in A[0] and with 90deg offset with A[1]. With this how to find speed and direction. Actually now I can see counter running and it keeps reducing. Some calculation need to be done?

Regards

ram

0 项奖励
回复
1,766 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi Ram,

The speed measuring method depends on sensor signal (frequency range). The interrupt can be used, but it is not sufficient for high rates. You can also use the capture feature then read the period upon needs, etc. It is so application dependent I think.

 

There is no “flag” which say you if counter is counting up/down in Quadrature count mode. The easiest way how to get the direction is to take two counter samples and calculate the difference.

But you can also do it in HW way; set the output mode for the counter which asserts OFLAG when counting up and cleares when counting down. You can use this output as secondary input for other channel within module. If this channel will be stopped, then the CTRL2[INPUT] bit will reflect that direction. If this channel will be started you can also detect the OFLAG edge and generate interrupt on direction change.

BR, Petr

1,767 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

See attached example testing quadrature count mode of the eTimer module.

It sets some eTimer channels and FlexPWM to generate quadrature signals and another eTimer channel for a Quadrature count mode.

BR, Petr