I have used the 3 GND pins of the Arduino Uno without combining them
I have a 30A esc
I did not cross-connect one of the ESC-motor pairs
Everything worked fine as I changed my pid values. Suddenly my bldc motors stopped turning and began beeping. When pushing the reset button on the Arduino Uno the motors started spinning for half a second and stopped, and then the beeping sound started again (see video). To check if the problem was in the code, the bldc or the ESC, I uploaded the following ESC calibration code:
/*ESC calibration sketch; author: ELECTRONOOBS */
#include <Servo.h>
#define MAX_SIGNAL 2000
#define MIN_SIGNAL 1000
#define MOTOR_PIN 3
int DELAY = 1000;
Servo motor;
void setup() {
Serial.begin(9600);
Serial.println("Don't forget to subscribe!");
Serial.println("ELECTRONOOBS ESC calibration...");
Serial.println(" ");
delay(1500);
Serial.println("Program begin...");
delay(1000);
Serial.println("This program will start the ESC.");
motor.attach(MOTOR_PIN);
Serial.print("Now writing maximum output: (");Serial.print(MAX_SIGNAL);Serial.print(" us in this case)");Serial.print("\n");
Serial.println("Turn on power source, then wait 2 seconds and press any key.");
motor.writeMicroseconds(MAX_SIGNAL);
// Wait for input
while (!Serial.available());
Serial.read();
// Send min output
Serial.println("\n");
Serial.println("\n");
Serial.print("Sending minimum output: (");Serial.print(MIN_SIGNAL);Serial.print(" us in this case)");Serial.print("\n");
motor.writeMicroseconds(MIN_SIGNAL);
Serial.println("The ESC is calibrated");
Serial.println("----");
Serial.println("Now, type a values between 1000 and 2000 and press enter");
Serial.println("and the motor will start rotating.");
Serial.println("Send 1000 to stop the motor and 2000 for full throttle");
}
void loop() {
if (Serial.available() > 0)
{
int DELAY = Serial.parseInt();
if (DELAY > 999)
{
motor.writeMicroseconds(DELAY);
float v = (DELAY-1000)/10;
Serial.print("\n");
Serial.println("Motor speed:"); Serial.print(" "); Serial.print(v); Serial.print("%");
}
}
}
I removed the propeller from one of the bldc's and started the calibration. I succeeded in varying the bldc speed from 1000 to 2000 with steps of 100. With each step I could hear that the motor spinned faster (except when going from 1900 to 2000; there was no difference in motor noise). Then I put the propeller on the bldc and tried the same; I could only go to 1300 (30% of the max speed). When reaching 1400 (40%), the motor stopped spinning. I did the calibration test on the other motor (first without propeller and then with it) and got exactly the same results.
I then bought 2 new same motor-esc pairs and got the same problem.
I tried with an Arduino Nano and the problem persisted.
(Except that I am using 2 motor-ESC pairs on pin 3 and 5)
With the following code:
#include <Servo.h>
Servo ESC1; // create servo object to control the ESC
Servo ESC2; // create servo object to control the ESC
int potValue; // value from the analog pin
void setup() {
ESC1.attach(3,1000,2000); // (pin, min pulse width, max pulse width in microseconds)
ESC2.attach(5,1000,2000); // (pin, min pulse width, max pulse width in microseconds)
}
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)
ESC1.write(potValue); // Send the signal to the ESC
ESC2.write(potValue); // Send the signal to the ESC
}
And I can get the motors to spin around 30% of it's max value. If I increase to 40% (or higher), the motors stop spinning.
Have you considered 1300 RPM is the max possible for that motor loaded and the power supply it has?
I would suggest you find a test program that simply controls your motor with no calibration or other code. See what the motor speeds are with the simple code.
I have applied the same PID code, but now with a limit of 1280 instead of 2000 (1300 stops the motors) and it works fine without stopping the motors. But it has not the same high spinning speed I used to see on my first tests
Is your battery dropping in capacity?
Do you know for sure what PWM percentage is being sent to the ESC?
I would not assume running the same PID code would necessarily give you the same outcome every time.
If I were testing this as my project I would create a code that put out the max PWM your ESC understands.
First photo looks wrong....ie no power to Arduino.
Other than that, are you aware that some esc require to be "programmed " to your rc signal.
(or whatever you are using) so the esc knows the upper and lower limits.
Yours might be different but who knows, you are the only one who knows exactly what they are.
double throttle=1140; //initial value of throttle to the motors
And got a max value of 1320
I have tried the following simple code:
#include <Servo.h>
Servo ESC1; // create servo object to control the ESC
Servo ESC2; // create servo object to control the ESC
int potValue; // value from the analog pin
void setup() {
ESC1.attach(10); // (pin, min pulse width, max pulse width in microseconds)
ESC2.attach(11); // (pin, min pulse width, max pulse width in microseconds)
ESC1.writeMicroseconds(1000);
ESC2.writeMicroseconds(1000);
}
void loop() {
ESC1.writeMicroseconds(1200); // Send the signal to the ESC
ESC2.writeMicroseconds(1200); // Send the signal to the ESC
}
And it only gave me beeps. Even with small signals like 1100... The motors don't spin with this code whatsoever. It only works with this code if I include a potentiometer (see this code).
@mrfimskiy I'm out of ideas. Whenever I get into a situation like this I will go back to basics. Being comfortable with BLDC motors I would concentrate on the ESC. I looked at you link and couldn't find the control details.
So I looked for other ESC controllers and found some have a different transfer function. Look at the attached and consider if your ESC input signal is similar.
I'm a rookie regarding Arduino so I can't comprehend your esc calibration tool, but I do know that a brushless esc is calibrated with max throttle value applied before connecting power to the ESC. So, power up your Arduino, set throttle to max. Connect battery to the ESC > You'll hear some beeps. Lower the throttle to the lowest position, again some beeps. From now the ESC knows the full range. Also, a lot of RC stuff goes from 900 to 2200, not from 1000 to 2000.
In the video I see a 10Amp lab supply that collapses (voltage readout) when the motors spin up.
A collapsing supply is the same (for the ESC) as turning the supply off/on.
Note that the motors draw at least 10Amp (maybe 20A) each on startup.
And maybe 10Amp each when spinning with the added load of a propeller.
So that 10Amp supply is totally inadequate.
Volt-drop in the supply leads could make things worse.
You could try a 3S LiPo battery that can handle the current near the motors,
With the supply set to 12.0volt, and also connected.
Both these supplies might be able to power the setup.
Don't leave the supply permanently connected to the battery though (safety).
Leo..
Yes, the point I was trying to make is, when dealing with pumps, fans and propellers (moving fluids, gas or liquid) you run into the "affinity laws", pressure, force, torque varies with the square of velocity and power varies with the cube. Doubling the velocity (RPM) increases torque by a factor of (approximately) 4 and power by 8. Look at the table you posted for 2000, 4000, and 6000 RPM. So, increasing RPM by only 50% increases torque by 225% and power by 338%. https://en.wikipedia.org/wiki/Affinity_laws