I have a servo motor .. DC motor with quadrature encoder .. connected to a servo controller. The controller gets fed a short pulse and applies enough power to the motor to move it one quadrature count. Give it a steady stream of pulses and the motor rotates as if it were a conventional motor.
I want to create these pulses using a microcontroller. (The end game is to control the speed using a potentiometer.)
I started with an Arduino Nano, but it couldn't generate pulses fast enough. So I moved to an ESP32 S2 because they're fast and because I have some.
It works .. kinda. What happens is that when I feed the pulses, the motor spins beautifully for almost exactly two seconds, then goes "thump" and continues to spin, then two seconds later, "thump" .. and so on.
Spin spin spin thump spin spin spin thump.
My GUESS is that the stream of pulses from the ESP32 are being interrupted by .. something inside the ESP32 .. and so the servo controller rightly tries to stop the motor. But the pulses resume almost immediately and so rotation continues, just with a thump in between.
The "thumps" are extremely regular. And they're independent of speed. No matter how fast or slow I feed the pulses, the thumps appears just about exactly 2 seconds apart.
Any idea what could be causing this?
Here's the test code .. pretty darn simple.
const byte stepPin = 13;
void setup()
{
pinMode(stepPin, OUTPUT);
digitalWrite(stepPin, LOW);
}
void loop()
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(5);
digitalWrite(stepPin, LOW);
delayMicroseconds(250);
}