The motor driver is very hot

The L6234d board from BaseCam simpleBGC ,I bought it from AliExpress when 3 years before.

Never drive this power motor with l6034!

I use l6234 to drive a 4110 motor (kv4xx), 12V power supply, the motor shakes a few times, “l6234d” in a few seconds …“bom…” burst!!!

OK,Thanks guys!
I found a MOSFET driver board,it is high integration and higher current.
All the well now!

1 Like

@Antun_Skuric
@Owen_Williams
Hello,guys! I have new problem
I bought a DRV8302 board,I downloaded “drv8305_driver” The motor has a lot of noise. And can’t rotate.
I know that this motor (6215 180kv) does not meet the requirements, but I want to use simplefoc for power motor. How can I complete it?
Thanks!

Hey @Leonardo,
You have an exciting setup, I am really looking forward to see it work! :smiley:

What is the sensor you are using?
What is the library version you are using?

If the motor is not moving at all then most probably you have a sensor problem, did you try to output the sensory data, the motor angle for example, can you check if it updates?
Maybe the motor and the sensor are not oriented in the same direction, this you can easily overcome by switching any two motor wires.

Or you can download the developmental version of the library where @Owen_Williams has implemented auto-detection of the sensor direction. Here is the link:

In this developmental version of the library you will also find the open loop control examples. So you can try turning the motor without sensor.
You can find examples in:

examples
    > motion_control
          > open_loop_motor_control

If you don’t want to use dev version, don’t worry. Everything will work without it as well. It just offers a bit more functionalities. :smiley:

Here is an example code of the open loop motor control which you can use with the regular library. You just need to copy paste the the drv8302 code.

@Antun_Skuric
Thanks for your help!
I found that the problem was that my PI control parameters were too high,
Now PI is like this, I successed to make the motor turn
motor.PI_ velocity.P = 0.1;
motor.PI_ velocity.I = 5;
pole pair number is 14
The encoder uses as5047u and is connected through SPI
The current library version is 1.3.0

But the starting current of the motor is 18A (after MOT: Enable.), so I limit the current on DC power to less than 5A, which will cause noise during starting.!!
I’m using the motor of the aircraft with an internal resistance of 0.2 ohm.
(Please watch this video for details,The “Target voltage” and “Target angle” are adjusted through the serial port in the video screen)
(There will be a clicking noise when the motor is highspeed)

  • List item
1 Like

Hey @Leonardo, thats cool!

Ok, so from the video I see that you might still need to tune your PID parameters a bit but at least it works.

During the initialization the motor pushed in a set of discrete positions from which we can calculate the necessary offsets. For this to happen we set certain voltage to the motor coils in predefined angles. So in your case the voltages are just too high and you have immense currents. You can change this by adding this line before motor.initFOC():

motor.voltage_sensor_align = 1; // defualt is 6 volts

Change the voltage to reduce the noise.

The other thing you can try to avoid this from happening is the new feature that is not yet documented but is implemented in dev version of the library. ( I think you are using the dev version already)

First go to the examples and run the find_sensor_offset_and_direction.ino

examples
    > utils 
          > find_sensor_offset_and_direction

This code will give you sensor offset and direction value.

In this example you will need to copy the DRV8302 specific code and maybe use the line above to limit the volatge

Once when you have the offset and the direction, then in your code from the video instead of the line

motor.initFOC();

write:

 // sensor offset is a float number
// sensor direction is either Direction::CW or Direction::CCW
motor.initFOC(sensor_offset, sensor_dirrection );

This line will allow the alignment to happen without moving the motor and you will not have to deal with limiting currents and voltages for alignment.

OK ,I manually set the sensor offset and motor direction, and now I can start the motor quickly.
I’ve been debugging the PID for a long time, but it’s still choppy. I think the internal resistance of aircraft motor is too small (< 1 Ω) and the power is very high, so it is difficult to achieve perfect linear control. When I change to gimbal motor (10 Ω). It’s very smooth.

motor.PI_velocity.P = 0.1;
motor.PI_velocity.I = 0.12;
motor.P_angle.P = 1.5;

1 Like

Hey @Leonardo,
I would not go with I component lower than 10.

Is this motor connected to DRV board or SimpleFOC shield?

This motor connected to driver board is High power DRV8302 board,and I have the bare board of simplefoc shield, but I was afraid that simplefoc shield would be burned .So it hasn’t been welded yet. :sweat_smile:

Are you using SinePWM or SpaceVectorPWM?
Try FOCModulationType::SpaceVectorPWM.

