3$ BLDC and Stepper FOC driver - L298N

@runger I understand this chip is obsolete and less efficient. But I want to use it for home automation use which does not require very precise motor movements or top efficiency. Combination of NDM3000 and BDR6300 is low cost in spirit of 3$ BLDC title of this thread.

I agree with you that I should start with tried and tested ESP32 first.

Can you please advice me how to implement wiring between these gates, mosfets and ESP32 for SimpleFOC?

Thank you.

I am also going to order PCB with 2 BLDC controller hat for STM32F01 blue pill using 6 DVR8871 chips.


I have to rout inputs pins from blue pill to 6 DRV8871 chips but could not identify pins so can you please give me hint about what pins should I use for SimpleFOC?

Thank you.

The fact that you are asking this question, suggests to me that you need to be following a more tried and tested solution. I.e look to find something that is really well supported and other people have had success with.

It is quite easy to spend 10x more time if you are choosing components others haven’t used.

Have you considered using a stepper motor to move your curtains? That would be far simpler and probably cheaper.

1 Like

@Owen_Williams Yes I have been using steppers to move curtains. But I want to explore new things like you making sound out of hoverboard motors. I have curious mind and time and energy to learn something new. As far as cost is concerned as stated earlier I will be spending 10X less ($3 for 2 BLDC controllers) with parts I have chosen. I am asking questions only related to best pinout suitable for SimpleFOC.

Thanks.

I understand. Those drivers are for brushed motors, what are you going to do with the second output of each driver?

I’m more of a software guy so I’m not sure if using brushed drivers will work e.g the driver typically sources and sinks current (at the same time) as it is connected to both sides of a brushed motor. But you’ll be asking it to source or sink current at any given time as current flows between phases on a bldc. Kinda feels like it should work, but some protection on board might not be happy with that. You are a doing stuff the datasheet doesn’t cover.

Are you wanting pwm pins for stm32f103 or esp32

@Owen_Williams Thank you for your response.

You were right in your earlier response that NDM3000 is not suitable so I will go with 6 individual pair of N and P type mosfets with BDR6300.It will take little more space on PCB but it will be more flexible for selection of mosfets and to replace mosfets if something goes wrong with one of them. The datasheet of BDR6300 is not very clear about exact type of mosfets suitable for that chip.

I will be driving 2 BLDC with 12 mosfets (6 N-type and 6 p-type) as @Antun_Skuric demonstrated it with L298N in this thread.

For DRV8871 I want to use STM32F103 and for BDR6300 gate drivers I will be using ESP32.

Thanks.

My last comment was referring to the drv8871, not ndm3000 (I haven’t looked at that). When it comes to gate drivers the drv831x series have integrated FETs and the drv830x require external FETs. I was saying that drv8871 is for a brushed motor and whilst you could try to use 3 of them it is not what the datasheet is expecting.

The L623x series from (STM) are also popular here.

Regarding pins on bluepill (STM32F103C8T6) - you are looking to choose pins on one of the advance timers (typically TIM1 and sometimes also TIM8).
stm32cubeide has a tool to help chose the right pins, this is an example of setting up blue pill for various peripherals:

@Owen_Williams Thank you.

Have you figured out the jerking problem? I have a Emax xa2212 / 1400KV wired up with l298n(as describe by @Antun_Skuric ).
I am powering the driver with 3s lipo battery. voltage_limit is set to 12V (although upon testing it’s a bit higher than 12v).
Full code:

// Open loop motor control example for L298N board
#include <SimpleFOC.h>

#define IN1 11
#define IN2 10
#define IN3 9
#define IN4 8

// 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(IN1, IN2, IN3);

void setup() {
  // deactivate the OUT4 output
  pinMode(IN4,OUTPUT);
  digitalWrite(IN4,LOW);


  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  driver.init();
  // link the motor and the driver
  motor.linkDriver(&driver);

  // limiting motor movements
  motor.voltage_limit = 3;   // [V]
  motor.velocity_limit = 20; // [rad/s]

  // open loop control config
  // motor.controller = ControlType::velocity_openloop;
  motor.controller = MotionControlType::velocity_openloop;

  // init motor hardware
  motor.init();

  Serial.begin(115200);
  Serial.println("Motor ready!");
  delay(1000);
}

float target_velocity = 3; // [rad/s]

void loop() {
  // open loop velocity movement
  // using motor.voltage_limit and motor.velocity_limit
  motor.move(target_velocity);

}

But the motor does not turn it just jerks in place and l298n gets very hot that I cannot touch it with bare hand. I have tried different target speeds slower or higher. With higher target speed the motor just vibrates faster.

You did not set your PWM frequency, the default is maybe 20kHz, this is way too fast for L298N. You need to set it to 2-5kHz probably.

I’ll try that and let you know. Thanks for your response.

Thanks it worked driver.pwm_frequency = 4000;. although still a bit jittery and only works if I gradually increase the speed by about 5rad/s increment.

1 Like

The problem is you are in open loop and also using a stepper motor. Stepper motors have large number of pole pairs, so the electrical revolution is very very small compared to the physical revolution. When you are in open loop if you increase the speed too quickly, you outpace the rate of commutation and then the motor won’t turn smoothly. Having both a sensor or using a motor with less pole pairs will make this less of a problem. On stepper motors I used MT6835, it works very well.

1 Like

Hi sir i am a college student from India and I am currently working on a gimbal project and while searching i saw this post of yours stating driving bldc using l298N motor drivers i want more details about this sir is there any way of contacting you sir it would be a pleasure Thank you you in advance sir