• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Interrupt usage with rotary encoders (not the $.50 push button type)

Q&A Forum › Category: Questions › Interrupt usage with rotary encoders (not the $.50 push button type)
0 Vote Up Vote Down
tony mollica asked 1 day ago

I’ve posted similar questions in the lvgl forum but I would surely like to see this implemented in a future update of the Learn LVGL book, with examples.  I’m working on implementing the recommendations I received elsewhere but I would like to see it here, too.  The issue is reading the data from an incremental rotary encoder and the best method for doing so.  I have the encoder being read in an interrupt routine, and it works, but I understand it’s not recommended for lvgl due to the possibility of catastrophically corrupting the lvgl program flow with the interrupt.  The encoder movement is relatively slow being mounted on the shaft of an arbor press measuring tics and converted to inches for measurement.  I’m not seeing a way to fetch the encoder data without losing any tics other than an interrupt routine. My particular encoder produces 2048 tics per 360 degrees of revolution.  I have NOT read through the lvgl interrupt functions and there may be something in there that might help.  Suggestions or insight?

Question Tags: interrupt routines or callbacks
3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 23 hours ago

Hi Tony.
Unfortunately, rotary encoders is a subject I’m not very familiar with.
I still don’t have any tutorials for rotary encoders in our blog.
 
I think you’ll need to use the rotary encoder as an LVGL input device: https://docs.lvgl.io/9.1/porting/indev.html
Regards,
Sara
 
 

0 Vote Up Vote Down
tony mollica answered 21 hours ago

I looked that over.  The problem is that the input device status or the request for it’s data is said to be ‘called periodically’, which isn’t gonna work.  I need to capture every tic from the encoder in order to measure distance accurately.  A missed tic from the encoder means lost accuracy.  I need to write a small sketch to measure the time between tics at the fastest rate or as fast as I can move the handle on the arbor press.  Depending on that speed then maybe a call to read the encoder at two or three times that speed might capture every tic.

0 Vote Up Vote Down
Sara Santos Staff answered 2 hours ago

Yes, that seems like a good workaround to detect all the tics.
You should try it out and see if it’s suitable for your application.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn LVGL: Build GUIs for ESP32 Projects – Version 1.5 July 7, 2025
  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.