Stepper Motor with DRV8833 - closed loop initialization fails

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!

Peter

There is a better and simpler solution. The driver supports active low pwm operation. To achieve that use the build flag in platformio:

-DSIMPLEFOC_PWM_ACTIVE_HIGH=false

This will achieve a HH signal to the driver for the passive pwm state which both DRV8833 and MX1508 convert to a LL output state.

(Thanks to @runger for pointing this solution out to me on Discord!)

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!

Peter

Hi,

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.

#ifdef DRV8833
_writeDutyCycle4PWM(1-duty_cycle1A, 1-duty_cycle1B, 1-duty_cycle2A, 1-duty_cycle2B, params);
#else
_writeDutyCycle4PWM(duty_cycle1A, duty_cycle1B, duty_cycle2A, duty_cycle2B, params);
#endif

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.

Peter