Description
Describe the bug
The motor skips approx every 2 seconds, in open loop as well as closed loop.
Describe the hardware setup
-
Which motor - 1.8 degreee stepper
-
Which driver - Custom 4PWM driver
-
Which microcontroller - ESP32S2
-
Which position sensor - Irrelevant
-
Current sensing used? - NO
-
Arduino IDE
While I am submitting a bug report, I already have a solution, so please forgive me if this is in the wrong place. There may be better solutions out there.
I investigated everything (Including a lot of time looking at the total angle stored as float precision issue) until it hit me-
this code has the glitch- (paraphrasing for clarity)
**void setup()
{
do_setup();
}
void loop()
{
motor.loopFOC();
motor.move();
motor.monitor();
command.run();
}**
This one fixes it:
**void setup()
{
do_setup();
while(1)
{
loop();
};
}
void loop()
{
motor.loopFOC();
motor.move();
motor.monitor();
command.run();
}**
Effectively equivalent to placing the contents of the loop function in the while loop. Therefore, the loop function never runs as a task in FreeRTOS. Otherwise there is apparently some delay between loops from time to time.
This issue is explored here:
https://www.reddit.com/r/esp32/comments/t9aqr6/what_on_earth_is_my_esp32_doing_between_loops/
It may be specific to the ESP32S2, and there may be other repercussions to my workaround.
EDIT: To be clear, this is an issue with the Arduino IDE, and not SimpleFOC