2019-12-05 04:23 AM
Hi there this is Akash, I am doing a project on STM32F100RB Discovery Kit, in this project I am controlling stepper motor with some parameter given by the user using rotary encoder, basically I want to run the motor in the while loop, and through external interrupt I want to use rotary encoder. when I rotate the rotary encoder a display will show some parameters, and based on that display setting the motor will change the speed, the display and motor are working fine, the problem is with rotary encoder, when I rotate the encoder, there is slip(bouncing issue)in the encoder, to make the encoder bounce free, what is the best algorithm when using encoder in External interrupt mode
2019-12-05 03:16 PM
> what is the best algorithm when using encoder in External interrupt mode
The best is to NOT use external interrupt.
The best is to use the encoder mode of a timer which supports it, including the filters on ins inputs.
The best software option is to sample the encoder's input in a regular timer interrupt and decode in software.
JW
2019-12-05 11:40 PM
thanks @Community member for the feedback, if I use Encoder mode, how to use it as Interrupt, I am unable to get the Encoder mode in interrupt, can anyone help me out with this
2019-12-06 12:52 AM
You can enable capture on any of the two channels, and then interrupt on capture. But I wouldn't do that - simply read out the current value of TIMx_CNT periodically.
For periodic readout, you can also run a different timer out of the internal clock and perform the readout or whatever you want to do in that timer's update interrupt.
JW
2019-12-06 11:50 PM
thank you @Community member this was helpul for me, ill try to do it.