DG

yeah,I’ve been using SpaceVector PWM

Hello, everyone!
I’m using the 6215 motor again,the driver is High power DRV8302 board and arduino mini pro
is the code is “velocity_ motion_ control”

“Target velocity:” is quiet at low speed (1-30),But when it’s over 35, there’s noise

I try to change the PID, phase PWM frequency, AS5027U sensor SPI frequency, and use other routines to make noise during fast rotation.

Thank guys very much for your answers.

Can you paste the code you are using?

DG

Sure,please.

/**
 * 
 * Velocity motion control example
 * Steps:
 * 1) Configure the motor and magnetic sensor 
 * 2) Run the code
 * 3) Set the target velocity (in radians per second) from serial terminal
 * 
 * 
 * By using the serial terminal set the velocity value you want to motor to obtain
 *
 */
#include "SimpleFOC.h"

#define EN_GATE 8
#define M_PWM A1
#define M_OC A2
#define OC_ADJ A3

// The cs is Pin7,board is simplebgc mos v1.3
MagneticSensorSPI sensor = MagneticSensorSPI(7, 14, 0x3FFF);

// magnetic sensor instance
// MagneticSensorSPI sensor = MagneticSensorSPI(10, 14, 0x3FFF);

// magnetic sensor instance
//MagneticSensorI2C sensor = MagneticSensorI2C(0x36, 12, 0x0E, 4);

// Motor instance
// BLDCMotor motor = BLDCMotor(9, 5, 6, 7, 8);

// Motor instace(Simplebgc v1.3) (MOT1 9,10,11;MOT2 3,5,6)
BLDCMotor motor = BLDCMotor(3, 5, 6, 14, 8);

void setup() {

  // initialise magnetic sensor hardware
  sensor.init();
  // link the motor to the sensor
  motor.linkSensor(&sensor);

  // DRV8302 specific code
  // M_OC  - enable overcurrent protection
  pinMode(M_OC,OUTPUT);
  digitalWrite(M_OC,LOW);
  // M_PWM  - enable 3pwm mode
  pinMode(M_PWM,OUTPUT);
  digitalWrite(M_PWM,HIGH);
  // OD_ADJ - set the maximum overcurrent limit possible
  // Better option would be to use voltage divisor to set exact value
  pinMode(OC_ADJ,OUTPUT);
  digitalWrite(OC_ADJ,HIGH);

  // power supply voltage
  // default 12V
  motor.voltage_power_supply = 12;

  // set motion control loop to be used
  motor.controller = ControlType::velocity;

  // contoller configuration 
  // default parameters in defaults.h

  // velocity PI controller parameters
  motor.PI_velocity.P = 0.001;
  motor.PI_velocity.I = 0.2;
  // default voltage_power_supply
  motor.PI_velocity.voltage_limit = 12;
  // jerk control using voltage voltage ramp
  // default value is 300 volts per sec  ~ 0.3V per millisecond
  motor.PI_velocity.voltage_ramp = 1000;

  // velocity low pass filtering
  // default 5ms - try different values to see what is the best. 
  // the lower the less filtered

  motor.LPF_velocity.Tf = 0.1;

  // use monitoring with serial
  Serial.begin(115200);
  // comment out if not needed
  motor.useMonitoring(Serial);

  // initialize motor
  motor.init();
  // align sensor and start FOC
  motor.initFOC(2.4666,CW);

  Serial.println("Motor ready.");
  Serial.println("Set the target velocity using serial terminal:");
  _delay(1000);
}

// velocity set point variable
float target_velocity = 0;

// utility function enabling serial communication with the user to set the target values
// this function can be implemented in serialEvent function as well
void serialReceiveUserCommand() {

  // a string to hold incoming data
  static String received_chars;

  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the string buffer:
    received_chars += inChar;
    // end of user input
    if (inChar == '\n') {

      // change the motor target
      target_velocity = received_chars.toFloat();
      Serial.print("Target velocity: ");
      Serial.println(target_velocity);

      // reset the command buffer
      received_chars = "";
    }
  }
}

void loop() {
  // main FOC algorithm function
  // the faster you run this function the better
  // Arduino UNO loop  ~1kHz
  // Bluepill loop ~10kHz
  motor.loopFOC();

  // Motion control function
  // velocity, position or voltage (defined in motor.controller)
  // this function can be run at much lower frequency than loopFOC() function
  // You can also use motor.move() and set the motor.target in the code
  motor.move(target_velocity);

  // function intended to be used with serial plotter to monitor motor variables
  // significantly slowing the execution down!!!!
  // motor.monitor();

  // user communication
  serialReceiveUserCommand();
}

