You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello i want to control a bldc 3 phase sensored Motor and i have a esp32 with three u3115s mosfet drivers that invert the low side so that the Low Side Mosfet is active if the Lin from the u3115 ic is low and the high side is active if the Hin of the u3115s is High. Maybe is there a way to invert the low side outputs from the esp?
here is my code:
#include <SimpleFOC.h>
// ------------------------
// Pins & Parameters
// ------------------------
const int potiPin = 34; // analog input for potentiometer
float target_velocity = 0;
// Hall sensor pins A, B, C + pole pairs
HallSensor sensor(35, 36, 39, 15);
You can do it in 6-PWM mode by setting the build flag -DSIMPLEFOC_PWM_LOWSIDE_ACTIVE_HIGH=false
Setting build flags depends on your environment. In platformio, you can put them in the platformio.ini
Be careful setting these options and using drivers with inverted polarity - check your PWM outputs and dead-time carefully before connecting power to the driver, or you could have shoot-through and burn your FETs.
Hello i want to control a bldc 3 phase sensored Motor and i have a esp32 with three u3115s mosfet drivers that invert the low side so that the Low Side Mosfet is active if the Lin from the u3115 ic is low and the high side is active if the Hin of the u3115s is High. Maybe is there a way to invert the low side outputs from the esp?
here is my code:
#include <SimpleFOC.h>
// ------------------------
// Pins & Parameters
// ------------------------
const int potiPin = 34; // analog input for potentiometer
float target_velocity = 0;
// Hall sensor pins A, B, C + pole pairs
HallSensor sensor(35, 36, 39, 15);
// 6PWM Driver for High- and Low-side MOSFETs
BLDCDriver6PWM driver(
32, // U-phase High-side input
33, // U-phase Low-side input
25, // V-phase High-side input
26, // V-phase Low-side input
27, // W-phase High-side input
14 // W-phase Low-side input
);
BLDCMotor motor(15);
// ISR routines for Hall signals
void isrA() { sensor.handleA(); }
void isrB() { sensor.handleB(); }
void isrC() { sensor.handleC(); }
void setup() {
Serial.begin(115200);
// Hall-Sensor initialization
sensor.init();
sensor.enableInterrupts(isrA, isrB, isrC);
motor.linkSensor(&sensor);
// Driver initialization
driver.voltage_power_supply = 24;
driver.pwm_frequency = 20000;
driver.init();
motor.linkDriver(&driver);
// Motor FOC settings
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
motor.controller = MotionControlType::velocity;
motor.voltage_limit = 6; // Volt
motor.velocity_limit = 14.9; // rad/s (~6 km/h)
motor.PID_velocity.P = 0.2;
motor.PID_velocity.I = 10;
motor.PID_velocity.D = 0;
motor.LPF_velocity.Tf = 0.01;
// initialize motor and FOC
motor.init();
motor.initFOC();
Serial.println("=== Poti-Controlled FOC Ready ===");
}
void readPoti() {
int potiValue = analogRead(potiPin); // 0 - 4095
float potiNorm = (potiValue - 2048.0f) / 2048.0f; // Range -1.0 to +1.0
target_velocity = potiNorm * motor.velocity_limit;
Serial.print("Target velocity: ");
Serial.println(target_velocity);
}
void loop() {
motor.loopFOC();
readPoti();
motor.move(target_velocity);
}
The text was updated successfully, but these errors were encountered: