Hi, I’m starting my SimpleFOC journey with a stepper motor. I am using an
ESP32, an AS5048A encoder hooked up to standard SPI and a DRV8833 driver hooked up like this:
StepperDriver4PWM driver = StepperDriver4PWM(16,17,4,12);
I know that the DRV8833 creates a Z-Z output for IN1=L and IN2=L, but I got the impression that for steppers that should work ok.
Using the provided example code, the angle sensor works fine, also I can run the stepper motor in open loop. However, when I try to run in closed loop mode, the motor does NOT move for sensor alignment. I get this output:
MOT: Init
MOT: Enable driver.
MOT: Align sensor.
MOT: sensor_direction==CCW
MOT: PP check: fail - estimated pp: 26.05
MOT: No current sense.
MOT: Ready.
Motor ready.
Direction is arbitrary, sometimes CW, sometimes CCW, likewise does the pp value change.
Setting the same target_velocity (20) as in my open loop test, the motor makes a loud noise, and my lab power supply reaches any current limit I set (>1A). During open loop operation current was between 100mA and 300mA.
Is the PP check: fail an issue? It’s a standard NEMA 17 stepper with 50 pole pairs. Can my angle measurement be corrupted by the motor currents? A readout in the loop ever 100ms shows shows fluctuations of the angle only in the 1/100° (eg. 168.35…168.40°) Or this the driver the issue? Thanks for any suggestions!
Changed the driver to MX1508 (officially supported to my understanding) causes no change in behavior. The motor does not initialize in closed loop mode and does not run. In open loop mode it runs just fine, and the angle is correctly updated while the motor runs.
I’d very happy about any clues. That’s my first approach to SimpleFOC. Should I just move to BLDC motors, is the stepper not so much in focus or do I miss anything? Thanks!
I believe I found the solution. I’ve been trying to use a DRV8833 first and then an MX1508. Both don’t work for this reason:
Both drivers switch the outputs to high impedance when both inputs of the half bridges for one coil are L. The function void StepperDriver4PWM::setPwm(float Ualpha, float Ubeta) always keeps either of the two sides at L, while the other gets the PWM signal. This means that rather then short circuiting the coil in the passive phase of PWM it is interrupted. I assume the L298N does not behave like that.
The solution is simple, just use the high side of the half bridges for switching. So one side is always H, the other switches to L for the active part of PWM and H for the passive part. As both chips maintain HH outputs for HH inputs that works. I achieved this behavior with the following line.
Actually the define may not be needed, other drivers should work in that mode just as well… As both the DRV8833 and the MX1508 are inexpensive, small, faster and have less heat loss these driver would be interesting options. Also the documentation claims that the MX1508 is supported which, to my belief, is currently not the case.