Use FTM for both Quadrature Decoder and Input Capture

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

Use FTM for both Quadrature Decoder and Input Capture

跳至解决方案
1,530 次查看
aberger
Senior Contributor I

I am using an FTM module on the K64F as a quadrature decoder to keep track of the position of an optical rotary encoder. I would also like to time-tag the edges of of the A/B quad channels using FTM Input Capture, so that I can more precisely calculate rotation speed. Is this possible with a single FTM module, or will I need to physically connect the quadrature signals to two separate physical pins, each one monitored by a separate FTM module? The first module would continue to act as the Quad Encoder (say FTM2), while the second module (say FTM3) would act as a free-running timer responsible for the periodic interrupt, and the input capture.

For example, say I am measuring angular speed by running a periodic interrupt (with period dt, in seconds) in which I execute the code:

current = FTM_GetQuadDecoderCounterValue(FTM2);
omega = (revCount + (current - previous))/(PPR*dt); // in revolutions per second
previous = current;

(where PPR is the number of pulses per revolution that the encoder provides, and revCount is incremented anytime that overflows). The above calculation assumes time dt between the current and previous edges, which need not be exactly true. That is, it neglects the time that has passed between the quad decoder increment (i.e. edge received), and the FTM_GetQuadDecoderCounterValue(FTM2) function call that happens in the above ISR. So what I really need is something like:

omega = (revCount + (current - previous))/(PPR*(t_current - t_previous));

where t_current and t_previous are recorded using input capture of the quad channel pulses on FTM3. 

0 项奖励
回复
1 解答
1,275 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Andy Berger,

The Quadrature Decoder mode has precedence over the other modes.
So you need to physically connect the quadrature signals to two separate physical pins, each one monitored by a separate FTM module.FTMx_QDCTRL[QUADEN].png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

1 回复
1,276 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Andy Berger,

The Quadrature Decoder mode has precedence over the other modes.
So you need to physically connect the quadrature signals to two separate physical pins, each one monitored by a separate FTM module.FTMx_QDCTRL[QUADEN].png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------