Quadrature encoder Kinetis k64

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

Quadrature encoder Kinetis k64

1,679 Views
Edrianocarlos
Contributor IV

Hello,

I would like to ask to you guys.

if i have to deal with counters higher than the 65535 from the 16 BITS counter.

how do you normally deal with that? use the overflow interrupt? 

what other way can i deal with that without loosing counts?

thank you.

Labels (1)
0 Kudos
4 Replies

1,350 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

The overflow interrupt should be used to deal with it.
TOFDIR indicates the counting was up when the FTM counter overflow occurred.

FTM Counter overflow in up counting for Quadrature Decoder mode.png

FTM counter overflow in down counting for Quadrature Decoder mode.png

Best Regards,

Robin

 

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

1,350 Views
Edrianocarlos
Contributor IV

Thanks for your answer.

Yes that is one way i thought how to implement.

My only concern is that lets suppose an overflow happen while i am reading the counter and updating the variable.

as i have a bigger variable i would need to increment it somewhere inside or outside the interrupt handle. 

my encoder can generate 1MHz frequency 4 edges.

it is really hard to simulate it and trying to realize if this can even happen.

0 Kudos

1,350 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

The KV4x and KV5x contain Quadrature Encoder/Decoder (ENC) module which support 32-bit position counter.

You can check if these MCU meet your needs.

Quadrature Encoder Decoder (ENC).png

Best Regards,

Robin

 

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

0 Kudos

1,350 Views
Edrianocarlos
Contributor IV

Thank you Robin.

I was able to make this one work.

running the core at 100 Mhz reading the counter and inc or dec one variable.

0 Kudos