ESC failure at startup

Hey!
I am trying to control 4 ESCs from an Arduino DUE. Everything works fine as long as I start the Arduino and the 4 ESCs at different times. I would like to power the Arduino from the ESC, so they will start simultaneously. And that is where I get a problem. If they get power at the same time, at least 3 from ESCs won't respond. They emit the typical 3 beeps and then nothing. If I have luck, one of them works properly.
Interesting: If I disconnect a certain ESC, the other 3 will work fine.
My setup: Arduino DUE and 4 typical yellow 30A Chinese ESCs.
I checked the PWM signal with an oscilloscope and the problem is not with that and I assume the code is also fine, because, as I mentioned, they work fine, if I power them in different times.

ESCs react in odd ways when they are powered on with no signal present. It may be possible to do something in the code to help it. I don't know, I can't see any code.

Steve

Could be the current demand is causing system to drop voltage at start up. Are you reading the signal while trying to start at same time?

Back when I used to have a recording studio I would put the equipment power up on delays so that they would all power up smoothly without weird artifacts. Perhaps you need to start them sequentially. 4 ESC... Is this for a drone? Perhaps you need to start them at a lower speed first.... less demand on power. Perhaps you need better power supply... it sounds like a power issue.

Thank you for your answers!
Actually, my ECSs react in a good way, when they don’t have any signal from the Arduino, I mean, when they are powered up before the Arduino. I have problems when they are powered up simultaneously.
I checked, but the voltage remains 12.6 all time, it doesn’t drop, so I think, that the power supply is fine.
Yes, the 4 ESC is for a drone.

Perhaps you need to start them at a lower speed first

What do you mean? I can’t control them, they won’t respond.
How could I power them up sequentially? For example Firstly the ESCs, after 2 seconds the Arduino. How could I accomplish that?

Here is the code.

main.ino

//main.ino
#include "ESCS.h"

ESCS *escs;

void setup() {
	delay(1000);
	Serial.begin(9600);
	Serial.println("<Arduino is ready>");
	Serial.setTimeout(50);
	delay(1000);
	escs = new ESCS;
	pinMode(LED_BUILTIN, OUTPUT);
}
int value;

void loop() {


	delay(5000);
	digitalWrite(LED_BUILTIN, HIGH);
	escs->start_motors();
	for (int i = 100; i <= 900; i++) {
		escs->esc1.setthrottle(i);
		escs->esc2.setthrottle(i);
		escs->esc3.setthrottle(i);
		escs->esc4.setthrottle(i);
		delay(10);
	}
	for (int i = 900; i >= 100; i--) {
		escs->esc1.setthrottle(i);
		escs->esc2.setthrottle(i);
		escs->esc3.setthrottle(i);
		escs->esc4.setthrottle(i);
		delay(10);
	}
	escs->stop_motors();
	digitalWrite(LED_BUILTIN, LOW);
}

ESCS.h

//ESCS.h
#ifndef ESCS_H
#define ESCS_H
#include <Arduino.h>
#include <Servo.h>

#define PIN_ESC1 2
#define PIN_ESC2 3
#define PIN_ESC3 4
#define PIN_ESC4 5
#define MIN_ESC_THROTTLE 100
#define MAX_ESC_THROTTLE 900

class ESCS{
private:
	class ESC {
	private:
		Servo servo;
		bool *p_started;
	public:
		ESC(int pin,bool *p);
		~ESC();
		void setthrottle(int throttle);
	};
	bool started = false;
public:
	ESCS();
	void start_motors();
	void stop_motors();
	bool get_state();
	ESC esc1 = ESC(PIN_ESC1, &started);
	ESC esc2 = ESC(PIN_ESC2, &started);
	ESC esc3 = ESC(PIN_ESC3, &started);
	ESC esc4 = ESC(PIN_ESC4, &started);
};

#endif // !ESCS_H

ESCS.cpp

//ESCS.cpp
#include "ESCS.h"

ESCS::ESCS(){
	//Serial.println("ESCS class created");
	started = false;
	stop_motors();
}

void ESCS::start_motors() {
	started = true;
	esc1.setthrottle(MIN_ESC_THROTTLE);
	esc2.setthrottle(MIN_ESC_THROTTLE);
	esc3.setthrottle(MIN_ESC_THROTTLE);
	esc4.setthrottle(MIN_ESC_THROTTLE);
}

void ESCS::stop_motors() {
	started = false;
	esc1.setthrottle(0);
	esc2.setthrottle(0);
	esc3.setthrottle(0);
	esc4.setthrottle(0);
}

bool ESCS::get_state() {
	return started;
}

ESCS::ESC::ESC(int pin, bool *p) {
	p_started = p;
	servo.attach(pin);
	setthrottle(0);
}

void ESCS::ESC::setthrottle(int throttle) {
	if (throttle != 0 && *p_started == false) return;
	if (throttle != 0 && (throttle < MIN_ESC_THROTTLE || throttle > MAX_ESC_THROTTLE)) return;
	if (throttle == 0 && *p_started == true) return;
	/*Serial.print("Set to");
	Serial.println(throttle + 1000);*/
	servo.writeMicroseconds(throttle + 1000);
}

ESCS::ESC::~ESC() {
	//Serial.println("ESC class destroyed");
	servo.detach();
}

Sorry, the code may be a little a too complicated.

Is there a reason for about 7 seconds of delay at the start?

What is you code suppose to so. Start the motors then throttle up and down?

Exactly, start the motors, throttle up and down, stop the motors.
The 2 seconds delay in the setup should be a waiting for the motors. The 5 seconds delay is a simple delay between the start-throttle_up-throttle_down-stop processes.

And what about the fact, that if I disconnect a certain ESC completely, everything works fine?
I don't know what does it matter, but that certain ESC's BEC powers a Raspberry Pi. I suppose that shouldn't be a problem.

Please share the schematics

Unfortunately, I am a noob at using Fritzing, so I created one in Paint. :smiley:
The other components such as barometer, gyro, GPS… aren’t connected yet, so I don’t show them up on the schematic.
Here it is: schematic.png

Youre powering the due and the pi though the esc? Why? That could be the problem.

Because I seems to be simple to power them from the ESCs. How could that cause a problem? And how else should I power them?

Looks like the internal BEC should be fine. The problem must be the code calling the commands from the ESC library. I’m not familiar with it. I found another library on GitHub. Do you have the link to the original?

Duh hey you need to declare the pins as outputs. You did it for the led but not for the motor control. Hope you didn’t hurt something

Thanks for the answers!
I wrote that ESCS class, so I don't have a link.
I have tried what you said, to declare the pins as outputs, but unfortunately no improvement. But the Servo::attach() function, which is called by the ESC class constructor sets the pins as output.

Have you tried another ESC library. If it works then you know it’s the library.

Well, I have tried to use only the Servo library without any classes, but the problem is the same.

The ESCS class seems just to be a complicated way of using the standard Servo library to control 4 ESCs.

But your diagram shows no signal ground connection to the Arduino from most of the ESCs. Try connecting all of ESC servo plug black wires direct to the Arduino ground and see if that makes a difference. And check if there are any other connections between Arduino and Pi that could be causing ground loops.

Steve

Thank you for the answer!
Yeah, the ESCS class is a complicated way to control the 4 ESCs. But I think the problem is not with that.
Why should I connect them directly with the Arduino? They are connected indirectly, through the main ground wire.
There aren't any other connection between the Raspberry Pi and the Arduino (yet).

So, I tried to connect all the grounds directly to the Arduino, but nothing, the problem still remained.

Curious what’s the pin your feeding due voltage and what the BEC voltage out?