Problems Calibrating ESC with Arduino

I have been trying to calibrate my esc to run my brushless motor with little success. I've had it run forward but with not very good speed control just full speed and a bit less than full speed but not both forward and backwards. I have attached my ESC calibration rules which I have followed and seem to have done except for the last part where the motor is supposed to run at the end of the set up. Here is the program I've been running and using the serial monitor to change what I'm sending to the ESC at the appropriate time. Any ideas of why this isn't working? Please help! Thanks!

#include <Servo.h>

#define MAX_SIGNAL 2000
#define MIN_SIGNAL 1000
#define NEUT_SIGNAL 1500
#define MOTOR_PIN 9

Servo motor;

void setup() {
 Serial.begin(9600);
 Serial.println("Program begin...");
 Serial.println("This program will calibrate the ESC.");

 motor.attach(MOTOR_PIN);



 // Send neutral output
 Serial.println("Now sending Neutral signal");
 motor.writeMicroseconds(NEUT_SIGNAL);

 // Wait for input
 while (!Serial.available());
 Serial.read();

 Serial.println("Now writing maximum output.");
 motor.writeMicroseconds(MAX_SIGNAL);

 // Wait for input
 while (!Serial.available());
 Serial.read();

  // Send min output
 Serial.println("Sending minimum output");
 motor.writeMicroseconds(MIN_SIGNAL);


 // Wait for input
 while (!Serial.available());
 Serial.read();
 


}

void loop() {  

}

