SimpleFOC Mini V1.0 - Not Working - Arduino UNO

Motor shows no signs of life. Driver doesn’t heat up.

I’ve tried running the motor in open loop mode just to see if the controller is working (script attached below). The motor is a 6000kv 6 pole motor, about 1.5 ohms resistance. Power supply is 12V 12A. I’ve tripled checked the wiring and measured all the enable/fault pins and all seems nominal.

#include <SimpleFOC.h>

// — PIN DEFINITIONS —

const int IN1_PIN = 11;

const int IN2_PIN = 10;

const int IN3_PIN = 9;

const int EN_PIN = 8;

// 1. Instantiate the motor with 6 POLE PAIRS (12 magnets / 2)

BLDCMotor motor = BLDCMotor(6);

// 2. Instantiate the driver

BLDCDriver3PWM driver = BLDCDriver3PWM(IN1_PIN, IN2_PIN, IN3_PIN, EN_PIN);

// Target velocity variable (in radians per second)

float target_velocity = 5.0;

// Instantiate the serial commander

Commander command = Commander(Serial);

void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }

void setup() {

// — PIN 12 LOGIC GROUND —

pinMode(12, OUTPUT);

digitalWrite(12, LOW);

// Setup serial communication

Serial.begin(115200);

// Power supply voltage set to 9V

driver.voltage_power_supply = 9.0;

// Initialize driver

driver.init();

// Link the driver to the motor

motor.linkDriver(&driver);

// — CURRENT LIMITING WITH KNOWN RESISTANCE —

// Now that we know the resistance, SimpleFOC can safely calculate the required voltage.

motor.phase_resistance = 1.5; // [Ohms]

// Set the current limit to 1.0 Amp

motor.current_limit = 1.0; // [Amps]

// Set motion control loop to be open loop velocity

motor.controller = MotionControlType::velocity_openloop;

// Initialize motor

motor.init();

// Add the target command to the commander

command.add(‘T’, doTarget, “target velocity”);

Serial.println(“Motor ready! Send ‘T10’ for 10 rad/s, ‘T0’ to stop.”);

_delay(1000);

}

void loop() {

// Move the motor at the target velocity

motor.move(target_velocity);

// Listen for serial commands

command.run();

}

2 Answers

2

Sorry, figured out the issue. It was a current limiting issue. The motor at 12V pulls too much on startup and instantly puts the driver into overcurrent protection. At 9V it’s working and with a different motor with 3.5Ohm it works at 12v.

Glad you got it figured out. Assuming you’re using the latest SimpleFOC, you need to set motor.torque_controller = TorqueControlType::estimated_current; for it to calculate current from resistance. Voltage mode used to change behavior depending on whether resistance was specified, which was always a little confusing. Now it’s confusing in a different way, needing to know which version of the library you’re using, but I think it’s better in the long run.