Hi all,
I’m new to electronics and PCB design, trying to remix the Mosquito board by @Valentine (Thank you Valentine btw for opening your designs :)).
Schematics : EasyEDA(Standard) - A Simple and Powerful Electronic Circuit Design Tool
PCB : EasyEDA(Standard) - A Simple and Powerful Electronic Circuit Design Tool
The board seems to work, tested able to spin open loop, using PlatformIO.
Video : https://youtu.be/srCh_Qw55Qw
Except that it exerts a weird high frequency noise while driving,
This is likely caused by bad PWM wave forms caused by linking issues ie.not setting lib_archive = false
(I’m still not sure of the details, but that seems to be the gist)
After setting lib_archive
to false however makes the motor not spin anymore. Looking at Serial debug getting:
00:53:36.546 -> MOT: Init not possible, driver not initialized
Now I’m a little bit stuck. Would anyone be able to illuminate further? (Code also attached below)
Thanks @runger / @VIPQualityPost / @Copper280z’s help already btw!! Really appreciate it.
Code here:
#include <Arduino.h>
#include <SimpleFOC.h>
#define serial1_tx_pin PA9
#define serial1_rx_pin PA10
#define PWM1 PB15
#define PWM2 PB14
#define PWM3 PB13
#define DRVENABLE PA8
#define DRVFAULT PB4
#define DRVRESET PB5
// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number, phase resistance (optional) );
HardwareTimer timer(TIM1);
BLDCMotor motor = BLDCMotor(11);
// BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
BLDCDriver3PWM driver = BLDCDriver3PWM(PWM1, PWM2, PWM3, DRVENABLE);
HardwareSerial Serial1(serial1_rx_pin, serial1_tx_pin);
const int ledPin = PA4;
int count = 0;
int dir = 1;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(DRVFAULT, INPUT);
pinMode(DRVRESET,OUTPUT);
digitalWrite(DRVRESET, HIGH);
timer.setPrescaleFactor(1);
timer.setOverflow(1);
SimpleFOCDebug::enable(&Serial1);
Serial1.begin(115200);
Serial1.println("Motor Ready");
_delay(500);
// driver config
// power supply voltage [V]
driver.voltage_power_supply = 12;
driver.pwm_frequency = 28100;
driver.init();
motor.linkDriver(&driver);
motor.motion_downsample = 2;
motor.phase_resistance = 16.52; // [Ohm]
motor.current_limit = 0.4; // [Amps] - if phase resistance defined
// open loop control config
motor.controller = MotionControlType::velocity_openloop;
//motor.initFOC();
motor.init();
_delay(1000);
}
void loop() {
motor.move(5);
digitalWrite(ledPin, dir);
}