trying to write to brusless motor ESC, no luck

i followed this video which clearly works ok for him, XXD HW30A ESC Brushless Electric Speed Controller - YouTube
i have the same ESC , XXD HW30A

but all i get is a slow steady beep

i know the ESC is working because if i connect it to my RC receiver PWM throttle pin, its fine

i’ve tried everything and i’m really stuck at this point, has anybody a thought about what to try next? here is the code i’m using

/*
*  This code is in the public domain.
*  (Do whatever you want with it.)
*/

// Need the Servo library
#include <Servo.h>

// This is our motor.

Servo myMotorFR;


// This is the final output
// written to the motor.
String incomingString;

// Set everything up
void setup()
{
 // Attach motors to pins

 myMotorFR.attach(10);
 Serial.begin(115200);

}

void initialize_motor()
{
   Serial.print("Arming the motor! \n");
 
   Serial.print("Setting low speed! \n");

   myMotorFR.write(25);
   delay(2000);
   
   Serial.print("Setting high speed! \n");
 myMotorFR.write(180);
 delay(2000);

   
myMotorFR.write(10);
  Serial.print("MOTOR IS READY! \n");
   delay(1000);
}

void testfunction()
{
   Serial.print("TEST APP IS STARTING IN :");
   delay(500);
   Serial.print(" 3");
   delay(1000);
   Serial.print(" 2");
   delay(1000);
   Serial.print(" 1 \n");
   delay(500);
   
   Serial.print("1st Speed = 30, speed will increase in 3sec \n");
 myMotorFR.write(30); 
 delay(3000);
   
   Serial.print("2nd Speed = 40, speed will increase in 3sec \n");
myMotorFR.write(40); 
 delay(3000);
   
   Serial.print("3th Speed = 50, speed will increase in 3sec \n");
 myMotorFR.write(50); 
 delay(3000);
   
   Serial.print("4th Speed = 60, speed will increase in 3sec \n");
 myMotorFR.write(60); 
 delay(3000);
   
    Serial.print("5th Speed = 70, speed will increase in 3sec \n");
 myMotorFR.write(70); 
 delay(3000);
   
   Serial.print("6th Speed = 80, speed will increase in 3sec \n");
 myMotorFR.write(80); 
  delay(3000);
   
   Serial.print("7th Speed = 90, speed will increase in 3sec \n");
 myMotorFR.write(90); 
  delay(3000);
   
   Serial.print("8th Speed = 100, speed will increase in 3sec \n");
  myMotorFR.write(100); 
 delay(3000);
   
   Serial.print("9th Speed = 120, motor will stop in 3sec \n");
  myMotorFR.write(120); 
  delay(3000);
   
   Serial.print("9th Speed = BURST, motor will stop in 2sec \n");
 myMotorFR.write(170); 
 delay(1000);
   
   Serial.print("STOP");
  myMotorFR.write(10);  
}

void loop()
{
 Serial.println("initializing...");
 delay(1000);
 initialize_motor();
 testfunction();
 while(1) { } 
}

Are you using the same power and the same motor as the video. If not what exactly are you using? In particular how is the motor/ESC powered? And do you have the ESC power supply -ve connected to the Arduino GND?

Steve

Hi steveh2112,
Can you edit your post and put your code inside of code tabs?
Read up about it in the sticky post titled "How to use this forum, please read" at the top of this forum.

Often, difficulties with RC ESCs lie in the arming sequence. I like to use a modified Knob tutorial to test this.
Do you have a poteniometer? Go look at the source for the Know tutorial. Modify it to write the value to the serial monitor. Hook up your ESC and try to simulate what you do with your RC transmitter to get the ESC to arm. When you move the pot to a position that makes your ESC move forward in the arming sequence (different beeping sequence), note that value on the serial monitor. You can use that value (or something close to it) in the arming sequence of your ultimate knobless sketch.

Edit: Do you know that you are writing successfully to the ESC? For kicks, try hocking up an RC servo instead of the ESC. Does it move following the same commands that your initializing routine is issuing?

I would ramp up the throttle slowly - remember the arming sequence is a safety thing for when
driving 100's of watts of motor/propeller - you don't want the thing suddenly coming to life without
warning, or going haywire if the connections are intermittent - the ESC will be programmed to
reject sudden abrupt changes like going from 25 to 180 in one step.

Start with a low level like 25, wait (as you are doing), then ramp up gradually. Works for several
of my ESCs.

Experimenting with a servo tester is a good way to figure out what your ESC likes. These are cheap
and easy to get handy devices.

thanks to all who replies, i'll try the ramp up thing today, and fix the code tabs in my post

the ESC is powered from a 3S lipo as it should be and the arduino Vin is powered from the BEC from the ESC, 5v
i cut the 5v line in the USB cable to the host PC

i have 4 servos connected to other digital pins and they all work fine

i'll reply more when i figure out whats going on, thanks

i know the ESC is working because if i connect it to my RC receiver PWM throttle pin, its fine

