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?

ソリューションへジャンプ
1,907件の閲覧回数
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,650件の閲覧回数
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,650件の閲覧回数
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,650件の閲覧回数
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,651件の閲覧回数
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