Go Down

Topic: Quadcopter motors running at full throttle when turning off Arduino. (Read 312 times) previous topic - next topic

DragoSupremo

Hi everybody,

i am trying to test the Arduino quadcopter i made, but i am facing a problem when i turn off the arduino.

The 4 escs are controlled by the arduino itself, and when i turn it off the motors burst at full speed for half a second.

Luckily i don't have any propeller on the motors so it's not dangerous, but when i'll put them on it could be a big problem

Here's the code on my Arduino:
Code: [Select]

#include <Servo.h>

Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4;

void setup() {
  // put your setup code here, to run once:

  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(11, OUTPUT);
  
  //Motor setup
  motor1.attach(11);
  motor2.attach(A2);
  motor3.attach(A1);
  motor4.attach(A0);


  //Esc calibration
  motor1.writeMicroseconds(2000);
  motor2.writeMicroseconds(2000);
  motor3.writeMicroseconds(2000);
  motor4.writeMicroseconds(2000);
  delay(10000);
  motor1.writeMicroseconds(1000);
  motor2.writeMicroseconds(1000);
  motor3.writeMicroseconds(1000);
  motor4.writeMicroseconds(1000);
  delay(10000);
  //Run motors
  motor1.writeMicroseconds(1000);
  motor2.writeMicroseconds(1000);
  motor3.writeMicroseconds(1000);
  motor4.writeMicroseconds(1000);

}

void loop() {
  // put your main code here, to run repeatedly:

}


 

The complete code is another but testing the escs and the motors with this sketch gives the same results: when turning arduino off, the motors speed rapidly increases for a fraction of time. This happens a good 70% of the times.

I also made the circuit diagram some time ago but it wasn't updated until now so i hope it is readable.
There is also a video of my problem.



zwieblum

Ladies and gentleme, come close, take a look! Whoever finds the question will get an answer for free! Ladies and gentlemen! ...

DragoSupremo


zwieblum

Nop. No questionmark, but in "I don't get it, you can't see the question?"

DragoSupremo

Oh strange, i am sorry i am gonna post it again here:
Hi everybody,

i am trying to test the Arduino quadcopter i made, but i am facing a problem when i turn off the arduino.

The 4 escs are controlled by the arduino itself, and when i turn it off the motors burst at full speed for half a second.

Luckily i don't have any propeller on the motors so it's not dangerous, but when i'll put them on it could be a big problem

Here's the code on my Arduino:
Code: [Select]

#include <Servo.h>

Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4;

void setup() {
// put your setup code here, to run once:

pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(11, OUTPUT);

//Motor setup
motor1.attach(11);
motor2.attach(A2);
motor3.attach(A1);
motor4.attach(A0);


//Esc calibration
motor1.writeMicroseconds(2000);
motor2.writeMicroseconds(2000);
motor3.writeMicroseconds(2000);
motor4.writeMicroseconds(2000);
delay(10000);
motor1.writeMicroseconds(1000);
motor2.writeMicroseconds(1000);
motor3.writeMicroseconds(1000);
motor4.writeMicroseconds(1000);
delay(10000);
//Run motors
motor1.writeMicroseconds(1000);
motor2.writeMicroseconds(1000);
motor3.writeMicroseconds(1000);
motor4.writeMicroseconds(1000);

}

void loop() {
// put your main code here, to run repeatedly:

}




The complete code is another but testing the escs and the motors with this sketch gives the same results: when turning arduino off, the motors speed rapidly increases for a fraction of time. This happens a good 70% of the times.

I also made the circuit diagram some time ago but it wasn't updated until now so i hope it is readable.
There is also a video of my problem.

