Haptic Feedback and LVGL

I am building a haptic knob style device and have been using some of the code in this thread to do detents and endstops using a SparkFun Brushless Motor Driver and an As5600 sensor. When I run my simpleFOC code on its own it runs great. However, I want to run it with a lvgl gui that I made using Squareline studio. When I enable the Lvgl_Loop function, my haptic feedback feels all wrong. The detents get mushy and I can feel the motor jumping between poles. Any thoughts on what might be wrong? I’m using the sensor in I2C and wondering if maybe there’s some interference from the lvgl components.

Hi @Jason_Greenberg , welcome to SimpleFOC!

This is a little bit tricky to get right.

I would recommend very strongly to use a dual core MCU - then you can dedicate one core to motor control, haptics and sensor, and use the other for communications, graphics and everything else. That should solve most of your problems, though it can take some work to make sure everything runs where it’s supposed to, interrupts get processed in the right core, etc

I’d also recommend using an SPI sensor rather than I2C, as I2C is really too slow and will limit your performance…

Which MCU are you using?

I’m using a waveshare ESP32-S3 1.85inch Round LCD Development Board.
I’ll have to look into how to run tasks on separate cores. Thanks for the suggestion.

Running the FOC loop on a second core worked great! Thanks again for the suggestion.