XIAO ESP32C2 ~5 ms pause/freeze every 2 seconds

Hmmm, been trying to get FastAccelStepper to work with my C6 and struggling. I tried this trivial example and the behavior is decidedly odd:

#include "FastAccelStepper.h"
#include "pins_arduino.h"
#include "fas_arch/common_esp32.h"
#include "fas_arch/common_esp32_idf5.h"

#define dirPinStepper    D0
#define stepPinStepper   D1

FastAccelStepperEngine engine = FastAccelStepperEngine();
FastAccelStepper *stepper = NULL;

void setup() {
   engine.init();
   stepper = engine.stepperConnectToPin(stepPinStepper);
   if (stepper) {
      stepper->setDirectionPin(dirPinStepper);
      stepper->setAutoEnable(true);

      stepper->setSpeedInHz(500);       // 500 steps/s
      stepper->setAcceleration(100);    // 100 steps/s²
      stepper->move(1000);
   }
}

void loop() {}

The motor starts very slowly, almost immediately chatters forward and backward for maybe a couple hundred ms, then accelerates to a moderate speed, then stops entirely for maybe a hundred ms, then restarts at the previous speed and decelerates at the same rate as the acceleration. “OK, that’s just because it’s going for only 1000 steps,” I thought, so I increased the move from 1000 to 9999 and tried again. The motor just ramped to the same speed as before, then sat there still for a longer period (I didn’t time it, but I’m quite sure it was the time needed to get up to 4999 and then back down), and then restarted and decelerated as before. Like I said, very odd.

I tried specifying the use of the DRIVER_RMT,
stepperMain = engine.stepperConnectToPin(stepPinStepper, DRIVER_RMT); but that fails during compilation with a “‘DRIVER_RMT’ was not declared in this scope” error.

Wheels are spinning in sand, but my motor isn’t spinning as intended. :confused:

Ideas welcome, drinking optional.

1 Like