Strange ESC Problem

Hello, I have a project that I am currently working on that requires me to fully program an ESC with an Arduino. All it really needs to do right now is go forward. I understand they need to be calibrated, so in my code I have an arm() command set to pulse the minimum length, then the maximum, then test.
BTW, I found this code on GitHub purely for testing ESCs.
STRANGE PART: I have made multiple different codes, using different pulses, different ways of calibration etc. However, after SUCCESSFULLY running all of these kinds of codes. The next test the ESC/motor will refuse to work. I truly have no idea what the problem is, the connections are fine and the battery is charged an obviously the code is fine if it works one seconds then doesnt the next. Should I just replace the ESC?

CODE:

#include <Servo.h>
// ---------------------------------------------------------------------------
// Customize here pulse lengths as needed
#define MIN_PULSE_LENGTH 1330 // Minimum pulse length in µs
#define MAX_PULSE_LENGTH 2000 // Maximum pulse length in µs
// ---------------------------------------------------------------------------
Servo motA;
char data;
// ---------------------------------------------------------------------------

/**
 * Initialisation routine
 */
void setup() {
    Serial.begin(9600);
    
    motA.attach(4, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);

    displayInstructions();
}

/**
 * Main function
 */
void loop() {
    if (Serial.available()) {
        data = Serial.read();

        switch (data) {
            // 0
            case 48 : Serial.println("Sending minimum throttle");
                      motA.writeMicroseconds(MIN_PULSE_LENGTH);

            break;

            // 1
            case 49 : Serial.println("Sending maximum throttle");
                      motA.writeMicroseconds(MAX_PULSE_LENGTH);

            break;

            // 2
            case 50 : Serial.print("Running test in 3");
                      delay(1000);
                      Serial.print(" 2");
                      delay(1000);
                      Serial.println(" 1...");
                      delay(1000);
                      test();
            break;
        }
    }
    

}

/**
 * Test function: send min throttle to max throttle to each ESC.
 */
void test()
{
    for (int i = MIN_PULSE_LENGTH; i <= MAX_PULSE_LENGTH; i += 5) {
        Serial.print("Pulse length = ");
        Serial.println(i);
        
        motA.writeMicroseconds(i);

        
        delay(200);
    }

    Serial.println("STOP");
    motA.writeMicroseconds(MIN_PULSE_LENGTH);

}

/**
 * Displays instructions to user
 */
void displayInstructions()
{  
    Serial.println("READY - PLEASE SEND INSTRUCTIONS AS FOLLOWING :");
    Serial.println("\t0 : Send min throttle");
    Serial.println("\t1 : Send max throttle");
    Serial.println("\t2 : Run test function\n");
}

If you want answers, provide a schematic of YOUR setup and documentation on what devices YOU Are using.

The code posted is the code I am using, the parts is simply a turnegy brushless motor used with a an esc and 2s lipo battery. All of which hooked up to the arduino.

What I find confusing is that it’ll work once, calibrate, then wont work again for that code or my previous simple ones. And it seems like it has a sort of timer for each successful run.- works once, then i let it sit off for a bit, then it works again on startup, repeat.

I really meant this to be a broad question, but those are my specs/situation.

You were asked for a schematic. That short verbal description is not good enough.

It really isn't, because presumably, other people made it work and you didn't. That makes it a narrow question, "what exactly did you do incorrectly?".

Unless, you really want a broad answer, like "you are doing something wrong".

1 Like

Thanks. Is that exactly what you have?

Yes, I did have a separate servo also attached, but for the sake of simplicity and the fact that it was running perfectly fine, I removed it once I started testing the motor.

But, what exactly doesn't work? Does the ESC move at all? Or, incorrectly? If so, how?

This is what I am so confused by, if it was a set in stone thing I could attempt to fix it myself. This is the best I can sum it up:

The motor on startup, will either continuously beep, or be completely silent. I understand it needs to be calibrated, so the test code that I use does exactly that. This is the issue, it will work the first time, then after I reupload the code for a second test - It simply will not work. Just continuous beeps.

If I give it some time, come back and replug in the lipo and usb connection to arduino it usually works once or twice, then stops.

This makes me feel like it has to be a hardware problem no? I already reordered a better ESC because i'm on a timeframe, but does this sound strange or what?

Can we catch up with this aspect, please?...

What does the ESC's user manual say about "arming"?

Yes:

  1. Arduino Uno
  2. Turnigy D2836 1100KV Brushless Motor
  3. ESC is a standard hobbywing esc, I have had it for so long I couldn't tell you anything but its cheap.
  4. Turnigy nano-tech 2S 7.4V

The ESC arming is, low,delay,high,delay. I haven't used it in a while, for for what I believe it is this.
Another reason I'm getting a different ESC lol, no manual.

I figured it out I think, I'm just a dumbass thank you for the help. I'll reply if I have any more questions. :slight_smile:

Maybe a simpler test script:
Control the Basic ESC with the Arduino Serial Monitor (bluerobotics.com)

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