AnsweredAssumed Answered

Encoder Trigger output at every transition

Question asked by Mate Rigo on Jun 3, 2013
Latest reply on Jun 4, 2013 by Mate Rigo
I have a timer configured to interface an encoder.
Basically what I want to do is to create a trigger event at every encoder pulse, which resets another free running timer's counter value to 0.

What I have now, is that I configured the encoder timer as master, the other timer as slave. TIM_TRGOSource_OC4Ref is set as output trigger. But now I obviously have to set the Capture/Compare 4 register of the encoder timer manually right after the capture happens.

The problem with this is, that at very fast encoder speed the CCR4 register has to be changed very often, resulting in a very high CPU usage.

What I've come up with is to set the Auto Reload Register of the encoder timer to 1, to be able to use the TIM_TRGOSource_Update for event generation. The obvious flaw of this method is, that I would loose the direction information of the encoder rotation.


If you are wondering why I would need to have a trigger at every encoder transition, then please see this paper: Speed Measurement Algorithms for Low-Resolution Incremental Encoder Equipped Drives: a Comparative Analysis Section III. MIXED MODE FREQUENCY/PERIOD MEASUREMENT

I also modified a picture from the paper for clarity on my method to implement the speed measurement: See here

If anyone has ideas, regarding the problem of the encoder transition triggering, or how to implement the mixed mode measurement, I am more than happy to hear them.

Outcomes