DRV8711 Stepper driver troubleshooting

Hi guys.

I’m trying to get a DRV8711 stepper motor driver working with SimpleFOC.

Now the thing with this driver is that it is configured via SPI and must be configured each time it starts up. I’m using two microcontrollers in this project, a Raspberry pi pico to run SimpleFOC and another pi pico to configure the motor driver. The sensor I’m using is a AS5147 running in encoder mode.

It all seems to be working, the signals from the encoder look good, the FOC core reads them and sends PWM signals in the 4-PWM stepper control configuration. But the driver is not driving the stepper motor.

I have tested the driver, in it’s step-direction mode it is working fine. But when I set it to direct PWM input mode I can’t get it to work. I enable to motor just like I do with the step-direction mode and set the PWM mode in the OFF register but I get nothing.

Here is the code for the pico running SimpleFOC,

#include <SimpleFOC.h>

// Stepper motor instance
StepperMotor motor = StepperMotor(50);
// Stepper driver instance
StepperDriver4PWM driver = StepperDriver4PWM(21, 20, 19, 18,17,16);

// encoder instance
Encoder encoder = Encoder(27, 26, 4096);
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}



// commander interface
Commander command = Commander(Serial);
void onMotor(char* cmd){ command.motor(&motor, cmd); }

void setup() {
 
  Serial.begin(115200);
  Serial.println("test");
  // initialize encoder sensor hardware
  encoder.init();
  encoder.enableInterrupts(doA, doB); 
  // link the motor to the sensor
  motor.linkSensor(&encoder);

  driver.pwm_frequency = 20000;
  // choose FOC modulation
  motor.foc_modulation = FOCModulationType::SinePWM;

  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  driver.init();
  // link the motor to the sensor
  motor.linkDriver(&driver);

  // set control loop type to be used
  motor.controller = MotionControlType::torque;

  // controller configuration based on the control type 
  motor.PID_velocity.P = 0.2;
  motor.PID_velocity.I = 20;
  motor.PID_velocity.D = 0;
  // default voltage_power_supply
  motor.voltage_limit = 12;

  // velocity low pass filtering time constant
  motor.LPF_velocity.Tf = 0.01;

  // angle loop controller
  motor.P_angle.P = 20;
  // angle loop velocity limit
  motor.velocity_limit = 50;

  // use monitoring with serial for motor init
  // monitoring port
 

  //SimpleFOCDebug::enable(&Serial);

  // comment out if not needed
  //motor.useMonitoring(Serial);

  // initialise motor
  motor.init();
  // align encoder and start FOC
  motor.initFOC();

  // set the initial target value
  motor.target = 2;

  // define the motor id
  command.add('M', onMotor, "motor");

 //_delay(1000);
  Serial.println("Motor ready.");
  // Run user commands to configure and the motor (find the full command list in docs.simplefoc.com)
  Serial.println(F("Motor commands sketch | Initial motion control > torque/voltage : target 2V."));
  
  _delay(1000);
}


void loop() {
  // iterative setting FOC phase voltage
  motor.loopFOC();

  // iterative function setting the outter loop target
  // velocity, position or voltage
  // if tatget not set in parameter uses motor.target variable
  motor.move();

  // user communication
  command.run();
}

I am really not sure what to do next. Surely even if the SimpleFOC code wasn’t working properly there would be some sort of response from the motor since there are PWM signals being sent. This seems like a problem on the driver side. But so far, it is enabled, works in step/direction mode and I’m pretty sure I’m enabling the correct register bits.

Any ideas?

Try adding a delay at the start to be sure the other pico has time to boot up and configure the driver before this one does anything.

I should have said that I’m using the terminal in Thonny to send the information from the controller pico. I wrote a little function were I can input the required bytes and it will output them on the picos SPI. I don’t think I’m putting it in the direct PWM mode despite sending the information to the right register. There must be something I’m missing. I might have to take this to TI’s forum.