(here's the video: https://drive.google.com/file/d/11Fwc_YfCwBZTO0yD3NfgB9FRQiIls4jP/view?usp=sharing)

zwieblum


Robin2

when turning arduino off, the motors speed rapidly increases for a fraction of time. This happens a good 70% of the times.
Does that happen even if the motors are stationary when you turn the Arduino off?

Apart from this problem (which, I agree, is serious) does the system work the way you want it to?

Have you tried commenting out parts of your program so that it is only controlling a single motor? Does it still misbehave?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

JCA34F

So the Arduino pins suddenly go from outputting signal pulses to high impedance state (floating). What is the ESC supposed to do with that? Turn the motor power supply off FIRST.

Robin2

So the Arduino pins suddenly go from outputting signal pulses to high impedance state (floating). What is the ESC supposed to do with that? Turn the motor power supply off FIRST.
I would prefer if the system would fail gracefully if the Arduino is stopped at any unexpected time - programs have been know to crash.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

slipstick

Most ESCs I've met will close the motor down cleanly if their signal suddenly disappears. So the first question is exactly what ESCs are you using and what have you done about setting up any internal ESC programming options?

It is certainly best practice not to leave the ESC/motor powered without any control signal but it shouldn't really be necessary.

Steve

DragoSupremo

Does that happen even if the motors are stationary when you turn the Arduino off?

Apart from this problem (which, I agree, is serious) does the system work the way you want it to?

Have you tried commenting out parts of your program so that it is only controlling a single motor? Does it still misbehave?

...R
Yea even if the motors are stationary they often bursts (even if with less intensity).

I also commented the code like so to try with a single motor:

Code: [Select]

#include <Servo.h>

Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4;

void setup() {
  // put your setup code here, to run once:

  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(11, OUTPUT);
 
  //Motor setup
  motor1.attach(11);
  motor2.attach(A2);
  motor3.attach(A1);
  motor4.attach(A0);


  //Esc calibration
  motor1.writeMicroseconds(2000);
  /*
  motor2.writeMicroseconds(2000);
  motor3.writeMicroseconds(2000);
  motor4.writeMicroseconds(2000);
  */
  delay(10000);
  motor1.writeMicroseconds(1000);
  /*
  motor2.writeMicroseconds(1000);
  motor3.writeMicroseconds(1000);
  motor4.writeMicroseconds(1000);
  */
  delay(10000);
  //Run motors
  motor1.writeMicroseconds(1000);
  /*
  motor2.writeMicroseconds(1000);
  motor3.writeMicroseconds(1000);
  motor4.writeMicroseconds(1000);
  */

}

void loop() {
  // put your main code here, to run repeatedly:

}


But the single motor also misbehave.

Apart from that i think the system works quite well (the hc-05 is ok and mpu-6050 gives conistent results). The only thing i noticed that is not very good is that i have to calibrate the escs each time i turn the Arduino on, but for now it's not a big problem because it's done automatically.


DragoSupremo

Most ESCs I've met will close the motor down cleanly if their signal suddenly disappears. So the first question is exactly what ESCs are you using and what have you done about setting up any internal ESC programming options?

It is certainly best practice not to leave the ESC/motor powered without any control signal but it shouldn't really be necessary.

Steve
The ESCs i am currently using are Crazepony-UK 30A Escs DYS DS30A 30amp BLHeli_S 3-5S.

I couldn't find how to set the programming options (i am also pretty new to this), so i preferred not touch them, i only calibrate them when i switch the arduino ON.


Yea actually the switch only controls the power to the arduino, the power distribution board is always powered (with ESCs and motors), also because the wires that supply it are quite large and the switch has pretty small pins. So if i want to completely turn off the motors i have to manually remove the battery.

zwieblum

If the ESCs don't shut down in absence of a PPM signal, throw them away and get working ones.

Robin2

If the ESCs don't shut down in absence of a PPM signal, throw them away and get working ones.
That sounds like good advice.

Or take the time to find out if the ESCs have settings that can be altered to get safe behaviour.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

DragoSupremo

Ok thank you very much for the help! I am gonna buy new ESCs and then try again, i'll keep you updated  :smiley:

Go Up