Hey @Leonardo, I am very happy to see that you were able to have some results. :smiley:

I’ve just made a small calculation and I think you are hitting the processing limit of the atmega328 chip.

So average time of one loop() function with magnetic SPI sensor is arround 1ms:
Your motor has 14 pole pairs which means that each

360/14 = 25.7 degrees ~ 0.44 radians

you do the full electrical rotation. To be able to turn your motor you will need to be able to detect, at least once, per 120 electrical degrees. What is:

25.7 * 120/360 = 8.57 degrees ~ 0.149 radians

And when you are running your code with velocities such as: 30rad/s

30 rad/s * 1ms = 0.03 radians ~ 1.71 degrees

Which means that for your velocity of 30rad/s you only have 8.57/1.71 = 5 discrete steps instead the sine wave. This may be the reason you hear so much noise when running this code.

One way to deal with this is to move to another microcontroller. For example STM32 bluepill.

Can you tell us what is the loop execution time when you run the exepriments?

Hi @Leonardo,
with a motor with 0.2 ohm and the DRV8302 board I suggest you to set at maximum motor.PI_velocity.voltage_limit = 3. I also suggest you to reduce motor.LPF_velocity.Tf = 0.01, because I noticed a strange movement of the motor at the end of the previous video.
About the noise problem, I agree with @Antun_Skuric. Try another microcontroller.

DG

Good day,guys!
I am still a novice in programming, so I used this code to check the execution time of loop() .

  void loop() {
  unsigned int timecnt;
  // main FOC algorithm function
  // the faster you run this function the better
  // Arduino UNO loop  ~1kHz
  // Bluepill loop ~10kHz
  imecnt = millis()-timecnt;//Read once before testing the function,The unit is ms
  motor.loopFOC();

  // Motion control function
  // velocity, position or voltage (defined in motor.controller)
  // this function can be run at much lower frequency than loopFOC() function
  // You can also use motor.move() and set the motor.target in the code
  motor.move(target_velocity);

  // function intended to be used with serial plotter to monitor motor variables
  // significantly slowing the execution down!!!!
  // motor.monitor();

  // user communication
  serialReceiveUserCommand();
  timecnt = millis()-timecnt;//Subtract the last result after the function test is completed
  Serial.print("timecnt=");//print the "timecnt"
  Serial.println(timecnt );
}

timecnt= 47-50 (ms)

In fact, I should have used ARM framework chips early, and besides testing Arduino this week, I have also been trying to use Arduino on ARM chips. I still have no success until today,

This is a STM32F103C8T6 128K mini board, I downloaded it through the serial port

generic_boot20_pc13.bin

and the flashing light is like this, Isn’t it an interval of one second? And the LED of PC13 will go out eventually.

The IDE I use is PlatformIO, I have created a new
bluepill_f103c8_128k
project, but it never succeeds when uploading through the serial port.
This is my
PlatformIO.ini
configuration file

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:bluepill_f103c8_128k]
platform = ststm32
board = bluepill_f103c8_128k
framework = arduino
upload_protocol = serial
upload_port = /dev/cu.usbmodem14101

This is the command window of PlatformIO

I will keep trying :slightly_smiling_face:

This article suggests using dfu rather than serial as an upload protocol:


Worth a try?

@Owen_Williams
Yeah,you are right.finally I replaced it .

upload_protocol = dfu

Oh,I had new trouble.
libusb not loaded
I tried my best to solve it, but it still didn’t help :crying_cat_face:

Configuring upload protocol...
AVAILABLE: blackmagic, dfu, jlink, stlink
CURRENT: upload_protocol = dfu
Looking for upload port...
Use manually specified: /dev/cu.usbmodem14201
Uploading .pio/build/bluepill_f103c8_128k/firmware.bin
dyld: Library not loaded: /opt/local/lib/libusb-1.0.0.dylib
  Referenced from: /Users/apple/.platformio/packages/tool-stm32duino/dfu-util/dfu-util
  Reason: image not found
/Users/apple/.platformio/packages/tool-stm32duino/maple_upload: line 53:  2938 Abort trap: 6           ${DFU_UTIL} -d ${usbID} -
a ${altID} -D ${binfile} -R ${dfuse_addr} -R
*** [upload] Error 134
========================== [FAILED] Took 4.81 seconds ==========================