Hi.
I’m trying to make an arduino setup with ir2110 and igbt or mosfet as final to drive a 3 phase compressor inverter.
i tryed this program but i dont have any output:
// Open loop motor control example
#include <SimpleFOC.h>
#define INH_A 3
#define INH_B 5
#define INH_C 9
#define INL_A 11
#define INL_B 6
#define INL_C 10
#define EN_GATE 7
// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(11);
BLDCDriver6PWM driver = BLDCDriver6PWM(INH_A,INH_A, INH_B,INH_B, INH_C,INL_C, EN_GATE);
//target variable
int target_velocity = 1000;
void setup() {
Serial.begin(115200);
motor.monitor();
driver.init();
// driver config
// power supply voltage [V]
driver.voltage_power_supply = 24;
// limit the maximal dc voltage the driver can set
// as a protection measure for the low-resistance motors
// this value is fixed on startup
driver.voltage_limit = 15;
// link the motor and the driver
motor.linkDriver(&driver);
driver.pwm_frequency = 20000;
// limiting motor movements
// limit the voltage to be set to the motor
// start very low for high resistance motors
// current = voltage / resistance, so try to be well under 1Amp
motor.voltage_limit = 3; // [V]
// open loop control config
motor.controller = MotionControlType::velocity_openloop;
Serial.println("Motor ready!");
}
void loop() {
// open loop velocity movement
// using motor.voltage_limit and motor.velocity_limit
_delay(1000);
motor.move(target_velocity);
}
I really dont know what it wrong with the setup.
Hi,
A few things to change:
BLDCDriver6PWM(INH_A,INH_A, INH_B,INH_B, INH_C,INL_C, EN_GATE);
→
BLDCDriver6PWM(INH_A,INL_A, INH_B,INL_B, INH_C,INL_C, EN_GATE);
_delay(1000);
→ remove this from the main loop - you won’t get proper motion if you have such long delays in the loop.
motor.init();
→ add it after the motor.controller = MotionControlType::velocity_openloop;
line
Please take a look at our examples directory in the library (available from the Examples Menu in ArduinoIDE), there are many examples for the different modes and different setups.
The order of doing things in the setup is important, so it is good to have examples.
// Open loop motor control example
#include <SimpleFOC.h>
// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(11);
// BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
//BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);
// BLDCDriver6PWM(IN1_H, IN1_L, IN2_H, IN2_L, IN3_H, IN3_L, enable(optional))
BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15, PB12);
// Stepper motor & driver instance
//StepperMotor motor = StepperMotor(50);
//StepperDriver4PWM driver = StepperDriver4PWM(9, 5, 10, 6, 8);
//target variable
float target_velocity = 100;
// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
void doLimit(char* cmd) { command.scalar(&motor.voltage_limit, cmd); }
void setup() {
// driver config
// power supply voltage [V]
driver.voltage_power_supply = 12;
// limit the maximal dc voltage the driver can set
// as a protection measure for the low-resistance motors
// this value is fixed on startup
driver.voltage_limit = 6;
driver.init();
// link the motor and the driver
motor.linkDriver(&driver);
driver.pwm_frequency = 2000;
// limiting motor movements
// limit the voltage to be set to the motor
// start very low for high resistance motors
// current = voltage / resistance, so try to be well under 1Amp
motor.voltage_limit = 3; // [V]
// open loop control config
motor.controller = MotionControlType::velocity_openloop;
// init motor hardware
motor.init();
// add target command T
command.add('T', doTarget, "target velocity");
command.add('L', doLimit, "voltage limit");
Serial.begin(115200);
Serial.println("Motor ready!");
Serial.println("Set target velocity [rad/s]");
//_delay(1000);
}
void loop() {
// open loop velocity movement
// using motor.voltage_limit and motor.velocity_limit
motor.move(target_velocity);
// user communication
command.run();
}
I understand from the wiki that arduino uno has pwm frecvency limitation at 32khz or 4 khz .
I need it to be adjustable so that i have the right settings for the motor.
The above code is for stm32 bluepill board clocked at 2 khz but according to my osciloscop the frecvency does not change it remains at 25khz.
I measured with nothing attached.
Thanks
Hi @Vlad_Daniel,
Sounds like you’re making progress 
Please set the frequency before calling driver.init()
and see if this helps.
yes it change now.I will connect the setup and power it up to see if all is working ok.
by the way is ir2104 better than ir2110?
I’m getting no output from the ir2110.
The below picture is rough sketch of the schematic with stm32 and ir2110
the motor does not start