Code Or Wiring?

Hi,

I am working with 4 brushless motors, everytime I try to ramp up the motors using a joystick one or two motors suddenly stops. When I lay off the joystick they reconnect and start working again until I turn up the speed.

Really trying to figure out if it is bad code or a wiring issue before I start going down that road.

#include <Servo.h>
Servo ESC;     // create servo object to control the ESC
Servo ESC2;
Servo ESC3;
Servo ESC4;
int potValue;  // value from the analog pin
void setup() {
  // Attach the ESC on pin 9
  ESC.attach(9,1000,2000); // (pin, min pulse width, max pulse width in microseconds)
  ESC2.attach(3,1000,2000);
  ESC3.attach(6,1000,2000);
  ESC4.attach(13,1000,2000);
  Serial.begin(9600); 
}
void loop() {
  potValue = analogRead(A0);   // reads the value of the potentiometer (value between 0 and 1023)
  potValue = map(potValue, 0, 1023, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue - 90);    // Send the signal to the ESC
  ESC2.write(potValue - 90);
  ESC3.write(potValue - 90);
  ESC4.write(potValue - 90);
  Serial.println(potValue);
  Serial.read();
}

Basic Motor Test.jpg

What is the printed value of potValue at the point of failure?

Also, I’d be more inclined to use map(potValue, 0, 1024, 0, 180)

And…an array.

It always seems to vary, I just tested 4-5 times, I got up to a potValue of 180, the power dips a little up/down and then the motors cease, followed by a few beeps from the ESC.

Perhaps it is because of the ESC, I have not done anything besides take them out and hook them up, maybe they need to be tuned?

Components

ESC: https://www.amazon.com/gp/product/B00E95VG2I/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Motor: Amazon.com: Nine to Nine 4 Pcs A2212 13T 1000KV Outrunner Brushless Motor for DJI F450 F550 MWC Multicopter: Camera & Photo

PCB: Amazon.com: PDB Power Distribution Board (Matek Systems) + 4pcs Sponge Mat Landing Pad Gear (2PCS XT60 PDB): Toys & Games

the power dips a little

Enough to cause a processor brown-out reset?

I guess I’m not sure.

I have it in my desk variable PS and have it at 7.4V, average pull of 3ishA when I have the joystick at 180. I have clocked it dipping down to lowish 6V, 6.2V.

Schematic required

More detailed than the one already attached?

ESCs needs vast amounts of current in reserve, 20A or more might be needed from the supply - they are designed to be powered from powerful LiPo packs which can easily source 50 or 100A.

I think what's happening as soon as the current spikes hit the supply's current limit the voltage drops out and resets everything.

jbarth200:
More detailed than the one already attached?

not funny.

Why (potvalue - 90)? What do you expect writing negative values to the ESCs to do?

Steve

You might try using microseconds instead of degrees since you’re controlling speed, not angle.

#include <Servo.h>
Servo ESC;     // create servo object to control the ESC
Servo ESC2;
Servo ESC3;
Servo ESC4;
int potValue;  // value from the analog pin
void setup() {
  // Attach the ESC on pin 9
  ESC.writeMicroseconds(1500); // zero speed
  ESC2.writeMicroseconds(1500);
  ESC3.writeMicroseconds(1500);
  ESC4.writeMicroseconds(1500);
  ESC.attach(9);
  ESC2.attach(3);
  ESC3.attach(6);
  ESC4.attach(13);
  Serial.begin(9600);
}
void loop() {
  potValue = analogRead(A0);   // reads the value of the potentiometer (value between 0 and 1023)
    // scale it to use it with the servo library (value between 0 and 180)
  potValue = map(potValue, 0, 1024, 1000, 2000);
  ESC.writeMicroseconds(potValue);    // Send the signal to the ESC
  ESC2.writeMicroseconds(potValue);
  ESC3.writeMicroseconds(potValue);
  ESC4.writeMicroseconds(potValue);
  Serial.println(potValue);
  Serial.read();
}