Testing Stepper motor (4-PWM) with MX1508 driver

Continuing the discussion from Community's list of tested off-the-shelf drivers:

Hello everyone, I’ve been testing the MX1508 with a NEMA 11/17 ( 200 steps/rev). I wanted to use it in closed loop mode with the AS5600 encoder. SimpleFOC library has made my project really easy.

Firstly I tested the find_pole_pairs_number. All I had to do was increase the pp_search_voltage and change the sensor to as5600, Here’s the edited code. The pole pair estimation works great.

Estimated PP : 50
PP = Electrical angle / Encoder angle 
2160.00/43.33 = 49.85

Open loop example codes work very well with voltage adjusted for the NEMA steppers (around 6V).
So I then moved on to the Closed loop control since I’m obsessed with the silent and efficient FOC control. Initially the sensor alignment failed due to a lower voltage_sensor_align and that was solved

Now the motor is working well, the motor goes to the set target angle. The sensor data is also consistent with this output. However when I try to manually disturb the motor angle, the motor tries to resist but beyond a certain degree, it starts spinning. Initially I thought this was an issue with the AS5600 encoder. But the encoder is working fine when I checked it with motor.monitor() function.

 * Position/angle motion control example
 * Steps:
 * 1) Configure the motor and magnetic sensor
 * 2) Run the code
 * 3) Set the target angle (in radians) from serial terminal
#include <SimpleFOC.h>

// magnetic sensor instance - SPI
//MagneticSensorSPI sensor = MagneticSensorSPI(AS5147_SPI, 10);
// magnetic sensor instance - MagneticSensorI2C
MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);
// magnetic sensor instance - analog output
// MagneticSensorAnalog sensor = MagneticSensorAnalog(A1, 14, 1020);

// BLDC motor & driver instance
//BLDCMotor motor = BLDCMotor(11);
//BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);
// Stepper motor & driver instance
StepperMotor motor = StepperMotor(50);
StepperDriver4PWM driver = StepperDriver4PWM(16,17,26,27);

// angle set point variable
float target_angle = 0;
// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }

void setup() {

  // initialise magnetic sensor hardware
  // link the motor to the sensor

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  // link the motor and the driver

  // choose FOC modulation (optional)
  motor.foc_modulation = FOCModulationType::SinePWM;

  // set motion control loop to be used
  motor.controller = MotionControlType::angle;

  // contoller configuration
  // default parameters in defaults.h

  // velocity PI controller parameters
  motor.PID_velocity.P = 0.2f;
  motor.PID_velocity.I = 20;
  motor.PID_velocity.D = 0;
  // maximal voltage to be set to the motor
  motor.voltage_limit = 8;

  // velocity low pass filtering time constant
  // the lower the less filtered
  motor.LPF_velocity.Tf = 0.01f;

  // angle P controller
  motor.P_angle.P = 20;
  // maximal velocity of the position control
  motor.velocity_limit = 20;

  // use monitoring with serial
  // comment out if not needed

  // initialize motor
  // align sensor and start FOC
  motor.voltage_sensor_align = 6;

  // add target command T
  command.add('T', doTarget, "target angle");

  Serial.println(F("Motor ready."));
  Serial.println(F("Set the target angle using serial terminal:"));

void loop() {

  // main FOC algorithm function
  // the faster you run this function the better
  // Arduino UNO loop  ~1kHz
  // Bluepill loop ~10kHz

  // Motion control function
  // velocity, position or voltage (defined in motor.controller)
  // this function can be run at much lower frequency than loopFOC() function
  // You can also use motor.move() and set the motor.target in the code

  // function intended to be used with serial plotter to monitor motor variables
  // significantly slowing the execution down!!!!

  // user communication

I’m trying to get similar results like this https://www.youtube.com/watch?v=zcb86TRxTxc
The demo shown in the video uses AMT103 encoder and L298 driver
Since there is no issue with the AS5600 encoder, I suppose the MX1508 might be causing problems.
I also tested the code with Arduino Nano, but the results are the same

Looking into the datasheets, This is the major difference I could see
(datasheet)The L298 has enable pins which allows coasting mode only when the driver is disabled
(datasheet)Since the MX1508 has no enable, It allows coasting when both input pins are LOW
I’m happy that using MX1508 for SimpleFOC is possible. Even though it didn’t work properly, it ran much cooler
I’m stuck here for now. Not sure what’s causing this issue. Can you guys suggest some possible solutions

I have a raspberry pi zero 2 WH connected to an MX1508 in an attempt to control a Nema 17. I’ve tried various sequences but cant get the Nema to rotate, any ideas ? python code ?