arduino and esc and motor

Hello

I am using an Arduino to turn a brushless motor with an esc. My code is working but there is one confusing element. Yesterday this code worked.

#include <Servo.h>

Servo esc;

void setup() {
 // put your setup code here, to run once:
 esc.attach(9);
 Serial.begin(9600);
 /*
 for(int pos = 0; pos < 61; pos++){
   esc.write(pos);
   delay(1000);
   Serial.println(pos);
 }
 */
 
 esc.write(60);
 delay(1000);
 Serial.println("armed");
}

void loop() {
 // put your main code here, to run repeatedly:
 esc.write(65);
 delay(1000);
 Serial.println("one loop");
}

The arming number was 60 and it worked with that. But today I have to use the code

#include <Servo.h>

Servo esc;

void setup() {
  // put your setup code here, to run once:
  esc.attach(9);
  Serial.begin(9600);
  
  for(int pos = 0; pos < 61; pos++){
    esc.write(pos);
    delay(1000);
    Serial.println(pos);
  }
  
  //esc.write(60);
  //delay(1000);
  Serial.println("armed");
}

void loop() {
  // put your main code here, to run repeatedly:
  esc.write(65);
  delay(1000);
  Serial.println("one loop");
}

to run the motor. I am bit confused does the arming number change for an esc. If I try yesterdays code the motor just sits there and beeps. I am bit confused by this and would love an explanation. I would appreciate any help.

What Arduino? What ESC and motor? What are you powering them with? Details matter!

The two bits of arming code are very different and they are both quite different from any arming sequence I've ever needed to use with any of my brushless ESCs (normally write(0) then wait a couple of seconds). So I can't really help because I don't actually understand why either of them works at all.

Steve

It worked yesterday but not today. That sounds alarming to me. Something thoasted? Hope not. Wiring diagram is requested.

Hello

I am using the esc and motor in this kit

https://www.amazon.com/abcGoodefg-Brushless-Propeller-Accessories-Quadcopter/dp/B07C5KYNY7/ref=sr_1_1?ie=UTF8&qid=1544319453&sr=8-1&keywords=rc+brushless+motor+esc+servo+battery+kit+for+plane

The wiring diagram is:

reciever signal wire (yellow wire) connected to pin 9 vin wire (red wire) connected to 5volts ground wire (brown wire) connected to ground

and the esc's battery wires (red and black wires) are connected to a 4s battery. The esc's blue wires are connected to the motor.

Thanks

It's not THAT difficult in this day and age to draw out a pencil sketch and scan it into a photo. Much clearer than a worded explanation of what you have connected.

e.g. do you have all the grounds connected together?

So you have an ESC specified for 2S or 3S and you're running it on a 4S battery? Good luck with that.

And you're powering the Arduino from the BEC. Do you have any other power sources, like the USB cable, connected at the same time?

How did you decide to use write(60) rather than any other value for the arming sequence? I don't think I've ever seen an ESC that will arm with such a high initial value, somewhere close to 0 is more normal.

Steve

Hello

It stopped working with arm 60 and started working with arm 6. The new code was

#include <Servo.h>

Servo esc;

void setup() {
  // put your setup code here, to run once:
  esc.attach(9);
  Serial.begin(9600);
  delay(20000);
  /*
  for(int pos = 0; pos < 25; pos++){
    esc.write(pos);
    delay(1000);
    Serial.println(pos);
  }
  */
  
  esc.write(6);
  //esc.write(7);
  //esc.write(8);
  delay(1000);
  Serial.println("armed");
}

void loop() {
  // put your main code here, to run repeatedly:
  
  esc.write(21);
  delay(1000);
  Serial.println("one loop");
  
}

Then that stopped working and now the code is

#include <Servo.h>

Servo esc;

void setup() {
  // put your setup code here, to run once:
  esc.attach(9);
  Serial.begin(9600);
  delay(20000);
  
  for(int pos = 0; pos < 25; pos++){
    esc.write(pos);
    delay(1000);
    Serial.println(pos);
  }
  
  
  //esc.write(6);
  //esc.write(7);
  //esc.write(8);
  delay(1000);
  Serial.println("armed");
}

void loop() {
  // put your main code here, to run repeatedly:
  /*
  esc.write(21);
  delay(1000);
  Serial.println("one loop");
  */
}

works. It seems like by running the loop

for(int pos = 0; pos < 25; pos++){
    esc.write(pos);
    delay(1000);
    Serial.println(pos);
  }

I am changing the esc settings.

The way I found the arming number was by running the loop

for(int pos = 0; pos < 180; pos++){
    esc.write(pos);
    delay(1000);
    Serial.println(pos);
  }

and listening for the double beep. I am using a 4s battery because the forum http://intofpv.com/t-esc-reciever?pid=51000#pid51000 instructed me to. I also have the arduino usb cable plugged in and the battery plugged in at the same time. The motor is spinning correctly but I have to change the code a lot.

Thanks

kingofjong: and the esc's battery wires (red and black wires) are connected to a 4s battery. The esc's blue wires are connected to the motor.

Amazon Specs table;

Fit for Battery : [u]2-3S[/u] Li-Poly, Fit for ESC : 30A

Have you really got an S4 battery connected? Thanks.. Tom.. :)

It sounds as though you are not completing an arming sequence so it's taking all subsequent commands as part of a setup/calibration routine until you accidentally hit on something that does finally end the setup and go back to normal mode.

Unfortunately I don't know what the correct arming sequence for that no-name ESC is. If I had that ESC I'd either read the instructions or use something like the Knob example sketch to work out what commands were needed. Usually the first set of beeps tells you how many cells are in the battery but what it does when it's only expecting either 2 or 3 but you're using 4 I don't know.

Steve