Did you have to move your RC transmitter throttle stick during the arming sequence or

did you just leave it alone at the low throttle setting?

ok, it seems i got the pin numbers wrong, duh! my eyes are crap and its really hard for me to read this tiny stuff, anyhow seems to work well now from my RC transmitter to the servos and the ESC, here’s the code if anyone interested for flysky RC using iBus to servo and ESC

/*
 * Simple interface to the Fly Sky IBus RC system.
 */

#include <Arduino.h>
#include <inttypes.h>
#include <Servo.h> 

Servo aiServoM, elServo, thServo, ruServo, aiServoS;  // create servo object to control a servo 


enum State
{
  GET_LENGTH,
  GET_DATA,
  GET_CHKSUML,
  GET_CHKSUMH,
  DISCARD,
};

static const uint8_t PROTOCOL_LENGTH = 0x20;
static const uint8_t PROTOCOL_OVERHEAD = 3; // <len><cmd><data....><chkl><chkh>
static const uint8_t PROTOCOL_TIMEGAP = 3; // Packets are received very ~7ms so use ~half that for the gap
static const uint8_t PROTOCOL_CHANNELS = 10;
static const uint8_t PROTOCOL_COMMAND40 = 0x40; // Command is always 0x40

uint8_t state;
uint32_t last;
uint8_t buffer[PROTOCOL_LENGTH];
uint8_t ptr;
uint8_t len;
int16_t channel[PROTOCOL_CHANNELS];
uint16_t chksum;
uint8_t lchksum;

void FlySkyIBusloop(void)
{
  while (Serial.available() > 0)
  {
    uint32_t now = millis();
    if (now - last >= PROTOCOL_TIMEGAP)
    {
      state = GET_LENGTH;
    }
    last = now;
    
    uint8_t v = Serial.read();
    switch (state)
    {
      case GET_LENGTH:
        if (v <= PROTOCOL_LENGTH)
        {
          ptr = 0;
          len = v - PROTOCOL_OVERHEAD;
          chksum = 0xFFFF - v;
          state = GET_DATA;
        }
        else
        {
          state = DISCARD;
        }
        break;

      case GET_DATA:
        buffer[ptr++] = v;
        chksum -= v;
        if (ptr == len)
        {
          state = GET_CHKSUML;
        }
        break;
        
      case GET_CHKSUML:
        lchksum = v;
        state = GET_CHKSUMH;
        break;

      case GET_CHKSUMH:
        // Validate checksum
        if (chksum == (v << 8) + lchksum)
        {
          // Execute command - we only know command 0x40
          switch (buffer[0])
          {
            case PROTOCOL_COMMAND40:
              // Valid - extract channel data
              for (uint8_t i = 1; i < PROTOCOL_CHANNELS * 2 + 1; i += 2)
              {
                channel[i / 2] = buffer[i] | (buffer[i + 1] << 8);
              }
              break;

            default:
              break;
          }
        }
        state = DISCARD;
        break;

      case DISCARD:
      default:
        break;
    }
  }
}

uint16_t FlySkyIBus_readChannel(uint8_t channelNr)
{
  if (channelNr < PROTOCOL_CHANNELS)
  {
    return channel[channelNr];
  }
  else
  {
    return 0;
  }
}

/*
 * Test FlySky IBus interface on an Arduino Mega.
 *  Connect FS-iA6B receiver to Serial1.
 */
 

void setup() 
{
  Serial.begin(115200);

  // servo setup
  aiServoM.attach(7); aiServoM.writeMicroseconds(1500);
  elServo.attach(8); elServo.writeMicroseconds(1500);
  thServo.attach(9); thServo.writeMicroseconds(1000);
  ruServo.attach(10); ruServo.writeMicroseconds(1500);
  aiServoS.attach(11); aiServoS.writeMicroseconds(1500);
  Serial.println("Setup done");
  delay(2000);
}

void loop() 
{
  FlySkyIBusloop();
  
  Serial.print(" 0:"); Serial.print(channel[0]-1500);
  Serial.print(" 1:"); Serial.print(channel[1]-1500);
  Serial.print(" 2:"); Serial.print(channel[2]-1500);
  Serial.print(" 3:"); Serial.print(channel[3]-1500);
  Serial.print(" 4:"); Serial.print(channel[4]-1500);
  Serial.print(" 5:"); Serial.print(channel[5]-1500);
  Serial.print(" 6:"); Serial.print(channel[6]-1500);
  Serial.print(" 7:"); Serial.print(channel[7]-1500);
  Serial.print(" 8:"); Serial.print(channel[8]-1500);
  Serial.print(" 9:"); Serial.println(channel[9]-1500);

  aiServoM.writeMicroseconds(channel[0]);
  elServo.writeMicroseconds(channel[1]);
  thServo.writeMicroseconds(channel[2]);
  ruServo.writeMicroseconds(channel[3]);
  aiServoS.writeMicroseconds(channel[4]);
  
  delay(50);
}