Use FTM for both Quadrature Decoder and Input Capture

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use FTM for both Quadrature Decoder and Input Capture

Jump to solution
798 Views
aberger
Contributor V

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 Kudos
1 Solution
543 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

1 Reply
544 Views
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!
-----------------------------------------------------------------------------------------------------------------------