Hello, community!
I implemented the DRV8316 driver to test the open loop example with this motor: Amazon.com: DC 3.7V-11.1V 7.4V 4300KV Mini 1104 3-phase Brushless Motor Micro Outer Rotor BLDC for Quadcopter Fixed Wing : Toys & Games. The code is shared below, I am using the 6PWM example, but the motor starts to vibrate. I powered with 5V and 3V3 comming out from an arduino.
#include "Arduino.h"
#include <Wire.h>
#include <SimpleFOC.h>
#include <Math.h>
#include "drivers/drv8316/drv8316.h"
#define PWM13 13
#define PWM12 12
#define PWM11 11
#define PWM10 10
#define PWM09 9
#define PWM07 7
#define PWM06 6
BLDCMotor motor = BLDCMotor(11);
DRV8316Driver6PWM driver = DRV8316Driver6PWM(PWM13, PWM12,PWM11,PWM10,PWM09,PWM07,PWM06,false); // MKR1010 6-PWM
//DRV8316Driver3PWM driver = DRV8316Driver3PWM(2,1,0,11,false); // MKR1010 3-PWM
void printDRV8316Status() {
DRV8316Status status = driver.getStatus();
if (status.isFault())
driver.clearFault();
delayMicroseconds(1); // ensure 400ns delay
DRV8316_PWMMode val = driver.getPWMMode();
Serial.print("PWM Mode: ");
Serial.println(val);
delayMicroseconds(1); // ensure 400ns delay
bool lock = driver.isRegistersLocked();
Serial.print("Lock: ");
Serial.println(lock);
}
void setup() {
Serial.begin(115200);
while (!Serial);
delay(1);
Serial.println("Initializing...");
driver.voltage_power_supply = 5;
driver.init();
motor.linkDriver(&driver);
motor.controller = MotionControlType::velocity_openloop;
motor.voltage_limit = 3;
motor.velocity_limit = 20;
motor.init();
Serial.println("Init complete...");
delay(100);
printDRV8316Status();
}
// velocity set point variable
float target_velocity = 7.0;
void loop() {
//delay(100);
//driver.setPwm(7.4/4, 7.4/2, 7.4/4*3);
motor.move(target_velocity);
}