What shall be the frequency at which I must update esc to fly drone stably?

I am working on drone,i am using Arduino Uno , IMU BNO055 , 1000 KV bldc motor, Hobby wing X ROTOR 50 A esc, Flysky 6 channel transmitter and receiver

I am writing the code by myself for educational purpose.
My drone always of the time unstable.
I am using servo library to rotate bldc.
Now the speed at which motor rotates depends upon the pid values calculated after in the loop.

Now I calculated imu sends data to Arduino via i2c at 400hz.
Means 100000/400= 2500 us
It means I shall update the values of motor every 2500 us which is not possible.

I need to know what shall be the frequency at which I must update esc so that it flies stably.

The Servo library sends control pulses at about 50 Hz (20 milliseconds) so you can't practically update faster than that.

It would be an interesting experiment to get it working and then slow down the control rate to see how slow you can go and still get stable control.

I believe this is a Laplace Transform Problem (advanced math) but it's been too long since I studied this stuff and I probably just-barely understood it enough to pass the test. :stuck_out_tongue: Plus, I'd guess there are unknown variables. :frowning:

So you'll probably just have to experiment, or MAYBE there are some simplified guidelines/rules.

Thanks for answering.
My question is a bit different. Let me explain again please

void setup (){
}
void loop(){

getIMUdata();//code to get imu data

loadIMUdata();// code to load imu data into pid controller

getPIDvalue();// code to get pid values for esc

updateESCvalues();// here motors will be updated<--- 




}

as we can see my motors are updated once a loop .
If loop time is 100000us then it is too much, I believe.
Now I want to know what shall be the range of time required to complete the loop so that drone flies stably.

Correct me if I am wrong.

Hi @anchalshivank

Personally, I'd put the Arduino's PWM motor outputs on pins 3, 9, 10 and 11. That way you'll more easily be able to drive them at 490Hz with the Arduino analogWrite() function.

Traditionally, multi-rotors used a 490Hz PWM rather than 50Hz, as the faster update rate saturated the ESC's input filters (which at the time were designed for fixed wing and helis) and thereby made them more responsive. Essentially, the filter would converge on the desired output more quickly. Obviously nowadays there are quad specific ESCs that support any number of protocols (Oneshot, Multishot, DShot, etc...), but the 490Hz standard still remains.

By the way it doesn't really matter whether the PWM update is synchronised to the loop() or not. If your microcontroller's capable of meeting the update rate every 2ms (at 490Hz) all well and good, if it's a bit less than that's still OK, the aircraft will still stabilise.

The reason for the development of faster ESC procotols such as Oneshot125, Oneshot42, Multishot and then DShot in it's various speed, was caused by the advent of small 32-bit ARM based microcontrollers. The huge increase in processing power they provided, meant that the 2ms update rate that 490Hz imposed, really started to become a limiting factor.

1 Like

@anchalshivank Just to give you an indication of loop time, my Arduino Micro (ATmega32U4) based flight controller was able to update the motors at around 250Hz (or every 4ms) with 490Hz PWM motor output. It was still good enough.

1 Like

Thank you @MartinL

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.