Unable to Increase Motor Velocity

Hi All,

I just managed to get my simple foc project to work. However my motor speed seems to be limited, topping out at about 20rad/s. As I raise the velocity limit above this level, the speed doesn’t increase further. I have upped the velocity limit to 800rad/s in the below code and no change. Top speed does not change when I up the amperage or change to velocity mode (below code is in angle mode). How do you think I can turn up the speed? I am using an arduino nano clone and an as5600 as the sensor. Would this be the issue?

Below is my code for your reference.

Appreciate any help regarding this!

#include <SimpleFOC.h>

MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8); //tried this last
BLDCMotor motor = BLDCMotor(7, 0.4);

void setup() {
Serial.begin(115200);
motor.useMonitoring(Serial);
sensor.init();
motor.linkSensor(&sensor);
driver.voltage_power_supply = 21;
driver.init();
motor.linkDriver(&driver);
motor.controller = MotionControlType::angle;
motor.PID_velocity.P = 0.2;
motor.PID_velocity.I = 20;
motor.PID_velocity.D = 0.001;
motor.PID_velocity.output_ramp = 1000;
motor.LPF_velocity.Tf = 0.01;
motor.P_angle.P = 40;
motor.P_angle.I = 0; // usually only P controller is enough
motor.P_angle.D = .001; // usually only P controller is enough
motor.P_angle.output_ramp = 10000; // default 1e6 rad/s^2
motor.LPF_angle.Tf = 0.01; // default 0
motor.current_limit = 5; // Amps
motor.velocity_limit = 800;
motor.init();
motor.initFOC();
_delay(1000);
}

void loop() {
motor.loopFOC();
motor.move(100);
motor.monitor();
}

Thanks,
Amit

Most probably yes. These are really slow MCU and sensor. The as5600 maxes out at a few hundred rpm, which is about the speed you got (20rad/s), and the Nano is really slow, so you got two strikes against you. Also, looking at your setup, you have 7pp, so probably using a gimbal? Gimbals are not designed to spin quickly to begin with, so that’s three strikes against you.

Get a fast sensor (as5047p), fast MCU (60MHz or better) and a fast motor (lower ohm) and a high powered driver.

Cheers,
Valentine

What happens when you remove the Phase resistance?
I think that limits the voltage to the motor to 2V(5A x 0.4).
Test with current limited supply

This is exactly the point! In fact I was in the same situation some months ago and I leave to you the thread where @Antun_Skuric kindly explained the concept.

Bye

Hi @slayerizer ,

I think you have 3 problems, which are in combination limiting your performance. You can get some extra performance by fixing one or two of these, but you won’t really get the full performance until you fix all three:

  1. as people have already pointed out, with settings of phase resistance of 0.4Ω, and current limit of 5A, the voltage limit will be set to 2V - kind of low for getting much speed. However with such low phase resistance and PSU of 21V you would need current sensing / limiting in order to be able to raise the voltage limit, or currents will simply rise too high and burn up your setup.
  2. An AS5600 is not a good sensor, and I2C will greatly limit your performance because it is so slow. Try SPI, SSI or ABZ based sensors for better performance.
  3. An Arduino Uno is a very slow, 8bit MCUs. Arduino are great, but for this type of task (FOC control) they are too slow if you also want high performance. So you’ll have to switch to a faster MCU type, like STM32 or ESP32.

Hi All,

Just wanted to post a quick update. Thanks again for all your support
@Valentine I’ve updated the sensor to as5047p and using a teensy, thanks for the advice!
@luzz94 Thanks for that link! Elegantly explained
@runger as mentioned I’ve updated the sensor and microcontroller meeting two of the points you mentioned. As per the current sensing, explained below…

With just updating the MC to a teensy and the sensor to a as5047p, the velocity is increased, and further increases as I increase the current limit. But to your point @runger current seems to be rising quite high, and I can see the solder on my driver liquifying haha. In order to incorporate current sensing on the teesny, it appears my driver board (below) only supports low side current sensing and the teensy supports in-line current sensing only.

Is there any work around that I can do to support current sensing in my setup?

My driver board:

Thank you,
S

1 Like

Hi @slayerizer ,

Which teensy MCU are you using? There’s a couple of different models.

I just took a look at some of the datasheets, and the problem is not with Teensy, but with the SimpleFOC library support for this MCU series.

So far, our Teensy support is still simple, and we don’t support low side current sensing, 6-PWM or software dead-time insertion.

So there is no need for a workaround, but just a need to develop the library further for this MCU.

What would be needed?

  • to improve the hardware PWM driver to support 6-PWM, and set appropriate output triggers on the PWM peripheral so the ADC can be triggered
  • write a ADC hardware driver (current sensing implementation) which sets the hardware up to be triggered by the PWM for low side sensing.
  • ideally, implement DMA based transfer of the values from the ADC, so the whole system can run without interrupts.

All of this is very MCU-specific, and usually not that simple to do. I haven’t tried for the NXP MCUs, so I can’t really say how hard it will be in the end…

I suspect we will get to implementing this in the end, but it could take a while - in the meantime we’d be very happy to look at contributions if someone wants to give it a try! :slight_smile:

@runger i would totally love to help with FOC development but unfortunately I’m not there yet with my understanding of embedded systems coding. Will take a look though!

In terms of getting current sensing to work, I am currently using a teensy 4.1. Since my driver already supports low side current sensing, do you think switching over to the currently supported stm mcus would be my easiest solution? (supported mcus shown in below pic from the docs)

I’m not married to the teensy, but def don’t want the mcu to be the limiting reactant. That being said, we mentioned the arduino is too slow at 8mhz, but the stms seem to be about 72mhz or about an order of magnitude of higher speed. Do you know what rpm of control this would limit my setup to?

Thanks again,
S

Teensy is a very fast MCU, we just don’t support current sensing on it… (yet)

STM32s come in a wide variety, some (H7) can have 400MHz or more. Slower ones can be 48MHz or 72 like the one you mention.

So how does MCU speed translate into RPM?

A good question, and of course, like so often, the answer is „it depends“.

Your MCU speed will determine the loop frequency of your main loop…
Predicting the loop frequency is hard - it depends on the MCU clock frequency for sure, but also other things like how much stuff you’re doing in the loop, whether the MCU has floating point acceleration, the amount of interrupts that have to be processed, etc…

So instead of MHz let’s consider how many kHz the main loop runs at.
Each time the main loop runs it calls motor.move() and advances the motor position.

Ignoring motor dynamics like backEMF, let’s just assume the motor goes as fast as we can command it.

When doing so, we have to activate the motors magnets in the right sequence. If we miss commutation steps the efficiency is greatly reduced, or the motor can even stall or move in the wrong direction.

While smoother motion needs more steps the minimum number of commutation steps per electrical revolution can be considered as 6.

The number of electrical revolutions for a physical revolution is given by the motors pole pairs.

So let’s assume the motor has 7PP, and your loop runs at 12kHz. Thus 12kHz / 6 steps / 7PP = 285 rotations per second or about 17000 RPM

Perhaps someone with more knowledge than I have can give more information, or point out why my simplistic calculations are wrong :smiley:

1 Like