How to use Rotary Encoder effectively in external interrupt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-05 4: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
- Labels:
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-05 3: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-06 11:50 PM
thank you @Community member​ this was helpul for me, ill try to do it.