Then Ive been running this to test the motor plugging in various number in to test. (Typically 1600, 1700, 1800, 1900, 2000 are the only things that work.

#include <Servo.h>

//#define MOTOR_PIN 9

Servo motor;

void setup() {
 // put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Program begin");

motor.attach(9);

motor.writeMicroseconds(1600);
delay(500);  // run forward for 1 second
motor.writeMicroseconds(0);
delay(100);  // 'coast' for 1/10 second

}

void loop() {
 // put your main code here, to run repeatedly:
 

}

Hi,
Welcome to the Forum

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

then come back to your posts and edit it (lower right of your post screen) add the code tags and make us happy.

Thank you.. Tom.. :slight_smile:

That's great and all and I fixed it...but that still doesn't solve my problem...

You mention a brushless DC motor, which you control in servo style (PWM). The servo controller (data sheet?) may limit the available speed range, eventually also your power supply.

I don't know anything about a servo controller(data sheet) you mentioned. This is my setup.
DYNS1425 ESC
DYN4830 Motor
3s 2200mAh 20c 11.1V Battery
Arduino UNO

Jordanar:

Quote from: JordanarThis is my setup.
DYNS1425 ESC
DYN4830 Motor

One thing to note: The motor spec says to use a 30Amp ESC and the ESC is a 25Amp model.
ESC manual: Dynamite | Horizon Hobby RC Batteries and Accessories
Motor manual: Dynamite | Horizon Hobby RC Batteries and Accessories

QUICK START
The quick start setup guide will get you running quickly using the ESC’s default settings.

  1. Mount the ESC and motor in the vehicle.
  2. Connect the ESC to the motor.
  3. Connect the ESC receiver lead to CH2 on your receiver.
  4. Ensure the ESC switch is OFF.
  5. Connect a fully charged battery to the ESC. Power ON the ESC.
  6. Calibrate the ESC to the transmitter.
    ESC CALIBRATION PROCEDURE
    Ensure proper ESC function by calibrating the ESC to your transmitter inputs.
  7. Power OFF the ESC.
  8. Ensure your transmitter is powered ON, the throttle is not reversed, the throttle trim is neutral and the throttle travel range is at 100%. Disable any special functions such as ABS, etc.
  9. Press the SET button while powering on the ESC. Release the button as soon as the red LED starts to flash.
  10. Calibrate the throttle points by pressing the SET button once after each step.
    • Neutral point (1 flash) - leave the throttle at rest, untouched
    • Full throttle (2 flashes) - pull the throttle fully back
    • Full brakes/reverse (3 flashes) - push the throttle fully forward
  11. The motor will run 3 seconds after the last step is completed.

I continue to have problems with this ESC calibration process. So it will calibrate with an rc controller fine but as soon as I try and use the arduino the esc seems to calibrate however the reverse doesn't work and forward doesn't work until like 1800microSeconds although really I get about a different result every time I calibrate it...or sometimes when I experimented with other numbers in calibration I've had it going at 100microseconds. I tried calibrating it with the Rc controller and then using that calibration with the arduino and it started at 1800microseconds and was working up at 15000microseconds! I think it may want a neutral signal before I send it any throttle too. Anyways it's pretty wacky and maybe one of you experienced people can help!

Jordanar:
was working up at 15000microseconds!

Since the servo object has a default limit of 2400 microseconds any value over that limit will be treated the same as 2400.
Sounds like the ESC is doing braking, not reverse. I don't know if that is a setting you control in the ESC. If it is doing breaking then any value under 1500 microseconds will give various degrees of braking and the motor won't go any slower than stopped. You could try setting "neutral" at 1100 microseconds with MIN at 1000 and MAX at 2000. That should give you a greater range of control on the forward throttle.

Ok I tried that which brings me to another problem Im having. First I don't know why forward/brake/reverse all work with RC controller but with nothing changed but the arduino reverse won't work. I don't really need reverse I guess though it would be very helpful and I can figure that out down the road. The other problem is that lets say for your calibration above (min 1000, 1100, 2000) the first time it starts was 1300 although I didn't try all the individual numbers but 1200 didn't work. Anyways, the beginning speed is very fast. I've had it calibrated somehow that it was moving nice and slow for the minimum speeds which is useful to me. Im not sure how much you guys can help as your not messing with it hands on here but regardless I appreciate the help. Is there a different way than PWM using a digital pin that may be more cooperative with my ESC? Also, instead of writeMicroseconds() using 1000-2000 I tried just wrie() 0-180 but had the same results. I've tried all kinds of number combinations. I like keeping things as simple as possible and I don't want to create more chaos but just throwing that out there. Thanks

A diagram of the signal were helpful, as sent by the RC controller for various speeds.

Your best bet is to use arduino to decode pulse timings the RC receiver is sending to the ESC when you do a manual (from RC transmitter) calibration/setup, that you say it works.
And then program the arduino to replicate the same PWM sequence.

This thread should help you with the RC signal decoding

EDIT since it requires you to push some buttons during calibration, my advice above won't work.
In normal RC use, do you need to recalibrate the ESC every time you connect batteries or it saves the settings during power off?

It does remember the calibration or at least it did when I just tested calibrating it unplugging everything and getting the same result when i plugged it back in. The receiver it works with is the Exceed Rc SP-03020 wit AM 27.095 MHz R-06 (I don't know what most that means but if it helps than great if not ignore it). This receiver did not initially come with this ESC/ motor combo I just got new ESC/ motor but it still works with it and everything. Exceed-RC Radio Control Pistol 2 Channel AM Transmitter Set w/ Receiver + 2 Car Servos 51C00-80119-TransmitterSet
ESC Dynamite | Horizon Hobby RC Batteries and Accessories
Motor Dynamite Fuze Mini 4500Kv Brushless Motor, 2mm Shaft | Horizon Hobby

I followed this code to receive the signals from my receiver. I got Neutral 1245, Max 1990, Min 865. I calibrated the ESC using my receiver and it remembers this as I use my Arduino to send it corresponding PWM with the result of forward, break, and reverse

int pin = 9;  // set this to the pin connected to your receiver
unsigned long duration;

void setup()
{
 Serial.begin(9600);
 pinMode(pin, INPUT);
}

void loop()
{
 duration = pulseIn(pin, HIGH);
 Serial.println(duration);
 delay(250);
}

mabe it has to do with the order you power things up. When you use it with the receiver, at the same time it also turns the receiver on via BEC.

The calibration procedure states you have to have the transmitter turned on on powering up, that means it gets a valid RC neutral pwm pulse in very short time after powering up.

But that shouldn't apply to normal startup.

Somehow it gets confused at startup. Using arduino RC decoder to "sniff" the signal from receiver during power-on could help. There-s some receiver signal behavior esc is expecting that arduino isn't performing.

How about having both receiver & arduino - default mode esc receives signal from receiver, then arduino takes over by switching on/off a pair of AND gates.

Why do you need to calibrate the ESC?

You try to run the ESC directly from a arduino or you got already a receiver device that runs your ESC ?

If you feel or got problems running the ESC from a arduino I can help not sure why you need calibration
but that's not the problem.

I made myself a UAV circuit running servos and ESC I had few problems but that wasn't because of calibration.

D.60

I mean not every speed works for reverse basically full or nothing. Pretty fast on the forward too but thats kind of how it was when using the RC controller too but more or less it works and is improvement. What do you mean calibration is not necessary/ not the problem? My intent is to just use the arduino to send ppm the receiver was just here to help me understand my calibration issues. I know I kind of got it working but what did you have in mind to help. Definitely could improve on this if you know how

Jordanar:
I followed this code to receive the signals from my receiver. I got Neutral 1245, Max 1990, Min 865. I calibrated the ESC using my receiver and it remembers this as I use my Arduino to send it corresponding PWM with the result of forward, break, and reverse

So now that you send the timings it was calibrated with, is it working?

Is arduino powered from ESC's BEC? if so, is possible the higher power rating of the motor could mess the BEC's voltage?

Sorry still a bit new. What is a BEC. The arduino was just charged by being plugged into my mac / will be charged through 9v battery when in use and the ESC is charged by a separate battery(11.1V 2200mah 20C 3s lips battery)

What do you mean calibration is not necessary/ not the problem?

Use servo library to control the speed of a ESC send signal in degrees to your ESC slowly, having a 10k potsentiometer and turning it from 0(0) to 180(1023) using a map, you can see when your ESC will start arm,
mine start arming at 240, and i shouldn't get it lower than 200 because i could disarm it.
from 280(0%) and 1023(100%) it was the actual speed / thrust.

Make sure you send the signal without noise, that could affect the communication between arduino and ESC,
make sure you got the wires soldered not just jumper wires, they can affect the transmission and as well make sure while testing you got the LiPo battery at 100% charged, i done some tests and i thought i get lower speed because of the arduino PWM but it was actually the battery.

some people suggest a resistor between the Signal pin of the ESC and PWM of arduino to reduce the noise, but in my case printed PCB's i didn't used any resistor.

You can see in this video the black PCB on the right is my homemade transmitter i used to control the ESC

I can post code of the ESC + arduino if you need.
Probably tomorrow, I need to search in my files.

D.60